blob: 1104e797ae631885691bab5557af70e4946bac4c [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 McGrewb67061f2005-09-28 14:23:06 +000016.PHONY: all test
Cullen Jennings235513a2005-09-21 22:51:36 +000017
David McGrewb67061f2005-09-28 14:23:06 +000018all: test
19
20runtest: 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."
David McGrewb67061f2005-09-28 14:23:06 +000028 cd crypto/; $(MAKE) runtest
Cullen Jennings235513a2005-09-21 22:51:36 +000029
30# makefile variables
31
32CC = @CC@
David McGrewb67061f2005-09-28 14:23:06 +000033INCDIR = -I./include -I./crypto/include
34CDEFS = @DEFS@
35CPPFLAGS = @CPPFLAGS@ $(CDEFS) $(INCDIR)
36CFLAGS = @CFLAGS@
37LIBS = @LIBS@
38LDFLAGS = @LDFLAGS@ -L.
39SRTPLIB = -lsrtp
40
41INSTALL = @INSTALL@
42
43prefix = @prefix@
44exec_prefix = @exec_prefix@
45includedir = @includedir@
46libdir = @libdir@
Cullen Jennings235513a2005-09-21 22:51:36 +000047
48
49# implicit rules for object files and test apps
50
51%.o: %.c
David McGrewb67061f2005-09-28 14:23:06 +000052 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
Cullen Jennings235513a2005-09-21 22:51:36 +000053
54%: %.c libsrtp.a
David McGrewb67061f2005-09-28 14:23:06 +000055 $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +000056
57
58# libcrypt.a (the crypto engine)
Cullen Jennings235513a2005-09-21 22:51:36 +000059ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
60 crypto/cipher/aes.o crypto/cipher/aes_icm.o \
61 crypto/cipher/aes_cbc.o
62
63hashes = crypto/hash/null_auth.o crypto/hash/sha1.o \
64 crypto/hash/hmac.o crypto/hash/auth.o # crypto/hash/tmmhv2.o
65
66replay = crypto/replay/rdb.o crypto/replay/rdbx.o \
67 crypto/replay/ut_sim.o
68
69math = crypto/math/datatypes.o crypto/math/stat.o
70
71ust = crypto/ust/ust.o
72
73rng = crypto/rng/rand_source.o crypto/rng/prng.o crypto/rng/ctr_prng.o
74
75err = crypto/kernel/err.o
76
77kernel = crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o \
78 crypto/kernel/key.o $(rng) $(err) # $(ust)
79
80cryptobj = $(ciphers) $(hashes) $(math) $(stat) $(kernel) $(replay)
81
David McGrewfec49dd2005-09-23 19:34:11 +000082aesicm = crypto/cipher/cipher.o crypto/cipher/aes.o crypto/cipher/aes_icm.o \
83 crypto/hash/auth.o crypto/kernel/alloc.o crypto/kernel/err.o \
84 crypto/math/datatypes.o crypto/replay/rdbx.o
85
Cullen Jennings235513a2005-09-21 22:51:36 +000086aesicmobj = $(aesicm) $(rng)
87
88# gdoi is the group domain of interpretation for isakmp, a group key
89# management system which can provide keys for srtp
90
91gdoi = @GDOI_OBJS@
92
93# libsrtp.a (implements srtp processing)
94
95srtpobj = srtp/srtp.o
96
97libsrtp.a: $(srtpobj) $(cryptobj) $(gdoi)
98 ar cr libsrtp.a $(srtpobj) $(cryptobj) $(gdoi)
99 ranlib libsrtp.a
100
101# libaesicm.a provides an icm implementation used by mpeg4ip
102
103libaesicm.a: $(aesicmobj)
104 ar cr libaesicm.a $(aesicmobj)
105 ranlib libaesicm.a
106
107# libcryptomath.a contains general-purpose routines that are used to
108# generate tables and verify cryptoalgorithm implementations - this
109# library is not meant to be included in production code
110
David McGrewb67061f2005-09-28 14:23:06 +0000111cryptomath = crypto/math/math.o crypto/math/gf2_8.o
Cullen Jennings235513a2005-09-21 22:51:36 +0000112
113libcryptomath.a: $(cryptomath)
114 ar cr libcryptomath.a $(cryptomath)
115 ranlib libcryptomath.a
116
117
118# test applications
119
120testapp = test/cipher_driver test/datatypes_driver test/srtp_driver \
121 test/replay_driver test/roc_driver test/rdbx_driver \
122 test/stat_driver test/sha1_driver test/kernel_driver \
David McGrewb67061f2005-09-28 14:23:06 +0000123 test/aes_calc test/rand_gen test/rtpw
Cullen Jennings235513a2005-09-21 22:51:36 +0000124
125test/rtpw: test/rtpw.c test/rtp.c
David McGrewb67061f2005-09-28 14:23:06 +0000126 $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(SRTPLIB)
Cullen Jennings235513a2005-09-21 22:51:36 +0000127
128test: $(testapp)
David McGrewb67061f2005-09-28 14:23:06 +0000129 @echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings235513a2005-09-21 22:51:36 +0000130
131memtest: test/srtp_driver
132 @test/srtp_driver -v -d "alloc" > tmp
133 @grep freed tmp | wc -l > freed
134 @grep allocated tmp | wc -l > allocated
135 @echo "checking for memory leaks (only works with --enable-stdout)"
136 cmp -s allocated freed
137 @echo "passed (same number of alloc() and dealloc() calls found)"
138 @rm freed allocated tmp
139
140# tables_apps are used to generate the tables used in the crypto
141# implementations; these need only be generated during porting, not
142# for building libsrtp or the test applications
143
David McGrewb67061f2005-09-28 14:23:06 +0000144table_apps: tables/aes_tables
145
Cullen Jennings235513a2005-09-21 22:51:36 +0000146
147# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
148
149tables/%: tables/%.c libcryptomath.a
David McGrewb67061f2005-09-28 14:23:06 +0000150 $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LIBS) libcryptomath.a
Cullen Jennings235513a2005-09-21 22:51:36 +0000151
152# the target 'plot' runs the timing test (test/srtp_driver -t) then
153# uses gnuplot to produce plots of the results - see the script file
154# 'timing'
155
156plot: test/srtp_driver
157 test/srtp_driver -t > timing.dat
158
159
160# bookkeeping: tags, clean, and distribution
161
162tags:
163 etags */*.[ch] */*/*.[ch]
164
165
166# documentation - the target libsrtpdoc builds a PDF file documenting
167# libsrtp
168
169libsrtpdoc:
David McGrewb67061f2005-09-28 14:23:06 +0000170 cd doc; $(MAKE)
Cullen Jennings235513a2005-09-21 22:51:36 +0000171
172# EXE defines the suffix on executables - it's .exe for cygwin, and
173# null on linux, bsd, and OS X and other OSes. we define this so that
174# `make clean` will work on the cygwin platform
175
176EXE = @EXE@
177
178.PHONY: clean superclean install
179
180install:
David McGrewb67061f2005-09-28 14:23:06 +0000181 @if [ -d $(DESTDIR)$(includedir)/srtp ]; then \
Cullen Jennings235513a2005-09-21 22:51:36 +0000182 echo "you should run 'make uninstall' first"; exit 1; \
183 fi
David McGrewb67061f2005-09-28 14:23:06 +0000184 $(INSTALL) -d $(DESTDIR)$(includedir)/srtp
185 $(INSTALL) -d $(DESTDIR)$(libdir)
186 cp include/*.h $(DESTDIR)$(includedir)/srtp
187 cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp
188 cp libsrtp.a $(DESTDIR)$(libdir)/
189 if [ -f libaesicm.a ]; then cp libaesicm.a $(DESTDIR)$(libdir)/; fi
190
Cullen Jennings235513a2005-09-21 22:51:36 +0000191
192uninstall:
David McGrewb67061f2005-09-28 14:23:06 +0000193 rm -rf $(DESTDIR)$(includedir)/srtp
194 rm -rf $(DESTDIR)$(libdir)/libsrtp.a
195 rm -rf $(DESTDIR)$(libdir)/libaesicm.a; fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000196
197clean:
198 rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
199 libcryptomath.a libsrtp.a libaesicm.a core *.core test/core
200 for a in * */* */*/*; do \
201 if [ -f "$$a~" ] ; then rm -f $$a~; fi; \
202 done;
203 for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
204 rm -rf *.pict *.jpg *.dat
205 rm -rf freed allocated tmp
David McGrewb67061f2005-09-28 14:23:06 +0000206 cd doc; $(MAKE) clean
207 cd crypto; $(MAKE) clean
Cullen Jennings235513a2005-09-21 22:51:36 +0000208
209
210superclean: clean
David McGrewe11033e2005-09-26 20:41:14 +0000211 rm -rf crypto/include/config.h config.log config.cache config.status \
Cullen Jennings235513a2005-09-21 22:51:36 +0000212 Makefile .gdb_history test/.gdb_history .DS_Store
213 rm -rf autom4te.cache
214
215distname = srtp-$(shell cat VERSION)
216
David McGrewb67061f2005-09-28 14:23:06 +0000217distribution: runtest superclean
Cullen Jennings235513a2005-09-21 22:51:36 +0000218 if ! [ -f VERSION ]; then exit 1; fi
219 if [ -f ../$(distname).tgz ]; then \
220 mv ../$(distname).tgz ../$(distname).tgz.bak; \
221 fi
222 cd ..; tar cvzf $(distname).tgz srtp
223
224# EOF
225
226