blob: 3f02fdb8c8d28790db1a9b00d145459aec6b4573 [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
Cullen Jennings235513a2005-09-21 22:51:36 +000010# libsrtp.a static library implementing srtp
jfigus50046422013-10-10 08:35:16 -040011# libsrtp.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
jfigus8aa936e2014-11-06 10:16:35 -050020.PHONY: all 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
Cullen Jennings235513a2005-09-21 22:51:36 +000025 @echo "running libsrtp 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
Cullen Jennings235513a2005-09-21 22:51:36 +000037 @echo "libsrtp 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@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000045CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000046CFLAGS = @CFLAGS@
47LIBS = @LIBS@
48LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000049COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000050SRTPLIB = -lsrtp
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@
jfigusa14b5a02013-03-29 12:24:12 -040062RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040063AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000064
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000065srcdir = @srcdir@
66top_srcdir = @top_srcdir@
67top_builddir = @top_builddir@
68VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000069prefix = @prefix@
70exec_prefix = @exec_prefix@
71includedir = @includedir@
72libdir = @libdir@
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
76pkgconfig_DATA = libsrtp.pc
77endif
Cullen Jennings235513a2005-09-21 22:51:36 +000078
79# implicit rules for object files and test apps
80
81%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000082 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000083
Marcus Sundberg1f84c402005-10-06 13:59:21 +000084%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000085 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000086
Cullen Jennings235513a2005-09-21 22:51:36 +000087ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040088 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000089
jfigus0d3a2682013-04-02 15:42:37 -040090hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
91 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000092
93replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
94 crypto/replay/ut_sim.o
95
96math = crypto/math/datatypes.o crypto/math/stat.o
97
98ust = crypto/ust/ust.o
99
jfigusa14b5a02013-03-29 12:24:12 -0400100rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000101
102err = crypto/kernel/err.o
103
104kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
105 crypto/kernel/key.o $(rng) $(err) # $(ust)
106
107cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
108
Cullen Jennings235513a2005-09-21 22:51:36 +0000109# libsrtp.a (implements srtp processing)
110
David McGrew79870d62007-06-15 18:17:39 +0000111srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000112
jfigus97a80f42014-11-04 14:15:40 -0500113libsrtp.a: $(srtpobj) $(cryptobj)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000114 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000115 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000116
jfigus97a80f42014-11-04 14:15:40 -0500117libsrtp.so: $(srtpobj) $(cryptobj)
jfigus2b486652014-07-24 15:01:41 -0400118 $(CC) -shared -Wl,-soname,libsrtp.so \
119 -o libsrtp.so $^ $(LDFLAGS)
jfigus50046422013-10-10 08:35:16 -0400120
Cullen Jennings235513a2005-09-21 22:51:36 +0000121# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400122ifneq (1, $(USE_OPENSSL))
123AES_CALC = crypto/test/aes_calc$(EXE)
124endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000125
jfigus0d3a2682013-04-02 15:42:37 -0400126crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000127 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
jfigus339b61d2014-11-04 15:36:15 -0500128 crypto/test/sha1_driver$(EXE) \
129 crypto/test/stat_driver$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000130
131testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000132 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000133 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000134
jfigus98bb4fb2014-10-15 09:48:03 -0400135ifeq (1, $(HAVE_PCAP))
136testapp += test/rtp_decoder$(EXE)
137endif
138
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000139$(testapp): libsrtp.a
140
jfigus46d6b472014-11-14 16:42:01 -0500141test/rtpw$(EXE): test/rtpw.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100142 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500143 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000144
Bernardo Torresb3c51422014-10-14 12:40:09 -0300145ifeq (1, $(HAVE_PCAP))
jfigus46d6b472014-11-14 16:42:01 -0500146test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100147 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500148 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300149endif
150
jfigus46d6b472014-11-14 16:42:01 -0500151crypto/test/aes_calc$(EXE): crypto/test/aes_calc.c test/util.c
152 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
153
154crypto/test/datatypes_driver$(EXE): crypto/test/datatypes_driver.c test/util.c
155 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
156
157crypto/test/sha1_driver$(EXE): crypto/test/sha1_driver.c test/util.c
158 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
159
160test/srtp_driver$(EXE): test/srtp_driver.c test/util.c test/getopt_s.c
David McGrew79bd3012006-07-17 20:41:21 +0000161 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
162
163test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
164 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
165
166test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000167 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000168
169test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000170 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000171
172memtest: test/srtp_driver
173 @test/srtp_driver -v -d "alloc" > tmp
174 @grep freed tmp | wc -l > freed
175 @grep allocated tmp | wc -l > allocated
176 @echo "checking for memory leaks (only works with --enable-stdout)"
177 cmp -s allocated freed
178 @echo "passed (same number of alloc() and dealloc() calls found)"
179 @rm freed allocated tmp
180
Cullen Jennings235513a2005-09-21 22:51:36 +0000181# the target 'plot' runs the timing test (test/srtp_driver -t) then
182# uses gnuplot to produce plots of the results - see the script file
183# 'timing'
184
185plot: test/srtp_driver
186 test/srtp_driver -t > timing.dat
187
188
189# bookkeeping: tags, clean, and distribution
190
191tags:
192 etags */*.[ch] */*/*.[ch]
193
194
195# documentation - the target libsrtpdoc builds a PDF file documenting
196# libsrtp
197
198libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000199 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000200
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000201.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000202
203install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000204 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000205 echo "you should run 'make uninstall' first"; exit 1; \
206 fi
David McGrewb67061f2005-09-28 14:23:06 +0000207 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
208 $(INSTALL) -d $(DESTDIR)$(libdir)
jfigusa9ac8982014-10-31 14:49:31 -0400209 cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp
210 cp $(srcdir)/include/ekt.h $(DESTDIR)$(includedir)/srtp
211 cp $(srcdir)/include/rtp.h $(DESTDIR)$(includedir)/srtp
David McGrew7c7ff312006-02-23 14:11:11 +0000212 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
jfigus50046422013-10-10 08:35:16 -0400213 if [ -f libsrtp.so ]; then cp libsrtp.so $(DESTDIR)$(libdir)/; fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200214 if [ "$(pkgconfig_DATA)" != "" ]; then \
215 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
216 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
217 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000218
219uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000220 rm -f $(DESTDIR)$(includedir)/srtp/*.h
221 rm -f $(DESTDIR)$(libdir)/libsrtp.a
jfigus50046422013-10-10 08:35:16 -0400222 rm -f $(DESTDIR)$(libdir)/libsrtp.so
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000223 -rmdir $(DESTDIR)$(includedir)/srtp
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200224 if [ "$(pkgconfig_DATA)" != "" ]; then \
225 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
226 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000227
228clean:
jfigus8aa936e2014-11-06 10:16:35 -0500229 rm -rf $(cryptobj) $(srtpobj) TAGS \
230 libsrtp.a libsrtp.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000231 for a in * */* */*/*; do \
232 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
233 done;
jfigus8aa936e2014-11-06 10:16:35 -0500234 for a in $(testapp); do rm -rf $$a$(EXE); done
Cullen Jennings235513a2005-09-21 22:51:36 +0000235 rm -rf *.pict *.jpg *.dat
236 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000237 $(MAKE) -C doc clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000238
239superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000240 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000241 Makefile crypto/Makefile doc/Makefile \
242 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000243 rm -rf autom4te.cache
244
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000245distclean: superclean
246
Cullen Jenningsef29a902013-04-30 12:54:54 -0600247distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000248
David McGrewb67061f2005-09-28 14:23:06 +0000249distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000250 if ! [ -f VERSION ]; then exit 1; fi
251 if [ -f ../$(distname).tgz ]; then \
252 mv ../$(distname).tgz ../$(distname).tgz.bak; \
253 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600254 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000255
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000256# EOF