From 60030d0fb4a83d16b3b84d0fc7e2c86aa139b736 Mon Sep 17 00:00:00 2001 From: Carsten Schoenert Date: Wed, 11 Mar 2015 19:56:02 +0100 Subject: [PATCH] examples: adding the examples folder to the build After including the doc/ and the tests/ folder under the hood of the autotools now adding the examples/ foolder too. The user is now able to add the build of the example binarys if configure is called with '--enable-examples' as option. The example binarys will not be build by default! Currently only 'coap-client', 'coap-server' and 'rd' is build. --- Makefile.am | 2 +- configure.ac | 20 ++++++++++++++++ examples/Makefile.am | 28 +++++++++++++++++++++++ examples/{Makefile.in => Makefile.in.old} | 0 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 examples/Makefile.am rename examples/{Makefile.in => Makefile.in.old} (100%) diff --git a/Makefile.am b/Makefile.am index c93d721a..989fe53a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,7 +14,7 @@ ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4 AM_CFLAGS = -I @top_builddir@/include/coap/ $(WARNING_CFLAGS) -std=c99 -SUBDIRS = . $(DOC_DIR) tests +SUBDIRS = . $(DOC_DIR) tests examples ## Define a libtool archive target "libcoap-@LIBCOAP_API_VERSION@.la", with ## @LIBCOAP_API_VERSION@ substituted into the generated Makefile at configure diff --git a/configure.ac b/configure.ac index 5f9727f5..641c77a7 100644 --- a/configure.ac +++ b/configure.ac @@ -222,6 +222,22 @@ if test "x$build_tests" = "xyes"; then fi AM_CONDITIONAL(HAVE_CUNIT, [test "x$CUNIT_LIBS" != "x"]) +# configure options +# __examples__ +AC_ARG_ENABLE([examples], + [AC_HELP_STRING([--enable-examples], + [Enable building the tests (default=yes)])], + [build_examples="$enableval"], + [build_examples="yes"]) + +if test "x$build_examples" = "xyes"; then + BUILD_EXAMPLES="YES" +fi +AM_CONDITIONAL(BUILD_EXAMPLES, [test "x$build_examples" != "x"]) + +# end configure options +####################### + # Check for ctags AC_ARG_VAR([CTAGS_PROG],[the 'ctag' program to use for make target 'update-map-file']) AC_PATH_PROG([CTAGS_PROG],[ctags],[]) @@ -305,6 +321,7 @@ esac AC_CONFIG_FILES([ Makefile doc/Makefile +examples/Makefile tests/Makefile libcoap-$LIBCOAP_API_VERSION.pc:libcoap-$LIBCOAP_API_VERSION.pc.in ]) @@ -335,3 +352,6 @@ if test "x$build_tests" = "xyes"; then else AC_MSG_RESULT([ build unit test binary : "no"]) fi +if test "x$build_examples" = "xyes"; then + AC_MSG_RESULT([ build examples : "yes"]) +fi diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 00000000..7a3f6c4b --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,28 @@ +# doc/Makefile.am +# +# Copyright (C) 2015 Carsten Schoenert +# +# This file is part of the CoAP C library libcoap. Please see README and +# COPYING for terms of use. + +# just do nothing if 'BUILD_EXAMPLES' isn't defined +if BUILD_EXAMPLES + +# picking up the default warning CFLAGS into AM_CFLAGS +AM_CFLAGS = -I@top_builddir@/include/coap/ $(WARNING_CFLAGS) -std=c99 + +# etsi_iot_01 and tiny are missing +bin_PROGRAMS = coap-client coap-server rd + +coap_client_SOURCES = client.c coap_list.c +coap_client_LDADD = @top_builddir@/.libs/libcoap-$(LIBCOAP_API_VERSION).la + +coap_server_SOURCES = server.c +coap_server_LDADD = @top_builddir@/.libs/libcoap-$(LIBCOAP_API_VERSION).la + +rd_SOURCES = rd.c +rd_LDADD = @top_builddir@/.libs/libcoap-$(LIBCOAP_API_VERSION).la + +install-exec-am: all-local + +endif # BUILD_EXAMPLES diff --git a/examples/Makefile.in b/examples/Makefile.in.old similarity index 100% rename from examples/Makefile.in rename to examples/Makefile.in.old