blob: 0b61949d95852a8ed182716ee435b9f6249c7b77 [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@
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 Sundberg8ebe5ce2005-09-29 13:59:56 +000045srcdir = @srcdir@
46top_srcdir = @top_srcdir@
47top_builddir = @top_builddir@
48VPATH = @srcdir@
David McGrewb67061f2005-09-28 14:23:06 +000049prefix = @prefix@
50exec_prefix = @exec_prefix@
51includedir = @includedir@
52libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000053
54
55# implicit rules for object files and test apps
56
57%.o: %.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000058 $(COMPILE) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000059
60%: %.c libsrtp.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +000061 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +000062
63
64# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000065ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
66 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
67 crypto/cipher/aes_cbc.o
68
69hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
70 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
71
72replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
73 crypto/replay/ut_sim.o
74
75math = crypto/math/datatypes.o crypto/math/stat.o
76
77ust = crypto/ust/ust.o
78
79rng = crypto/rng/rand_source.o crypto/rng/prng.o crypto/rng/ctr_prng.o
80
81err = crypto/kernel/err.o
82
83kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
84 crypto/kernel/key.o $(rng) $(err) # $(ust)
85
86cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
87
David McGrewfec49dd2005-09-23 19:34:11 +000088aesicm = crypto/cipher/cipher.o crypto/cipher/aes.o crypto/cipher/aes_icm.o \
89 crypto/hash/auth.o crypto/kernel/alloc.o crypto/kernel/err.o \
90 crypto/math/datatypes.o crypto/replay/rdbx.o
91
Cullen Jennings235513a2005-09-21 22:51:36 +000092aesicmobj = $(aesicm) $(rng)
93
94# gdoi is the group domain of interpretation for isakmp, a group key
95# management system which can provide keys for srtp
96
97gdoi = @GDOI_OBJS@
98
99# libsrtp.a (implements srtp processing)
100
101srtpobj = srtp/srtp.o
102
103libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000104 ar cr libsrtp.a $^
Marcus Sundberg589127e2005-09-29 13:34:06 +0000105 $(RANLIB) libsrtp.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000106
107# libaesicm.a provides an icm implementation used by mpeg4ip
108
109libaesicm.a: $(aesicmobj)
110 ar cr libaesicm.a $(aesicmobj)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000111 $(RANLIB) libaesicm.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000112
113# libcryptomath.a contains general-purpose routines that are used to
114# generate tables and verify cryptoalgorithm implementations - this
115# library is not meant to be included in production code
116
David McGrewb67061f2005-09-28 14:23:06 +0000117cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000118
119libcryptomath.a: $(cryptomath)
120 ar cr libcryptomath.a $(cryptomath)
Marcus Sundberg589127e2005-09-29 13:34:06 +0000121 $(RANLIB) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000122
123
124# test applications
125
126testapp = test/cipher_driver test/datatypes_driver test/srtp_driver \
127 test/replay_driver test/roc_driver test/rdbx_driver \
128 test/stat_driver test/sha1_driver test/kernel_driver \
David McGrewb67061f2005-09-28 14:23:06 +0000129 test/aes_calc test/rand_gen test/rtpw
Cullen Jennings235513a2005-09-21 22:51:36 +0000130
131test/rtpw: test/rtpw.c test/rtp.c
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000132 $(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000133
134test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000135 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000136
137memtest: test/srtp_driver
138 @test/srtp_driver -v -d "alloc" > tmp
139 @grep freed tmp | wc -l > freed
140 @grep allocated tmp | wc -l > allocated
141 @echo "checking for memory leaks (only works with --enable-stdout)"
142 cmp -s allocated freed
143 @echo "passed (same number of alloc() and dealloc() calls found)"
144 @rm freed allocated tmp
145
146# tables_apps are used to generate the tables used in the crypto
147# implementations; these need only be generated during porting, not
148# for building libsrtp or the test applications
149
David McGrew5529f102005-09-29 11:25:10 +0000150table_apps = tables/aes_tables
David McGrewb67061f2005-09-28 14:23:06 +0000151
David McGrew5529f102005-09-29 11:25:10 +0000152build_table_apps: $(table_apps)
Cullen Jennings235513a2005-09-21 22:51:36 +0000153
154# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
155
156tables/%: tables/%.c libcryptomath.a
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000157 $(COMPILE) $(LDFLAGS) $< -o $@ $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000158
159# the target 'plot' runs the timing test (test/srtp_driver -t) then
160# uses gnuplot to produce plots of the results - see the script file
161# 'timing'
162
163plot: test/srtp_driver
164 test/srtp_driver -t > timing.dat
165
166
167# bookkeeping: tags, clean, and distribution
168
169tags:
170 etags */*.[ch] */*/*.[ch]
171
172
173# documentation - the target libsrtpdoc builds a PDF file documenting
174# libsrtp
175
176libsrtpdoc:
Marcus Sundberg589127e2005-09-29 13:34:06 +0000177 $(MAKE) -C doc
Cullen Jennings235513a2005-09-21 22:51:36 +0000178
179# EXE defines the suffix on executables - it's .exe for cygwin, and
180# null on linux, bsd, and OS X and other OSes. we define this so that
181# `make clean` will work on the cygwin platform
182
183EXE = @EXE@
184
185.PHONY: clean superclean install
186
187install:
David McGrewb67061f2005-09-28 14:23:06 +0000188 @if [ -d $(DESTDIR)$(includedir)/srtp ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000189 echo "you should run 'make uninstall' first"; exit 1; \
190 fi
David McGrewb67061f2005-09-28 14:23:06 +0000191 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
192 $(INSTALL) -d $(DESTDIR)$(libdir)
193 cp include/*.h $(DESTDIR)$(includedir)/srtp
194 cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp
195 cp libsrtp.a $(DESTDIR)$(libdir)/
196 if [ -f libaesicm.a ]; then cp libaesicm.a $(DESTDIR)$(libdir)/; fi
197
Cullen Jennings235513a2005-09-21 22:51:36 +0000198
199uninstall:
David McGrewb67061f2005-09-28 14:23:06 +0000200 rm -rf $(DESTDIR)$(includedir)/srtp
201 rm -rf $(DESTDIR)$(libdir)/libsrtp.a
202 rm -rf $(DESTDIR)$(libdir)/libaesicm.a; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000203
204clean:
205 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
206 libcryptomath.a libsrtp.a libaesicm.a core *.core test/core
207 for a in * */* */*/*; do \
208 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
209 done;
210 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
211 rm -rf *.pict *.jpg *.dat
212 rm -rf freed allocated tmp
Marcus Sundberg589127e2005-09-29 13:34:06 +0000213 $(MAKE) -C doc clean
214 $(MAKE) -C crypto clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000215
216
217superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000218 rm -rf crypto/include/config.h config.log config.cache config.status \
Cullen Jennings235513a2005-09-21 22:51:36 +0000219 Makefile .gdb_history test/.gdb_history .DS_Store
220 rm -rf autom4te.cache
221
222distname = srtp-$(shell cat VERSION)
223
David McGrewb67061f2005-09-28 14:23:06 +0000224distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000225 if ! [ -f VERSION ]; then exit 1; fi
226 if [ -f ../$(distname).tgz ]; then \
227 mv ../$(distname).tgz ../$(distname).tgz.bak; \
228 fi
229 cd ..; tar cvzf $(distname).tgz srtp
230
Marcus Sundberg8ebe5ce2005-09-29 13:59:56 +0000231# EOF