1# Makefile for libcryptomodule.a
2#
3# David A. McGrew
4# Cisco Systems, Inc.
5
6srcdir = @srcdir@
7top_srcdir = @top_srcdir@
8top_builddir = @top_builddir@
9VPATH = @srcdir@
10
11CC	= @CC@
12INCDIR	= -Iinclude -I$(srcdir)/include
13DEFS	= @DEFS@
14CPPFLAGS= @CPPFLAGS@
15CFLAGS	= @CFLAGS@
16LIBS	= @LIBS@
17LDFLAGS	= @LDFLAGS@ -L.
18COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
19CRYPTOLIB = -lcryptomodule
20
21RANLIB	= @RANLIB@
22
23# EXE defines the suffix on executables - it's .exe for cygwin, and
24# null on linux, bsd, and OS X and other OSes.  we define this so that
25# `make clean` will work on the cygwin platform
26EXE = @EXE@
27# Random source.
28RNG_OBJS = @RNG_OBJS@
29
30ifdef ARCH
31  DEFS += -D$(ARCH)=1
32endif
33
34ifdef sysname
35  DEFS += -D$(sysname)=1
36endif
37
38.PHONY: dummy all runtest clean superclean
39
40dummy : all runtest 
41
42# test applications 
43
44testapp = test/cipher_driver$(EXE) test/datatypes_driver$(EXE) \
45	  test/stat_driver$(EXE) test/sha1_driver$(EXE) \
46	  test/kernel_driver$(EXE) test/aes_calc$(EXE) test/rand_gen$(EXE) \
47	  test/env$(EXE)
48
49# data values used to test the aes_calc application
50
51k=000102030405060708090a0b0c0d0e0f
52p=00112233445566778899aabbccddeeff
53c=69c4e0d86a7b0430d8cdb78070b4c55a
54
55runtest: libcryptomodule.a $(testapp)
56	test/env$(EXE) # print out information on the build environment
57	@echo "running libcryptomodule test applications..."
58	test `test/aes_calc $k $p` = $c
59	test/cipher_driver$(EXE) -v >/dev/null
60	test/datatypes_driver$(EXE) -v >/dev/null
61	test/stat_driver$(EXE) >/dev/null
62	test/sha1_driver$(EXE) -v >/dev/null
63	test/kernel_driver$(EXE) -v >/dev/null
64	test/rand_gen$(EXE) -n 256 >/dev/null
65	@echo "libcryptomodule test applications passed."
66
67# libcryptomodule.a (the crypto engine) 
68
69ciphers = cipher/cipher.o cipher/null_cipher.o      \
70          cipher/aes.o cipher/aes_icm.o             \
71          cipher/aes_cbc.o
72
73hashes  = hash/null_auth.o hash/sha1.o \
74          hash/hmac.o hash/auth.o
75
76math    = math/datatypes.o math/stat.o
77
78rng     = rng/$(RNG_OBJS) rng/rand_source.o rng/prng.o rng/ctr_prng.o
79
80err     = kernel/err.o
81
82kernel  = kernel/crypto_kernel.o  kernel/alloc.o   \
83          kernel/key.o $(rng) $(err)
84
85xfm     = ae_xfm/xfm.o
86
87cryptobj =  $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(xfm)
88
89# the rule for making object files and test apps
90
91%.o: %.c
92	$(COMPILE) -c $< -o $@
93
94%$(EXE): %.c libcryptomodule.a 
95	$(COMPILE) $(LDFLAGS) $< -o $@ $(CRYPTOLIB) $(LIBS)
96
97ifndef AR
98  AR=ar
99endif
100
101# and the crypto module library itself
102
103libcryptomodule.a: $(cryptobj) 
104	$(AR) cr libcryptomodule.a $(cryptobj) 
105	$(RANLIB) libcryptomodule.a
106
107all: libcryptomodule.a $(testapp)
108
109# housekeeping functions
110
111clean:
112	rm -f libcryptomodule.a
113	rm -f $(testapp) *.o */*.o 
114	for a in * .* */*; do if [ -f "$$a~" ] ; then rm $$a~; fi; done;
115	rm -f `find . -name "*.[ch]~*~"`
116	rm -rf latex
117
118superclean: clean
119	rm -f *core TAGS ktrace.out
120
121
122# the target 'package' builds a compressed tar archive of the source code
123
124distname = crypto-$(shell cat VERSION)
125
126package: superclean
127	cd ..; tar cvzf $(distname).tgz crypto/
128
129
130# EOF
131