blob: d9956a02f871da9aa804188b19a62a402059df94 [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
David McGrew5529f102005-09-29 11:25:10 +000021.PHONY: all 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@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000047CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000048CFLAGS = @CFLAGS@
49LIBS = @LIBS@
50LDFLAGS = @LDFLAGS@ -L.
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@
Cullen Jennings235513a2005-09-21 22:51:36 +000079
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020080ifeq (1, $(HAVE_PKG_CONFIG))
81pkgconfigdir = $(libdir)/pkgconfig
82pkgconfig_DATA = libsrtp.pc
83endif
Cullen Jennings235513a2005-09-21 22:51:36 +000084
85# implicit rules for object files and test apps
86
87%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000088 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000089
Marcus Sundberg1f84c402005-10-06 13:59:21 +000090%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000091 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000092
93
94# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000095ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040096 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000097
jfigus0d3a2682013-04-02 15:42:37 -040098hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
99 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000100
101replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
102 crypto/replay/ut_sim.o
103
104math = crypto/math/datatypes.o crypto/math/stat.o
105
106ust = crypto/ust/ust.o
107
jfigusa14b5a02013-03-29 12:24:12 -0400108rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000109
110err = crypto/kernel/err.o
111
112kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
113 crypto/kernel/key.o $(rng) $(err) # $(ust)
114
115cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
116
Cullen Jennings235513a2005-09-21 22:51:36 +0000117# libsrtp.a (implements srtp processing)
118
David McGrew79870d62007-06-15 18:17:39 +0000119srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000120
121libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000122 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000123 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000124
jfigus50046422013-10-10 08:35:16 -0400125libsrtp.so: $(srtpobj) $(cryptobj) $(gdoi)
jfigus2b486652014-07-24 15:01:41 -0400126 $(CC) -shared -Wl,-soname,libsrtp.so \
127 -o libsrtp.so $^ $(LDFLAGS)
jfigus50046422013-10-10 08:35:16 -0400128
Cullen Jennings235513a2005-09-21 22:51:36 +0000129# libcryptomath.a contains general-purpose routines that are used to
130# generate tables and verify cryptoalgorithm implementations - this
131# library is not meant to be included in production code
132
David McGrewb67061f2005-09-28 14:23:06 +0000133cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000134
135libcryptomath.a: $(cryptomath)
136 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000137 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000138
139
140# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400141ifneq (1, $(USE_OPENSSL))
142AES_CALC = crypto/test/aes_calc$(EXE)
143endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000144
jfigus0d3a2682013-04-02 15:42:37 -0400145crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000146 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
147 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
Rich Rodriguez29b152e2014-07-01 06:01:33 +0000148 crypto/test/stat_driver$(EXE) crypto/test/rand_gen_soak$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000149
150testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000151 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000152 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000153
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000154$(testapp): libsrtp.a
155
Bernardo Torresb3c51422014-10-14 12:40:09 -0300156test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c
David McGrew79bd3012006-07-17 20:41:21 +0000157 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
158
Bernardo Torresb3c51422014-10-14 12:40:09 -0300159ifeq (1, $(HAVE_PCAP))
160testapp += test/rtp_decoder$(EXE)
161test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/getopt_s.c
162 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
163endif
164
David McGrew79bd3012006-07-17 20:41:21 +0000165test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
166 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
167
168test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
169 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
170
171test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000172 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000173
174test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000175 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000176
177memtest: test/srtp_driver
178 @test/srtp_driver -v -d "alloc" > tmp
179 @grep freed tmp | wc -l > freed
180 @grep allocated tmp | wc -l > allocated
181 @echo "checking for memory leaks (only works with --enable-stdout)"
182 cmp -s allocated freed
183 @echo "passed (same number of alloc() and dealloc() calls found)"
184 @rm freed allocated tmp
185
186# tables_apps are used to generate the tables used in the crypto
187# implementations; these need only be generated during porting, not
188# for building libsrtp or the test applications
189
David McGrew5529f102005-09-29 11:25:10 +0000190table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000191
David McGrew5529f102005-09-29 11:25:10 +0000192build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000193
194# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
195
196tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000197 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000198
199# the target 'plot' runs the timing test (test/srtp_driver -t) then
200# uses gnuplot to produce plots of the results - see the script file
201# 'timing'
202
203plot: test/srtp_driver
204 test/srtp_driver -t > timing.dat
205
206
207# bookkeeping: tags, clean, and distribution
208
209tags:
210 etags */*.[ch] */*/*.[ch]
211
212
213# documentation - the target libsrtpdoc builds a PDF file documenting
214# libsrtp
215
216libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000217 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000218
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000219.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000220
221install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000222 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000223 echo "you should run 'make uninstall' first"; exit 1; \
224 fi
David McGrewb67061f2005-09-28 14:23:06 +0000225 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
226 $(INSTALL) -d $(DESTDIR)$(libdir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000227 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp
228 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp
229 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000230 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
jfigus50046422013-10-10 08:35:16 -0400231 if [ -f libsrtp.so ]; then cp libsrtp.so $(DESTDIR)$(libdir)/; fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200232 if [ "$(pkgconfig_DATA)" != "" ]; then \
233 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
234 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
235 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000236
237uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000238 rm -f $(DESTDIR)$(includedir)/srtp/*.h
239 rm -f $(DESTDIR)$(libdir)/libsrtp.a
jfigus50046422013-10-10 08:35:16 -0400240 rm -f $(DESTDIR)$(libdir)/libsrtp.so
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000241 -rmdir $(DESTDIR)$(includedir)/srtp
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200242 if [ "$(pkgconfig_DATA)" != "" ]; then \
243 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
244 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000245
246clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000247 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
jfigus50046422013-10-10 08:35:16 -0400248 libcryptomath.a libsrtp.a libsrtp.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000249 for a in * */* */*/*; do \
250 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
251 done;
252 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
253 rm -rf *.pict *.jpg *.dat
254 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000255 $(MAKE) -C doc clean
256 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000257
258
259superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000260 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000261 Makefile crypto/Makefile doc/Makefile \
262 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000263 rm -rf autom4te.cache
264
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000265distclean: superclean
266
Cullen Jenningsef29a902013-04-30 12:54:54 -0600267distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000268
David McGrewb67061f2005-09-28 14:23:06 +0000269distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000270 if ! [ -f VERSION ]; then exit 1; fi
271 if [ -f ../$(distname).tgz ]; then \
272 mv ../$(distname).tgz ../$(distname).tgz.bak; \
273 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600274 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000275
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000276# EOF