blob: 854f07a0190a11a88ea1c5b9f9544463777ffae4 [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
Cullen Jennings235513a2005-09-21 22:51:36 +000027 @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@
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000033INCDIR = -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
34DEFS = @DEFS@
35CPPFLAGS= @CPPFLAGS@
Marcus Sundberg589127e2005-09-29 13:34:06 +000036CFLAGS = @CFLAGS@
37LIBS = @LIBS@
38LDFLAGS = @LDFLAGS@ -L.
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000039COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
Marcus Sundberg589127e2005-09-29 13:34:06 +000040SRTPLIB = -lsrtp
David McGrewb67061f2005-09-28 14:23:06 +000041
Marcus Sundberg589127e2005-09-29 13:34:06 +000042RANLIB = @RANLIB@
43INSTALL = @INSTALL@
David McGrewb67061f2005-09-28 14:23:06 +000044
Marcus Sundberg95e23722005-10-02 19:44:28 +000045# EXE defines the suffix on executables - it's .exe for Windows, and
46# null on linux, bsd, and OS X and other OSes.
47EXE = @EXE@
48# gdoi is the group domain of interpretation for isakmp, a group key
49# management system which can provide keys for srtp
50gdoi = @GDOI_OBJS@
51
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000052srcdir = @srcdir@
53top_srcdir = @top_srcdir@
54top_builddir = @top_builddir@
55VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000056prefix = @prefix@
57exec_prefix = @exec_prefix@
58includedir = @includedir@
59libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000060
61
62# implicit rules for object files and test apps
63
64%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000065 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000066
Marcus Sundberg95e23722005-10-02 19:44:28 +000067%$(EXE): %.c libsrtp.a
68 $(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings235513a2005-09-21 22:51:36 +000069
70
71# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000072ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
73 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
74 crypto/cipher/aes_cbc.o
75
76hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
77 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
78
79replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
80 crypto/replay/ut_sim.o
81
82math = crypto/math/datatypes.o crypto/math/stat.o
83
84ust = crypto/ust/ust.o
85
86rng = crypto/rng/rand_source.o crypto/rng/prng.o crypto/rng/ctr_prng.o
87
88err = crypto/kernel/err.o
89
90kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
91 crypto/kernel/key.o $(rng) $(err) # $(ust)
92
93cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
94
David McGrewfec49dd2005-09-23 19:34:11 +000095aesicm = crypto/cipher/cipher.o crypto/cipher/aes.o crypto/cipher/aes_icm.o \
96 crypto/hash/auth.o crypto/kernel/alloc.o crypto/kernel/err.o \
97 crypto/math/datatypes.o crypto/replay/rdbx.o
98
Cullen Jennings235513a2005-09-21 22:51:36 +000099aesicmobj = $(aesicm) $(rng)
100
Cullen Jennings235513a2005-09-21 22:51:36 +0000101# libsrtp.a (implements srtp processing)
102
103srtpobj = srtp/srtp.o
104
105libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000106 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000107 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000108
109# libaesicm.a provides an icm implementation used by mpeg4ip
110
111libaesicm.a: $(aesicmobj)
112 ar cr libaesicm.a $(aesicmobj)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000113 $(RANLIB) libaesicm.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000114
115# libcryptomath.a contains general-purpose routines that are used to
116# generate tables and verify cryptoalgorithm implementations - this
117# library is not meant to be included in production code
118
David McGrewb67061f2005-09-28 14:23:06 +0000119cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000120
121libcryptomath.a: $(cryptomath)
122 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000123 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000124
125
126# test applications
127
Marcus Sundbergb0a93112005-10-02 21:11:33 +0000128crypto_testapp = crypto/test/aes_calc$(EXE) crypto/test/cipher_driver$(EXE) \
129 crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
130 crypto/test/rand_gen$(EXE) crypto/test/sha1_driver$(EXE) \
131 crypto/test/stat_driver$(EXE)
132
133testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
134 test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000135
Marcus Sundberg95e23722005-10-02 19:44:28 +0000136test/rtpw$(EXE): test/rtpw.c test/rtp.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000137 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000138
139test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000140 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000141
142memtest: test/srtp_driver
143 @test/srtp_driver -v -d "alloc" > tmp
144 @grep freed tmp | wc -l > freed
145 @grep allocated tmp | wc -l > allocated
146 @echo "checking for memory leaks (only works with --enable-stdout)"
147 cmp -s allocated freed
148 @echo "passed (same number of alloc() and dealloc() calls found)"
149 @rm freed allocated tmp
150
151# tables_apps are used to generate the tables used in the crypto
152# implementations; these need only be generated during porting, not
153# for building libsrtp or the test applications
154
David McGrew5529f102005-09-29 11:25:10 +0000155table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000156
David McGrew5529f102005-09-29 11:25:10 +0000157build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000158
159# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
160
161tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000162 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000163
164# the target 'plot' runs the timing test (test/srtp_driver -t) then
165# uses gnuplot to produce plots of the results - see the script file
166# 'timing'
167
168plot: test/srtp_driver
169 test/srtp_driver -t > timing.dat
170
171
172# bookkeeping: tags, clean, and distribution
173
174tags:
175 etags */*.[ch] */*/*.[ch]
176
177
178# documentation - the target libsrtpdoc builds a PDF file documenting
179# libsrtp
180
181libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000182 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000183
Cullen Jennings235513a2005-09-21 22:51:36 +0000184.PHONY: clean superclean install
185
186install:
David McGrewb67061f2005-09-28 14:23:06 +0000187 @if [ -d $(DESTDIR)$(includedir)/srtp ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000188 echo "you should run 'make uninstall' first"; exit 1; \
189 fi
David McGrewb67061f2005-09-28 14:23:06 +0000190 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
191 $(INSTALL) -d $(DESTDIR)$(libdir)
192 cp include/*.h $(DESTDIR)$(includedir)/srtp
193 cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp
194 cp libsrtp.a $(DESTDIR)$(libdir)/
195 if [ -f libaesicm.a ]; then cp libaesicm.a $(DESTDIR)$(libdir)/; fi
196
Cullen Jennings235513a2005-09-21 22:51:36 +0000197
198uninstall:
David McGrewb67061f2005-09-28 14:23:06 +0000199 rm -rf $(DESTDIR)$(includedir)/srtp
200 rm -rf $(DESTDIR)$(libdir)/libsrtp.a
201 rm -rf $(DESTDIR)$(libdir)/libaesicm.a; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000202
203clean:
204 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
205 libcryptomath.a libsrtp.a libaesicm.a core *.core test/core
206 for a in * */* */*/*; do \
207 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
208 done;
209 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
210 rm -rf *.pict *.jpg *.dat
211 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000212 $(MAKE) -C doc clean
213 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000214
215
216superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000217 rm -rf crypto/include/config.h config.log config.cache config.status \
Cullen Jennings235513a2005-09-21 22:51:36 +0000218 Makefile .gdb_history test/.gdb_history .DS_Store
219 rm -rf autom4te.cache
220
221distname = srtp-$(shell cat VERSION)
222
David McGrewb67061f2005-09-28 14:23:06 +0000223distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000224 if ! [ -f VERSION ]; then exit 1; fi
225 if [ -f ../$(distname).tgz ]; then \
226 mv ../$(distname).tgz ../$(distname).tgz.bak; \
227 fi
228 cd ..; tar cvzf $(distname).tgz srtp
229
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000230# EOF