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