blob: f119231f757c144bdfe518268e488a1fc538f761 [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
Jonathan Lennoxf4647432010-05-14 23:17:51 +000034 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null
jfigus8c36da22013-10-01 16:41:19 -040035ifeq (1, $(USE_OPENSSL))
36 cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh >/dev/null
37endif
Cullen Jennings235513a2005-09-21 22:51:36 +000038 @echo "libsrtp test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000039 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000040
41# makefile variables
42
Marcus Sundberg589127e2005-09-29 13:34:06 +000043CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000044INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
jfigus44947602014-10-08 13:08:52 -040045DEFS = @DEFS@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000046CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000047CFLAGS = @CFLAGS@
48LIBS = @LIBS@
49LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000050COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000051SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000052
Marcus Sundberg589127e2005-09-29 13:34:06 +000053RANLIB = @RANLIB@
54INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000055
Marcus Sundberg95e23722005-10-02 19:44:28 +000056# EXE defines the suffix on executables - it's .exe for Windows, and
57# null on linux, bsd, and OS X and other OSes.
58EXE = @EXE@
Cullen Jenningsef29a902013-04-30 12:54:54 -060059
Marcus Sundberg5c714e42005-10-03 15:16:06 +000060# Random source.
61RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040062HMAC_OBJS = @HMAC_OBJS@
jfigusa14b5a02013-03-29 12:24:12 -040063RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040064AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000065
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000066srcdir = @srcdir@
67top_srcdir = @top_srcdir@
68top_builddir = @top_builddir@
69VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000070prefix = @prefix@
71exec_prefix = @exec_prefix@
72includedir = @includedir@
73libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000074
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020075ifeq (1, $(HAVE_PKG_CONFIG))
76pkgconfigdir = $(libdir)/pkgconfig
77pkgconfig_DATA = libsrtp.pc
78endif
Cullen Jennings235513a2005-09-21 22:51:36 +000079
80# implicit rules for object files and test apps
81
82%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000083 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000084
Marcus Sundberg1f84c402005-10-06 13:59:21 +000085%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000086 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000087
88
89# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000090ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040091 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000092
jfigus0d3a2682013-04-02 15:42:37 -040093hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
94 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000095
96replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
97 crypto/replay/ut_sim.o
98
99math = crypto/math/datatypes.o crypto/math/stat.o
100
101ust = crypto/ust/ust.o
102
jfigusa14b5a02013-03-29 12:24:12 -0400103rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000104
105err = crypto/kernel/err.o
106
107kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
108 crypto/kernel/key.o $(rng) $(err) # $(ust)
109
110cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
111
Cullen Jennings235513a2005-09-21 22:51:36 +0000112# libsrtp.a (implements srtp processing)
113
David McGrew79870d62007-06-15 18:17:39 +0000114srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000115
jfigus97a80f42014-11-04 14:15:40 -0500116libsrtp.a: $(srtpobj) $(cryptobj)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000117 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000118 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000119
jfigus97a80f42014-11-04 14:15:40 -0500120libsrtp.so: $(srtpobj) $(cryptobj)
jfigus2b486652014-07-24 15:01:41 -0400121 $(CC) -shared -Wl,-soname,libsrtp.so \
122 -o libsrtp.so $^ $(LDFLAGS)
jfigus50046422013-10-10 08:35:16 -0400123
Cullen Jennings235513a2005-09-21 22:51:36 +0000124# libcryptomath.a contains general-purpose routines that are used to
125# generate tables and verify cryptoalgorithm implementations - this
126# library is not meant to be included in production code
127
David McGrewb67061f2005-09-28 14:23:06 +0000128cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000129
130libcryptomath.a: $(cryptomath)
131 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000132 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000133
134
135# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400136ifneq (1, $(USE_OPENSSL))
137AES_CALC = crypto/test/aes_calc$(EXE)
138endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000139
jfigus0d3a2682013-04-02 15:42:37 -0400140crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000141 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
jfigus339b61d2014-11-04 15:36:15 -0500142 crypto/test/sha1_driver$(EXE) \
143 crypto/test/stat_driver$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000144
145testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000146 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000147 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000148
jfigus98bb4fb2014-10-15 09:48:03 -0400149ifeq (1, $(HAVE_PCAP))
150testapp += test/rtp_decoder$(EXE)
151endif
152
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000153$(testapp): libsrtp.a
154
Christian Oien9e4c0912014-10-29 09:11:16 +0100155test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c \
156 crypto/math/datatypes.c
157 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000158
Bernardo Torresb3c51422014-10-14 12:40:09 -0300159ifeq (1, $(HAVE_PCAP))
Christian Oien9e4c0912014-10-29 09:11:16 +0100160test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/getopt_s.c \
161 crypto/math/datatypes.c
162 $(COMPILE) -DTESTAPP_SOURCE=1 $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300163endif
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)
jfigusa9ac8982014-10-31 14:49:31 -0400227 cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp
228 cp $(srcdir)/include/ekt.h $(DESTDIR)$(includedir)/srtp
229 cp $(srcdir)/include/rtp.h $(DESTDIR)$(includedir)/srtp
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