blob: a8ddac0779ebd2af992f9ad6bcd6598521f7efdc [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
jfigusd196e022014-11-20 16:43:44 -050010# libsrtp2.a static library implementing srtp
11# libsrtp2.so shared library implementing srtp
Cullen Jennings235513a2005-09-21 22:51:36 +000012# 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
jfigus8c36da22013-10-01 16:41:19 -040016USE_OPENSSL = @USE_OPENSSL@
Bernardo Torresb3c51422014-10-14 12:40:09 -030017HAVE_PCAP = @HAVE_PCAP@
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020018HAVE_PKG_CONFIG = @HAVE_PKG_CONFIG@
jfigus8c36da22013-10-01 16:41:19 -040019
jfigus8aa936e2014-11-06 10:16:35 -050020.PHONY: all test
Cullen Jennings235513a2005-09-21 22:51:36 +000021
David McGrewb67061f2005-09-28 14:23:06 +000022all: test
23
jfigus8aa936e2014-11-06 10:16:35 -050024runtest: test
jfigusd196e022014-11-20 16:43:44 -050025 @echo "running libsrtp2 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
Jonathan Lennoxf4647432010-05-14 23:17:51 +000033 cd test; $(abspath $(srcdir))/test/rtpw_test.sh >/dev/null
jfigus8c36da22013-10-01 16:41:19 -040034ifeq (1, $(USE_OPENSSL))
35 cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh >/dev/null
36endif
jfigusd196e022014-11-20 16:43:44 -050037 @echo "libsrtp2 test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000038 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000039
40# makefile variables
41
Marcus Sundberg589127e2005-09-29 13:34:06 +000042CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000043INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
jfigus44947602014-10-08 13:08:52 -040044DEFS = @DEFS@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000045CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000046CFLAGS = @CFLAGS@
47LIBS = @LIBS@
48LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000049COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
jfigusd196e022014-11-20 16:43:44 -050050SRTPLIB = -lsrtp2
David McGrewb67061f2005-09-28 14:23:06 +000051
Marcus Sundberg589127e2005-09-29 13:34:06 +000052RANLIB = @RANLIB@
53INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000054
Marcus Sundberg95e23722005-10-02 19:44:28 +000055# EXE defines the suffix on executables - it's .exe for Windows, and
56# null on linux, bsd, and OS X and other OSes.
57EXE = @EXE@
Cullen Jenningsef29a902013-04-30 12:54:54 -060058
Marcus Sundberg5c714e42005-10-03 15:16:06 +000059# Random source.
60RNG_OBJS = @RNG_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040061HMAC_OBJS = @HMAC_OBJS@
jfigus0d3a2682013-04-02 15:42:37 -040062AES_ICM_OBJS = @AES_ICM_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000063
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000064srcdir = @srcdir@
65top_srcdir = @top_srcdir@
66top_builddir = @top_builddir@
67VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000068prefix = @prefix@
69exec_prefix = @exec_prefix@
70includedir = @includedir@
71libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000072
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020073ifeq (1, $(HAVE_PKG_CONFIG))
74pkgconfigdir = $(libdir)/pkgconfig
jfigusd196e022014-11-20 16:43:44 -050075pkgconfig_DATA = libsrtp2.pc
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +020076endif
Cullen Jennings235513a2005-09-21 22:51:36 +000077
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
Cullen Jennings235513a2005-09-21 22:51:36 +000086ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
jfigus0d3a2682013-04-02 15:42:37 -040087 $(AES_ICM_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000088
jfigus0d3a2682013-04-02 15:42:37 -040089hashes = crypto/hash/null_auth.o crypto/hash/auth.o \
90 $(HMAC_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +000091
92replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
93 crypto/replay/ut_sim.o
94
95math = crypto/math/datatypes.o crypto/math/stat.o
96
97ust = crypto/ust/ust.o
98
jfigus25690492014-11-19 12:07:18 -050099rng = crypto/rng/$(RNG_OBJS)
Cullen Jennings235513a2005-09-21 22:51:36 +0000100
101err = crypto/kernel/err.o
102
103kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
104 crypto/kernel/key.o $(rng) $(err) # $(ust)
105
106cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
107
jfigusd196e022014-11-20 16:43:44 -0500108# libsrtp2.a (implements srtp processing)
Cullen Jennings235513a2005-09-21 22:51:36 +0000109
David McGrew79870d62007-06-15 18:17:39 +0000110srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000111
jfigusd196e022014-11-20 16:43:44 -0500112libsrtp2.a: $(srtpobj) $(cryptobj)
113 ar cr libsrtp2.a $^
114 $(RANLIB) libsrtp2.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000115
jfigusd196e022014-11-20 16:43:44 -0500116libsrtp2.so: $(srtpobj) $(cryptobj)
117 $(CC) -shared -Wl,-soname,libsrtp2.so \
118 -o libsrtp2.so $^ $(LDFLAGS)
jfigus50046422013-10-10 08:35:16 -0400119
Cullen Jennings235513a2005-09-21 22:51:36 +0000120# test applications
jfigus0d3a2682013-04-02 15:42:37 -0400121ifneq (1, $(USE_OPENSSL))
122AES_CALC = crypto/test/aes_calc$(EXE)
123endif
Cullen Jennings235513a2005-09-21 22:51:36 +0000124
jfigus0d3a2682013-04-02 15:42:37 -0400125crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000126 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
jfigus339b61d2014-11-04 15:36:15 -0500127 crypto/test/sha1_driver$(EXE) \
128 crypto/test/stat_driver$(EXE)
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000129
130testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
David McGrew0cb86ee2006-07-07 15:46:57 +0000131 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
David McGrew5506a8b2006-07-18 17:42:42 +0000132 test/dtls_srtp_driver$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000133
jfigus98bb4fb2014-10-15 09:48:03 -0400134ifeq (1, $(HAVE_PCAP))
135testapp += test/rtp_decoder$(EXE)
136endif
137
jfigusd196e022014-11-20 16:43:44 -0500138$(testapp): libsrtp2.a
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000139
jfigus46d6b472014-11-14 16:42:01 -0500140test/rtpw$(EXE): test/rtpw.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100141 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500142 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
David McGrew79bd3012006-07-17 20:41:21 +0000143
Bernardo Torresb3c51422014-10-14 12:40:09 -0300144ifeq (1, $(HAVE_PCAP))
jfigus46d6b472014-11-14 16:42:01 -0500145test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/util.c test/getopt_s.c \
Christian Oien9e4c0912014-10-29 09:11:16 +0100146 crypto/math/datatypes.c
jfigus46d6b472014-11-14 16:42:01 -0500147 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Bernardo Torresb3c51422014-10-14 12:40:09 -0300148endif
149
jfigus46d6b472014-11-14 16:42:01 -0500150crypto/test/aes_calc$(EXE): crypto/test/aes_calc.c test/util.c
151 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
152
153crypto/test/datatypes_driver$(EXE): crypto/test/datatypes_driver.c test/util.c
154 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
155
156crypto/test/sha1_driver$(EXE): crypto/test/sha1_driver.c test/util.c
157 $(COMPILE) -I./test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
158
159test/srtp_driver$(EXE): test/srtp_driver.c test/util.c test/getopt_s.c
David McGrew79bd3012006-07-17 20:41:21 +0000160 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
161
162test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
163 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
164
165test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000166 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000167
168test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000169 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000170
171memtest: test/srtp_driver
172 @test/srtp_driver -v -d "alloc" > tmp
173 @grep freed tmp | wc -l > freed
174 @grep allocated tmp | wc -l > allocated
175 @echo "checking for memory leaks (only works with --enable-stdout)"
176 cmp -s allocated freed
177 @echo "passed (same number of alloc() and dealloc() calls found)"
178 @rm freed allocated tmp
179
Cullen Jennings235513a2005-09-21 22:51:36 +0000180# the target 'plot' runs the timing test (test/srtp_driver -t) then
181# uses gnuplot to produce plots of the results - see the script file
182# 'timing'
183
184plot: test/srtp_driver
185 test/srtp_driver -t > timing.dat
186
187
188# bookkeeping: tags, clean, and distribution
189
190tags:
191 etags */*.[ch] */*/*.[ch]
192
193
194# documentation - the target libsrtpdoc builds a PDF file documenting
jfigusd196e022014-11-20 16:43:44 -0500195# libsrtp2
Cullen Jennings235513a2005-09-21 22:51:36 +0000196
jfigusd196e022014-11-20 16:43:44 -0500197libsrtp2doc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000198 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000199
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000200.PHONY: clean superclean distclean install
Cullen Jennings235513a2005-09-21 22:51:36 +0000201
202install:
jfigusd196e022014-11-20 16:43:44 -0500203 @if [ -r $(DESTDIR)$(includedir)/srtp2/srtp.h ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000204 echo "you should run 'make uninstall' first"; exit 1; \
205 fi
jfigusd196e022014-11-20 16:43:44 -0500206 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp2
David McGrewb67061f2005-09-28 14:23:06 +0000207 $(INSTALL) -d $(DESTDIR)$(libdir)
jfigusd196e022014-11-20 16:43:44 -0500208 cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp2
209 cp $(srcdir)/include/ekt.h $(DESTDIR)$(includedir)/srtp2
210 cp $(srcdir)/include/rtp.h $(DESTDIR)$(includedir)/srtp2
211 if [ -f libsrtp2.a ]; then cp libsrtp2.a $(DESTDIR)$(libdir)/; fi
212 if [ -f libsrtp2.so ]; then cp libsrtp2.so $(DESTDIR)$(libdir)/; fi
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200213 if [ "$(pkgconfig_DATA)" != "" ]; then \
214 $(INSTALL) -d $(DESTDIR)$(pkgconfigdir); \
215 cp $(srcdir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/; \
216 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000217
218uninstall:
jfigusd196e022014-11-20 16:43:44 -0500219 rm -f $(DESTDIR)$(includedir)/srtp2/*.h
220 rm -f $(DESTDIR)$(libdir)/libsrtp2.a
221 rm -f $(DESTDIR)$(libdir)/libsrtp2.so
222 -rmdir $(DESTDIR)$(includedir)/srtp2
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200223 if [ "$(pkgconfig_DATA)" != "" ]; then \
224 rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA); \
225 fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000226
227clean:
jfigus8aa936e2014-11-06 10:16:35 -0500228 rm -rf $(cryptobj) $(srtpobj) TAGS \
jfigusd196e022014-11-20 16:43:44 -0500229 libsrtp2.a libsrtp2.so core *.core test/core
Cullen Jennings235513a2005-09-21 22:51:36 +0000230 for a in * */* */*/*; do \
231 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
232 done;
jfigus8aa936e2014-11-06 10:16:35 -0500233 for a in $(testapp); do rm -rf $$a$(EXE); done
Cullen Jennings235513a2005-09-21 22:51:36 +0000234 rm -rf *.pict *.jpg *.dat
235 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000236 $(MAKE) -C doc clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000237
238superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000239 rm -rf crypto/include/config.h config.log config.cache config.status \
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000240 Makefile crypto/Makefile doc/Makefile \
241 .gdb_history test/.gdb_history .DS_Store
Cullen Jennings235513a2005-09-21 22:51:36 +0000242 rm -rf autom4te.cache
243
Jonathan Lennoxfc655522010-05-21 17:45:35 +0000244distclean: superclean
245
Cullen Jenningsef29a902013-04-30 12:54:54 -0600246distname = libsrtp-$(shell cat VERSION)
Cullen Jennings235513a2005-09-21 22:51:36 +0000247
David McGrewb67061f2005-09-28 14:23:06 +0000248distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000249 if ! [ -f VERSION ]; then exit 1; fi
250 if [ -f ../$(distname).tgz ]; then \
251 mv ../$(distname).tgz ../$(distname).tgz.bak; \
252 fi
Cullen Jenningsef29a902013-04-30 12:54:54 -0600253 cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings235513a2005-09-21 22:51:36 +0000254
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000255# EOF