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 |
Jonathan Lennox | f464743 | 2010-05-14 23:17:51 +0000 | [diff] [blame] | 29 | cd test; $(abspath $(srcdir))/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@ |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame^] | 56 | HMAC_OBJS = @HMAC_OBJS@ |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 57 | RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@ |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame^] | 58 | AES_ICM_OBJS = @AES_ICM_OBJS@ |
| 59 | USE_OPENSSL = @USE_OPENSSL@ |
Marcus Sundberg | 95e2372 | 2005-10-02 19:44:28 +0000 | [diff] [blame] | 60 | |
Marcus Sundberg | 8ebe5ce | 2005-09-29 13:59:56 +0000 | [diff] [blame] | 61 | srcdir = @srcdir@ |
| 62 | top_srcdir = @top_srcdir@ |
| 63 | top_builddir = @top_builddir@ |
| 64 | VPATH = @srcdir@ |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 65 | prefix = @prefix@ |
| 66 | exec_prefix = @exec_prefix@ |
| 67 | includedir = @includedir@ |
| 68 | libdir = @libdir@ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 69 | |
| 70 | |
| 71 | # implicit rules for object files and test apps |
| 72 | |
| 73 | %.o: %.c |
Marcus Sundberg | 8ebe5ce | 2005-09-29 13:59:56 +0000 | [diff] [blame] | 74 | $(COMPILE) -c $< -o $@ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 75 | |
Marcus Sundberg | 1f84c40 | 2005-10-06 13:59:21 +0000 | [diff] [blame] | 76 | %$(EXE): %.c |
Marcus Sundberg | 95e2372 | 2005-10-02 19:44:28 +0000 | [diff] [blame] | 77 | $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 78 | |
| 79 | |
| 80 | # libcrypt.a (the crypto engine) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 81 | ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \ |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame^] | 82 | $(AES_ICM_OBJS) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 83 | |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame^] | 84 | hashes = crypto/hash/null_auth.o crypto/hash/auth.o \ |
| 85 | $(HMAC_OBJS) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 86 | |
| 87 | replay = crypto/replay/rdb.o crypto/replay/rdbx.o \ |
| 88 | crypto/replay/ut_sim.o |
| 89 | |
| 90 | math = crypto/math/datatypes.o crypto/math/stat.o |
| 91 | |
| 92 | ust = crypto/ust/ust.o |
| 93 | |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 94 | rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 95 | |
| 96 | err = crypto/kernel/err.o |
| 97 | |
| 98 | kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \ |
| 99 | crypto/kernel/key.o $(rng) $(err) # $(ust) |
| 100 | |
| 101 | cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay) |
| 102 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 103 | # libsrtp.a (implements srtp processing) |
| 104 | |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 105 | srtpobj = srtp/srtp.o srtp/ekt.o |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 106 | |
| 107 | libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi) |
Marcus Sundberg | 8ebe5ce | 2005-09-29 13:59:56 +0000 | [diff] [blame] | 108 | ar cr libsrtp.a $^ |
Marcus Sundberg | 589127e | 2005-09-29 13:34:06 +0000 | [diff] [blame] | 109 | $(RANLIB) libsrtp.a |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 110 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 111 | # libcryptomath.a contains general-purpose routines that are used to |
| 112 | # generate tables and verify cryptoalgorithm implementations - this |
| 113 | # library is not meant to be included in production code |
| 114 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 115 | cryptomath = crypto/math/math.o crypto/math/gf2_8.o |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 116 | |
| 117 | libcryptomath.a: $(cryptomath) |
| 118 | ar cr libcryptomath.a $(cryptomath) |
Marcus Sundberg | 589127e | 2005-09-29 13:34:06 +0000 | [diff] [blame] | 119 | $(RANLIB) libcryptomath.a |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 120 | |
| 121 | |
| 122 | # test applications |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame^] | 123 | ifneq (1, $(USE_OPENSSL)) |
| 124 | AES_CALC = crypto/test/aes_calc$(EXE) |
| 125 | endif |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 126 | |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame^] | 127 | crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \ |
Marcus Sundberg | b0a9311 | 2005-10-02 21:11:33 +0000 | [diff] [blame] | 128 | crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \ |
| 129 | crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \ |
| 130 | crypto/test/stat_driver$(EXE) |
| 131 | |
| 132 | testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \ |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 133 | test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \ |
David McGrew | 5506a8b | 2006-07-18 17:42:42 +0000 | [diff] [blame] | 134 | test/dtls_srtp_driver$(EXE) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 135 | |
Marcus Sundberg | 1f84c40 | 2005-10-06 13:59:21 +0000 | [diff] [blame] | 136 | $(testapp): libsrtp.a |
| 137 | |
David McGrew | 79bd301 | 2006-07-17 20:41:21 +0000 | [diff] [blame] | 138 | test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c |
| 139 | $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) |
| 140 | |
| 141 | test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c |
| 142 | $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) |
| 143 | |
| 144 | test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c |
| 145 | $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) |
| 146 | |
| 147 | test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c |
Marcus Sundberg | 8ebe5ce | 2005-09-29 13:59:56 +0000 | [diff] [blame] | 148 | $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 149 | |
| 150 | test: $(testapp) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 151 | @echo "Build done. Please run '$(MAKE) runtest' to run self tests." |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 152 | |
| 153 | memtest: test/srtp_driver |
| 154 | @test/srtp_driver -v -d "alloc" > tmp |
| 155 | @grep freed tmp | wc -l > freed |
| 156 | @grep allocated tmp | wc -l > allocated |
| 157 | @echo "checking for memory leaks (only works with --enable-stdout)" |
| 158 | cmp -s allocated freed |
| 159 | @echo "passed (same number of alloc() and dealloc() calls found)" |
| 160 | @rm freed allocated tmp |
| 161 | |
| 162 | # tables_apps are used to generate the tables used in the crypto |
| 163 | # implementations; these need only be generated during porting, not |
| 164 | # for building libsrtp or the test applications |
| 165 | |
David McGrew | 5529f10 | 2005-09-29 11:25:10 +0000 | [diff] [blame] | 166 | table_apps = tables/aes_tables |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 167 | |
David McGrew | 5529f10 | 2005-09-29 11:25:10 +0000 | [diff] [blame] | 168 | build_table_apps: $(table_apps) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 169 | |
| 170 | # in the tables/ subdirectory, we use libcryptomath instead of libsrtp |
| 171 | |
| 172 | tables/%: tables/%.c libcryptomath.a |
Marcus Sundberg | 8ebe5ce | 2005-09-29 13:59:56 +0000 | [diff] [blame] | 173 | $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 174 | |
| 175 | # the target 'plot' runs the timing test (test/srtp_driver -t) then |
| 176 | # uses gnuplot to produce plots of the results - see the script file |
| 177 | # 'timing' |
| 178 | |
| 179 | plot: test/srtp_driver |
| 180 | test/srtp_driver -t > timing.dat |
| 181 | |
| 182 | |
| 183 | # bookkeeping: tags, clean, and distribution |
| 184 | |
| 185 | tags: |
| 186 | etags */*.[ch] */*/*.[ch] |
| 187 | |
| 188 | |
| 189 | # documentation - the target libsrtpdoc builds a PDF file documenting |
| 190 | # libsrtp |
| 191 | |
| 192 | libsrtpdoc: |
Marcus Sundberg | 589127e | 2005-09-29 13:34:06 +0000 | [diff] [blame] | 193 | $(MAKE) -C doc |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 194 | |
Jonathan Lennox | fc65552 | 2010-05-21 17:45:35 +0000 | [diff] [blame] | 195 | .PHONY: clean superclean distclean install |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 196 | |
| 197 | install: |
Jonathan Lennox | a7897f0 | 2010-05-14 23:34:10 +0000 | [diff] [blame] | 198 | @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 199 | echo "you should run 'make uninstall' first"; exit 1; \ |
| 200 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 201 | $(INSTALL) -d $(DESTDIR)$(includedir)/srtp |
| 202 | $(INSTALL) -d $(DESTDIR)$(libdir) |
Jonathan Lennox | f464743 | 2010-05-14 23:17:51 +0000 | [diff] [blame] | 203 | cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp |
| 204 | cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp |
| 205 | if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi |
David McGrew | 7c7ff31 | 2006-02-23 14:11:11 +0000 | [diff] [blame] | 206 | if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 207 | |
| 208 | uninstall: |
Jonathan Lennox | a7897f0 | 2010-05-14 23:34:10 +0000 | [diff] [blame] | 209 | rm -f $(DESTDIR)$(includedir)/srtp/*.h |
| 210 | rm -f $(DESTDIR)$(libdir)/libsrtp.a |
| 211 | -rmdir $(DESTDIR)$(includedir)/srtp |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 212 | |
| 213 | clean: |
David McGrew | 5506a8b | 2006-07-18 17:42:42 +0000 | [diff] [blame] | 214 | rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \ |
David McGrew | 2d4b3a7 | 2006-03-17 21:00:46 +0000 | [diff] [blame] | 215 | libcryptomath.a libsrtp.a core *.core test/core |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 216 | for a in * */* */*/*; do \ |
| 217 | if [ -f "$$a~" ] ; then rm -f $$a~; fi; \ |
| 218 | done; |
| 219 | for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done |
| 220 | rm -rf *.pict *.jpg *.dat |
| 221 | rm -rf freed allocated tmp |
Marcus Sundberg | 589127e | 2005-09-29 13:34:06 +0000 | [diff] [blame] | 222 | $(MAKE) -C doc clean |
| 223 | $(MAKE) -C crypto clean |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 224 | |
| 225 | |
| 226 | superclean: clean |
David McGrew | e11033e | 2005-09-26 20:41:14 +0000 | [diff] [blame] | 227 | rm -rf crypto/include/config.h config.log config.cache config.status \ |
Jonathan Lennox | fc65552 | 2010-05-21 17:45:35 +0000 | [diff] [blame] | 228 | Makefile crypto/Makefile doc/Makefile \ |
| 229 | .gdb_history test/.gdb_history .DS_Store |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 230 | rm -rf autom4te.cache |
| 231 | |
Jonathan Lennox | fc65552 | 2010-05-21 17:45:35 +0000 | [diff] [blame] | 232 | distclean: superclean |
| 233 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 234 | distname = srtp-$(shell cat VERSION) |
| 235 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 236 | distribution: runtest superclean |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 237 | if ! [ -f VERSION ]; then exit 1; fi |
| 238 | if [ -f ../$(distname).tgz ]; then \ |
| 239 | mv ../$(distname).tgz ../$(distname).tgz.bak; \ |
| 240 | fi |
| 241 | cd ..; tar cvzf $(distname).tgz srtp |
| 242 | |
Marcus Sundberg | 8ebe5ce | 2005-09-29 13:59:56 +0000 | [diff] [blame] | 243 | # EOF |