1# Makefile for tinydtls 2# 3# Copyright (C) 2011--2014 Olaf Bergmann <bergmann@tzi.org> 4# 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: 12# 13# The above copyright notice and this permission notice shall be 14# included in all copies or substantial portions of the Software. 15# 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 23# SOFTWARE. 24 25# the library's version 26VERSION:=@PACKAGE_VERSION@ 27 28# tools 29@SET_MAKE@ 30SHELL = /bin/sh 31MKDIR = mkdir 32ETAGS = @ETAGS@ 33 34prefix = @prefix@ 35exec_prefix = @exec_prefix@ 36abs_builddir = @abs_builddir@ 37top_builddir = @top_builddir@ 38libdir = @libdir@ 39includedir = @includedir@/@PACKAGE_NAME@ 40package = @PACKAGE_TARNAME@-@PACKAGE_VERSION@ 41 42install := cp 43 44# files and flags 45SOURCES:= dtls.c crypto.c ccm.c hmac.c netq.c peer.c dtls_time.c session.c 46ifneq ("@NDEBUG@", "1") 47SOURCES += debug.c 48endif 49SUB_OBJECTS:=aes/rijndael.o @OPT_OBJS@ 50OBJECTS:= $(patsubst %.c, %.o, $(SOURCES)) $(SUB_OBJECTS) 51HEADERS:=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 \ 53 tinydtls.h 54CFLAGS:=-Wall -pedantic -std=c99 @CFLAGS@ 55CPPFLAGS:=@CPPFLAGS@ -DDTLS_CHECK_CONTENTTYPE 56SUBDIRS:=tests doc platform-specific sha2 aes ecc 57DISTSUBDIRS:=$(SUBDIRS) examples/contiki 58DISTDIR=$(top_builddir)/$(package) 59FILES:=Makefile.in configure configure.in dtls_config.h.in tinydtls.h.in \ 60 Makefile.tinydtls $(SOURCES) $(HEADERS) 61LIB:=libtinydtls.a 62LDFLAGS:=@LIBS@ 63ARFLAGS:=cru 64doc:=doc 65 66.PHONY: all dirs clean install dist distclean .gitignore doc TAGS 67 68ifneq ("@WITH_CONTIKI@", "1") 69.SUFFIXES: 70.SUFFIXES: .c .o 71 72all: $(LIB) dirs 73 74check: 75 echo DISTDIR: $(DISTDIR) 76 echo top_builddir: $(top_builddir) 77 $(MAKE) -C tests check 78 79dirs: $(SUBDIRS) 80 for dir in $^; do \ 81 $(MAKE) -C $$dir ; \ 82 done 83 84$(SUB_OBJECTS):: 85 $(MAKE) -C $(@D) $(@F) 86 87$(LIB): $(OBJECTS) 88 $(AR) $(ARFLAGS) $@ $^ 89 ranlib $@ 90 91clean: 92 @rm -f $(PROGRAM) main.o $(LIB) $(OBJECTS) 93 for dir in $(SUBDIRS); do \ 94 $(MAKE) -C $$dir clean ; \ 95 done 96else # WITH_CONTIKI 97all: 98 $(MAKE) -C examples/contiki $@ 99endif # WITH_CONTIKI 100 101doc: 102 $(MAKE) -C doc 103 104distclean: clean 105 @rm -rf $(DISTDIR) 106 @rm -f *~ $(DISTDIR).tar.gz 107 108dist: $(FILES) $(DISTSUBDIRS) 109 test -d $(DISTDIR) || mkdir $(DISTDIR) 110 cp $(FILES) $(DISTDIR) 111 for dir in $(DISTSUBDIRS); do \ 112 $(MAKE) -C $$dir dist; \ 113 done 114 tar czf $(package).tar.gz $(DISTDIR) 115 116install: $(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; \ 123 done 124 125TAGS: 126 $(ETAGS) -o $@.new $(SOURCES) 127 $(ETAGS) -a -o $@.new $(HEADERS) 128 mv $@.new $@ 129 130# files that should be ignored by git 131GITIGNOREDS:= 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/*))) \ 138 .project 139 140.gitignore: 141 echo $(GITIGNOREDS) | sed 's/ /\n/g' > $@ 142 143