blob: fc041e038c2da47e304b0ebc4be399685ac99f6d [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
13# distribution cleans and builds a .tgz
14# tags builds etags file from all .c and .h files
15
16.PHONY: test all runtest
17
18runtest: test
19 @echo "running libsrtp test applications..."
20 test/cipher_driver$(EXE) -v >/dev/null
21 test/rdbx_driver$(EXE) -v >/dev/null
22 test/srtp_driver$(EXE) -v >/dev/null
23 test/roc_driver$(EXE) -v >/dev/null
24 test/kernel_driver$(EXE) -v >/dev/null
25 @echo "libsrtp test applications passed."
26
27all: test tables
28
29# makefile variables
30
31CC = @CC@
32CFLAGS = -Wall -O4 -fexpensive-optimizations -funroll-loops
33CDEFS = -DHAVE_CONFIG_H
34INCDIR = -I./include/ -I./crypto/include
35LIBS = @LIBS@ -lsrtp
36LIBDIR = -L.
37
38
39# implicit rules for object files and test apps
40
41%.o: %.c
42 $(CC) $(CDEFS) -c $(CFLAGS) $(INCDIR) $< -o $@
43
44%: %.c libsrtp.a
45 $(CC) $(CDEFS) $(CFLAGS) $(INCDIR) $< -o $@ $(LIBDIR) $(LIBS)
46
47
48# libcrypt.a (the crypto engine)
49
50ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
51 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
52 crypto/cipher/aes_cbc.o
53
54hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
55 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
56
57replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
58 crypto/replay/ut_sim.o
59
60math = crypto/math/datatypes.o crypto/math/stat.o
61
62ust = crypto/ust/ust.o
63
64rng = crypto/rng/rand_source.o crypto/rng/prng.o crypto/rng/ctr_prng.o
65
66err = crypto/kernel/err.o
67
68kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
69 crypto/kernel/key.o $(rng) $(err) # $(ust)
70
71cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
72
73aesicmobj = $(aesicm) $(rng)
74
75# gdoi is the group domain of interpretation for isakmp, a group key
76# management system which can provide keys for srtp
77
78gdoi = @GDOI_OBJS@
79
80# libsrtp.a (implements srtp processing)
81
82srtpobj = srtp/srtp.o
83
84libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
85 ar cr libsrtp.a $(srtpobj) $(cryptobj) $(gdoi)
86 ranlib libsrtp.a
87
88# libaesicm.a provides an icm implementation used by mpeg4ip
89
90libaesicm.a: $(aesicmobj)
91 ar cr libaesicm.a $(aesicmobj)
92 ranlib libaesicm.a
93
94# libcryptomath.a contains general-purpose routines that are used to
95# generate tables and verify cryptoalgorithm implementations - this
96# library is not meant to be included in production code
97
98cryptomath = crypto/math/math.o crypto/math/gf2_8.o crypto/math/gf2_128.o
99
100libcryptomath.a: $(cryptomath)
101 ar cr libcryptomath.a $(cryptomath)
102 ranlib libcryptomath.a
103
104
105# test applications
106
107testapp = test/cipher_driver test/datatypes_driver test/srtp_driver \
108 test/replay_driver test/roc_driver test/rdbx_driver \
109 test/stat_driver test/sha1_driver test/kernel_driver \
110 test/aes_calc test/rand_gen # test/ust_driver @GDOI_APPS@
111# test/auth_driver test/rtpw \
112
113test/rtpw: test/rtpw.c test/rtp.c
114 $(CC) $(CDEFS) $(CFLAGS) $(INCDIR) -o test/rtpw test/rtpw.c test/rtp.c $(LIBDIR) $(LIBS)
115
116test: $(testapp)
117
118memtest: test/srtp_driver
119 @test/srtp_driver -v -d "alloc" > tmp
120 @grep freed tmp | wc -l > freed
121 @grep allocated tmp | wc -l > allocated
122 @echo "checking for memory leaks (only works with --enable-stdout)"
123 cmp -s allocated freed
124 @echo "passed (same number of alloc() and dealloc() calls found)"
125 @rm freed allocated tmp
126
127# tables_apps are used to generate the tables used in the crypto
128# implementations; these need only be generated during porting, not
129# for building libsrtp or the test applications
130
131table_apps = tables/aes_tables tables/gf_128_tables
132
133# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
134
135tables/%: tables/%.c libcryptomath.a
136 $(CC) $(CDEFS) $(CFLAGS) $(INCDIR) $< -o $@ $(LIBDIR) libcryptomath.a
137
138# the target 'plot' runs the timing test (test/srtp_driver -t) then
139# uses gnuplot to produce plots of the results - see the script file
140# 'timing'
141
142plot: test/srtp_driver
143 test/srtp_driver -t > timing.dat
144
145
146# bookkeeping: tags, clean, and distribution
147
148tags:
149 etags */*.[ch] */*/*.[ch]
150
151
152# documentation - the target libsrtpdoc builds a PDF file documenting
153# libsrtp
154
155libsrtpdoc:
156 cd doc; make
157
158# EXE defines the suffix on executables - it's .exe for cygwin, and
159# null on linux, bsd, and OS X and other OSes. we define this so that
160# `make clean` will work on the cygwin platform
161
162EXE = @EXE@
163
164.PHONY: clean superclean install
165
166install:
167 if [ -d /usr/local/include/srtp ]; then \
168 echo "you should run 'make uninstall' first"; exit 1; \
169 fi
170 mkdir /usr/local/include/srtp
171 cp include/*.h /usr/local/include/srtp
172 cp crypto/include/*.h /usr/local/include/srtp
173 cp libsrtp.a /usr/local/lib/
174 if [ -f libaesicm.a ]; then cp libaesicm.a /usr/local/lib/; fi
175
176uninstall:
177 rm -rf /usr/local/include/srtp
178 rm -rf /usr/local/lib/libsrtp.a
179 if [ -f libaesicm.a ]; then rm -rf /usr/local/lib/libaesicm.a; fi
180
181clean:
182 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
183 libcryptomath.a libsrtp.a libaesicm.a core *.core test/core
184 for a in * */* */*/*; do \
185 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
186 done;
187 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
188 rm -rf *.pict *.jpg *.dat
189 rm -rf freed allocated tmp
190 cd doc; make clean
191 cd crypto; make clean
192
193
194superclean: clean
195 rm -rf include/config.h config.log config.cache config.status \
196 Makefile .gdb_history test/.gdb_history .DS_Store
197 rm -rf autom4te.cache
198
199distname = srtp-$(shell cat VERSION)
200
201distribution: superclean
202 if ! [ -f VERSION ]; then exit 1; fi
203 if [ -f ../$(distname).tgz ]; then \
204 mv ../$(distname).tgz ../$(distname).tgz.bak; \
205 fi
206 cd ..; tar cvzf $(distname).tgz srtp
207
208# EOF
209
210