Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1 | # Makefile for secure rtp |
| 2 | # |
| 3 | # David A. McGrew |
| 4 | # Cisco Systems, Inc. |
| 5 | |
| 6 | # targets: |
| 7 | # |
| 8 | # runtest runs test applications |
| 9 | # test builds test applications |
| 10 | # libcrypt.a static library implementing crypto engine |
| 11 | # libsrtp.a static library implementing srtp |
| 12 | # clean removes objects, libs, and executables |
| 13 | # distribution cleans and builds a .tgz |
| 14 | # tags builds etags file from all .c and .h files |
| 15 | |
| 16 | .PHONY: test all runtest |
| 17 | |
| 18 | runtest: test |
| 19 | @echo "running libsrtp test applications..." |
| 20 | test/cipher_driver$(EXE) -v >/dev/null |
| 21 | test/rdbx_driver$(EXE) -v >/dev/null |
| 22 | test/srtp_driver$(EXE) -v >/dev/null |
| 23 | test/roc_driver$(EXE) -v >/dev/null |
| 24 | test/kernel_driver$(EXE) -v >/dev/null |
| 25 | @echo "libsrtp test applications passed." |
| 26 | |
| 27 | all: test tables |
| 28 | |
| 29 | # makefile variables |
| 30 | |
| 31 | CC = @CC@ |
| 32 | CFLAGS = -Wall -O4 -fexpensive-optimizations -funroll-loops |
| 33 | CDEFS = -DHAVE_CONFIG_H |
| 34 | INCDIR = -I./include/ -I./crypto/include |
| 35 | LIBS = @LIBS@ -lsrtp |
| 36 | LIBDIR = -L. |
| 37 | |
| 38 | |
| 39 | # implicit rules for object files and test apps |
| 40 | |
| 41 | %.o: %.c |
| 42 | $(CC) $(CDEFS) -c $(CFLAGS) $(INCDIR) $< -o $@ |
| 43 | |
| 44 | %: %.c libsrtp.a |
| 45 | $(CC) $(CDEFS) $(CFLAGS) $(INCDIR) $< -o $@ $(LIBDIR) $(LIBS) |
| 46 | |
| 47 | |
| 48 | # libcrypt.a (the crypto engine) |
| 49 | |
| 50 | ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \ |
| 51 | crypto/cipher/aes.o crypto/cipher/aes_icm.o \ |
| 52 | crypto/cipher/aes_cbc.o |
| 53 | |
| 54 | hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \ |
| 55 | crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o |
| 56 | |
| 57 | replay = crypto/replay/rdb.o crypto/replay/rdbx.o \ |
| 58 | crypto/replay/ut_sim.o |
| 59 | |
| 60 | math = crypto/math/datatypes.o crypto/math/stat.o |
| 61 | |
| 62 | ust = crypto/ust/ust.o |
| 63 | |
| 64 | rng = crypto/rng/rand_source.o crypto/rng/prng.o crypto/rng/ctr_prng.o |
| 65 | |
| 66 | err = crypto/kernel/err.o |
| 67 | |
| 68 | kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \ |
| 69 | crypto/kernel/key.o $(rng) $(err) # $(ust) |
| 70 | |
| 71 | cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay) |
| 72 | |
David McGrew | fec49dd | 2005-09-23 19:34:11 +0000 | [diff] [blame] | 73 | aesicm = crypto/cipher/cipher.o crypto/cipher/aes.o crypto/cipher/aes_icm.o \ |
| 74 | crypto/hash/auth.o crypto/kernel/alloc.o crypto/kernel/err.o \ |
| 75 | crypto/math/datatypes.o crypto/replay/rdbx.o |
| 76 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 77 | aesicmobj = $(aesicm) $(rng) |
| 78 | |
| 79 | # gdoi is the group domain of interpretation for isakmp, a group key |
| 80 | # management system which can provide keys for srtp |
| 81 | |
| 82 | gdoi = @GDOI_OBJS@ |
| 83 | |
| 84 | # libsrtp.a (implements srtp processing) |
| 85 | |
| 86 | srtpobj = srtp/srtp.o |
| 87 | |
| 88 | libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi) |
| 89 | ar cr libsrtp.a $(srtpobj) $(cryptobj) $(gdoi) |
| 90 | ranlib libsrtp.a |
| 91 | |
| 92 | # libaesicm.a provides an icm implementation used by mpeg4ip |
| 93 | |
| 94 | libaesicm.a: $(aesicmobj) |
| 95 | ar cr libaesicm.a $(aesicmobj) |
| 96 | ranlib libaesicm.a |
| 97 | |
| 98 | # libcryptomath.a contains general-purpose routines that are used to |
| 99 | # generate tables and verify cryptoalgorithm implementations - this |
| 100 | # library is not meant to be included in production code |
| 101 | |
| 102 | cryptomath = crypto/math/math.o crypto/math/gf2_8.o crypto/math/gf2_128.o |
| 103 | |
| 104 | libcryptomath.a: $(cryptomath) |
| 105 | ar cr libcryptomath.a $(cryptomath) |
| 106 | ranlib libcryptomath.a |
| 107 | |
| 108 | |
| 109 | # test applications |
| 110 | |
| 111 | testapp = test/cipher_driver test/datatypes_driver test/srtp_driver \ |
| 112 | test/replay_driver test/roc_driver test/rdbx_driver \ |
| 113 | test/stat_driver test/sha1_driver test/kernel_driver \ |
| 114 | test/aes_calc test/rand_gen # test/ust_driver @GDOI_APPS@ |
| 115 | # test/auth_driver test/rtpw \ |
| 116 | |
| 117 | test/rtpw: test/rtpw.c test/rtp.c |
| 118 | $(CC) $(CDEFS) $(CFLAGS) $(INCDIR) -o test/rtpw test/rtpw.c test/rtp.c $(LIBDIR) $(LIBS) |
| 119 | |
| 120 | test: $(testapp) |
| 121 | |
| 122 | memtest: test/srtp_driver |
| 123 | @test/srtp_driver -v -d "alloc" > tmp |
| 124 | @grep freed tmp | wc -l > freed |
| 125 | @grep allocated tmp | wc -l > allocated |
| 126 | @echo "checking for memory leaks (only works with --enable-stdout)" |
| 127 | cmp -s allocated freed |
| 128 | @echo "passed (same number of alloc() and dealloc() calls found)" |
| 129 | @rm freed allocated tmp |
| 130 | |
| 131 | # tables_apps are used to generate the tables used in the crypto |
| 132 | # implementations; these need only be generated during porting, not |
| 133 | # for building libsrtp or the test applications |
| 134 | |
| 135 | table_apps = tables/aes_tables tables/gf_128_tables |
| 136 | |
| 137 | # in the tables/ subdirectory, we use libcryptomath instead of libsrtp |
| 138 | |
| 139 | tables/%: tables/%.c libcryptomath.a |
| 140 | $(CC) $(CDEFS) $(CFLAGS) $(INCDIR) $< -o $@ $(LIBDIR) libcryptomath.a |
| 141 | |
| 142 | # the target 'plot' runs the timing test (test/srtp_driver -t) then |
| 143 | # uses gnuplot to produce plots of the results - see the script file |
| 144 | # 'timing' |
| 145 | |
| 146 | plot: test/srtp_driver |
| 147 | test/srtp_driver -t > timing.dat |
| 148 | |
| 149 | |
| 150 | # bookkeeping: tags, clean, and distribution |
| 151 | |
| 152 | tags: |
| 153 | etags */*.[ch] */*/*.[ch] |
| 154 | |
| 155 | |
| 156 | # documentation - the target libsrtpdoc builds a PDF file documenting |
| 157 | # libsrtp |
| 158 | |
| 159 | libsrtpdoc: |
| 160 | cd doc; make |
| 161 | |
| 162 | # EXE defines the suffix on executables - it's .exe for cygwin, and |
| 163 | # null on linux, bsd, and OS X and other OSes. we define this so that |
| 164 | # `make clean` will work on the cygwin platform |
| 165 | |
| 166 | EXE = @EXE@ |
| 167 | |
| 168 | .PHONY: clean superclean install |
| 169 | |
| 170 | install: |
| 171 | if [ -d /usr/local/include/srtp ]; then \ |
| 172 | echo "you should run 'make uninstall' first"; exit 1; \ |
| 173 | fi |
| 174 | mkdir /usr/local/include/srtp |
| 175 | cp include/*.h /usr/local/include/srtp |
| 176 | cp crypto/include/*.h /usr/local/include/srtp |
| 177 | cp libsrtp.a /usr/local/lib/ |
| 178 | if [ -f libaesicm.a ]; then cp libaesicm.a /usr/local/lib/; fi |
| 179 | |
| 180 | uninstall: |
| 181 | rm -rf /usr/local/include/srtp |
| 182 | rm -rf /usr/local/lib/libsrtp.a |
David McGrew | fec49dd | 2005-09-23 19:34:11 +0000 | [diff] [blame] | 183 | rm -rf /usr/local/lib/libaesicm.a |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 184 | |
| 185 | clean: |
| 186 | rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \ |
| 187 | libcryptomath.a libsrtp.a libaesicm.a core *.core test/core |
| 188 | for a in * */* */*/*; do \ |
| 189 | if [ -f "$$a~" ] ; then rm -f $$a~; fi; \ |
| 190 | done; |
| 191 | for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done |
| 192 | rm -rf *.pict *.jpg *.dat |
| 193 | rm -rf freed allocated tmp |
| 194 | cd doc; make clean |
| 195 | cd crypto; make clean |
| 196 | |
| 197 | |
| 198 | superclean: clean |
David McGrew | e11033e | 2005-09-26 20:41:14 +0000 | [diff] [blame^] | 199 | rm -rf crypto/include/config.h config.log config.cache config.status \ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 200 | Makefile .gdb_history test/.gdb_history .DS_Store |
| 201 | rm -rf autom4te.cache |
| 202 | |
| 203 | distname = srtp-$(shell cat VERSION) |
| 204 | |
| 205 | distribution: superclean |
| 206 | if ! [ -f VERSION ]; then exit 1; fi |
| 207 | if [ -f ../$(distname).tgz ]; then \ |
| 208 | mv ../$(distname).tgz ../$(distname).tgz.bak; \ |
| 209 | fi |
| 210 | cd ..; tar cvzf $(distname).tgz srtp |
| 211 | |
| 212 | # EOF |
| 213 | |
| 214 | |