# Makefile for the KLIPS interface utilities
# Copyright (C) 1998, 1999  Henry Spencer.
# Copyright (C) 1999, 2000, 2001  Richard Guy Briggs
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# RCSID $Id: Makefile,v 1.3 2003/03/31 23:14:37 swahl Exp $


include ../../Makefile.inc



#CC=gcc
CFLAGS+=$(USERCOMPILE) -I../net/ipsec -I../../lib

CFLAGS+= -Wall
#CFLAGS+= -Wconversion
#CFLAGS+= -Wmissing-prototypes
CFLAGS+= -Wpointer-arith
CFLAGS+= -Wcast-qual
#CFLAGS+= -Wmissing-declarations
CFLAGS+= -Wstrict-prototypes
#CFLAGS+= -pedantic
#CFLAGS+= -W
#CFLAGS+= -Wwrite-strings
CFLAGS+= -Wbad-function-cast 
CFLAGS+= -DNAT_TRAVERSAL

ALL=spi eroute spigrp tncfg klipsdebug pf_key
MANDIR8=$(MANTREE)/man8
MANDIR5=$(MANTREE)/man5
FREESWANLIB=../../lib/libfreeswan.a

all: $(ALL)

programs: all

check: $(ALL)

install: $(ALL)
	mkdir -p $(BINDIR) $(MANDIR8) $(MANDIR5)
	$(INSTALL) $(ALL) $(BINDIR)
	for f in $(addsuffix .8, $(ALL)) ; do \
		$(INSTALL) $$f $(MANDIR8)/ipsec_$$f || exit 1 ; done
	for f in $(addsuffix .5, $(ALL) version pf_key) ; do \
		$(INSTALL) $$f $(MANDIR5)/ipsec_$$f || exit 1 ; done

constants.o : ../../pluto/constants.c ../../pluto/constants.h
	$(CC) $(CFLAGS) -c -o $@ $<

alg_info.o : ../../pluto/alg_info.c ../../pluto/alg_info.h
	$(CC) $(CFLAGS) -DNO_PLUTO -c -o $@ $<

kernel_alg.o : ../../pluto/kernel_alg.c ../../pluto/kernel_alg.h
	$(CC) $(CFLAGS) -DNO_PLUTO -c -o $@ $<

spi: spi.o constants.o alg_info.o kernel_alg.o
#	$(CC) $(DFLAGS) -o $@ $^ $(FREESWANLIB)
	$(LD) $(LDFLAGS) -o $@ $(LIBS) $^ $(FREESWANLIB) $(LDLIBS) $(LDADD)

eroute: eroute.o
#	$(CC) $(DFLAGS) -o $@ $? $(FREESWANLIB)
	$(LD) $(LDFLAGS) -o $@ $(LIBS) $^ $(FREESWANLIB) $(LDLIBS) $(LDADD)

spigrp: spigrp.o
#	$(CC) $(DFLAGS) -o $@ $? $(FREESWANLIB)
	$(LD) $(LDFLAGS) -o $@ $(LIBS) $^ $(FREESWANLIB) $(LDLIBS) $(LDADD)

tncfg: tncfg.o
#	$(CC) $(DFLAGS) -o $@ $? $(FREESWANLIB)
	$(LD) $(LDFLAGS) -o $@ $(LIBS) $^ $(FREESWANLIB) $(LDLIBS) $(LDADD)

pf_key: pf_key.o
#	$(CC) $(DFLAGS) -o $@ $? $(FREESWANLIB)
	$(LD) $(LDFLAGS) -o $@ $(LIBS) $^ $(FREESWANLIB) $(LDLIBS) $(LDADD)

klipsdebug: klipsdebug.o
#	$(CC) $(DFLAGS) -o $@ $? $(FREESWANLIB)
	$(LD) $(LDFLAGS) -o $@ $(LIBS) $^ $(FREESWANLIB) $(LDLIBS) $(LDADD)

cleanall: clean

distclean: clean

mostlyclean: clean

realclean: clean

clean:
	rm -f *.o $(ALL)

checkprograms:

