blob: 0170a51aa8e401fe6b7c7d9aa99c6a80d88c8f99 [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@
18
David McGrew5529f102005-09-29 11:25:10 +000019.PHONY: all test build_table_apps
Cullen Jennings235513a2005-09-21 22:51:36 +000020
David McGrewb67061f2005-09-28 14:23:06 +000021all: test
22
David McGrew5529f102005-09-29 11:25:10 +000023runtest: build_table_apps test
Cullen Jennings235513a2005-09-21 22:51:36 +000024 @echo "running libsrtp test applications..."
Marcus Sundbergb0a93112005-10-02 21:11:33 +000025 crypto/test/cipher_driver$(EXE) -v >/dev/null
26 crypto/test/kernel_driver$(EXE) -v >/dev/null
Cullen Jennings235513a2005-09-21 22:51:36 +000027 test/rdbx_driver$(EXE) -v >/dev/null
28 test/srtp_driver$(EXE) -v >/dev/null
29 test/roc_driver$(EXE) -v >/dev/null
David McGrew11b2e412006-03-16 19:13:31 +000030 test/replay_driver$(EXE) -v >/dev/null
David McGrew0cb86ee2006-07-07 15:46:57 +000031 test/dtls_srtp_driver$(EXE) >/dev/null
Jonathan Lennoxf4647432010-05-14 23:17:51 +000032 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null
jfigus8c36da22013-10-01 16:41:19 -040033ifeq (1, $(USE_OPENSSL))
34 cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh >/dev/null
35endif
Cullen Jennings235513a2005-09-21 22:51:36 +000036 @echo "libsrtp test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000037 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000038
39# makefile variables
40
Marcus Sundberg589127e2005-09-29 13:34:06 +000041CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000042INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
43DEFS = @DEFS@
44CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000045CFLAGS = @CFLAGS@
46LIBS = @LIBS@
47LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000048COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000049SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000050
Marcus Sundberg589127e2005-09-29 13:34:06 +000051RANLIB = @RANLIB@
52INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000053
Marcus Sundberg95e23722005-10-02 19:44:28 +000054# EXE defines the suffix on executables - it's .exe for Windows, and
55# null on linux, bsd, and OS X and other OSes.
56EXE = @EXE@
Cullen Jenningsef29a902013-04-30 12:54:54 -060057
Marcus Sundberg95e23722005-10-02 19:44:28 +000058# gdoi is the group domain of interpretation for isakmp, a group key
59# management system which can provide keys for srtp
60gdoi = @GDOI_OBJS@
Cullen Jenningsef29a902013-04-30 12:54:54 -060061
Marcus Sundberg5c714e42005-10-03 15:16:06 +000062# Random source.
63RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040064HMAC_OBJS = @HMAC_OBJS@
jfigusa14b5a02013-03-29 12:24:12 -040065RNG_EXTRA_OBJS = @RNG_EXTRA_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040066AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000067
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000068srcdir = @srcdir@
69top_srcdir = @top_srcdir@
70top_builddir = @top_builddir@
71VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000072prefix = @prefix@
73exec_prefix = @exec_prefix@
74includedir = @includedir@
75libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000076
77
78# implicit rules for object files and test apps
79
80%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000081 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000082
Marcus Sundberg1f84c402005-10-06 13:59:21 +000083%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000084 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000085
86
87# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000088ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040089 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000090
jfigus0d3a2682013-04-02 15:42:37 -040091hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
92 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000093
94replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
95 crypto/replay/ut_sim.o
96
97math = crypto/math/datatypes.o crypto/math/stat.o
98
99ust = crypto/ust/ust.o
100
jfigusa14b5a02013-03-29 12:24:12 -0400101rng = crypto/rng/$(RNG_OBJS) $(RNG_EXTRA_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000102
103err = crypto/kernel/err.o
104
105kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
106 crypto/kernel/key.o $(rng) $(err) # $(ust)
107
108cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
109
Cullen Jennings235513a2005-09-21 22:51:36 +0000110# libsrtp.a (implements srtp processing)
111
David McGrew79870d62007-06-15 18:17:39 +0000112srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000113
114libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000115 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000116 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000117
jfigus50046422013-10-10 08:35:16 -0400118libsrtp.so: $(srtpobj) $(cryptobj) $(gdoi)
119 $(CC) -shared -Wl,-soname,libsrtp.so $(LDFLAGS) \
120 -o libsrtp.so $^
121
Cullen Jennings235513a2005-09-21 22:51:36 +0000122# libcryptomath.a contains general-purpose routines that are used to
123# generate tables and verify cryptoalgorithm implementations - this
124# library is not meant to be included in production code
125
David McGrewb67061f2005-09-28 14:23:06 +0000126cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000127
128libcryptomath.a: $(cryptomath)
129 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000130 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000131
132
133# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400134ifneq (1, $(USE_OPENSSL))
135AES_CALC = crypto/test/aes_calc$(EXE)
136endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000137
jfigus0d3a2682013-04-02 15:42:37 -0400138crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000139 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
140 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
141 crypto/test/stat_driver$(EXE)
142
143testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000144 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000145 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000146
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000147$(testapp): libsrtp.a
148
David McGrew79bd3012006-07-17 20:41:21 +0000149test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c
150 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
151
152test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
153 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
154
155test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
156 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
157
158test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000159 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000160
161test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000162 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000163
164memtest: test/srtp_driver
165 @test/srtp_driver -v -d "alloc" > tmp
166 @grep freed tmp | wc -l > freed
167 @grep allocated tmp | wc -l > allocated
168 @echo "checking for memory leaks (only works with --enable-stdout)"
169 cmp -s allocated freed
170 @echo "passed (same number of alloc() and dealloc() calls found)"
171 @rm freed allocated tmp
172
173# tables_apps are used to generate the tables used in the crypto
174# implementations; these need only be generated during porting, not
175# for building libsrtp or the test applications
176
David McGrew5529f102005-09-29 11:25:10 +0000177table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000178
David McGrew5529f102005-09-29 11:25:10 +0000179build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000180
181# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
182
183tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000184 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000185
186# the target 'plot' runs the timing test (test/srtp_driver -t) then
187# uses gnuplot to produce plots of the results - see the script file
188# 'timing'
189
190plot: test/srtp_driver
191 test/srtp_driver -t > timing.dat
192
193
194# bookkeeping: tags, clean, and distribution
195
196tags:
197 etags */*.[ch] */*/*.[ch]
198
199
200# documentation - the target libsrtpdoc builds a PDF file documenting
201# libsrtp
202
203libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000204 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000205
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000206.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000207
208install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000209 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000210 echo "you should run 'make uninstall' first"; exit 1; \
211 fi
David McGrewb67061f2005-09-28 14:23:06 +0000212 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
213 $(INSTALL) -d $(DESTDIR)$(libdir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000214 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp
215 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp
216 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000217 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
jfigus50046422013-10-10 08:35:16 -0400218 if [ -f libsrtp.so ]; then cp libsrtp.so $(DESTDIR)$(libdir)/; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000219
220uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000221 rm -f $(DESTDIR)$(includedir)/srtp/*.h
222 rm -f $(DESTDIR)$(libdir)/libsrtp.a
jfigus50046422013-10-10 08:35:16 -0400223 rm -f $(DESTDIR)$(libdir)/libsrtp.so
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000224 -rmdir $(DESTDIR)$(includedir)/srtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000225
226clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000227 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
jfigus50046422013-10-10 08:35:16 -0400228 libcryptomath.a libsrtp.a libsrtp.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000229 for a in * */* */*/*; do \
230 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
231 done;
232 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
233 rm -rf *.pict *.jpg *.dat
234 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000235 $(MAKE) -C doc clean
236 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000237
238
239superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000240 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000241 Makefile crypto/Makefile doc/Makefile \
242 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000243 rm -rf autom4te.cache
244
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000245distclean: superclean
246
Cullen Jenningsef29a902013-04-30 12:54:54 -0600247distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000248
David McGrewb67061f2005-09-28 14:23:06 +0000249distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000250 if ! [ -f VERSION ]; then exit 1; fi
251 if [ -f ../$(distname).tgz ]; then \
252 mv ../$(distname).tgz ../$(distname).tgz.bak; \
253 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600254 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000255
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000256# EOF