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