1 # Makefile for tinydtls
3 # Copyright (C) 2011--2014 Olaf Bergmann <bergmann@tzi.org>
5 # Permission is hereby granted, free of charge, to any person
6 # obtaining a copy of this software and associated documentation
7 # files (the "Software"), to deal in the Software without
8 # restriction, including without limitation the rights to use, copy,
9 # modify, merge, publish, distribute, sublicense, and/or sell copies
10 # of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 # the library's version
26 VERSION:=@PACKAGE_VERSION@
35 exec_prefix = @exec_prefix@
36 abs_builddir = @abs_builddir@
37 top_builddir = @top_builddir@
39 includedir = @includedir@/@PACKAGE_NAME@
40 package = @PACKAGE_TARNAME@-@PACKAGE_VERSION@
45 SOURCES:= dtls.c crypto.c ccm.c hmac.c netq.c peer.c dtls_time.c session.c
46 ifneq ("@NDEBUG@", "1")
49 SUB_OBJECTS:=aes/rijndael.o @OPT_OBJS@
50 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES)) $(SUB_OBJECTS)
51 HEADERS:=dtls.h hmac.h debug.h dtls_config.h uthash.h numeric.h crypto.h global.h ccm.h \
52 netq.h t_list.h alert.h utlist.h prng.h peer.h state.h dtls_time.h session.h \
54 CFLAGS:=-Wall -pedantic -std=c99 @CFLAGS@
55 CPPFLAGS:=@CPPFLAGS@ -DDTLS_CHECK_CONTENTTYPE
56 SUBDIRS:=tests doc platform-specific sha2 aes ecc
57 DISTSUBDIRS:=$(SUBDIRS) examples/contiki
58 DISTDIR=$(top_builddir)/$(package)
59 FILES:=Makefile.in configure configure.in dtls_config.h.in tinydtls.h.in \
60 Makefile.tinydtls $(SOURCES) $(HEADERS)
66 .PHONY: all dirs clean install dist distclean .gitignore doc TAGS
68 ifneq ("@WITH_CONTIKI@", "1")
75 echo DISTDIR: $(DISTDIR)
76 echo top_builddir: $(top_builddir)
77 $(MAKE) -C tests check
85 $(MAKE) -C $(@D) $(@F)
88 $(AR) $(ARFLAGS) $@ $^
92 @rm -f $(PROGRAM) main.o $(LIB) $(OBJECTS)
93 for dir in $(SUBDIRS); do \
94 $(MAKE) -C $$dir clean ; \
98 $(MAKE) -C examples/contiki $@
106 @rm -f *~ $(DISTDIR).tar.gz
108 dist: $(FILES) $(DISTSUBDIRS)
109 test -d $(DISTDIR) || mkdir $(DISTDIR)
110 cp $(FILES) $(DISTDIR)
111 for dir in $(DISTSUBDIRS); do \
112 $(MAKE) -C $$dir dist; \
114 tar czf $(package).tar.gz $(DISTDIR)
116 install: $(LIB) $(HEADERS) $(SUBDIRS)
117 test -d $(libdir) || mkdir -p $(libdir)
118 test -d $(includedir) || mkdir -p $(includedir)
119 $(install) $(LIB) $(libdir)/
120 $(install) $(HEADERS) $(includedir)/
121 for dir in $(SUBDIRS); do \
122 $(MAKE) -C $$dir install="$(install)" includedir=$(includedir) install; \
126 $(ETAGS) -o $@.new $(SOURCES)
127 $(ETAGS) -a -o $@.new $(HEADERS)
130 # files that should be ignored by git
131 GITIGNOREDS:= core \*~ \*.[oa] \*.gz \*.cap \*.pcap Makefile \
132 autom4te.cache/ config.h config.log config.status configure \
133 doc/Doxyfile doc/doxygen.out doc/html/ $(LIB) tests/ccm-test \
134 tests/dtls-client tests/dtls-server tests/prf-test $(package) \
135 $(DISTDIR)/ TAGS \*.patch .gitignore ecc/testecc ecc/testfield \
136 \*.d \*.hex \*.elf \*.map obj_\* tinydtls.h dtls_config.h \
137 $(addprefix \*., $(notdir $(wildcard ../../platform/*))) \
141 echo $(GITIGNOREDS) | sed 's/ /\n/g' > $@