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