• 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-2023 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 = \
12  share.libcoap.examples.Makefile \
13  share.libcoap.examples.README \
14  coap_list.h \
15  getopt.c \
16  interop/a_client.conf \
17  interop/b_server.conf \
18  interop/c_client.conf \
19  interop/d_server.conf \
20  interop/e_client.conf \
21  interop/f_client.conf \
22  interop/g_client.conf \
23  oscore_testcases.sh
24
25# just do nothing if 'BUILD_EXAMPLES' isn't defined
26if BUILD_EXAMPLES
27
28# picking up the default warning CFLAGS into AM_CFLAGS
29AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include \
30            $(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99 $(EXTRA_CFLAGS)
31
32#
33
34bin_PROGRAMS =
35noinst_PROGRAMS =
36check_PROGRAMS =
37
38if HAVE_CLIENT_SUPPORT
39
40bin_PROGRAMS += coap-client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@
41check_PROGRAMS += coap-tiny
42
43if BUILD_ADD_DEFAULT_NAMES
44noinst_PROGRAMS += coap-client
45endif # BUILD_ADD_DEFAULT_NAMES
46
47endif # HAVE_CLIENT_SUPPORT
48
49if HAVE_SERVER_SUPPORT
50
51bin_PROGRAMS += coap-server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ \
52                coap-rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@
53check_PROGRAMS += coap-etsi_iot_01 oscore-interop-server
54
55if BUILD_ADD_DEFAULT_NAMES
56noinst_PROGRAMS += coap-server coap-rd
57endif # BUILD_ADD_DEFAULT_NAMES
58
59if ! HAVE_CLIENT_SUPPORT
60coap_server_CPPFLAGS=-DSERVER_CAN_PROXY=0
61coap_server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_CPPFLAGS=-DSERVER_CAN_PROXY=0
62endif # ! HAVE_CLIENT_SUPPORT
63
64endif # HAVE_SERVER_SUPPORT
65
66coap_client_SOURCES = coap-client.c
67coap_client_LDADD =  $(DTLS_LIBS) \
68             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
69
70coap_server_SOURCES = coap-server.c
71coap_server_LDADD = $(DTLS_LIBS) \
72             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
73
74coap_rd_SOURCES = coap-rd.c
75coap_rd_LDADD = $(DTLS_LIBS) \
76             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
77
78coap_client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_SOURCES = coap-client.c
79coap_client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_LDADD =  $(DTLS_LIBS) \
80             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
81
82coap_server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_SOURCES = coap-server.c
83coap_server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_LDADD = $(DTLS_LIBS) \
84             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
85
86coap_rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_SOURCES = coap-rd.c
87coap_rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@_LDADD = $(DTLS_LIBS) \
88             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
89
90coap_etsi_iot_01_SOURCES = etsi_iot_01.c
91coap_etsi_iot_01_LDADD = $(DTLS_LIBS) \
92             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
93
94oscore_interop_server_SOURCES = oscore-interop-server.c
95oscore_interop_server_LDADD = $(DTLS_LIBS) \
96             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
97
98coap_tiny_SOURCES = tiny.c
99coap_tiny_LDADD = $(DTLS_LIBS) \
100             $(top_builddir)/.libs/libcoap-$(LIBCOAP_NAME_SUFFIX).la
101
102endif # BUILD_EXAMPLES
103
104if BUILD_EXAMPLES_SOURCE
105EXAMPLES_DIR = $(DESTDIR)$(datadir)/libcoap/examples
106EXAMPLES_SRC = coap-client.c coap-server.c
107endif # BUILD_EXAMPLES_SOURCE
108
109## Install example files
110install-exec-hook:
111if BUILD_EXAMPLES_SOURCE
112	$(MKDIR_P) $(EXAMPLES_DIR)
113	(cd $(top_srcdir)/examples ; \
114	$(INSTALL_DATA) $(EXAMPLES_SRC) ../LICENSE ../COPYING $(EXAMPLES_DIR) ; \
115	$(INSTALL_DATA) share.libcoap.examples.Makefile $(EXAMPLES_DIR)/Makefile; \
116	$(INSTALL_DATA) share.libcoap.examples.README $(EXAMPLES_DIR)/README)
117endif # BUILD_EXAMPLES_SOURCE
118if BUILD_ADD_DEFAULT_NAMES
119	if [ -d "$(DESTDIR)$(bindir)" ] ; then \
120		(cd $(DESTDIR)$(bindir) && \
121			(if [ -f coap-client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ ] ; then \
122				rm -f coap-client ; \
123				$(LN_S) coap-client@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ coap-client ; \
124			fi ; \
125			if [ -f coap-server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ ] ; then \
126				rm -f coap-server ; \
127				$(LN_S) coap-server@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ coap-server ; \
128			fi ; \
129			if [ -f coap-rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ ] ; then \
130				rm -f coap-rd ; \
131				$(LN_S) coap-rd@LIBCOAP_DTLS_LIB_EXTENSION_NAME@ coap-rd ; \
132			fi) \
133		) ; \
134	fi
135endif # BUILD_ADD_DEFAULT_NAMES
136
137uninstall-hook:
138if BUILD_EXAMPLES_SOURCE
139	rm -rf $(DESTDIR)$(datadir)/libcoap/examples
140endif # BUILD_EXAMPLES_SOURCE
141if BUILD_ADD_DEFAULT_NAMES
142	rm -f $(DESTDIR)$(bindir)/coap-client
143	rm -f $(DESTDIR)$(bindir)/coap-server
144	rm -f $(DESTDIR)$(bindir)/coap-rd
145endif # BUILD_ADD_DEFAULT_NAMES
146