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