blob: 0c091be3a07f92de6c6d477cff296e105f16d394 [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
10# libcrypt.a static library implementing crypto engine
11# libsrtp.a static library implementing srtp
jfigus50046422013-10-10 08:35:16 -040012# libsrtp.so shared library implementing srtp
Cullen Jennings235513a2005-09-21 22:51:36 +000013# clean removes objects, libs, and executables
David McGrewb67061f2005-09-28 14:23:06 +000014# distribution cleans and builds a .tgz
15# tags builds etags file from all .c and .h files
Cullen Jennings235513a2005-09-21 22:51:36 +000016
jfigus8c36da22013-10-01 16:41:19 -040017USE_OPENSSL = @USE_OPENSSL@
Bernardo Torresb3c51422014-10-14 12:40:09 -030018HAVE_PCAP = @HAVE_PCAP@
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020019HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
jfigus8c36da22013-10-01 16:41:19 -040020
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053021.PHONY: all shared_library test build_table_apps
Cullen Jennings235513a2005-09-21 22:51:36 +000022
David McGrewb67061f2005-09-28 14:23:06 +000023all: test
24
David McGrew5529f102005-09-29 11:25:10 +000025runtest: build_table_apps test
Cullen Jennings235513a2005-09-21 22:51:36 +000026 @echo "running libsrtp test applications..."
Marcus Sundbergb0a93112005-10-02 21:11:33 +000027 crypto/test/cipher_driver$(EXE) -v >/dev/null
28 crypto/test/kernel_driver$(EXE) -v >/dev/null
Cullen Jennings235513a2005-09-21 22:51:36 +000029 test/rdbx_driver$(EXE) -v >/dev/null
30 test/srtp_driver$(EXE) -v >/dev/null
31 test/roc_driver$(EXE) -v >/dev/null
David McGrew11b2e412006-03-16 19:13:31 +000032 test/replay_driver$(EXE) -v >/dev/null
David McGrew0cb86ee2006-07-07 15:46:57 +000033 test/dtls_srtp_driver$(EXE) >/dev/null
Rich Rodriguez29b152e2014-07-01 06:01:33 +000034 crypto/test/rand_gen_soak$(EXE) -v >/dev/null
Jonathan Lennoxf4647432010-05-14 23:17:51 +000035 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null
jfigus8c36da22013-10-01 16:41:19 -040036ifeq (1, $(USE_OPENSSL))
37 cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh >/dev/null
38endif
Cullen Jennings235513a2005-09-21 22:51:36 +000039 @echo "libsrtp test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000040 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000041
42# makefile variables
43
Marcus Sundberg589127e2005-09-29 13:34:06 +000044CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000045INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
jfigus44947602014-10-08 13:08:52 -040046DEFS = @DEFS@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053047CPPFLAGS= -fPIC @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000048CFLAGS = @CFLAGS@
49LIBS = @LIBS@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053050LDFLAGS = -L. @LDFLAGS@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000051COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000052SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000053
Marcus Sundberg589127e2005-09-29 13:34:06 +000054RANLIB = @RANLIB@
55INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000056
Marcus Sundberg95e23722005-10-02 19:44:28 +000057# EXE defines the suffix on executables - it's .exe for Windows, and
58# null on linux, bsd, and OS X and other OSes.
59EXE = @EXE@
Cullen Jenningsef29a902013-04-30 12:54:54 -060060
Marcus Sundberg95e23722005-10-02 19:44:28 +000061# gdoi is the group domain of interpretation for isakmp, a group key
62# management system which can provide keys for srtp
63gdoi = @GDOI_OBJS@
Cullen Jenningsef29a902013-04-30 12:54:54 -060064
Marcus Sundberg5c714e42005-10-03 15:16:06 +000065# Random source.
66RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040067HMAC_OBJS = @HMAC_OBJS@
jfigusa14b5a02013-03-29 12:24:12 -040068RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040069AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000070
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000071srcdir = @srcdir@
72top_srcdir = @top_srcdir@
73top_builddir = @top_builddir@
74VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000075prefix = @prefix@
76exec_prefix = @exec_prefix@
77includedir = @includedir@
78libdir = @libdir@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053079bindir = @bindir@
Cullen Jennings235513a2005-09-21 22:51:36 +000080
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020081ifeq (1, $(HAVE_PKG_CONFIG))
82pkgconfigdir = $(libdir)/pkgconfig
83pkgconfig_DATA = libsrtp.pc
84endif
Cullen Jennings235513a2005-09-21 22:51:36 +000085
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053086SHAREDLIBVERSION = 1
87ifeq (linux,$(findstring linux,@host@))
88SHAREDLIB_DIR = $(libdir)
89SHAREDLIB_LDFLAGS = -shared -Wl,-soname,$@
90SHAREDLIBSUFFIXNOVER = so
91SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER).$(SHAREDLIBVERSION)
92else ifeq (mingw,$(findstring mingw,@host@))
93SHAREDLIB_DIR = $(bindir)
94SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp.dll.a
95SHAREDLIBVERSION =
96SHAREDLIBSUFFIXNOVER = dll
97SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER)
98else ifeq (darwin,$(findstring darwin,@host@))
99SHAREDLIB_DIR = $(libdir)
100SHAREDLIB_LDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \
101 -fno-common -headerpad_max_install_names -install_name $(libdir)/$@
102SHAREDLIBSUFFIXNOVER = dylib
103SHAREDLIBSUFFIX = $(SHAREDLIBVERSION).$(SHAREDLIBSUFFIXNOVER)
104endif
105
Cullen Jennings235513a2005-09-21 22:51:36 +0000106# implicit rules for object files and test apps
107
108%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000109 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +0000110
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000111%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +0000112 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000113
114
115# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +0000116ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -0400117 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000118
jfigus0d3a2682013-04-02 15:42:37 -0400119hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
120 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000121
122replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
123 crypto/replay/ut_sim.o
124
125math = crypto/math/datatypes.o crypto/math/stat.o
126
127ust = crypto/ust/ust.o
128
jfigusa14b5a02013-03-29 12:24:12 -0400129rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000130
131err = crypto/kernel/err.o
132
133kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
134 crypto/kernel/key.o $(rng) $(err) # $(ust)
135
136cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
137
Cullen Jennings235513a2005-09-21 22:51:36 +0000138# libsrtp.a (implements srtp processing)
139
David McGrew79870d62007-06-15 18:17:39 +0000140srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000141
142libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000143 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000144 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000145
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530146libsrtp.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi)
147 $(CC) -shared -o $@ $(SHAREDLIB_LDFLAGS) \
148 $^ $(LDFLAGS) $(LIBS)
149 if [ -n "$(SHAREDLIBVERSION)" ]; then \
150 ln -sfn $@ libsrtp.$(SHAREDLIBSUFFIXNOVER); \
151 fi
152
153shared_library: libsrtp.$(SHAREDLIBSUFFIX)
jfigus50046422013-10-10 08:35:16 -0400154
Cullen Jennings235513a2005-09-21 22:51:36 +0000155# libcryptomath.a contains general-purpose routines that are used to
156# generate tables and verify cryptoalgorithm implementations - this
157# library is not meant to be included in production code
158
David McGrewb67061f2005-09-28 14:23:06 +0000159cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000160
161libcryptomath.a: $(cryptomath)
162 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000163 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000164
165
166# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400167ifneq (1, $(USE_OPENSSL))
168AES_CALC = crypto/test/aes_calc$(EXE)
169endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000170
jfigus0d3a2682013-04-02 15:42:37 -0400171crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000172 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
173 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
Rich Rodriguez29b152e2014-07-01 06:01:33 +0000174 crypto/test/stat_driver$(EXE) crypto/test/rand_gen_soak$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000175
176testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000177 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000178 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000179
jfigus98bb4fb2014-10-15 09:48:03 -0400180ifeq (1, $(HAVE_PCAP))
181testapp += test/rtp_decoder$(EXE)
182endif
183
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000184$(testapp): libsrtp.a
185
Christian Oien9e4c0912014-10-29 09:11:16 +0100186test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c \
187 crypto/math/datatypes.c
188 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000189
Bernardo Torresb3c51422014-10-14 12:40:09 -0300190ifeq (1, $(HAVE_PCAP))
Christian Oien9e4c0912014-10-29 09:11:16 +0100191test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/getopt_s.c \
192 crypto/math/datatypes.c
193 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300194endif
195
David McGrew79bd3012006-07-17 20:41:21 +0000196test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
197 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
198
199test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
200 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
201
202test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000203 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000204
Joachim Bauch4cdf4672015-03-27 16:56:43 +0100205crypto/test/cipher_driver$(EXE): crypto/test/cipher_driver.c test/getopt_s.c
206 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
207
208crypto/test/kernel_driver$(EXE): crypto/test/kernel_driver.c test/getopt_s.c
209 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
210
211crypto/test/rand_gen$(EXE): crypto/test/rand_gen.c test/getopt_s.c
212 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
213
214crypto/test/rand_gen_soak$(EXE): crypto/test/rand_gen_soak.c test/getopt_s.c
215 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
216
Cullen Jennings235513a2005-09-21 22:51:36 +0000217test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000218 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000219
220memtest: test/srtp_driver
221 @test/srtp_driver -v -d "alloc" > tmp
222 @grep freed tmp | wc -l > freed
223 @grep allocated tmp | wc -l > allocated
224 @echo "checking for memory leaks (only works with --enable-stdout)"
225 cmp -s allocated freed
226 @echo "passed (same number of alloc() and dealloc() calls found)"
227 @rm freed allocated tmp
228
229# tables_apps are used to generate the tables used in the crypto
230# implementations; these need only be generated during porting, not
231# for building libsrtp or the test applications
232
David McGrew5529f102005-09-29 11:25:10 +0000233table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000234
David McGrew5529f102005-09-29 11:25:10 +0000235build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000236
237# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
238
239tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000240 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000241
242# the target 'plot' runs the timing test (test/srtp_driver -t) then
243# uses gnuplot to produce plots of the results - see the script file
244# 'timing'
245
246plot: test/srtp_driver
247 test/srtp_driver -t > timing.dat
248
249
250# bookkeeping: tags, clean, and distribution
251
252tags:
253 etags */*.[ch] */*/*.[ch]
254
255
256# documentation - the target libsrtpdoc builds a PDF file documenting
257# libsrtp
258
259libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000260 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000261
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000262.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000263
264install:
David McGrewb67061f2005-09-28 14:23:06 +0000265 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
266 $(INSTALL) -d $(DESTDIR)$(libdir)
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530267 $(INSTALL) -d $(DESTDIR)$(bindir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000268 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)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000271 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530272 if [ -f libsrtp.dll.a ]; then cp libsrtp.dll.a $(DESTDIR)$(libdir)/; fi
273 if [ -f libsrtp.$(SHAREDLIBSUFFIX) ]; then \
274 cp libsrtp.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \
275 cp libsrtp.$(SHAREDLIBSUFFIXNOVER) $(DESTDIR)$(SHAREDLIB_DIR)/; \
276 fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200277 if [ "$(pkgconfig_DATA)" != "" ]; then \
278 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
Tom Hughes6fd7fa42014-12-09 13:32:33 -0800279 cp $(top_builddir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200280 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000281
282uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000283 rm -f $(DESTDIR)$(includedir)/srtp/*.h
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530284 rm -f $(DESTDIR)$(libdir)/libsrtp.*
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000285 -rmdir $(DESTDIR)$(includedir)/srtp
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200286 if [ "$(pkgconfig_DATA)" != "" ]; then \
287 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
288 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000289
290clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000291 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
jfigusde35bea2014-12-01 11:07:12 -0500292 libcryptomath.a libsrtp.a libsrtp.so libsrtp.dll.a core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000293 for a in * */* */*/*; do \
294 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
295 done;
296 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
297 rm -rf *.pict *.jpg *.dat
298 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000299 $(MAKE) -C doc clean
300 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000301
302
303superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000304 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000305 Makefile crypto/Makefile doc/Makefile \
306 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000307 rm -rf autom4te.cache
308
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000309distclean: superclean
310
Cullen Jenningsef29a902013-04-30 12:54:54 -0600311distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000312
David McGrewb67061f2005-09-28 14:23:06 +0000313distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000314 if ! [ -f VERSION ]; then exit 1; fi
315 if [ -f ../$(distname).tgz ]; then \
316 mv ../$(distname).tgz ../$(distname).tgz.bak; \
317 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600318 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000319
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000320# EOF