• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# examples/Makefile.am
2#
3# Copyright (C)      2015 Carsten Schoenert <c.schoenert@t-online.de>
4# Copyright (C) 2018-2021 Jon Shallow <supjps-libcoap@jpshallow.com>
5#
6# SPDX-License-Identifier: BSD-2-Clause
7#
8# This file is part of the CoAP C library libcoap. Please see README and
9# COPYING for terms of use.
10
11EXTRA_DIST = share.libcoap.examples.Makefile share.libcoap.examples.README
12
13# just do nothing if 'BUILD_EXAMPLES' isn't defined
14if BUILD_EXAMPLES
15
16# picking up the default warning CFLAGS into AM_CFLAGS
17AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \
18            $(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99
19
20#
21
22bin_PROGRAMS = coap-client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ \
23               coap-server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ \
24               coap-rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@
25
26check_PROGRAMS = coap-etsi_iot_01 coap-tiny
27
28if BUILD_ADD_DEFAULT_NAMES
29noinst_PROGRAMS = coap-client coap-server coap-rd
30
31coap_client_SOURCES = coap-client.c
32coap_client_LDADD =  $(DTLS_LIBS) \
33             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
34
35coap_server_SOURCES = coap-server.c
36coap_server_LDADD = $(DTLS_LIBS) \
37             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
38
39coap_rd_SOURCES = coap-rd.c
40coap_rd_LDADD = $(DTLS_LIBS) \
41             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
42endif # BUILD_ADD_DEFAULT_NAMES
43
44coap_client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_SOURCES = coap-client.c
45coap_client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_LDADD =  $(DTLS_LIBS) \
46             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
47
48coap_server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_SOURCES = coap-server.c
49coap_server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_LDADD = $(DTLS_LIBS) \
50             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
51
52coap_rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_SOURCES = coap-rd.c
53coap_rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_LDADD = $(DTLS_LIBS) \
54             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
55
56coap_etsi_iot_01_SOURCES = etsi_iot_01.c
57coap_etsi_iot_01_LDADD = $(DTLS_LIBS) \
58             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
59
60coap_tiny_SOURCES = tiny.c
61coap_tiny_LDADD = $(DTLS_LIBS) \
62             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
63
64endif # BUILD_EXAMPLES
65
66if BUILD_EXAMPLES_SOURCE
67EXAMPLES_DIR = $(DESTDIR)$(datadir)/libcoap/examples
68EXAMPLES_SRC = coap-client.c coap-server.c
69endif # BUILD_EXAMPLES_SOURCE
70
71## Install example files
72install-exec-hook:
73if BUILD_EXAMPLES_SOURCE
74	$(MKDIR_P) $(EXAMPLES_DIR)
75	(cd $(top_srcdir)/examples ; \
76	$(INSTALL_DATA) $(EXAMPLES_SRC) ../LICENSE ../COPYING $(EXAMPLES_DIR) ; \
77	$(INSTALL_DATA) share.libcoap.examples.Makefile $(EXAMPLES_DIR)/Makefile; \
78	$(INSTALL_DATA) share.libcoap.examples.README $(EXAMPLES_DIR)/README)
79endif # BUILD_EXAMPLES_SOURCE
80if BUILD_ADD_DEFAULT_NAMES
81	if [ -d "$(DESTDIR)$(bindir)" ] ; then \
82		(cd $(DESTDIR)$(bindir) && \
83			(if [ -f coap-client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ ] ; then \
84				rm -f coap-client ; \
85				$(LN_S) coap-client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ coap-client ; \
86			fi ; \
87			if [ -f coap-server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ ] ; then \
88				rm -f coap-server ; \
89				$(LN_S) coap-server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ coap-server ; \
90			fi ; \
91			if [ -f coap-rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ ] ; then \
92				rm -f coap-rd ; \
93				$(LN_S) coap-rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ coap-rd ; \
94			fi) \
95		) ; \
96	fi
97endif # BUILD_ADD_DEFAULT_NAMES
98
99uninstall-hook:
100if BUILD_EXAMPLES_SOURCE
101	rm -rf $(DESTDIR)$(datadir)/libcoap/examples
102endif # BUILD_EXAMPLES_SOURCE
103if BUILD_ADD_DEFAULT_NAMES
104	rm -f $(DESTDIR)$(bindir)/coap-client
105	rm -f $(DESTDIR)$(bindir)/coap-server
106	rm -f $(DESTDIR)$(bindir)/coap-rd
107endif # BUILD_ADD_DEFAULT_NAMES
108