include config.inc #CC = $(CROSS_PREFIX)gcc CP = cp -f RM = rm -f LN = ln -sf LS = ls -l CD = cd MKDIR = mkdir -p CMP = cmp CFLAGS += -DARCH_FREEBSD LDFLAGS = BINDIR = $(PREFIX)/bin TEATOTAL = teatotal TEA = tea UNTEA = untea TEA-KGEN = tea-kgen PROGRAMS = $(TEATOTAL) MANPAGES = doc/teatotal.1 doc/tea.1 doc/untea.1 doc/tea-kgen.1 TEATOTAL_OBJS = teatotal.o ifeq ($(ARCH), LINUX) MANDIR = $(PREFIX)/man/man1 RANDOM_DEVICE = \"/dev/random\" else ifeq ($(ARCH), OPENBSD) MANDIR = $(PREFIX)/share/man/man1 RANDOM_DEVICE = \"/dev/srandom\" else MANDIR = $(PREFIX)/man/man1 RANDOM_DEVICE = \"/dev/random\" endif endif ifeq ($(BUILD_TEA_UNTEA), Y) PROGRAMS += $(TEA) $(UNTEA) CFLAGS += -DBUILD_TEA_UNTEA TEATOTAL_OBJS += teauntea.o BUILD_BTEA = Y BUILD_READKEY = Y BUILD_TEAPROT = Y endif ifeq ($(BUILD_TEA_KGEN), Y) PROGRAMS += $(TEA-KGEN) CFLAGS += -DBUILD_TEA_KGEN TEATOTAL_OBJS += tea-kgen.o ifdef RANDOM_DEVICE TEATOTAL_OBJS += randdev.o CFLAGS += -DRANDOM_DEVICE=$(RANDOM_DEVICE) else BUILD_MD5 = Y TEATOTAL_OBJS += randint.o endif endif ifeq ($(BUILD_TEAPROT), Y) TEATOTAL_OBJS += teaprot.o endif ifeq ($(BUILD_HUFFMAN), Y) CFLAGS += -DBUILD_HUFFMAN TEATOTAL_OBJS += huffman.o heap.o endif ifeq ($(BUILD_PPKEYS), Y) CFLAGS += -DBUILD_PPKEYS BUILD_READKEY = Y BUILD_MD5 = Y BUILD_BTEA = Y endif ifeq ($(BUILD_BASE64), Y) CFLAGS += -DBUILD_BASE64 TEATOTAL_OBJS += base64.o BUILD_LINEGET = Y endif ifeq ($(BUILD_MD5), Y) TEATOTAL_OBJS += md5.o endif ifeq ($(BUILD_BTEA), Y) TEATOTAL_OBJS += btea.o endif ifeq ($(BUILD_READKEY), Y) TEATOTAL_OBJS += readkey.o endif ifeq ($(BUILD_LINEGET), Y) TEATOTAL_OBJS += lineget.o endif ifeq ($(VERBOSE_ARGUMENT_ERRORS), Y) CFLAGS += -DVERBOSE_ARGUMENT_ERRORS endif ifeq ($(DEBUGGING), Y) CFLAGS += -g else LDFLAGS += -s endif ifeq ($(PEDANTIC), Y) CFLAGS += -pedantic endif ifeq ($(STATIC), Y) LDFLAGS += -static endif TEATOTAL_OBJS += util.o getarg.o .PHONY: all clean install check all: $(PROGRAMS) check install: all $(MKDIR) $(BINDIR) ${BSD_INSTALL_PROGRAM} $(TEATOTAL) $(BINDIR) $(LN) $(TEATOTAL) $(BINDIR)/$(TEA) $(LN) $(TEATOTAL) $(BINDIR)/$(UNTEA) $(LN) $(TEATOTAL) $(BINDIR)/$(TEA-KGEN) $(MKDIR) $(MANDIR) ${BSD_INSTALL_MAN} $(MANPAGES) $(MANDIR) clean: $(RM) core *.o $(PROGRAMS) testout.tea test.out test2.key test3.key \ testlit.out testbig.out testcomp.tea testcomp.out testa0.tea \ testa0.out testa1.out testa2.out testa3.out check: ifeq ($(BUILD_TEA_UNTEA), Y) @echo Doing checks... ./tea test.key test.in testout.tea ./untea test.key testout.tea test.out ./untea test.key testlit.tea testlit.out ./untea test.key testbig.tea testbig.out ifeq ($(BUILD_PPKEYS), Y) $(CP) test.key test2.key ./tea-kgen -cP -k test test2.key $(CP) test2.key test3.key ./tea-kgen -cP -k test2 -p test test3.key ./tea-kgen -c -p test2 test3.key endif ifeq ($(BUILD_BASE64), Y) ./tea -a test.key test.in testa0.tea ./untea -a test.key testa0.tea testa0.out ./untea -a test.key testa.tea endif ifeq ($(BUILD_HUFFMAN), Y) ./tea -c test.key test.txt testcomp.tea ./untea test.key testcomp.tea testcomp.out endif @echo Check that the compares succeed: $(CMP) test.in test.out $(CMP) test.in testlit.out $(CMP) test.in testbig.out ifeq ($(BUILD_PPKEYS), Y) $(CMP) testp.key test2.key $(CMP) test.key test3.key endif ifeq ($(BUILD_BASE64), Y) $(CMP) test.in testa0.out $(CMP) test.in testa1.out $(CMP) test.in testa2.out $(CMP) test.in testa3.out endif ifeq ($(BUILD_HUFFMAN), Y) $(CMP) test.txt testcomp.out @echo Check that testcomp.tea is smaller than test.txt: $(LS) test.txt testcomp.tea endif @echo Finished checks endif teatotal.o: teatotal.c arch.h teatotal.h util.h getarg.h teauntea.h tea-kgen.h \ config.inc $(CC) $(CFLAGS) -c $< md5.o: md5.c arch.h md5.h config.inc $(CC) $(CFLAGS) -c $< huffman.o: huffman.c arch.h huffman.h fixed.h heap.h config.inc $(CC) $(CFLAGS) -c $< heap.o: heap.c arch.h heap.h config.inc $(CC) $(CFLAGS) -c $< base64.o: base64.c arch.h base64.h config.inc $(CC) $(CFLAGS) -c $< randint.o: randint.c arch.h teatotal.h tea-kgen.h md5.h getarg.h config.inc $(CC) $(CFLAGS) -c $< randdev.o: randdev.c arch.h teatotal.h util.h tea-kgen.h getarg.h config.inc $(CC) $(CFLAGS) -c $< btea.o: btea.c arch.h util.h btea.h config.inc $(CC) $(CFLAGS) -c $< tea-kgen.o: tea-kgen.c arch.h teatotal.h util.h tea-kgen.h readkey.h getarg.h \ config.inc $(CC) $(CFLAGS) -c $< teauntea.o: teauntea.c arch.h teatotal.h util.h teauntea.h readkey.h teaprot.h \ getarg.h config.inc $(CC) $(CFLAGS) -c $< util.o: util.c arch.h teatotal.h util.h getarg.h config.inc $(CC) $(CFLAGS) -c $< readkey.o: readkey.c arch.h teatotal.h util.h readkey.h getarg.h config.inc $(CC) $(CFLAGS) -c $< teaprot.o: teaprot.c arch.h teatotal.h util.h btea.h base64.h huffman.h \ teaprot.h getarg.h config.inc $(CC) $(CFLAGS) -c $< getarg.o: getarg.c getarg.h $(CC) $(CFLAGS) -c $< lineget.o: lineget.c lineget.h $(CC) $(CFLAGS) -c $< teatotal: $(TEATOTAL_OBJS) $(CC) $(LDFLAGS) -o teatotal $(TEATOTAL_OBJS) tea: teatotal $(LN) teatotal tea untea: teatotal $(LN) teatotal untea tea-kgen: teatotal $(LN) teatotal tea-kgen