Param Reddappagari | 386ce4d | 2011-10-04 12:15:40 -0700 | [diff] [blame] | 1 | # Makefile for libcryptomodule.a |
| 2 | # |
| 3 | # David A. McGrew |
| 4 | # Cisco Systems, Inc. |
| 5 | |
| 6 | srcdir = @srcdir@ |
| 7 | top_srcdir = @top_srcdir@ |
| 8 | top_builddir = @top_builddir@ |
| 9 | VPATH = @srcdir@ |
| 10 | |
| 11 | CC = @CC@ |
| 12 | INCDIR = -Iinclude -I$(srcdir)/include |
| 13 | DEFS = @DEFS@ |
| 14 | CPPFLAGS= @CPPFLAGS@ |
| 15 | CFLAGS = @CFLAGS@ |
| 16 | LIBS = @LIBS@ |
| 17 | LDFLAGS = @LDFLAGS@ -L. |
| 18 | COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS) |
| 19 | CRYPTOLIB = -lcryptomodule |
| 20 | |
| 21 | RANLIB = @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 |
| 26 | EXE = @EXE@ |
| 27 | # Random source. |
| 28 | RNG_OBJS = @RNG_OBJS@ |
| 29 | |
| 30 | ifdef ARCH |
| 31 | DEFS += -D$(ARCH)=1 |
| 32 | endif |
| 33 | |
| 34 | ifdef sysname |
| 35 | DEFS += -D$(sysname)=1 |
| 36 | endif |
| 37 | |
| 38 | .PHONY: dummy all runtest clean superclean |
| 39 | |
| 40 | dummy : all runtest |
| 41 | |
| 42 | # test applications |
| 43 | |
| 44 | testapp = 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 | |
| 51 | k=000102030405060708090a0b0c0d0e0f |
| 52 | p=00112233445566778899aabbccddeeff |
| 53 | c=69c4e0d86a7b0430d8cdb78070b4c55a |
| 54 | |
| 55 | runtest: 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 | |
| 69 | ciphers = cipher/cipher.o cipher/null_cipher.o \ |
| 70 | cipher/aes.o cipher/aes_icm.o \ |
| 71 | cipher/aes_cbc.o |
| 72 | |
| 73 | hashes = hash/null_auth.o hash/sha1.o \ |
| 74 | hash/hmac.o hash/auth.o |
| 75 | |
| 76 | math = math/datatypes.o math/stat.o |
| 77 | |
| 78 | rng = rng/$(RNG_OBJS) rng/rand_source.o rng/prng.o rng/ctr_prng.o |
| 79 | |
| 80 | err = kernel/err.o |
| 81 | |
| 82 | kernel = kernel/crypto_kernel.o kernel/alloc.o \ |
| 83 | kernel/key.o $(rng) $(err) |
| 84 | |
| 85 | xfm = ae_xfm/xfm.o |
| 86 | |
| 87 | cryptobj = $(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 | |
| 97 | ifndef AR |
| 98 | AR=ar |
| 99 | endif |
| 100 | |
| 101 | # and the crypto module library itself |
| 102 | |
| 103 | libcryptomodule.a: $(cryptobj) |
| 104 | $(AR) cr libcryptomodule.a $(cryptobj) |
| 105 | $(RANLIB) libcryptomodule.a |
| 106 | |
| 107 | all: libcryptomodule.a $(testapp) |
| 108 | |
| 109 | # housekeeping functions |
| 110 | |
| 111 | clean: |
| 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 | |
| 118 | superclean: clean |
| 119 | rm -f *core TAGS ktrace.out |
| 120 | |
| 121 | |
| 122 | # the target 'package' builds a compressed tar archive of the source code |
| 123 | |
| 124 | distname = crypto-$(shell cat VERSION) |
| 125 | |
| 126 | package: superclean |
| 127 | cd ..; tar cvzf $(distname).tgz crypto/ |
| 128 | |
| 129 | |
| 130 | # EOF |