Makefile.in 9.21 KB
Newer Older
1
# Makefile for secure rtp
Cullen Jennings's avatar
Cullen Jennings committed
2 3 4 5 6 7
#
# David A. McGrew
# Cisco Systems, Inc.

# targets:
#
8
# runtest       runs test applications
9
# runtest-valgrind runs test applications with valgrind
Cullen Jennings's avatar
Cullen Jennings committed
10
# test		builds test applications
11 12
# libsrtp2.a	static library implementing srtp
# libsrtp2.so	shared library implementing srtp
Cullen Jennings's avatar
Cullen Jennings committed
13
# clean		removes objects, libs, and executables
14 15
# distribution  cleans and builds a .tgz
# tags          builds etags file from all .c and .h files
Cullen Jennings's avatar
Cullen Jennings committed
16

17
USE_OPENSSL = @USE_OPENSSL@
18
HAVE_PCAP = @HAVE_PCAP@
19

20
.PHONY: all shared_library test
Cullen Jennings's avatar
Cullen Jennings committed
21

22
all: test
23

24
runtest: test
25
	@echo "running libsrtp2 test applications..."
26 27
	crypto/test/cipher_driver$(EXE) -v >/dev/null
	crypto/test/kernel_driver$(EXE) -v >/dev/null
28
	test/test_srtp$(EXE) >/dev/null
Cullen Jennings's avatar
Cullen Jennings committed
29 30 31
	test/rdbx_driver$(EXE) -v >/dev/null
	test/srtp_driver$(EXE) -v >/dev/null
	test/roc_driver$(EXE) -v >/dev/null
32
	test/replay_driver$(EXE) -v >/dev/null
33
	test/dtls_srtp_driver$(EXE) >/dev/null
34
	cd test; $(abspath $(srcdir))/test/rtpw_test.sh -w $(abspath $(srcdir))/test/words.txt >/dev/null
35
ifeq (1, $(USE_OPENSSL))
36
	cd test; $(abspath $(srcdir))/test/rtpw_test_gcm.sh -w $(abspath $(srcdir))/test/words.txt >/dev/null
37
endif
38
	@echo "libsrtp2 test applications passed."
39
	$(MAKE) -C crypto runtest
Cullen Jennings's avatar
Cullen Jennings committed
40

41 42 43 44 45 46
runtest-valgrind: test
	@echo "running libsrtp2 test applications... (valgrind)"
	valgrind --error-exitcode=1 --leak-check=full test/test_srtp$(EXE) -v >/dev/null
	valgrind --error-exitcode=1 --leak-check=full test/srtp_driver$(EXE) -v >/dev/null
	@echo "libsrtp2 test applications passed. (valgrind)"

Cullen Jennings's avatar
Cullen Jennings committed
47 48
# makefile variables

49
CC	= @CC@
50
INCDIR	= -Icrypto/include -I$(srcdir)/include -I$(srcdir)/crypto/include
51
DEFS	= @DEFS@
52
CPPFLAGS= @CPPFLAGS@
53 54
CFLAGS	= @CFLAGS@
LIBS	= @LIBS@
55
LDFLAGS	= -L. @LDFLAGS@
56
COMPILE = $(CC) $(DEFS) $(INCDIR) $(CPPFLAGS) $(CFLAGS)
57
SRTPLIB	= -lsrtp2
58
PCAP_LIB = @PCAP_LIB@
59

60
AR      = @AR@
61 62
RANLIB	= @RANLIB@
INSTALL	= @INSTALL@
63

64 65 66
# EXE defines the suffix on executables - it's .exe for Windows, and
# null on linux, bsd, and OS X and other OSes.
EXE	= @EXE@
67

68 69
HMAC_OBJS = @HMAC_OBJS@
AES_ICM_OBJS = @AES_ICM_OBJS@
70

71 72 73 74
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
VPATH = @srcdir@
75 76 77 78
prefix = @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
libdir = @libdir@
79
bindir = @bindir@
Cullen Jennings's avatar
Cullen Jennings committed
80

81
pkgconfigdir = $(libdir)/pkgconfig
82
pkgconfig_DATA = libsrtp2.pc
Cullen Jennings's avatar
Cullen Jennings committed
83

