include ${srcdir}../Makefile.unit-settings

${TESTCASE}:	${TESTCASE}.o ${IPSEC_OBJS} Makefile
	${CC} -g -o ${TESTCASE} ${TESTCASE}.o ${IPSEC_OBJS} ${KUTILLIB} ${LIBRESWANLIB} -lefence

${TESTCASE}.o: ${srcdir}${TESTCASE}.c 
	${CC} ${UCFLAGS} -c -o ${TESTCASE}.o ${srcdir}${TESTCASE}.c

%.o: %.c 
	${CC} ${UCFLAGS} -DKBUILD_BASENAME=$* -c -o $*.o $< 

%.o: ${KLIPSSRC}/%.c
	${CC} ${KCFLAGS} -DKBUILD_BASENAME=$* -c -o $*.o $< 

%.o: ${KLIPSSRC}/des/%.c
	${CC} ${KCFLAGS} -DKBUILD_BASENAME=$* -c -o $*.o $< 

%.o: ${KLIPSSRC}/aes/%.c
	${CC} ${KCFLAGS} -DKBUILD_BASENAME=$* -c -o $*.o $< 

# build version.c using version number from Makefile.ver
version.c:	${KLIPSSRC}/version.in.c ${LIBRESWANSRCDIR}/Makefile.ver
	sed '/"/s/@IPSECVERSION@/$(IPSECVERSION)/' ${KLIPSSRC}/version.in.c >$@

ifneq (${PACKFILE},)
${TESTCASE}.o: ${PACKFILE}.c 
endif

${PACKFILE}.c: ${INPUTS}
	${PCAP2SKB} ${INPUTS} >$*.c

clean:
	rm -rf *.o ${PACKFILE}.c

check:	${TESTCASE}
	(./${TESTCASE} && echo done)| sed -f ${srcdir}../fixup.sed | tee ${TESTCASE}-check.txt | diff - ${srcdir}${TESTCASE}.out

