blob: e249c3fe6fb6a4b59a8362ae799b1aba14d0c528 [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
Cullen Jennings235513a2005-09-21 22:51:36 +000028 @echo "libsrtp test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000029 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000030
31# makefile variables
32
Marcus Sundberg589127e2005-09-29 13:34:06 +000033CC = @CC@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000034INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
35DEFS = @DEFS@
36CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000037CFLAGS = @CFLAGS@
38LIBS = @LIBS@
39LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000040COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000041SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000042
Marcus Sundberg589127e2005-09-29 13:34:06 +000043RANLIB = @RANLIB@
44INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000045
Marcus Sundberg95e23722005-10-02 19:44:28 +000046# EXE defines the suffix on executables - it's .exe for Windows, and
47# null on linux, bsd, and OS X and other OSes.
48EXE = @EXE@
49# gdoi is the group domain of interpretation for isakmp, a group key
50# management system which can provide keys for srtp
51gdoi = @GDOI_OBJS@
Marcus Sundberg5c714e42005-10-03 15:16:06 +000052# Random source.
53RNG_OBJS = @RNG_OBJS@
Marcus Sundberg95e23722005-10-02 19:44:28 +000054
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000055srcdir = @srcdir@
56top_srcdir = @top_srcdir@
57top_builddir = @top_builddir@
58VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000059prefix = @prefix@
60exec_prefix = @exec_prefix@
61includedir = @includedir@
62libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000063
64
65# implicit rules for object files and test apps
66
67%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000068 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000069
Marcus Sundberg1f84c402005-10-06 13:59:21 +000070%$(EXE): %.c
Marcus Sundberg95e23722005-10-02 19:44:28 +000071 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000072
73
74# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000075ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
76 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
77 crypto/cipher/aes_cbc.o
78
79hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
80 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
81
82replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
83 crypto/replay/ut_sim.o
84
85math = crypto/math/datatypes.o crypto/math/stat.o
86
87ust = crypto/ust/ust.o
88
Marcus Sundberg5c714e42005-10-03 15:16:06 +000089rng = crypto/rng/$(RNG_OBJS) crypto/rng/prng.o crypto/rng/ctr_prng.o
Cullen Jennings235513a2005-09-21 22:51:36 +000090
91err = crypto/kernel/err.o
92
93kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
94 crypto/kernel/key.o $(rng) $(err) # $(ust)
95
96cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
97
David McGrewfec49dd2005-09-23 19:34:11 +000098aesicm = crypto/cipher/cipher.o crypto/cipher/aes.o crypto/cipher/aes_icm.o \
99 crypto/hash/auth.o crypto/kernel/alloc.o crypto/kernel/err.o \
100 crypto/math/datatypes.o crypto/replay/rdbx.o
101
Cullen Jennings235513a2005-09-21 22:51:36 +0000102aesicmobj = $(aesicm) $(rng)
103
Cullen Jennings235513a2005-09-21 22:51:36 +0000104# libsrtp.a (implements srtp processing)
105
106srtpobj = srtp/srtp.o
107
108libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000109 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000110 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000111
112# libaesicm.a provides an icm implementation used by mpeg4ip
113
114libaesicm.a: $(aesicmobj)
115 ar cr libaesicm.a $(aesicmobj)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000116 $(RANLIB) libaesicm.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000117
118# libcryptomath.a contains general-purpose routines that are used to
119# generate tables and verify cryptoalgorithm implementations - this
120# library is not meant to be included in production code
121
David McGrewb67061f2005-09-28 14:23:06 +0000122cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000123
124libcryptomath.a: $(cryptomath)
125 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000126 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000127
128
129# test applications
130
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000131crypto_testapp = crypto/test/aes_calc$(EXE) crypto/test/cipher_driver$(EXE) \
132 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
133 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
134 crypto/test/stat_driver$(EXE)
135
136testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
137 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000138
Marcus Sundberg1f84c402005-10-06 13:59:21 +0000139$(testapp): libsrtp.a
140
Marcus Sundberg95e23722005-10-02 19:44:28 +0000141test/rtpw$(EXE): test/rtpw.c test/rtp.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000142 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000143
144test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000145 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000146
147memtest: test/srtp_driver
148 @test/srtp_driver -v -d "alloc" > tmp
149 @grep freed tmp | wc -l > freed
150 @grep allocated tmp | wc -l > allocated
151 @echo "checking for memory leaks (only works with --enable-stdout)"
152 cmp -s allocated freed
153 @echo "passed (same number of alloc() and dealloc() calls found)"
154 @rm freed allocated tmp
155
156# tables_apps are used to generate the tables used in the crypto
157# implementations; these need only be generated during porting, not
158# for building libsrtp or the test applications
159
David McGrew5529f102005-09-29 11:25:10 +0000160table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000161
David McGrew5529f102005-09-29 11:25:10 +0000162build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000163
164# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
165
166tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000167 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000168
169# the target 'plot' runs the timing test (test/srtp_driver -t) then
170# uses gnuplot to produce plots of the results - see the script file
171# 'timing'
172
173plot: test/srtp_driver
174 test/srtp_driver -t > timing.dat
175
176
177# bookkeeping: tags, clean, and distribution
178
179tags:
180 etags */*.[ch] */*/*.[ch]
181
182
183# documentation - the target libsrtpdoc builds a PDF file documenting
184# libsrtp
185
186libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000187 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000188
Cullen Jennings235513a2005-09-21 22:51:36 +0000189.PHONY: clean superclean install
190
191install:
David McGrewb67061f2005-09-28 14:23:06 +0000192 @if [ -d $(DESTDIR)$(includedir)/srtp ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000193 echo "you should run 'make uninstall' first"; exit 1; \
194 fi
David McGrewb67061f2005-09-28 14:23:06 +0000195 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
196 $(INSTALL) -d $(DESTDIR)$(libdir)
197 cp include/*.h $(DESTDIR)$(includedir)/srtp
198 cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp
David McGrew7c7ff312006-02-23 14:11:11 +0000199 if [ -f libsrtp.a ]; then cp libsrtp.a $(DESTDIR)$(libdir)/; fi
David McGrewb67061f2005-09-28 14:23:06 +0000200 if [ -f libaesicm.a ]; then cp libaesicm.a $(DESTDIR)$(libdir)/; fi
201
Cullen Jennings235513a2005-09-21 22:51:36 +0000202
203uninstall:
David McGrewb67061f2005-09-28 14:23:06 +0000204 rm -rf $(DESTDIR)$(includedir)/srtp
205 rm -rf $(DESTDIR)$(libdir)/libsrtp.a
David McGrew7c7ff312006-02-23 14:11:11 +0000206 rm -rf $(DESTDIR)$(libdir)/libaesicm.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000207
208clean:
209 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
210 libcryptomath.a libsrtp.a libaesicm.a core *.core test/core
211 for a in * */* */*/*; do \
212 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
213 done;
214 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
215 rm -rf *.pict *.jpg *.dat
216 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000217 $(MAKE) -C doc clean
218 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000219
220
221superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000222 rm -rf crypto/include/config.h config.log config.cache config.status \
Cullen Jennings235513a2005-09-21 22:51:36 +0000223 Makefile .gdb_history test/.gdb_history .DS_Store
224 rm -rf autom4te.cache
225
226distname = srtp-$(shell cat VERSION)
227
David McGrewb67061f2005-09-28 14:23:06 +0000228distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000229 if ! [ -f VERSION ]; then exit 1; fi
230 if [ -f ../$(distname).tgz ]; then \
231 mv ../$(distname).tgz ../$(distname).tgz.bak; \
232 fi
233 cd ..; tar cvzf $(distname).tgz srtp
234
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000235# EOF