84
SHAREDLIBVERSION = 1
85
ifneq (,$(or $(findstring linux,@host@), $(findstring gnu,@host@)))
86 87 88 89
SHAREDLIB_DIR = $(libdir)
SHAREDLIB_LDFLAGS = -shared -Wl,-soname,$@
SHAREDLIBSUFFIXNOVER = so
SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER).$(SHAREDLIBVERSION)
90
else ifneq (,$(or $(findstring cygwin,@host@), $(findstring mingw,@host@)))
91
SHAREDLIB_DIR = $(bindir)
92
SHAREDLIB_LDFLAGS = -shared -Wl,--out-implib,libsrtp2.dll.a
93 94 95 96 97 98
SHAREDLIBVERSION =
SHAREDLIBSUFFIXNOVER = dll
SHAREDLIBSUFFIX = $(SHAREDLIBSUFFIXNOVER)
else ifeq (darwin,$(findstring darwin,@host@))
SHAREDLIB_DIR = $(libdir)
SHAREDLIB_LDFLAGS = -dynamiclib -twolevel_namespace -undefined dynamic_lookup \
99
		-fno-common -headerpad_max_install_names -install_name $(libdir)/$@
100 101 102 103
SHAREDLIBSUFFIXNOVER = dylib
SHAREDLIBSUFFIX = $(SHAREDLIBVERSION).$(SHAREDLIBSUFFIXNOVER)
endif

Cullen Jennings's avatar
Cullen Jennings committed
104 105 106
# implicit rules for object files and test apps

%.o: %.c
107
	$(COMPILE) -c $< -o $@
Cullen Jennings's avatar
Cullen Jennings committed
108

109
%$(EXE): %.c
110
	$(COMPILE) $(LDFLAGS) $< -o $@ $(SRTPLIB) $(LIBS)
Cullen Jennings's avatar
Cullen Jennings committed
111 112

ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o      \
113
		  $(AES_ICM_OBJS)
Cullen Jennings's avatar
Cullen Jennings committed
114

115 116
hashes  = crypto/hash/null_auth.o  crypto/hash/auth.o            \
	  $(HMAC_OBJS)
Cullen Jennings's avatar
Cullen Jennings committed
117 118

replay  = crypto/replay/rdb.o crypto/replay/rdbx.o               \
119
		  crypto/replay/ut_sim.o
Cullen Jennings's avatar
Cullen Jennings committed
120

121
math    = crypto/math/datatypes.o crypto/math/stat.o
Cullen Jennings's avatar
Cullen Jennings committed
122

123
ust     = crypto/ust/ust.o
Cullen Jennings's avatar
Cullen Jennings committed
124 125 126 127

err     = crypto/kernel/err.o

kernel  = crypto/kernel/crypto_kernel.o  crypto/kernel/alloc.o   \
128
		  crypto/kernel/key.o $(err) # $(ust)
Cullen Jennings's avatar
Cullen Jennings committed
129

130
cryptobj =  $(ciphers) $(hashes) $(math) $(kernel) $(replay)
Cullen Jennings's avatar
Cullen Jennings committed
131

132
# libsrtp2.a (implements srtp processing)
Cullen Jennings's avatar
Cullen Jennings committed
133

David McGrew's avatar
David McGrew committed
134
srtpobj = srtp/srtp.o srtp/ekt.o
Cullen Jennings's avatar
Cullen Jennings committed
135

136
libsrtp2.a: $(srtpobj) $(cryptobj) $(gdoi)
137
	$(AR) cr libsrtp2.a $^
138
	$(RANLIB) libsrtp2.a
Cullen Jennings's avatar
Cullen Jennings committed
139

140
libsrtp2.$(SHAREDLIBSUFFIX): $(srtpobj) $(cryptobj) $(gdoi)
141
	$(CC) -shared -o $@ $(SHAREDLIB_LDFLAGS) \
142
				$^ $(LDFLAGS) $(LIBS)
143
	if [ -n "$(SHAREDLIBVERSION)" ]; then \
144
		ln -sfn $@ libsrtp2.$(SHAREDLIBSUFFIXNOVER); \
145 146
	fi

147
shared_library: libsrtp2.$(SHAREDLIBSUFFIX)
Cullen Jennings's avatar
Cullen Jennings committed
148

149
libsrtp2.so: $(srtpobj) $(cryptobj)
150
	$(CC) -shared -Wl,-soname,libsrtp2.so \
151
		-o libsrtp2.so $^ $(LDFLAGS)
