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