blob: 828655049f740031daf3509f8c2801be9f578970 [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
Christian Oien9e4c0912014-10-29 09:11:16 +0100141test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c \
142 crypto/math/datatypes.c
143 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000144
Bernardo Torresb3c51422014-10-14 12:40:09 -0300145ifeq (1, $(HAVE_PCAP))
Christian Oien9e4c0912014-10-29 09:11:16 +0100146test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/getopt_s.c \
147 crypto/math/datatypes.c
148 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300149endif
150
David McGrew79bd3012006-07-17 20:41:21 +0000151test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
152 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
153
154test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
155 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
156
157test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000158 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000159
160test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000161 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000162
163memtest: test/srtp_driver
164 @test/srtp_driver -v -d "alloc" > tmp
165 @grep freed tmp | wc -l > freed
166 @grep allocated tmp | wc -l > allocated
167 @echo "checking for memory leaks (only works with --enable-stdout)"
168 cmp -s allocated freed
169 @echo "passed (same number of alloc() and dealloc() calls found)"
170 @rm freed allocated tmp
171
Cullen Jennings235513a2005-09-21 22:51:36 +0000172# the target 'plot' runs the timing test (test/srtp_driver -t) then
173# uses gnuplot to produce plots of the results - see the script file
174# 'timing'
175
176plot: test/srtp_driver
177 test/srtp_driver -t > timing.dat
178
179
180# bookkeeping: tags, clean, and distribution
181
182tags:
183 etags */*.[ch] */*/*.[ch]
184
185
186# documentation - the target libsrtpdoc builds a PDF file documenting
187# libsrtp
188
189libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000190 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000191
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000192.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000193
194install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000195 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000196 echo "you should run 'make uninstall' first"; exit 1; \
197 fi
David McGrewb67061f2005-09-28 14:23:06 +0000198 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
199 $(INSTALL) -d $(DESTDIR)$(libdir)
jfigusa9ac8982014-10-31 14:49:31 -0400200 cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp
201 cp $(srcdir)/include/ekt.h $(DESTDIR)$(includedir)/srtp
202 cp $(srcdir)/include/rtp.h $(DESTDIR)$(includedir)/srtp
David McGrew7c7ff312006-02-23 14:11:11 +0000203 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
jfigus50046422013-10-10 08:35:16 -0400204 if [ -f libsrtp.so ]; then cp libsrtp.so $(DESTDIR)$(libdir)/; fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200205 if [ "$(pkgconfig_DATA)" != "" ]; then \
206 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
207 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
208 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000209
210uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000211 rm -f $(DESTDIR)$(includedir)/srtp/*.h
212 rm -f $(DESTDIR)$(libdir)/libsrtp.a
jfigus50046422013-10-10 08:35:16 -0400213 rm -f $(DESTDIR)$(libdir)/libsrtp.so
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000214 -rmdir $(DESTDIR)$(includedir)/srtp
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200215 if [ "$(pkgconfig_DATA)" != "" ]; then \
216 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
217 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000218
219clean:
jfigus8aa936e2014-11-06 10:16:35 -0500220 rm -rf $(cryptobj) $(srtpobj) TAGS \
221 libsrtp.a libsrtp.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000222 for a in * */* */*/*; do \
223 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
224 done;
jfigus8aa936e2014-11-06 10:16:35 -0500225 for a in $(testapp); do rm -rf $$a$(EXE); done
Cullen Jennings235513a2005-09-21 22:51:36 +0000226 rm -rf *.pict *.jpg *.dat
227 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000228 $(MAKE) -C doc clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000229
230superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000231 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000232 Makefile crypto/Makefile doc/Makefile \
233 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000234 rm -rf autom4te.cache
235
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000236distclean: superclean
237
Cullen Jenningsef29a902013-04-30 12:54:54 -0600238distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000239
David McGrewb67061f2005-09-28 14:23:06 +0000240distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000241 if ! [ -f VERSION ]; then exit 1; fi
242 if [ -f ../$(distname).tgz ]; then \
243 mv ../$(distname).tgz ../$(distname).tgz.bak; \
244 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600245 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000246
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000247# EOF