152

153
# test applications
154 155 156
ifneq (1, $(USE_OPENSSL))
AES_CALC = crypto/test/aes_calc$(EXE)
endif
Cullen Jennings's avatar
Cullen Jennings committed
157

158
crypto_testapp = $(AES_CALC) crypto/test/cipher_driver$(EXE) \
159
	crypto/test/datatypes_driver$(EXE) crypto/test/kernel_driver$(EXE) \
160 161
	crypto/test/sha1_driver$(EXE) crypto/test/stat_driver$(EXE) \
	crypto/test/env$(EXE)
162 163

testapp = $(crypto_testapp) test/srtp_driver$(EXE) test/replay_driver$(EXE) \
164
	  test/roc_driver$(EXE) test/rdbx_driver$(EXE) test/rtpw$(EXE) \
165
	  test/dtls_srtp_driver$(EXE) test/test_srtp$(EXE)
Cullen Jennings's avatar
Cullen Jennings committed
166

jfigus's avatar
jfigus committed
167 168 169 170
ifeq (1, $(HAVE_PCAP))
testapp += test/rtp_decoder$(EXE)
endif

171
$(testapp): libsrtp2.a
172

173
test/rtpw$(EXE): test/rtpw.c test/rtp.c test/util.c test/getopt_s.c \
174
		crypto/math/datatypes.c
175
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
176

177
ifeq (1, $(HAVE_PCAP))
178
test/rtp_decoder$(EXE): test/rtp_decoder.c test/rtp.c test/util.c test/getopt_s.c \
179
		crypto/math/datatypes.c
180
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(PCAP_LIB) $(LIBS) $(SRTPLIB)
181 182
endif

183
crypto/test/aes_calc$(EXE): crypto/test/aes_calc.c test/util.c
184
	$(COMPILE) -I$(srcdir)/test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
185 186 187

test/test_srtp$(EXE): test/test_srtp.c
	$(COMPILE) -I$(srcdir)/test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
188 189

crypto/test/datatypes_driver$(EXE): crypto/test/datatypes_driver.c test/util.c
190
	$(COMPILE) -I$(srcdir)/test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
191 192

crypto/test/sha1_driver$(EXE): crypto/test/sha1_driver.c test/util.c
193
	$(COMPILE) -I$(srcdir)/test $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
194 195

test/srtp_driver$(EXE): test/srtp_driver.c test/util.c test/getopt_s.c
196 197 198 199 200
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)

test/rdbx_driver$(EXE): test/rdbx_driver.c test/getopt_s.c
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)

Ryan Hooper's avatar
Ryan Hooper committed
201
test/dtls_srtp_driver$(EXE): test/dtls_srtp_driver.c test/getopt_s.c test/util.c
202
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)
Cullen Jennings's avatar
Cullen Jennings committed
203

204 205 206 207 208 209
crypto/test/cipher_driver$(EXE): crypto/test/cipher_driver.c test/getopt_s.c
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)

crypto/test/kernel_driver$(EXE): crypto/test/kernel_driver.c test/getopt_s.c
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)

210
crypto/test/env$(EXE): crypto/test/env.c test/getopt_s.c
211 212
	$(COMPILE) $(LDFLAGS) -o $@ $^ $(LIBS) $(SRTPLIB)

Cullen Jennings's avatar
Cullen Jennings committed
213
test: $(testapp)
214
	@echo "Build done. Please run '$(MAKE) runtest' to run self tests."
Cullen Jennings's avatar
Cullen Jennings committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235

memtest: test/srtp_driver
	@test/srtp_driver -v -d "alloc" > tmp
	@grep freed tmp | wc -l > freed
	@grep allocated tmp | wc -l > allocated
	@echo "checking for memory leaks (only works with --enable-stdout)"
	cmp -s allocated freed
	@echo "passed (same number of alloc() and dealloc() calls found)"
	@rm freed allocated tmp

# the target 'plot' runs the timing test (test/srtp_driver -t) then
# uses gnuplot to produce plots of the results - see the script file
# 'timing'

plot:	test/srtp_driver
	test/srtp_driver -t > timing.dat


# bookkeeping: tags, clean, and distribution

