blob: 582c20c5f96252d3cc700b408359b6e6d52101a5 [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
12# 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
David McGrew5529f102005-09-29 11:25:10 +000016.PHONY: all test build_table_apps
Cullen Jennings235513a2005-09-21 22:51:36 +000017
David McGrewb67061f2005-09-28 14:23:06 +000018all: test
19
David McGrew5529f102005-09-29 11:25:10 +000020runtest: build_table_apps test
Cullen Jennings235513a2005-09-21 22:51:36 +000021 @echo "running libsrtp test applications..."
Marcus Sundbergb0a93112005-10-02 21:11:33 +000022 crypto/test/cipher_driver$(EXE) -v >/dev/null
23 crypto/test/kernel_driver$(EXE) -v >/dev/null
Cullen Jennings235513a2005-09-21 22:51:36 +000024 test/rdbx_driver$(EXE) -v >/dev/null
25 test/srtp_driver$(EXE) -v >/dev/null
26 test/roc_driver$(EXE) -v >/dev/null
David McGrew11b2e412006-03-16 19:13:31 +000027 test/replay_driver$(EXE) -v >/dev/null
David McGrew0cb86ee2006-07-07 15:46:57 +000028 test/dtls_srtp_driver$(EXE) >/dev/null
Jonathan Lennoxf4647432010-05-14 23:17:51 +000029 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null
Cullen Jennings235513a2005-09-21 22:51:36 +000030 @echo "libsrtp test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000031 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000032
33# makefile variables
34
Marcus Sundberg589127e2005-09-29 13:34:06 +000035CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000036INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
37DEFS = @DEFS@
38CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000039CFLAGS = @CFLAGS@
40LIBS = @LIBS@
41LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000042COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000043SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000044
Marcus Sundberg589127e2005-09-29 13:34:06 +000045RANLIB = @RANLIB@
46INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000047
Marcus Sundberg95e23722005-10-02 19:44:28 +000048# EXE defines the suffix on executables - it's .exe for Windows, and
49# null on linux, bsd, and OS X and other OSes.
50EXE = @EXE@
51# gdoi is the group domain of interpretation for isakmp, a group key
52# management system which can provide keys for srtp
53gdoi = @GDOI_OBJS@
Marcus Sundberg5c714e42005-10-03 15:16:06 +000054# Random source.
55RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040056HMAC_OBJS = @HMAC_OBJS@
jfigusa14b5a02013-03-29 12:24:12 -040057RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040058AES_ICM_OBJS = @AES_ICM_OBJS@
59USE_OPENSSL = @USE_OPENSSL@
Marcus Sundberg95e23722005-10-02 19:44:28 +000060
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000061srcdir = @srcdir@
62top_srcdir = @top_srcdir@
63top_builddir = @top_builddir@
64VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000065prefix = @prefix@
66exec_prefix = @exec_prefix@
67includedir = @includedir@
68libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000069
70
71# implicit rules for object files and test apps
72
73%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000074 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000075
Marcus Sundberg1f84c402005-10-06 13:59:21 +000076%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000077 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000078
79
80# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000081ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040082 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000083
jfigus0d3a2682013-04-02 15:42:37 -040084hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
85 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000086
87replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
88 crypto/replay/ut_sim.o
89
90math = crypto/math/datatypes.o crypto/math/stat.o
91
92ust = crypto/ust/ust.o
93
jfigusa14b5a02013-03-29 12:24:12 -040094rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000095
96err = crypto/kernel/err.o
97
98kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
99 crypto/kernel/key.o $(rng) $(err) # $(ust)
100
101cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
102
Cullen Jennings235513a2005-09-21 22:51:36 +0000103# libsrtp.a (implements srtp processing)
104
David McGrew79870d62007-06-15 18:17:39 +0000105srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000106
107libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000108 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000109 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000110
Cullen Jennings235513a2005-09-21 22:51:36 +0000111# libcryptomath.a contains general-purpose routines that are used to
112# generate tables and verify cryptoalgorithm implementations - this
113# library is not meant to be included in production code
114
David McGrewb67061f2005-09-28 14:23:06 +0000115cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000116
117libcryptomath.a: $(cryptomath)
118 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000119 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000120
121
122# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400123ifneq (1, $(USE_OPENSSL))
124AES_CALC = crypto/test/aes_calc$(EXE)
125endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000126
jfigus0d3a2682013-04-02 15:42:37 -0400127crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000128 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
129 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
130 crypto/test/stat_driver$(EXE)
131
132testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000133 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000134 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000135
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000136$(testapp): libsrtp.a
137
David McGrew79bd3012006-07-17 20:41:21 +0000138test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c
139 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
140
141test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
142 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
143
144test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
145 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
146
147test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000148 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000149
150test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000151 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000152
153memtest: test/srtp_driver
154 @test/srtp_driver -v -d "alloc" > tmp
155 @grep freed tmp | wc -l > freed
156 @grep allocated tmp | wc -l > allocated
157 @echo "checking for memory leaks (only works with --enable-stdout)"
158 cmp -s allocated freed
159 @echo "passed (same number of alloc() and dealloc() calls found)"
160 @rm freed allocated tmp
161
162# tables_apps are used to generate the tables used in the crypto
163# implementations; these need only be generated during porting, not
164# for building libsrtp or the test applications
165
David McGrew5529f102005-09-29 11:25:10 +0000166table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000167
David McGrew5529f102005-09-29 11:25:10 +0000168build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000169
170# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
171
172tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000173 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000174
175# the target 'plot' runs the timing test (test/srtp_driver -t) then
176# uses gnuplot to produce plots of the results - see the script file
177# 'timing'
178
179plot: test/srtp_driver
180 test/srtp_driver -t > timing.dat
181
182
183# bookkeeping: tags, clean, and distribution
184
185tags:
186 etags */*.[ch] */*/*.[ch]
187
188
189# documentation - the target libsrtpdoc builds a PDF file documenting
190# libsrtp
191
192libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000193 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000194
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000195.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000196
197install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000198 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000199 echo "you should run 'make uninstall' first"; exit 1; \
200 fi
David McGrewb67061f2005-09-28 14:23:06 +0000201 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
202 $(INSTALL) -d $(DESTDIR)$(libdir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000203 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp
204 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp
205 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000206 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000207
208uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000209 rm -f $(DESTDIR)$(includedir)/srtp/*.h
210 rm -f $(DESTDIR)$(libdir)/libsrtp.a
211 -rmdir $(DESTDIR)$(includedir)/srtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000212
213clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000214 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
David McGrew2d4b3a72006-03-17 21:00:46 +0000215 libcryptomath.a libsrtp.a core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000216 for a in * */* */*/*; do \
217 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
218 done;
219 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
220 rm -rf *.pict *.jpg *.dat
221 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000222 $(MAKE) -C doc clean
223 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000224
225
226superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000227 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000228 Makefile crypto/Makefile doc/Makefile \
229 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000230 rm -rf autom4te.cache
231
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000232distclean: superclean
233
Cullen Jennings235513a2005-09-21 22:51:36 +0000234distname = srtp-$(shell cat VERSION)
235
David McGrewb67061f2005-09-28 14:23:06 +0000236distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000237 if ! [ -f VERSION ]; then exit 1; fi
238 if [ -f ../$(distname).tgz ]; then \
239 mv ../$(distname).tgz ../$(distname).tgz.bak; \
240 fi
241 cd ..; tar cvzf $(distname).tgz srtp
242
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000243# EOF