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 for AES-128
50k128=000102030405060708090a0b0c0d0e0f
51p128=00112233445566778899aabbccddeeff
52c128=69c4e0d86a7b0430d8cdb78070b4c55a
53
54
55# data values used to test the aes_calc application for AES-256
56k256=000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
57p256=00112233445566778899aabbccddeeff
58c256=8ea2b7ca516745bfeafc49904b496089
59
60
61runtest: libcryptomodule.a $(testapp)
62	test/env$(EXE) # print out information on the build environment
63	@echo "running libcryptomodule test applications..."
64	test `test/aes_calc $(k128) $(p128)` = $(c128)
65	test `test/aes_calc $(k256) $(p256)` = $(c256)
66	test/cipher_driver$(EXE) -v >/dev/null
67	test/datatypes_driver$(EXE) -v >/dev/null
68	test/stat_driver$(EXE) >/dev/null
69	test/sha1_driver$(EXE) -v >/dev/null
70	test/kernel_driver$(EXE) -v >/dev/null
71	test/rand_gen$(EXE) -n 256 >/dev/null
72	@echo "libcryptomodule test applications passed."
73
74# libcryptomodule.a (the crypto engine) 
75
76ciphers = cipher/cipher.o cipher/null_cipher.o      \
77          cipher/aes.o cipher/aes_icm.o             \
78          cipher/aes_cbc.o
79
80hashes  = hash/null_auth.o hash/sha1.o \
81          hash/hmac.o hash/auth.o
82
83math    = math/datatypes.o math/stat.o
84
85rng     = rng/$(RNG_OBJS) rng/rand_source.o rng/prng.o rng/ctr_prng.o
86
87err     = kernel/err.o
88
89kernel  = kernel/crypto_kernel.o  kernel/alloc.o   \
90          kernel/key.o $(rng) $(err)
91
92xfm     = ae_xfm/xfm.o
93
94cryptobj =  $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(xfm)
95
96# the rule for making object files and test apps
97
98%.o: %.c
99	$(COMPILE) -c $< -o $@
100
101%$(EXE): %.c libcryptomodule.a 
102	$(COMPILE) $(LDFLAGS) $< -o $@ $(CRYPTOLIB) $(LIBS)
103
104ifndef AR
105  AR=ar
106endif
107
108# and the crypto module library itself
109
110libcryptomodule.a: $(cryptobj) 
111	$(AR) cr libcryptomodule.a $(cryptobj) 
112	$(RANLIB) libcryptomodule.a
113
114all: libcryptomodule.a $(testapp)
115
116# housekeeping functions
117
118clean:
119	rm -f libcryptomodule.a
120	rm -f $(testapp) *.o */*.o 
121	for a in * .* */*; do if [ -f "$$a~" ] ; then rm $$a~; fi; done;
122	rm -f `find . -name "*.[ch]~*~"`
123	rm -rf latex
124
125superclean: clean
126	rm -f *core TAGS ktrace.out
127
128
129# the target 'package' builds a compressed tar archive of the source code
130
131distname = crypto-$(shell cat VERSION)
132
133package: superclean
134	cd ..; tar cvzf $(distname).tgz crypto/
135
136
137# EOF
138