tags:
236
	etags */*.[ch] */*/*.[ch]
Cullen Jennings's avatar
Cullen Jennings committed
237 238


239
# documentation - the target libsrtp2doc builds html documentation
Cullen Jennings's avatar
Cullen Jennings committed
240

241
libsrtp2doc:
242
	$(MAKE) -C doc
Cullen Jennings's avatar
Cullen Jennings committed
243

244
.PHONY: clean superclean distclean install
Cullen Jennings's avatar
Cullen Jennings committed
245 246

install:
247
	$(INSTALL) -d $(DESTDIR)$(includedir)/srtp2
248
	$(INSTALL) -d $(DESTDIR)$(libdir)
249
	cp $(srcdir)/include/srtp.h $(DESTDIR)$(includedir)/srtp2
250 251 252
	cp $(srcdir)/crypto/include/cipher.h $(DESTDIR)$(includedir)/srtp2
	cp $(srcdir)/crypto/include/auth.h $(DESTDIR)$(includedir)/srtp2
	cp $(srcdir)/crypto/include/crypto_types.h $(DESTDIR)$(includedir)/srtp2
253
	if [ -f libsrtp2.a ]; then cp libsrtp2.a $(DESTDIR)$(libdir)/; fi
254 255
	if [ -f libsrtp2.dll.a ]; then cp libsrtp2.dll.a $(DESTDIR)$(libdir)/; fi
	if [ -f libsrtp2.$(SHAREDLIBSUFFIX) ]; then \
256
		$(INSTALL) -d $(DESTDIR)$(SHAREDLIB_DIR); \
257 258
		cp libsrtp2.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/; \
		cp libsrtp2.$(SHAREDLIBSUFFIXNOVER) $(DESTDIR)$(SHAREDLIB_DIR)/; \
259 260 261
		if [ -n "$(SHAREDLIBVERSION)" ]; then \
			ln -sfn libsrtp2.$(SHAREDLIBSUFFIX) $(DESTDIR)$(SHAREDLIB_DIR)/libsrtp2.$(SHAREDLIBSUFFIXNOVER); \
		fi; \
262
	fi
263 264
	$(INSTALL) -d $(DESTDIR)$(pkgconfigdir)
	cp $(top_builddir)/$(pkgconfig_DATA) $(DESTDIR)$(pkgconfigdir)/
Cullen Jennings's avatar
Cullen Jennings committed
265 266

uninstall:
267
	rm -f $(DESTDIR)$(includedir)/srtp2/*.h
268
	rm -f $(DESTDIR)$(libdir)/libsrtp2.*
269
	-rmdir $(DESTDIR)$(includedir)/srtp2
270
	rm -f $(DESTDIR)$(pkgconfigdir)/$(pkgconfig_DATA)
Cullen Jennings's avatar
Cullen Jennings committed
271 272

clean:
273
	rm -rf $(cryptobj) $(srtpobj) TAGS \
274
		libsrtp2.a libsrtp2.so libsrtp2.dll.a core *.core test/core
Cullen Jennings's avatar
Cullen Jennings committed
275
	for a in * */* */*/*; do			\
276 277
			  if [ -f "$$a~" ] ; then rm -f $$a~; fi;	\
		done;
278
	for a in $(testapp); do rm -rf $$a$(EXE); done
279
	rm -rf *.pict *.jpg *.dat
Cullen Jennings's avatar
Cullen Jennings committed
280
	rm -rf freed allocated tmp
281
	$(MAKE) -C doc clean
Cullen Jennings's avatar
Cullen Jennings committed
282 283

superclean: clean
284
	rm -rf crypto/include/config.h config.log config.cache config.status \
285 286
			   Makefile crypto/Makefile doc/Makefile \
			   .gdb_history test/.gdb_history .DS_Store
Cullen Jennings's avatar
Cullen Jennings committed
287 288
	rm -rf autom4te.cache

289 290
distclean: superclean

291
distname = libsrtp-$(shell cat VERSION)
Cullen Jennings's avatar
Cullen Jennings committed
292

293
distribution: runtest superclean
Cullen Jennings's avatar
Cullen Jennings committed
294 295
	if ! [ -f VERSION ]; then exit 1; fi
	if [ -f ../$(distname).tgz ]; then               \
296 297
		   mv ../$(distname).tgz ../$(distname).tgz.bak; \
		fi
298
	cd ..; tar cvzf $(distname).tgz libsrtp
Cullen Jennings's avatar
Cullen Jennings committed
299

300
# EOF