From 9b1257180411b6596d989f78c4586aed56b6b5f4 Mon Sep 17 00:00:00 2001 From: Diego Santa Cruz Date: Wed, 20 Sep 2017 10:48:54 +0200 Subject: [PATCH 1/3] Makefile.am: fix building outside of source tree When building outside the source tree compilation fails on examples, because the libcoap headers expect to be all in the same directory but coap.h is generated under the build directory, so it is necessary to add an extra include path for it. Also, build directories should always appear before source directories in the include path, so that any leftover generated files in the source tree are ignored. --- examples/Makefile.am | 4 +++- tests/Makefile.am | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 6ac37f74..20a45e92 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -9,7 +9,9 @@ if BUILD_EXAMPLES # picking up the default warning CFLAGS into AM_CFLAGS -AM_CFLAGS = -isystem$(top_builddir)/include -I$(top_srcdir)/include $(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99 +AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \ + -I$(top_srcdir)/include/coap \ + $(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99 # etsi_iot_01 and tiny are missing bin_PROGRAMS = coap-client coap-server coap-rd diff --git a/tests/Makefile.am b/tests/Makefile.am index b24dd3ef..e70125b1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,7 +9,7 @@ if HAVE_CUNIT # picking up the default warning CFLAGS -AM_CFLAGS = -I$(top_srcdir)/include/coap -I$(top_builddir)/include/coap $(WARNING_CFLAGS) $(CUNIT_CFLAGS) $(DTLS_CFLAGS) -std=c99 +AM_CFLAGS = -I$(top_builddir)/include/coap -I$(top_srcdir)/include/coap $(WARNING_CFLAGS) $(CUNIT_CFLAGS) $(DTLS_CFLAGS) -std=c99 noinst_PROGRAMS = \ testdriver From fde93fca909a48532c8159bac5f4e249a19b4df2 Mon Sep 17 00:00:00 2001 From: Diego Santa Cruz Date: Wed, 20 Sep 2017 10:54:02 +0200 Subject: [PATCH 2/3] configure.ac: fix linker version script detection The detection of linker's support for version scripts fails when building outside the source tree due to missing source path to the linker script. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fd6d7db3..791d32e0 100644 --- a/configure.ac +++ b/configure.ac @@ -146,7 +146,7 @@ AX_CHECK_COMPILE_FLAG([-Wunused-result], [WARNING_CFLAGS="$WARNING_CFLAGS -Wunus AC_SUBST([WARNING_CFLAGS]) -AX_CHECK_LINK_FLAG([-Wl,--version-script=./libcoap-${LIBCOAP_API_VERSION}.map], +AX_CHECK_LINK_FLAG([-Wl,--version-script=${srcdir}/libcoap-${LIBCOAP_API_VERSION}.map], [libcoap_SYMBOLS="-Wl,--version-script=\$(srcdir)/libcoap-\$(LIBCOAP_API_VERSION).map"], [libcoap_SYMBOLS="-export-symbols \$(srcdir)/libcoap-\$(LIBCOAP_API_VERSION).sym"]) From cfb9575e01ec422236670870c2dc36d7ffcd986b Mon Sep 17 00:00:00 2001 From: Diego Santa Cruz Date: Wed, 20 Sep 2017 10:57:46 +0200 Subject: [PATCH 3/3] libcoap-1.pc.in: do not unnecessarily expose DTLS libs to users The SSL lib used to implement DTLS is only used internally by libcoap, so it is not necessary and sometimes harmful to expose it via the pkg-config file. Only when doing static linking is it necessary to link the SSL lib, this is done via the "Libs.private: pkg-config directive. --- libcoap-1.pc.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libcoap-1.pc.in b/libcoap-1.pc.in index 723e9a16..f1c1c339 100644 --- a/libcoap-1.pc.in +++ b/libcoap-1.pc.in @@ -7,5 +7,6 @@ Name: @PACKAGE_NAME@ Description: C-Implementation of CoAP. Version: @PACKAGE_VERSION@ URL: @PACKAGE_URL@ -Libs: -L${libdir} -lcoap-@LIBCOAP_API_VERSION@ @DTLS_LIBS@ -Cflags: -I${includedir} @DTLS_CFLAGS@ +Libs: -L${libdir} -lcoap-@LIBCOAP_API_VERSION@ +Libs.private: @DTLS_LIBS@ +Cflags: -I${includedir}