blob: 5a7fc216dc1bcee873bbd1539eed2b71e8394193 [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@
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020018HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
jfigus8c36da22013-10-01 16:41:19 -040019
David McGrew5529f102005-09-29 11:25:10 +000020.PHONY: all test build_table_apps
Cullen Jennings235513a2005-09-21 22:51:36 +000021
David McGrewb67061f2005-09-28 14:23:06 +000022all: test
23
David McGrew5529f102005-09-29 11:25:10 +000024runtest: build_table_apps 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
Rich Rodriguez29b152e2014-07-01 06:01:33 +000033 crypto/test/rand_gen_soak$(EXE) -v >/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
45DEFS = @DEFS@
46CPPFLAGS= @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 Sundberg95e23722005-10-02 19:44:28 +000060# gdoi is the group domain of interpretation for isakmp, a group key
61# management system which can provide keys for srtp
62gdoi = @GDOI_OBJS@
Cullen Jenningsef29a902013-04-30 12:54:54 -060063
Marcus Sundberg5c714e42005-10-03 15:16:06 +000064# Random source.
65RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040066HMAC_OBJS = @HMAC_OBJS@
jfigusa14b5a02013-03-29 12:24:12 -040067RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040068AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000069
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000070srcdir = @srcdir@
71top_srcdir = @top_srcdir@
72top_builddir = @top_builddir@
73VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000074prefix = @prefix@
75exec_prefix = @exec_prefix@
76includedir = @includedir@
77libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000078
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020079ifeq (1, $(HAVE_PKG_CONFIG))
80pkgconfigdir = $(libdir)/pkgconfig
81pkgconfig_DATA = libsrtp.pc
82endif
Cullen Jennings235513a2005-09-21 22:51:36 +000083
84# implicit rules for object files and test apps
85
86%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000087 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000088
Marcus Sundberg1f84c402005-10-06 13:59:21 +000089%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000090 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000091
92
93# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000094ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040095 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000096
jfigus0d3a2682013-04-02 15:42:37 -040097hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
98 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000099
100replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
101 crypto/replay/ut_sim.o
102
103math = crypto/math/datatypes.o crypto/math/stat.o
104
105ust = crypto/ust/ust.o
106
jfigusa14b5a02013-03-29 12:24:12 -0400107rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000108
109err = crypto/kernel/err.o
110
111kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
112 crypto/kernel/key.o $(rng) $(err) # $(ust)
113
114cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
115
Cullen Jennings235513a2005-09-21 22:51:36 +0000116# libsrtp.a (implements srtp processing)
117
David McGrew79870d62007-06-15 18:17:39 +0000118srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000119
120libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000121 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000122 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000123
jfigus50046422013-10-10 08:35:16 -0400124libsrtp.so: $(srtpobj) $(cryptobj) $(gdoi)
jfigus2b486652014-07-24 15:01:41 -0400125 $(CC) -shared -Wl,-soname,libsrtp.so \
126 -o libsrtp.so $^ $(LDFLAGS)
jfigus50046422013-10-10 08:35:16 -0400127
Cullen Jennings235513a2005-09-21 22:51:36 +0000128# libcryptomath.a contains general-purpose routines that are used to
129# generate tables and verify cryptoalgorithm implementations - this
130# library is not meant to be included in production code
131
David McGrewb67061f2005-09-28 14:23:06 +0000132cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000133
134libcryptomath.a: $(cryptomath)
135 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000136 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000137
138
139# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400140ifneq (1, $(USE_OPENSSL))
141AES_CALC = crypto/test/aes_calc$(EXE)
142endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000143
jfigus0d3a2682013-04-02 15:42:37 -0400144crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000145 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
146 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
Rich Rodriguez29b152e2014-07-01 06:01:33 +0000147 crypto/test/stat_driver$(EXE) crypto/test/rand_gen_soak$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000148
149testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000150 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000151 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000152
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000153$(testapp): libsrtp.a
154
David McGrew79bd3012006-07-17 20:41:21 +0000155test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c
156 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
157
158test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
159 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
160
161test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
162 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
163
164test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000165 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000166
167test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000168 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000169
170memtest: test/srtp_driver
171 @test/srtp_driver -v -d "alloc" > tmp
172 @grep freed tmp | wc -l > freed
173 @grep allocated tmp | wc -l > allocated
174 @echo "checking for memory leaks (only works with --enable-stdout)"
175 cmp -s allocated freed
176 @echo "passed (same number of alloc() and dealloc() calls found)"
177 @rm freed allocated tmp
178
179# tables_apps are used to generate the tables used in the crypto
180# implementations; these need only be generated during porting, not
181# for building libsrtp or the test applications
182
David McGrew5529f102005-09-29 11:25:10 +0000183table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000184
David McGrew5529f102005-09-29 11:25:10 +0000185build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000186
187# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
188
189tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000190 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000191
192# the target 'plot' runs the timing test (test/srtp_driver -t) then
193# uses gnuplot to produce plots of the results - see the script file
194# 'timing'
195
196plot: test/srtp_driver
197 test/srtp_driver -t > timing.dat
198
199
200# bookkeeping: tags, clean, and distribution
201
202tags:
203 etags */*.[ch] */*/*.[ch]
204
205
206# documentation - the target libsrtpdoc builds a PDF file documenting
207# libsrtp
208
209libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000210 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000211
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000212.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000213
214install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000215 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000216 echo "you should run 'make uninstall' first"; exit 1; \
217 fi
David McGrewb67061f2005-09-28 14:23:06 +0000218 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
219 $(INSTALL) -d $(DESTDIR)$(libdir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000220 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp
221 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp
222 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000223 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
jfigus50046422013-10-10 08:35:16 -0400224 if [ -f libsrtp.so ]; then cp libsrtp.so $(DESTDIR)$(libdir)/; fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200225 if [ "$(pkgconfig_DATA)" != "" ]; then \
226 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
227 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
228 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000229
230uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000231 rm -f $(DESTDIR)$(includedir)/srtp/*.h
232 rm -f $(DESTDIR)$(libdir)/libsrtp.a
jfigus50046422013-10-10 08:35:16 -0400233 rm -f $(DESTDIR)$(libdir)/libsrtp.so
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000234 -rmdir $(DESTDIR)$(includedir)/srtp
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200235 if [ "$(pkgconfig_DATA)" != "" ]; then \
236 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
237 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000238
239clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000240 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
jfigus50046422013-10-10 08:35:16 -0400241 libcryptomath.a libsrtp.a libsrtp.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000242 for a in * */* */*/*; do \
243 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
244 done;
245 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
246 rm -rf *.pict *.jpg *.dat
247 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000248 $(MAKE) -C doc clean
249 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000250
251
252superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000253 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000254 Makefile crypto/Makefile doc/Makefile \
255 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000256 rm -rf autom4te.cache
257
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000258distclean: superclean
259
Cullen Jenningsef29a902013-04-30 12:54:54 -0600260distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000261
David McGrewb67061f2005-09-28 14:23:06 +0000262distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000263 if ! [ -f VERSION ]; then exit 1; fi
264 if [ -f ../$(distname).tgz ]; then \
265 mv ../$(distname).tgz ../$(distname).tgz.bak; \
266 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600267 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000268
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000269# EOF