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