blob: 2b8e38f04041bb841bc615960bd0fb3b85485e69 [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..."
22 test/cipher_driver$(EXE) -v >/dev/null
23 test/rdbx_driver$(EXE) -v >/dev/null
24 test/srtp_driver$(EXE) -v >/dev/null
25 test/roc_driver$(EXE) -v >/dev/null
26 test/kernel_driver$(EXE) -v >/dev/null
27 @echo "libsrtp test applications passed."
Marcus Sundberg589127e2005-09-29 13:34:06 +000028 $(MAKE) -C crypto runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000029
30# makefile variables
31
Marcus Sundberg589127e2005-09-29 13:34:06 +000032CC = @CC@
33INCDIR = -I./include -I./crypto/include
34CDEFS = @DEFS@
David McGrewb67061f2005-09-28 14:23:06 +000035CPPFLAGS = @CPPFLAGS@ $(CDEFS) $(INCDIR)
Marcus Sundberg589127e2005-09-29 13:34:06 +000036CFLAGS = @CFLAGS@
37LIBS = @LIBS@
38LDFLAGS = @LDFLAGS@ -L.
39SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000040
Marcus Sundberg589127e2005-09-29 13:34:06 +000041RANLIB = @RANLIB@
42INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000043
44prefix = @prefix@
45exec_prefix = @exec_prefix@
46includedir = @includedir@
47libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000048
49
50# implicit rules for object files and test apps
51
52%.o: %.c
David McGrewb67061f2005-09-28 14:23:06 +000053 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000054
55%: %.c libsrtp.a
David McGrewb67061f2005-09-28 14:23:06 +000056 $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +000057
58
59# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000060ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
61 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
62 crypto/cipher/aes_cbc.o
63
64hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
65 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
66
67replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
68 crypto/replay/ut_sim.o
69
70math = crypto/math/datatypes.o crypto/math/stat.o
71
72ust = crypto/ust/ust.o
73
74rng = crypto/rng/rand_source.o crypto/rng/prng.o crypto/rng/ctr_prng.o
75
76err = crypto/kernel/err.o
77
78kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
79 crypto/kernel/key.o $(rng) $(err) # $(ust)
80
81cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
82
David McGrewfec49dd2005-09-23 19:34:11 +000083aesicm = crypto/cipher/cipher.o crypto/cipher/aes.o crypto/cipher/aes_icm.o \
84 crypto/hash/auth.o crypto/kernel/alloc.o crypto/kernel/err.o \
85 crypto/math/datatypes.o crypto/replay/rdbx.o
86
Cullen Jennings235513a2005-09-21 22:51:36 +000087aesicmobj = $(aesicm) $(rng)
88
89# gdoi is the group domain of interpretation for isakmp, a group key
90# management system which can provide keys for srtp
91
92gdoi = @GDOI_OBJS@
93
94# libsrtp.a (implements srtp processing)
95
96srtpobj = srtp/srtp.o
97
98libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
99 ar cr libsrtp.a $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000100 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000101
102# libaesicm.a provides an icm implementation used by mpeg4ip
103
104libaesicm.a: $(aesicmobj)
105 ar cr libaesicm.a $(aesicmobj)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000106 $(RANLIB) libaesicm.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000107
108# libcryptomath.a contains general-purpose routines that are used to
109# generate tables and verify cryptoalgorithm implementations - this
110# library is not meant to be included in production code
111
David McGrewb67061f2005-09-28 14:23:06 +0000112cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000113
114libcryptomath.a: $(cryptomath)
115 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000116 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000117
118
119# test applications
120
121testapp = test/cipher_driver test/datatypes_driver test/srtp_driver \
122 test/replay_driver test/roc_driver test/rdbx_driver \
123 test/stat_driver test/sha1_driver test/kernel_driver \
David McGrewb67061f2005-09-28 14:23:06 +0000124 test/aes_calc test/rand_gen test/rtpw
Cullen Jennings235513a2005-09-21 22:51:36 +0000125
126test/rtpw: test/rtpw.c test/rtp.c
David McGrewb67061f2005-09-28 14:23:06 +0000127 $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000128
129test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000130 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000131
132memtest: test/srtp_driver
133 @test/srtp_driver -v -d "alloc" > tmp
134 @grep freed tmp | wc -l > freed
135 @grep allocated tmp | wc -l > allocated
136 @echo "checking for memory leaks (only works with --enable-stdout)"
137 cmp -s allocated freed
138 @echo "passed (same number of alloc() and dealloc() calls found)"
139 @rm freed allocated tmp
140
141# tables_apps are used to generate the tables used in the crypto
142# implementations; these need only be generated during porting, not
143# for building libsrtp or the test applications
144
David McGrew5529f102005-09-29 11:25:10 +0000145table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000146
David McGrew5529f102005-09-29 11:25:10 +0000147build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000148
149# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
150
151tables/%: tables/%.c libcryptomath.a
David McGrewb67061f2005-09-28 14:23:06 +0000152 $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000153
154# the target 'plot' runs the timing test (test/srtp_driver -t) then
155# uses gnuplot to produce plots of the results - see the script file
156# 'timing'
157
158plot: test/srtp_driver
159 test/srtp_driver -t > timing.dat
160
161
162# bookkeeping: tags, clean, and distribution
163
164tags:
165 etags */*.[ch] */*/*.[ch]
166
167
168# documentation - the target libsrtpdoc builds a PDF file documenting
169# libsrtp
170
171libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000172 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000173
174# EXE defines the suffix on executables - it's .exe for cygwin, and
175# null on linux, bsd, and OS X and other OSes. we define this so that
176# `make clean` will work on the cygwin platform
177
178EXE = @EXE@
179
180.PHONY: clean superclean install
181
182install:
David McGrewb67061f2005-09-28 14:23:06 +0000183 @if [ -d $(DESTDIR)$(includedir)/srtp ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000184 echo "you should run 'make uninstall' first"; exit 1; \
185 fi
David McGrewb67061f2005-09-28 14:23:06 +0000186 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
187 $(INSTALL) -d $(DESTDIR)$(libdir)
188 cp include/*.h $(DESTDIR)$(includedir)/srtp
189 cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp
190 cp libsrtp.a $(DESTDIR)$(libdir)/
191 if [ -f libaesicm.a ]; then cp libaesicm.a $(DESTDIR)$(libdir)/; fi
192
Cullen Jennings235513a2005-09-21 22:51:36 +0000193
194uninstall:
David McGrewb67061f2005-09-28 14:23:06 +0000195 rm -rf $(DESTDIR)$(includedir)/srtp
196 rm -rf $(DESTDIR)$(libdir)/libsrtp.a
197 rm -rf $(DESTDIR)$(libdir)/libaesicm.a; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000198
199clean:
200 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
201 libcryptomath.a libsrtp.a libaesicm.a core *.core test/core
202 for a in * */* */*/*; do \
203 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
204 done;
205 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
206 rm -rf *.pict *.jpg *.dat
207 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000208 $(MAKE) -C doc clean
209 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000210
211
212superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000213 rm -rf crypto/include/config.h config.log config.cache config.status \
Cullen Jennings235513a2005-09-21 22:51:36 +0000214 Makefile .gdb_history test/.gdb_history .DS_Store
215 rm -rf autom4te.cache
216
217distname = srtp-$(shell cat VERSION)
218
David McGrewb67061f2005-09-28 14:23:06 +0000219distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000220 if ! [ -f VERSION ]; then exit 1; fi
221 if [ -f ../$(distname).tgz ]; then \
222 mv ../$(distname).tgz ../$(distname).tgz.bak; \
223 fi
224 cd ..; tar cvzf $(distname).tgz srtp
225
226# EOF
227
228