1# Makefile for tinydtls 2# 3# 4# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Olaf Bergmann (TZI) and others. 5# All rights reserved. This program and the accompanying materials 6# are made available under the terms of the Eclipse Public License v1.0 7# and Eclipse Distribution License v. 1.0 which accompanies this distribution. 8# 9# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 10# and the Eclipse Distribution License is available at 11# http://www.eclipse.org/org/documents/edl-v10.php. 12# 13# Contributors: 14# Olaf Bergmann - initial API and implementation 15# 16 17# the library's version 18VERSION:=@PACKAGE_VERSION@ 19 20# tools 21@SET_MAKE@ 22SHELL = /bin/sh 23MKDIR = mkdir 24ETAGS = @ETAGS@ 25CC=@CC@ 26AR=@AR@ 27RANLIB=@RANLIB@ 28 29prefix = @prefix@ 30exec_prefix = @exec_prefix@ 31abs_builddir = @abs_builddir@ 32top_builddir = @top_builddir@ 33top_srcdir = @top_srcdir@ 34libdir = @libdir@ 35includedir = @includedir@/@PACKAGE_NAME@ 36package = @PACKAGE_TARNAME@-@PACKAGE_VERSION@ 37 38install := cp 39 40# files and flags 41SOURCES:= dtls.c crypto.c ccm.c hmac.c netq.c peer.c dtls_time.c session.c dtls_debug.c dtls_prng.c 42SUB_OBJECTS:=aes/rijndael.o @OPT_OBJS@ 43OBJECTS:= $(patsubst %.c, %.o, $(SOURCES)) $(SUB_OBJECTS) 44HEADERS:=dtls.h hmac.h dtls_debug.h dtls_config.h uthash.h numeric.h crypto.h global.h ccm.h \ 45 netq.h alert.h utlist.h dtls_prng.h peer.h state.h dtls_time.h session.h \ 46 tinydtls.h 47CFLAGS:=-Wall -pedantic -std=c99 -DSHA2_USE_INTTYPES_H @CFLAGS@ @WARNING_CFLAGS@ 48CPPFLAGS:=@CPPFLAGS@ -DDTLS_CHECK_CONTENTTYPE -I$(top_srcdir) 49SUBDIRS:=tests doc platform-specific sha2 aes ecc 50DISTSUBDIRS:=$(SUBDIRS) 51DISTDIR=$(top_builddir)/$(package) 52FILES:=Makefile.in configure configure.in dtls_config.h.in tinydtls.h.in \ 53 Makefile.tinydtls $(SOURCES) $(HEADERS) 54LIB:=libtinydtls 55LIBS:=$(LIB).a $(LIB).so 56LDFLAGS:=@LIBS@ 57ARFLAGS:=cru 58doc:=doc 59 60.PHONY: all dirs clean install dist distclean .gitignore doc TAGS 61 62ifneq ("@WITH_CONTIKI@", "1") 63.SUFFIXES: 64.SUFFIXES: .c .o 65 66all: $(LIBS) dirs 67 68check: tests 69 echo DISTDIR: $(DISTDIR) 70 echo top_builddir: $(top_builddir) 71 $(MAKE) -C tests check 72 73tests: $(LIBS) 74 $(MAKE) -C tests 75 76dirs: $(SUBDIRS) 77 for dir in $^; do \ 78 $(MAKE) -C $$dir ; \ 79 done 80 81$(SUB_OBJECTS):: 82 $(MAKE) -C $(@D) $(@F) 83 84$(LIB).so: $(OBJECTS) 85 $(LINK.c) $(LDFLAGS) -shared $^ -o $@ 86 87$(LIB).a: $(OBJECTS) 88 $(AR) $(ARFLAGS) $@ $^ 89 $(RANLIB) $@ 90 91clean: 92 @rm -f $(PROGRAM) main.o $(LIBS) $(OBJECTS) 93 for dir in $(SUBDIRS); do \ 94 $(MAKE) -C $$dir clean ; \ 95 done 96endif # WITH_CONTIKI 97 98doc: 99 $(MAKE) -C doc 100 101distclean: clean 102 @rm -rf $(DISTDIR) 103 @rm -f *~ $(DISTDIR).tar.gz 104 105dist: $(FILES) $(DISTSUBDIRS) 106 test -d $(DISTDIR) || mkdir $(DISTDIR) 107 cp $(FILES) $(DISTDIR) 108 for dir in $(DISTSUBDIRS); do \ 109 $(MAKE) -C $$dir dist; \ 110 done 111 tar czf $(package).tar.gz $(DISTDIR) 112 113install: $(LIBS) $(HEADERS) $(SUBDIRS) 114 test -d $(libdir) || mkdir -p $(libdir) 115 test -d $(includedir) || mkdir -p $(includedir) 116 $(install) $(LIBS) $(libdir)/ 117 $(install) $(HEADERS) $(includedir)/ 118 for dir in $(SUBDIRS); do \ 119 $(MAKE) -C $$dir install="$(install)" includedir=$(includedir) install; \ 120 done 121 122TAGS: 123 $(ETAGS) -o $@.new $(SOURCES) 124 $(ETAGS) -a -o $@.new $(HEADERS) 125 mv $@.new $@ 126 127# files that should be ignored by git 128GITIGNOREDS:= core \*~ \*.[oa] \*.gz \*.cap \*.pcap Makefile \ 129 autom4te.cache/ config.h config.log config.status configure \ 130 doc/Doxyfile doc/doxygen.out doc/html/ $(LIBS) tests/ccm-test \ 131 tests/dtls-client tests/dtls-server tests/prf-test $(package) \ 132 $(DISTDIR)/ TAGS \*.patch .gitignore ecc/testecc ecc/testfield \ 133 \*.d \*.hex \*.elf \*.map obj_\* tinydtls.h dtls_config.h \ 134 $(addprefix \*., $(notdir $(wildcard ../../platform/*))) \ 135 .project 136 137.gitignore: 138 echo $(GITIGNOREDS) | sed 's/ /\n/g' > $@ 139 140