blob: bbbbab7e0f9be064eebc5b9a0e8f3977ed413287 [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
jfigus98bb4fb2014-10-15 09:48:03 -0400154ifeq (1, $(HAVE_PCAP))
155testapp += test/rtp_decoder$(EXE)
156endif
157
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000158$(testapp): libsrtp.a
159
Bernardo Torresb3c51422014-10-14 12:40:09 -0300160test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c
David McGrew79bd3012006-07-17 20:41:21 +0000161 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
162
Bernardo Torresb3c51422014-10-14 12:40:09 -0300163ifeq (1, $(HAVE_PCAP))
Bernardo Torresb3c51422014-10-14 12:40:09 -0300164test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/getopt_s.c
165 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
166endif
167
David McGrew79bd3012006-07-17 20:41:21 +0000168test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
169 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
170
171test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
172 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
173
174test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000175 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000176
177test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000178 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000179
180memtest: test/srtp_driver
181 @test/srtp_driver -v -d "alloc" > tmp
182 @grep freed tmp | wc -l > freed
183 @grep allocated tmp | wc -l > allocated
184 @echo "checking for memory leaks (only works with --enable-stdout)"
185 cmp -s allocated freed
186 @echo "passed (same number of alloc() and dealloc() calls found)"
187 @rm freed allocated tmp
188
189# tables_apps are used to generate the tables used in the crypto
190# implementations; these need only be generated during porting, not
191# for building libsrtp or the test applications
192
David McGrew5529f102005-09-29 11:25:10 +0000193table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000194
David McGrew5529f102005-09-29 11:25:10 +0000195build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000196
197# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
198
199tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000200 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000201
202# the target 'plot' runs the timing test (test/srtp_driver -t) then
203# uses gnuplot to produce plots of the results - see the script file
204# 'timing'
205
206plot: test/srtp_driver
207 test/srtp_driver -t > timing.dat
208
209
210# bookkeeping: tags, clean, and distribution
211
212tags:
213 etags */*.[ch] */*/*.[ch]
214
215
216# documentation - the target libsrtpdoc builds a PDF file documenting
217# libsrtp
218
219libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000220 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000221
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000222.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000223
224install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000225 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000226 echo "you should run 'make uninstall' first"; exit 1; \
227 fi
David McGrewb67061f2005-09-28 14:23:06 +0000228 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
229 $(INSTALL) -d $(DESTDIR)$(libdir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000230 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp
231 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp
232 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000233 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
jfigus50046422013-10-10 08:35:16 -0400234 if [ -f libsrtp.so ]; then cp libsrtp.so $(DESTDIR)$(libdir)/; fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200235 if [ "$(pkgconfig_DATA)" != "" ]; then \
236 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
237 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
238 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000239
240uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000241 rm -f $(DESTDIR)$(includedir)/srtp/*.h
242 rm -f $(DESTDIR)$(libdir)/libsrtp.a
jfigus50046422013-10-10 08:35:16 -0400243 rm -f $(DESTDIR)$(libdir)/libsrtp.so
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000244 -rmdir $(DESTDIR)$(includedir)/srtp
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200245 if [ "$(pkgconfig_DATA)" != "" ]; then \
246 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
247 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000248
249clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000250 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
jfigus50046422013-10-10 08:35:16 -0400251 libcryptomath.a libsrtp.a libsrtp.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000252 for a in * */* */*/*; do \
253 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
254 done;
255 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
256 rm -rf *.pict *.jpg *.dat
257 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000258 $(MAKE) -C doc clean
259 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000260
261
262superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000263 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000264 Makefile crypto/Makefile doc/Makefile \
265 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000266 rm -rf autom4te.cache
267
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000268distclean: superclean
269
Cullen Jenningsef29a902013-04-30 12:54:54 -0600270distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000271
David McGrewb67061f2005-09-28 14:23:06 +0000272distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000273 if ! [ -f VERSION ]; then exit 1; fi
274 if [ -f ../$(distname).tgz ]; then \
275 mv ../$(distname).tgz ../$(distname).tgz.bak; \
276 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600277 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000278
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000279# EOF