blob: 29a00abf1de34beb0af0a684b5749ead15249967 [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
Marcus Sundberg5c714e42005-10-03 15:16:06 +000059# Random source.
60RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040061HMAC_OBJS = @HMAC_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040062AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000063
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000064srcdir = @srcdir@
65top_srcdir = @top_srcdir@
66top_builddir = @top_builddir@
67VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000068prefix = @prefix@
69exec_prefix = @exec_prefix@
70includedir = @includedir@
71libdir = @libdir@
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053072bindir = @bindir@
Cullen Jennings235513a2005-09-21 22:51:36 +000073
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020074ifeq (1, $(HAVE_PKG_CONFIG))
75pkgconfigdir = $(libdir)/pkgconfig
jfigusd196e022014-11-20 16:43:44 -050076pkgconfig_DATA = libsrtp2.pc
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020077endif
Cullen Jennings235513a2005-09-21 22:51:36 +000078
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053079SHAREDLIBVERSION = 1
80ifeq (linux,$(findstring linux,@host@))
81SHAREDLIB_DIR = $(libdir)
82SHAREDLIB_LDFLAGS = -shared -Wl,-soname,$@
83SHAREDLIBSUFFIXNOVER = so
84SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER).$(SHAREDLIBVERSION)
85else ifeq (mingw,$(findstring mingw,@host@))
86SHAREDLIB_DIR = $(bindir)
jfigus219ce4b2014-12-01 11:03:42 -050087SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp2.dll.a
Nirbheek Chauhancae277e2014-11-05 18:35:14 +053088SHAREDLIBVERSION =
89SHAREDLIBSUFFIXNOVER = dll
90SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER)
91else ifeq (darwin,$(findstring darwin,@host@))
92SHAREDLIB_DIR = $(libdir)
93SHAREDLIB_LDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \
94 -fno-common -headerpad_max_install_names -install_name $(libdir)/$@
95SHAREDLIBSUFFIXNOVER = dylib
96SHAREDLIBSUFFIX = $(SHAREDLIBVERSION).$(SHAREDLIBSUFFIXNOVER)
97endif
98
Cullen Jennings235513a2005-09-21 22:51:36 +000099# implicit rules for object files and test apps
100
101%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000102 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +0000103
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000104%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +0000105 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000106
Cullen Jennings235513a2005-09-21 22:51:36 +0000107ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -0400108 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000109
jfigus0d3a2682013-04-02 15:42:37 -0400110hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
111 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000112
113replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
114 crypto/replay/ut_sim.o
115
116math = crypto/math/datatypes.o crypto/math/stat.o
117
118ust = crypto/ust/ust.o
119
jfigus25690492014-11-19 12:07:18 -0500120rng = crypto/rng/$(RNG_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000121
122err = crypto/kernel/err.o
123
124kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
125 crypto/kernel/key.o $(rng) $(err) # $(ust)
126
127cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
128
jfigusd196e022014-11-20 16:43:44 -0500129# libsrtp2.a (implements srtp processing)
Cullen Jennings235513a2005-09-21 22:51:36 +0000130
David McGrew79870d62007-06-15 18:17:39 +0000131srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000132
jfigus219ce4b2014-12-01 11:03:42 -0500133libsrtp2.a: $(srtpobj) $(cryptobj) $(gdoi)
jfigusd196e022014-11-20 16:43:44 -0500134 ar cr libsrtp2.a $^
135 $(RANLIB) libsrtp2.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000136
jfigus219ce4b2014-12-01 11:03:42 -0500137libsrtp2.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi)
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530138 $(CC) -shared -o $@ $(SHAREDLIB_LDFLAGS) \
139 $^ $(LDFLAGS) $(LIBS)
140 if [ -n "$(SHAREDLIBVERSION)" ]; then \
jfigus219ce4b2014-12-01 11:03:42 -0500141 ln -sfn $@ libsrtp2.$(SHAREDLIBSUFFIXNOVER); \
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530142 fi
143
jfigus219ce4b2014-12-01 11:03:42 -0500144shared_library: libsrtp2.$(SHAREDLIBSUFFIX)
jfigus50046422013-10-10 08:35:16 -0400145
jfigusd196e022014-11-20 16:43:44 -0500146libsrtp2.so: $(srtpobj) $(cryptobj)
147 $(CC) -shared -Wl,-soname,libsrtp2.so \
148 -o libsrtp2.so $^ $(LDFLAGS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000149
Cullen Jennings235513a2005-09-21 22:51:36 +0000150# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400151ifneq (1, $(USE_OPENSSL))
152AES_CALC = crypto/test/aes_calc$(EXE)
153endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000154
jfigus0d3a2682013-04-02 15:42:37 -0400155crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000156 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
jfigus339b61d2014-11-04 15:36:15 -0500157 crypto/test/sha1_driver$(EXE) \
158 crypto/test/stat_driver$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000159
160testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000161 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000162 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000163
jfigus98bb4fb2014-10-15 09:48:03 -0400164ifeq (1, $(HAVE_PCAP))
165testapp += test/rtp_decoder$(EXE)
166endif
167
jfigusd196e022014-11-20 16:43:44 -0500168$(testapp): libsrtp2.a
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000169
jfigus46d6b472014-11-14 16:42:01 -0500170test/rtpw$(EXE): test/rtpw.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100171 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500172 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000173
Bernardo Torresb3c51422014-10-14 12:40:09 -0300174ifeq (1, $(HAVE_PCAP))
jfigus46d6b472014-11-14 16:42:01 -0500175test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100176 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500177 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300178endif
179
jfigus46d6b472014-11-14 16:42:01 -0500180crypto/test/aes_calc$(EXE): crypto/test/aes_calc.c test/util.c
181 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
182
183crypto/test/datatypes_driver$(EXE): crypto/test/datatypes_driver.c test/util.c
184 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
185
186crypto/test/sha1_driver$(EXE): crypto/test/sha1_driver.c test/util.c
187 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
188
189test/srtp_driver$(EXE): test/srtp_driver.c test/util.c test/getopt_s.c
David McGrew79bd3012006-07-17 20:41:21 +0000190 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
191
192test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
193 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
194
195test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000196 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000197
198test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000199 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000200
201memtest: test/srtp_driver
202 @test/srtp_driver -v -d "alloc" > tmp
203 @grep freed tmp | wc -l > freed
204 @grep allocated tmp | wc -l > allocated
205 @echo "checking for memory leaks (only works with --enable-stdout)"
206 cmp -s allocated freed
207 @echo "passed (same number of alloc() and dealloc() calls found)"
208 @rm freed allocated tmp
209
Cullen Jennings235513a2005-09-21 22:51:36 +0000210# the target 'plot' runs the timing test (test/srtp_driver -t) then
211# uses gnuplot to produce plots of the results - see the script file
212# 'timing'
213
214plot: test/srtp_driver
215 test/srtp_driver -t > timing.dat
216
217
218# bookkeeping: tags, clean, and distribution
219
220tags:
221 etags */*.[ch] */*/*.[ch]
222
223
224# documentation - the target libsrtpdoc builds a PDF file documenting
jfigusd196e022014-11-20 16:43:44 -0500225# libsrtp2
Cullen Jennings235513a2005-09-21 22:51:36 +0000226
jfigusd196e022014-11-20 16:43:44 -0500227libsrtp2doc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000228 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000229
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000230.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000231
232install:
jfigusd196e022014-11-20 16:43:44 -0500233 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp2
David McGrewb67061f2005-09-28 14:23:06 +0000234 $(INSTALL) -d $(DESTDIR)$(libdir)
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530235 $(INSTALL) -d $(DESTDIR)$(bindir)
jfigusd196e022014-11-20 16:43:44 -0500236 cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp2
237 cp $(srcdir)/include/ekt.h $(DESTDIR)$(includedir)/srtp2
238 cp $(srcdir)/include/rtp.h $(DESTDIR)$(includedir)/srtp2
239 if [ -f libsrtp2.a ]; then cp libsrtp2.a $(DESTDIR)$(libdir)/; fi
jfigus219ce4b2014-12-01 11:03:42 -0500240 if [ -f libsrtp2.dll.a ]; then cp libsrtp2.dll.a $(DESTDIR)$(libdir)/; fi
241 if [ -f libsrtp2.$(SHAREDLIBSUFFIX) ]; then \
242 cp libsrtp2.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \
243 cp libsrtp2.$(SHAREDLIBSUFFIXNOVER) $(DESTDIR)$(SHAREDLIB_DIR)/; \
Nirbheek Chauhancae277e2014-11-05 18:35:14 +0530244 fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200245 if [ "$(pkgconfig_DATA)" != "" ]; then \
246 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
247 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
248 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000249
250uninstall:
jfigusd196e022014-11-20 16:43:44 -0500251 rm -f $(DESTDIR)$(includedir)/srtp2/*.h
jfigus219ce4b2014-12-01 11:03:42 -0500252 rm -f $(DESTDIR)$(libdir)/libsrtp2.*
jfigusd196e022014-11-20 16:43:44 -0500253 -rmdir $(DESTDIR)$(includedir)/srtp2
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200254 if [ "$(pkgconfig_DATA)" != "" ]; then \
255 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
256 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000257
258clean:
jfigus8aa936e2014-11-06 10:16:35 -0500259 rm -rf $(cryptobj) $(srtpobj) TAGS \
jfigus219ce4b2014-12-01 11:03:42 -0500260 libsrtp2.a libsrtp2.so libsrtp2.dll.a core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000261 for a in * */* */*/*; do \
262 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
263 done;
jfigus8aa936e2014-11-06 10:16:35 -0500264 for a in $(testapp); do rm -rf $$a$(EXE); done
Cullen Jennings235513a2005-09-21 22:51:36 +0000265 rm -rf *.pict *.jpg *.dat
266 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000267 $(MAKE) -C doc clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000268
269superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000270 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000271 Makefile crypto/Makefile doc/Makefile \
272 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000273 rm -rf autom4te.cache
274
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000275distclean: superclean
276
Cullen Jenningsef29a902013-04-30 12:54:54 -0600277distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000278
David McGrewb67061f2005-09-28 14:23:06 +0000279distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000280 if ! [ -f VERSION ]; then exit 1; fi
281 if [ -f ../$(distname).tgz ]; then \
282 mv ../$(distname).tgz ../$(distname).tgz.bak; \
283 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600284 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000285
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000286# EOF