blob: 5e91d98f3037b8801285e1d0b9f3b0b138ad02ff [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@
Cullen Jenningsef29a902013-04-30 12:54:54 -060051
Marcus Sundberg95e23722005-10-02 19:44:28 +000052# gdoi is the group domain of interpretation for isakmp, a group key
53# management system which can provide keys for srtp
54gdoi = @GDOI_OBJS@
Cullen Jenningsef29a902013-04-30 12:54:54 -060055
Marcus Sundberg5c714e42005-10-03 15:16:06 +000056# Random source.
57RNG_OBJS = @RNG_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000058
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000059srcdir = @srcdir@
60top_srcdir = @top_srcdir@
61top_builddir = @top_builddir@
62VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000063prefix = @prefix@
64exec_prefix = @exec_prefix@
65includedir = @includedir@
66libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000067
68
69# implicit rules for object files and test apps
70
71%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000072 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000073
Marcus Sundberg1f84c402005-10-06 13:59:21 +000074%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000075 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000076
77
78# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000079ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
80 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
81 crypto/cipher/aes_cbc.o
82
83hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
84 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
85
86replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
87 crypto/replay/ut_sim.o
88
89math = crypto/math/datatypes.o crypto/math/stat.o
90
91ust = crypto/ust/ust.o
92
Marcus Sundberg5c714e42005-10-03 15:16:06 +000093rng = crypto/rng/$(RNG_OBJS) crypto/rng/prng.o crypto/rng/ctr_prng.o
Cullen Jennings235513a2005-09-21 22:51:36 +000094
95err = crypto/kernel/err.o
96
97kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
98 crypto/kernel/key.o $(rng) $(err) # $(ust)
99
100cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
101
Cullen Jennings235513a2005-09-21 22:51:36 +0000102# libsrtp.a (implements srtp processing)
103
David McGrew79870d62007-06-15 18:17:39 +0000104srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000105
106libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000107 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000108 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000109
Cullen Jennings235513a2005-09-21 22:51:36 +0000110# libcryptomath.a contains general-purpose routines that are used to
111# generate tables and verify cryptoalgorithm implementations - this
112# library is not meant to be included in production code
113
David McGrewb67061f2005-09-28 14:23:06 +0000114cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000115
116libcryptomath.a: $(cryptomath)
117 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000118 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000119
120
121# test applications
122
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000123crypto_testapp = crypto/test/aes_calc$(EXE) crypto/test/cipher_driver$(EXE) \
124 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
125 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
126 crypto/test/stat_driver$(EXE)
127
128testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000129 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000130 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000131
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000132$(testapp): libsrtp.a
133
David McGrew79bd3012006-07-17 20:41:21 +0000134test/rtpw$(EXE): test/rtpw.c test/rtp.c test/getopt_s.c
135 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
136
137test/srtp_driver$(EXE): test/srtp_driver.c test/getopt_s.c
138 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
139
140test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
141 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
142
143test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000144 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000145
146test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000147 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000148
149memtest: test/srtp_driver
150 @test/srtp_driver -v -d "alloc" > tmp
151 @grep freed tmp | wc -l > freed
152 @grep allocated tmp | wc -l > allocated
153 @echo "checking for memory leaks (only works with --enable-stdout)"
154 cmp -s allocated freed
155 @echo "passed (same number of alloc() and dealloc() calls found)"
156 @rm freed allocated tmp
157
158# tables_apps are used to generate the tables used in the crypto
159# implementations; these need only be generated during porting, not
160# for building libsrtp or the test applications
161
David McGrew5529f102005-09-29 11:25:10 +0000162table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000163
David McGrew5529f102005-09-29 11:25:10 +0000164build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000165
166# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
167
168tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000169 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000170
171# the target 'plot' runs the timing test (test/srtp_driver -t) then
172# uses gnuplot to produce plots of the results - see the script file
173# 'timing'
174
175plot: test/srtp_driver
176 test/srtp_driver -t > timing.dat
177
178
179# bookkeeping: tags, clean, and distribution
180
181tags:
182 etags */*.[ch] */*/*.[ch]
183
184
185# documentation - the target libsrtpdoc builds a PDF file documenting
186# libsrtp
187
188libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000189 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000190
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000191.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000192
193install:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000194 @if [ -r $(DESTDIR)$(includedir)/srtp/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000195 echo "you should run 'make uninstall' first"; exit 1; \
196 fi
David McGrewb67061f2005-09-28 14:23:06 +0000197 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
198 $(INSTALL) -d $(DESTDIR)$(libdir)
Jonathan Lennoxf4647432010-05-14 23:17:51 +0000199 cp $(srcdir)/include/*.h $(DESTDIR)$(includedir)/srtp
200 cp $(srcdir)/crypto/include/*.h $(DESTDIR)$(includedir)/srtp
201 if [ "$(srcdir)" != "." ]; then cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp; fi
David McGrew7c7ff312006-02-23 14:11:11 +0000202 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000203
204uninstall:
Jonathan Lennoxa7897f02010-05-14 23:34:10 +0000205 rm -f $(DESTDIR)$(includedir)/srtp/*.h
206 rm -f $(DESTDIR)$(libdir)/libsrtp.a
207 -rmdir $(DESTDIR)$(includedir)/srtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000208
209clean:
David McGrew5506a8b2006-07-18 17:42:42 +0000210 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) TAGS \
David McGrew2d4b3a72006-03-17 21:00:46 +0000211 libcryptomath.a libsrtp.a core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000212 for a in * */* */*/*; do \
213 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
214 done;
215 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
216 rm -rf *.pict *.jpg *.dat
217 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000218 $(MAKE) -C doc clean
219 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000220
221
222superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000223 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000224 Makefile crypto/Makefile doc/Makefile \
225 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000226 rm -rf autom4te.cache
227
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000228distclean: superclean
229
Cullen Jenningsef29a902013-04-30 12:54:54 -0600230distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000231
David McGrewb67061f2005-09-28 14:23:06 +0000232distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000233 if ! [ -f VERSION ]; then exit 1; fi
234 if [ -f ../$(distname).tgz ]; then \
235 mv ../$(distname).tgz ../$(distname).tgz.bak; \
236 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600237 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000238
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000239# EOF