blob: 9394cf0bccb29b849e017ef65b1e0fe4cd2bc43c [file] [log] [blame]
Cullen Jennings235513a2005-09-21 22:51:36 +00001# 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
jfigusd196e022014-11-20 16:43:44 -050010# libsrtp2.a static library implementing srtp
11# libsrtp2.so shared library implementing srtp
Cullen Jennings235513a2005-09-21 22:51:36 +000012# clean removes objects, libs, and executables
David McGrewb67061f2005-09-28 14:23:06 +000013# distribution cleans and builds a .tgz
14# tags builds etags file from all .c and .h files
Cullen Jennings235513a2005-09-21 22:51:36 +000015
jfigus8c36da22013-10-01 16:41:19 -040016USE_OPENSSL = @USE_OPENSSL@
Bernardo Torresb3c51422014-10-14 12:40:09 -030017HAVE_PCAP = @HAVE_PCAP@
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020018HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
jfigus8c36da22013-10-01 16:41:19 -040019
jfigus219ce4b2014-12-01 11:03:42 -050020.PHONY: all shared_library test
Cullen Jennings235513a2005-09-21 22:51:36 +000021
David McGrewb67061f2005-09-28 14:23:06 +000022all: test
23
jfigus8aa936e2014-11-06 10:16:35 -050024runtest: test
jfigusd196e022014-11-20 16:43:44 -050025 @echo "running libsrtp2 test applications..."
Marcus Sundbergb0a93112005-10-02 21:11:33 +000026 crypto/test/cipher_driver$(EXE) -v >/dev/null
27 crypto/test/kernel_driver$(EXE) -v >/dev/null
Cullen Jennings235513a2005-09-21 22:51:36 +000028 test/rdbx_driver$(EXE) -v >/dev/null
29 test/srtp_driver$(EXE) -v >/dev/null
30 test/roc_driver$(EXE) -v >/dev/null
David McGrew11b2e412006-03-16 19:13:31 +000031 test/replay_driver$(EXE) -v >/dev/null
David McGrew0cb86ee2006-07-07 15:46:57 +000032 test/dtls_srtp_driver$(EXE) >/dev/null
Jonathan Lennoxf4647432010-05-14 23:17:51 +000033 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null
jfigus8c36da22013-10-01 16:41:19 -040034ifeq (1, $(USE_OPENSSL))
35 cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh >/dev/null
36endif
jfigusd196e022014-11-20 16:43:44 -050037 @echo "libsrtp2 test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000038 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000039
40# makefile variables
41
Marcus Sundberg589127e2005-09-29 13:34:06 +000042CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000043INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
jfigus44947602014-10-08 13:08:52 -040044DEFS = @DEFS@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053045CPPFLAGS= -fPIC @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000046CFLAGS = @CFLAGS@
47LIBS = @LIBS@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053048LDFLAGS = -L. @LDFLAGS@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000049COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
jfigusd196e022014-11-20 16:43:44 -050050SRTPLIB = -lsrtp2
David McGrewb67061f2005-09-28 14:23:06 +000051
Marcus Sundberg589127e2005-09-29 13:34:06 +000052RANLIB = @RANLIB@
53INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000054
Marcus Sundberg95e23722005-10-02 19:44:28 +000055# EXE defines the suffix on executables - it's .exe for Windows, and
56# null on linux, bsd, and OS X and other OSes.
57EXE = @EXE@
Cullen Jenningsef29a902013-04-30 12:54:54 -060058
jfigus0d3a2682013-04-02 15:42:37 -040059HMAC_OBJS = @HMAC_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040060AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000061
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000062srcdir = @srcdir@
63top_srcdir = @top_srcdir@
64top_builddir = @top_builddir@
65VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000066prefix = @prefix@
67exec_prefix = @exec_prefix@
68includedir = @includedir@
69libdir = @libdir@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053070bindir = @bindir@
Cullen Jennings235513a2005-09-21 22:51:36 +000071
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020072ifeq (1, $(HAVE_PKG_CONFIG))
73pkgconfigdir = $(libdir)/pkgconfig
jfigusd196e022014-11-20 16:43:44 -050074pkgconfig_DATA = libsrtp2.pc
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020075endif
Cullen Jennings235513a2005-09-21 22:51:36 +000076
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053077SHAREDLIBVERSION = 1
78ifeq (linux,$(findstring linux,@host@))
79SHAREDLIB_DIR = $(libdir)
80SHAREDLIB_LDFLAGS = -shared -Wl,-soname,$@
81SHAREDLIBSUFFIXNOVER = so
82SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER).$(SHAREDLIBVERSION)
83else ifeq (mingw,$(findstring mingw,@host@))
84SHAREDLIB_DIR = $(bindir)
jfigus219ce4b2014-12-01 11:03:42 -050085SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp2.dll.a
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053086SHAREDLIBVERSION =
87SHAREDLIBSUFFIXNOVER = dll
88SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER)
89else ifeq (darwin,$(findstring darwin,@host@))
90SHAREDLIB_DIR = $(libdir)
91SHAREDLIB_LDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \
92 -fno-common -headerpad_max_install_names -install_name $(libdir)/$@
93SHAREDLIBSUFFIXNOVER = dylib
94SHAREDLIBSUFFIX = $(SHAREDLIBVERSION).$(SHAREDLIBSUFFIXNOVER)
95endif
96
Cullen Jennings235513a2005-09-21 22:51:36 +000097# implicit rules for object files and test apps
98
99%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000100 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +0000101
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000102%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +0000103 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000104
Cullen Jennings235513a2005-09-21 22:51:36 +0000105ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -0400106 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000107
jfigus0d3a2682013-04-02 15:42:37 -0400108hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
109 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000110
111replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
112 crypto/replay/ut_sim.o
113
jfigusfb838412014-12-04 10:15:47 -0500114math = crypto/math/datatypes.o crypto/math/stat.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000115
116ust = crypto/ust/ust.o
117
Cullen Jennings235513a2005-09-21 22:51:36 +0000118err = crypto/kernel/err.o
119
120kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
jfigusfb838412014-12-04 10:15:47 -0500121 crypto/kernel/key.o $(err) # $(ust)
Cullen Jennings235513a2005-09-21 22:51:36 +0000122
jfigusfb838412014-12-04 10:15:47 -0500123cryptobj = $(ciphers) $(hashes) $(math) $(kernel) $(replay)
Cullen Jennings235513a2005-09-21 22:51:36 +0000124
jfigusd196e022014-11-20 16:43:44 -0500125# libsrtp2.a (implements srtp processing)
Cullen Jennings235513a2005-09-21 22:51:36 +0000126
David McGrew79870d62007-06-15 18:17:39 +0000127srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000128
jfigus219ce4b2014-12-01 11:03:42 -0500129libsrtp2.a: $(srtpobj) $(cryptobj) $(gdoi)
jfigusd196e022014-11-20 16:43:44 -0500130 ar cr libsrtp2.a $^
131 $(RANLIB) libsrtp2.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000132
jfigus219ce4b2014-12-01 11:03:42 -0500133libsrtp2.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi)
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530134 $(CC) -shared -o $@ $(SHAREDLIB_LDFLAGS) \
135 $^ $(LDFLAGS) $(LIBS)
136 if [ -n "$(SHAREDLIBVERSION)" ]; then \
jfigus219ce4b2014-12-01 11:03:42 -0500137 ln -sfn $@ libsrtp2.$(SHAREDLIBSUFFIXNOVER); \
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530138 fi
139
jfigus219ce4b2014-12-01 11:03:42 -0500140shared_library: libsrtp2.$(SHAREDLIBSUFFIX)
jfigus50046422013-10-10 08:35:16 -0400141
jfigusd196e022014-11-20 16:43:44 -0500142libsrtp2.so: $(srtpobj) $(cryptobj)
143 $(CC) -shared -Wl,-soname,libsrtp2.so \
144 -o libsrtp2.so $^ $(LDFLAGS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000145
Cullen Jennings235513a2005-09-21 22:51:36 +0000146# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400147ifneq (1, $(USE_OPENSSL))
148AES_CALC = crypto/test/aes_calc$(EXE)
149endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000150
jfigus0d3a2682013-04-02 15:42:37 -0400151crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000152 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
jfigus339b61d2014-11-04 15:36:15 -0500153 crypto/test/sha1_driver$(EXE) \
154 crypto/test/stat_driver$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000155
156testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000157 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000158 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000159
jfigus98bb4fb2014-10-15 09:48:03 -0400160ifeq (1, $(HAVE_PCAP))
161testapp += test/rtp_decoder$(EXE)
162endif
163
jfigusd196e022014-11-20 16:43:44 -0500164$(testapp): libsrtp2.a
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000165
jfigus46d6b472014-11-14 16:42:01 -0500166test/rtpw$(EXE): test/rtpw.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100167 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500168 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000169
Bernardo Torresb3c51422014-10-14 12:40:09 -0300170ifeq (1, $(HAVE_PCAP))
jfigus46d6b472014-11-14 16:42:01 -0500171test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100172 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500173 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300174endif
175
jfigus46d6b472014-11-14 16:42:01 -0500176crypto/test/aes_calc$(EXE): crypto/test/aes_calc.c test/util.c
177 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
178
179crypto/test/datatypes_driver$(EXE): crypto/test/datatypes_driver.c test/util.c
180 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
181
182crypto/test/sha1_driver$(EXE): crypto/test/sha1_driver.c test/util.c
183 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
184
185test/srtp_driver$(EXE): test/srtp_driver.c test/util.c test/getopt_s.c
David McGrew79bd3012006-07-17 20:41:21 +0000186 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
187
188test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
189 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
190
191test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000192 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000193
194test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000195 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000196
197memtest: test/srtp_driver
198 @test/srtp_driver -v -d "alloc" > tmp
199 @grep freed tmp | wc -l > freed
200 @grep allocated tmp | wc -l > allocated
201 @echo "checking for memory leaks (only works with --enable-stdout)"
202 cmp -s allocated freed
203 @echo "passed (same number of alloc() and dealloc() calls found)"
204 @rm freed allocated tmp
205
Cullen Jennings235513a2005-09-21 22:51:36 +0000206# the target 'plot' runs the timing test (test/srtp_driver -t) then
207# uses gnuplot to produce plots of the results - see the script file
208# 'timing'
209
210plot: test/srtp_driver
211 test/srtp_driver -t > timing.dat
212
213
214# bookkeeping: tags, clean, and distribution
215
216tags:
217 etags */*.[ch] */*/*.[ch]
218
219
220# documentation - the target libsrtpdoc builds a PDF file documenting
jfigusd196e022014-11-20 16:43:44 -0500221# libsrtp2
Cullen Jennings235513a2005-09-21 22:51:36 +0000222
jfigusd196e022014-11-20 16:43:44 -0500223libsrtp2doc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000224 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000225
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000226.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000227
228install:
jfigusd196e022014-11-20 16:43:44 -0500229 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp2
David McGrewb67061f2005-09-28 14:23:06 +0000230 $(INSTALL) -d $(DESTDIR)$(libdir)
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530231 $(INSTALL) -d $(DESTDIR)$(bindir)
jfigusd196e022014-11-20 16:43:44 -0500232 cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp2
233 cp $(srcdir)/include/ekt.h $(DESTDIR)$(includedir)/srtp2
234 cp $(srcdir)/include/rtp.h $(DESTDIR)$(includedir)/srtp2
235 if [ -f libsrtp2.a ]; then cp libsrtp2.a $(DESTDIR)$(libdir)/; fi
jfigus219ce4b2014-12-01 11:03:42 -0500236 if [ -f libsrtp2.dll.a ]; then cp libsrtp2.dll.a $(DESTDIR)$(libdir)/; fi
237 if [ -f libsrtp2.$(SHAREDLIBSUFFIX) ]; then \
238 cp libsrtp2.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \
239 cp libsrtp2.$(SHAREDLIBSUFFIXNOVER) $(DESTDIR)$(SHAREDLIB_DIR)/; \
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530240 fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200241 if [ "$(pkgconfig_DATA)" != "" ]; then \
242 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
243 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
244 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000245
246uninstall:
jfigusd196e022014-11-20 16:43:44 -0500247 rm -f $(DESTDIR)$(includedir)/srtp2/*.h
jfigus219ce4b2014-12-01 11:03:42 -0500248 rm -f $(DESTDIR)$(libdir)/libsrtp2.*
jfigusd196e022014-11-20 16:43:44 -0500249 -rmdir $(DESTDIR)$(includedir)/srtp2
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200250 if [ "$(pkgconfig_DATA)" != "" ]; then \
251 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
252 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000253
254clean:
jfigus8aa936e2014-11-06 10:16:35 -0500255 rm -rf $(cryptobj) $(srtpobj) TAGS \
jfigus219ce4b2014-12-01 11:03:42 -0500256 libsrtp2.a libsrtp2.so libsrtp2.dll.a core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000257 for a in * */* */*/*; do \
258 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
259 done;
jfigus8aa936e2014-11-06 10:16:35 -0500260 for a in $(testapp); do rm -rf $$a$(EXE); done
Cullen Jennings235513a2005-09-21 22:51:36 +0000261 rm -rf *.pict *.jpg *.dat
262 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000263 $(MAKE) -C doc clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000264
265superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000266 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000267 Makefile crypto/Makefile doc/Makefile \
268 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000269 rm -rf autom4te.cache
270
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000271distclean: superclean
272
Cullen Jenningsef29a902013-04-30 12:54:54 -0600273distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000274
David McGrewb67061f2005-09-28 14:23:06 +0000275distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000276 if ! [ -f VERSION ]; then exit 1; fi
277 if [ -f ../$(distname).tgz ]; then \
278 mv ../$(distname).tgz ../$(distname).tgz.bak; \
279 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600280 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000281
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000282# EOF