| OLD | NEW |
| (Empty) |
| 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 # libsrtp.so shared library implementing srtp | |
| 13 # clean removes objects, libs, and executables | |
| 14 # distribution cleans and builds a .tgz | |
| 15 # tags builds etags file from all .c and .h files | |
| 16 | |
| 17 USE_OPENSSL = @USE_OPENSSL@ | |
| 18 HAVE_PCAP = @HAVE_PCAP@ | |
| 19 HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@ | |
| 20 | |
| 21 .PHONY: all shared_library test build_table_apps | |
| 22 | |
| 23 all: test | |
| 24 | |
| 25 runtest: build_table_apps test | |
| 26 @echo "running libsrtp test applications..." | |
| 27 crypto/test/cipher_driver$(EXE) -v >/dev/null | |
| 28 crypto/test/kernel_driver$(EXE) -v >/dev/null | |
| 29 test/rdbx_driver$(EXE) -v >/dev/null | |
| 30 test/srtp_driver$(EXE) -v >/dev/null | |
| 31 test/roc_driver$(EXE) -v >/dev/null | |
| 32 test/replay_driver$(EXE) -v >/dev/null | |
| 33 test/dtls_srtp_driver$(EXE) >/dev/null | |
| 34 crypto/test/rand_gen_soak$(EXE) -v >/dev/null | |
| 35 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null | |
| 36 ifeq (1, $(USE_OPENSSL)) | |
| 37 cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh >/dev/null | |
| 38 endif | |
| 39 @echo "libsrtp test applications passed." | |
| 40 $(MAKE) -C crypto runtest | |
| 41 | |
| 42 # makefile variables | |
| 43 | |
| 44 CC = @CC@ | |
| 45 INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include | |
| 46 DEFS = @DEFS@ | |
| 47 CPPFLAGS= -fPIC @CPPFLAGS@ | |
| 48 CFLAGS = @CFLAGS@ | |
| 49 LIBS = @LIBS@ | |
| 50 LDFLAGS = -L. @LDFLAGS@ | |
| 51 COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS) | |
| 52 SRTPLIB = -lsrtp | |
| 53 | |
| 54 AR = @AR@ | |
| 55 RANLIB = @RANLIB@ | |
| 56 INSTALL = @INSTALL@ | |
| 57 | |
| 58 # EXE defines the suffix on executables - it's .exe for Windows, and | |
| 59 # null on linux, bsd, and OS X and other OSes. | |
| 60 EXE = @EXE@ | |
| 61 | |
| 62 # gdoi is the group domain of interpretation for isakmp, a group key | |
| 63 # management system which can provide keys for srtp | |
| 64 gdoi = @GDOI_OBJS@ | |
| 65 | |
| 66 # Random source. | |
| 67 RNG_OBJS = @RNG_OBJS@ | |
| 68 HMAC_OBJS = @HMAC_OBJS@ | |
| 69 RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@ | |
| 70 AES_ICM_OBJS = @AES_ICM_OBJS@ | |
| 71 | |
| 72 srcdir = @srcdir@ | |
| 73 top_srcdir = @top_srcdir@ | |
| 74 top_builddir = @top_builddir@ | |
| 75 VPATH = @srcdir@ | |
| 76 prefix = @prefix@ | |
| 77 exec_prefix = @exec_prefix@ | |
| 78 includedir = @includedir@ | |
| 79 libdir = @libdir@ | |
| 80 bindir = @bindir@ | |
| 81 | |
| 82 ifeq (1, $(HAVE_PKG_CONFIG)) | |
| 83 pkgconfigdir = $(libdir)/pkgconfig | |
| 84 pkgconfig_DATA = libsrtp.pc | |
| 85 endif | |
| 86 | |
| 87 SHAREDLIBVERSION = 1 | |
| 88 ifeq (linux,$(findstring linux,@host@)) | |
| 89 SHAREDLIB_DIR = $(libdir) | |
| 90 SHAREDLIB_LDFLAGS = -shared -Wl,-soname,$@ | |
| 91 SHAREDLIBSUFFIXNOVER = so | |
| 92 SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER).$(SHAREDLIBVERSION) | |
| 93 else ifeq (mingw,$(findstring mingw,@host@)) | |
| 94 SHAREDLIB_DIR = $(bindir) | |
| 95 SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp.dll.a | |
| 96 SHAREDLIBVERSION = | |
| 97 SHAREDLIBSUFFIXNOVER = dll | |
| 98 SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER) | |
| 99 else ifeq (darwin,$(findstring darwin,@host@)) | |
| 100 SHAREDLIB_DIR = $(libdir) | |
| 101 SHAREDLIB_LDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \ | |
| 102 -fno-common -headerpad_max_install_names -install_name $(libdir)/$@ | |
| 103 SHAREDLIBSUFFIXNOVER = dylib | |
| 104 SHAREDLIBSUFFIX = $(SHAREDLIBVERSION).$(SHAREDLIBSUFFIXNOVER) | |
| 105 endif | |
| 106 | |
| 107 # implicit rules for object files and test apps | |
| 108 | |
| 109 %.o: %.c | |
| 110 $(COMPILE) -c $< -o $@ | |
| 111 | |
| 112 %$(EXE): %.c | |
| 113 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS) | |
| 114 | |
| 115 | |
| 116 # libcrypt.a (the crypto engine) | |
| 117 ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \ | |
| 118 $(AES_ICM_OBJS) | |
| 119 | |
| 120 hashes = crypto/hash/null_auth.o crypto/hash/auth.o \ | |
| 121 $(HMAC_OBJS) | |
| 122 | |
| 123 replay = crypto/replay/rdb.o crypto/replay/rdbx.o \ | |
| 124 crypto/replay/ut_sim.o | |
| 125 | |
| 126 math = crypto/math/datatypes.o crypto/math/stat.o | |
| 127 | |
| 128 ust = crypto/ust/ust.o | |
| 129 | |
| 130 rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS) | |
| 131 | |
| 132 err = crypto/kernel/err.o | |
| 133 | |
| 134 kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \ | |
| 135 crypto/kernel/key.o $(rng) $(err) # $(ust) | |
| 136 | |
| 137 cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay) | |
| 138 | |
| 139 # libsrtp.a (implements srtp processing) | |
| 140 | |
| 141 srtpobj = srtp/srtp.o srtp/ekt.o | |
| 142 | |
| 143 libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi) | |
| 144 $(AR) cr libsrtp.a $^ | |
| 145 $(RANLIB) libsrtp.a | |
| 146 | |
| 147 libsrtp.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi) | |
| 148 $(CC) -shared -o $@ $(SHAREDLIB_LDFLAGS) \ | |
| 149 $^ $(LDFLAGS) $(LIBS) | |
| 150 if [ -n "$(SHAREDLIBVERSION)" ]; then \ | |
| 151 ln -sfn $@ libsrtp.$(SHAREDLIBSUFFIXNOVER); \ | |
| 152 fi | |
| 153 | |
| 154 shared_library: libsrtp.$(SHAREDLIBSUFFIX) | |
| 155 | |
| 156 # libcryptomath.a contains general-purpose routines that are used to | |
| 157 # generate tables and verify cryptoalgorithm implementations - this | |
| 158 # library is not meant to be included in production code | |
| 159 | |
| 160 cryptomath = crypto/math/math.o crypto/math/gf2_8.o | |
| 161 | |
| 162 libcryptomath.a: $(cryptomath) | |
| 163 $(AR) cr libcryptomath.a $(cryptomath) | |
| 164 $(RANLIB) libcryptomath.a | |
| 165 | |
| 166 | |
| 167 # test applications | |
| 168 ifneq (1, $(USE_OPENSSL)) | |
| 169 AES_CALC = crypto/test/aes_calc$(EXE) | |
| 170 endif | |
| 171 | |
| 172 crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \ | |
| 173 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \ | |
| 174 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \ | |
| 175 crypto/test/stat_driver$(EXE) crypto/test/rand_gen_soak$(EXE) | |
| 176 | |
| 177 testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \ | |
| 178 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \ | |
| 179 test/dtls_srtp_driver$(EXE) | |
| 180 | |
| 181 ifeq (1, $(HAVE_PCAP)) | |
| 182 testapp += test/rtp_decoder$(EXE) | |
| 183 endif | |
| 184 | |
| 185 $(testapp): libsrtp.a | |
| 186 | |
| 187 test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c \ | |
| 188 crypto/math/datatypes.c | |
| 189 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 190 | |
| 191 ifeq (1, $(HAVE_PCAP)) | |
| 192 test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/getopt_s.c \ | |
| 193 crypto/math/datatypes.c | |
| 194 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 195 endif | |
| 196 | |
| 197 test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c | |
| 198 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 199 | |
| 200 test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c | |
| 201 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 202 | |
| 203 test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c | |
| 204 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 205 | |
| 206 crypto/test/cipher_driver$(EXE): crypto/test/cipher_driver.c test/getopt_s.c | |
| 207 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 208 | |
| 209 crypto/test/kernel_driver$(EXE): crypto/test/kernel_driver.c test/getopt_s.c | |
| 210 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 211 | |
| 212 crypto/test/rand_gen$(EXE): crypto/test/rand_gen.c test/getopt_s.c | |
| 213 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 214 | |
| 215 crypto/test/rand_gen_soak$(EXE): crypto/test/rand_gen_soak.c test/getopt_s.c | |
| 216 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB) | |
| 217 | |
| 218 test: $(testapp) | |
| 219 @echo "Build done. Please run '$(MAKE) runtest' to run self tests." | |
| 220 | |
| 221 memtest: test/srtp_driver | |
| 222 @test/srtp_driver -v -d "alloc" > tmp | |
| 223 @grep freed tmp | wc -l > freed | |
| 224 @grep allocated tmp | wc -l > allocated | |
| 225 @echo "checking for memory leaks (only works with --enable-stdout)" | |
| 226 cmp -s allocated freed | |
| 227 @echo "passed (same number of alloc() and dealloc() calls found)" | |
| 228 @rm freed allocated tmp | |
| 229 | |
| 230 # tables_apps are used to generate the tables used in the crypto | |
| 231 # implementations; these need only be generated during porting, not | |
| 232 # for building libsrtp or the test applications | |
| 233 | |
| 234 table_apps = tables/aes_tables | |
| 235 | |
| 236 build_table_apps: $(table_apps) | |
| 237 | |
| 238 # in the tables/ subdirectory, we use libcryptomath instead of libsrtp | |
| 239 | |
| 240 tables/%: tables/%.c libcryptomath.a | |
| 241 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a | |
| 242 | |
| 243 # the target 'plot' runs the timing test (test/srtp_driver -t) then | |
| 244 # uses gnuplot to produce plots of the results - see the script file | |
| 245 # 'timing' | |
| 246 | |
| 247 plot: test/srtp_driver | |
| 248 test/srtp_driver -t > timing.dat | |
| 249 | |
| 250 | |
| 251 # bookkeeping: tags, clean, and distribution | |
| 252 | |
| 253 tags: | |
| 254 etags */*.[ch] */*/*.[ch] | |
| 255 | |
| 256 | |
| 257 # documentation - the target libsrtpdoc builds a PDF file documenting | |
| 258 # libsrtp | |
| 259 | |
| 260 libsrtpdoc: | |
| 261 $(MAKE) -C doc | |
| 262 | |
| 263 .PHONY: clean superclean distclean install | |
| 264 | |
| 265 install: | |
| 266 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp | |
| 267 $(INSTALL) -d $(DESTDIR)$(libdir) | |
| 268 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp | |
| 269 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp | |
| 270 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includ
edir)/srtp; fi | |
| 271 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi | |
| 272 if [ -f libsrtp.dll.a ]; then cp libsrtp.dll.a $(DESTDIR)$(libdir)/; fi | |
| 273 if [ -f libsrtp.$(SHAREDLIBSUFFIX) ]; then \ | |
| 274 $(INSTALL) -d $(DESTDIR)$(SHAREDLIB_DIR); \ | |
| 275 cp libsrtp.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \ | |
| 276 ln -sfn libsrtp.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/li
bsrtp.$(SHAREDLIBSUFFIXNOVER); \ | |
| 277 fi | |
| 278 if [ "$(pkgconfig_DATA)" != "" ]; then \ | |
| 279 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \ | |
| 280 cp $(top_builddir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/;
\ | |
| 281 fi | |
| 282 | |
| 283 uninstall: | |
| 284 rm -f $(DESTDIR)$(includedir)/srtp/*.h | |
| 285 rm -f $(DESTDIR)$(libdir)/libsrtp.* | |
| 286 -rmdir $(DESTDIR)$(includedir)/srtp | |
| 287 if [ "$(pkgconfig_DATA)" != "" ]; then \ | |
| 288 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \ | |
| 289 fi | |
| 290 | |
| 291 clean: | |
| 292 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \ | |
| 293 libcryptomath.a libsrtp.a libsrtp.so libsrtp.dll.a core *.core test/core | |
| 294 for a in * */* */*/*; do \ | |
| 295 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \ | |
| 296 done; | |
| 297 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done | |
| 298 rm -rf *.pict *.jpg *.dat | |
| 299 rm -rf freed allocated tmp | |
| 300 $(MAKE) -C doc clean | |
| 301 $(MAKE) -C crypto clean | |
| 302 | |
| 303 | |
| 304 superclean: clean | |
| 305 rm -rf crypto/include/config.h config.log config.cache config.status \ | |
| 306 Makefile crypto/Makefile doc/Makefile \ | |
| 307 .gdb_history test/.gdb_history .DS_Store | |
| 308 rm -rf autom4te.cache | |
| 309 | |
| 310 distclean: superclean | |
| 311 | |
| 312 distname = libsrtp-$(shell cat VERSION) | |
| 313 | |
| 314 distribution: runtest superclean | |
| 315 if ! [ -f VERSION ]; then exit 1; fi | |
| 316 if [ -f ../$(distname).tgz ]; then \ | |
| 317 mv ../$(distname).tgz ../$(distname).tgz.bak; \ | |
| 318 fi | |
| 319 cd ..; tar cvzf $(distname).tgz libsrtp | |
| 320 | |
| 321 # EOF | |
| OLD | NEW |