1 From a6f312dfb4497d5e72664c4772a8b122e25b81d8 Mon Sep 17 00:00:00 2001
2 From: Fabrice Fontaine <fabrice.fontaine@orange.com>
3 Date: Tue, 26 Jul 2016 09:09:53 +0200
4 Subject: [PATCH] Update Makefile.in to allow cross-compilation
6 Use CC, CPP and DESTDIR environment variables passed to configure in Makefile.in files
7 Fix definition of LIBS and LDFLAGS (LDFLAGS was set to @LIBS@)
9 Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
11 Makefile.in | 13 ++++++++-----
12 aes/Makefile.in | 7 +++++--
13 doc/Makefile.in | 4 ++--
14 ecc/Makefile.in | 7 +++++--
15 sha2/Makefile.in | 7 +++++--
16 tests/Makefile.in | 4 +++-
17 6 files changed, 28 insertions(+), 14 deletions(-)
19 diff --git a/Makefile.in b/Makefile.in
20 index 38cc665..7dcd424 100644
23 @@ -40,7 +40,9 @@ OBJECTS:= $(patsubst %.c, %.o, $(SOURCES)) $(SUB_OBJECTS)
24 HEADERS:=dtls.h hmac.h dtls_debug.h dtls_config.h uthash.h numeric.h crypto.h global.h ccm.h \
25 netq.h alert.h utlist.h prng.h peer.h state.h dtls_time.h session.h \
28 CFLAGS:=-Wall -pedantic -std=c99 @CFLAGS@
30 CPPFLAGS:=@CPPFLAGS@ -DDTLS_CHECK_CONTENTTYPE
31 SUBDIRS:=tests doc platform-specific sha2 aes ecc
32 DISTSUBDIRS:=$(SUBDIRS)
33 @@ -48,7 +50,8 @@ DISTDIR=$(top_builddir)/$(package)
34 FILES:=Makefile.in configure configure.in dtls_config.h.in tinydtls.h.in \
35 Makefile.tinydtls $(SOURCES) $(HEADERS)
43 @@ -100,10 +103,10 @@ dist: $(FILES) $(DISTSUBDIRS)
44 tar czf $(package).tar.gz $(DISTDIR)
46 install: $(LIB) $(HEADERS) $(SUBDIRS)
47 - test -d $(libdir) || mkdir -p $(libdir)
48 - test -d $(includedir) || mkdir -p $(includedir)
49 - $(install) $(LIB) $(libdir)/
50 - $(install) $(HEADERS) $(includedir)/
51 + test -d $(DESTDIR)$(libdir) || mkdir -p $(DESTDIR)$(libdir)
52 + test -d $(DESTDIR)$(includedir) || mkdir -p $(DESTDIR)$(includedir)
53 + $(install) $(LIB) $(DESTDIR)$(libdir)/
54 + $(install) $(HEADERS) $(DESTDIR)$(includedir)/
55 for dir in $(SUBDIRS); do \
56 $(MAKE) -C $$dir install="$(install)" includedir=$(includedir) install; \
58 diff --git a/aes/Makefile.in b/aes/Makefile.in
59 index 7c9f6ef..9ff7799 100644
62 @@ -28,8 +28,11 @@ top_srcdir:= @top_srcdir@
65 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
69 CFLAGS=-Wall -std=c99 -pedantic @CFLAGS@
72 FILES:=Makefile.in $(SOURCES) $(HEADERS)
73 DISTDIR=$(top_builddir)/@PACKAGE_TARNAME@-@PACKAGE_VERSION@
74 @@ -60,8 +63,8 @@ dist: $(FILES)
75 cp -p $(FILES) $(DISTDIR)/aes
78 - test -d $(includedir)/aes || mkdir -p $(includedir)/aes
79 - $(install) $(HEADERS) $(includedir)/aes
80 + test -d $(DESTDIR)$(includedir)/aes || mkdir -p $(DESTDIR)$(includedir)/aes
81 + $(install) $(HEADERS) $(DESTDIR)$(includedir)/aes
84 echo "core\n*~\n*.[oa]\n*.gz\n*.cap\n$(PROGRAM)\n$(DISTDIR)\n.gitignore" >$@
85 diff --git a/doc/Makefile.in b/doc/Makefile.in
86 index a07101e..5ab0a35 100644
89 @@ -32,5 +32,5 @@ dist: doc
90 cp -r $(FILES) $(DISTDIR)/doc
93 - test -d $(htmldir) || mkdir -p $(htmldir)
94 - cp -r html/* $(htmldir)
95 + test -d $(DESTDIR)$(htmldir) || mkdir -p $(DESTDIR)$(htmldir)
96 + cp -r html/* $(DESTDIR)$(htmldir)
97 diff --git a/ecc/Makefile.in b/ecc/Makefile.in
98 index 2ba17a1..2086d4f 100644
100 +++ b/ecc/Makefile.in
101 @@ -36,8 +36,11 @@ include Makefile.contiki
103 ECC_OBJECTS:= $(patsubst %.c, %.o, $(ECC_SOURCES)) ecc_test.o
104 PROGRAMS:= testecc testfield
108 CFLAGS=-Wall -std=c99 -pedantic @CFLAGS@ -DTEST_INCLUDE
112 .PHONY: all dirs clean install distclean .gitignore doc
113 @@ -74,8 +77,8 @@ dist: $(FILES)
114 cp -p $(FILES) $(DISTDIR)/ecc
117 - test -d $(includedir)/ecc || mkdir -p $(includedir)/ecc
118 - $(install) $(HEADERS) $(includedir)/ecc
119 + test -d $(DESTDIR)$(includedir)/ecc || mkdir -p $(DESTDIR)$(includedir)/ecc
120 + $(install) $(ECC_HEADERS) $(DESTDIR)$(includedir)/ecc
123 echo "core\n*~\n*.[oa]\n*.gz\n*.cap\n$(PROGRAM)\n$(DISTDIR)\n.gitignore" >$@
124 diff --git a/sha2/Makefile.in b/sha2/Makefile.in
125 index 9f19314..69f8793 100644
126 --- a/sha2/Makefile.in
127 +++ b/sha2/Makefile.in
128 @@ -28,8 +28,11 @@ top_srcdir:= @top_srcdir@
131 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
133 CPPFLAGS=@CPPFLAGS@ -I$(top_srcdir)
135 CFLAGS=-Wall -std=c99 -pedantic @CFLAGS@
138 FILES:=Makefile.in $(SOURCES) $(HEADERS) README sha2prog.c sha2speed.c sha2test.pl
139 DISTDIR=$(top_builddir)/@PACKAGE_TARNAME@-@PACKAGE_VERSION@
140 @@ -62,8 +65,8 @@ dist: $(FILES)
141 cp -pr testvectors $(DISTDIR)/sha2/testvectors
144 - test -d $(includedir)/sha2 || mkdir -p $(includedir)/sha2
145 - $(install) $(HEADERS) $(includedir)/sha2
146 + test -d $(DESTDIR)$(includedir)/sha2 || mkdir -p $(DESTDIR)$(includedir)/sha2
147 + $(install) $(HEADERS) $(DESTDIR)$(includedir)/sha2
150 echo "core\n*~\n*.[oa]\n*.gz\n*.cap\n$(PROGRAM)\n$(DISTDIR)\n.gitignore" >$@
151 diff --git a/tests/Makefile.in b/tests/Makefile.in
152 index a8a2ed0..b45f440 100644
153 --- a/tests/Makefile.in
154 +++ b/tests/Makefile.in
155 @@ -32,9 +32,11 @@ SOURCES:= dtls-server.c ccm-test.c prf-test.c \
156 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
157 PROGRAMS:= $(patsubst %.c, %, $(SOURCES))
160 CFLAGS:=-Wall @CFLAGS@
162 CPPFLAGS:=-I$(top_srcdir) @CPPFLAGS@
163 -LDFLAGS:=-L$(top_builddir)
164 +LDFLAGS:=-L$(top_builddir) @LDFLAGS@
165 LDLIBS:=-ltinydtls @LIBS@
166 DISTDIR=$(top_builddir)/@PACKAGE_TARNAME@-@PACKAGE_VERSION@
167 FILES:=Makefile.in $(SOURCES) ccm-testdata.c #cbc_aes128-testdata.c