• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Makefile.am for libcoap
2#
3# Copyright (C) 2010-2021,2021 Olaf Bergmann <bergmann@tzi.org>
4# Copyright (C) 2015-2017 Carsten Schoenert <c.schoenert@t-online.de>
5# Copyright (C) 2018-2021 Jon Shallow <supjps-libcoap@jpshallow.com>
6#
7# SPDX-License-Identifier: BSD-2-Clause
8#
9# This file is part of the CoAP C library libcoap. Please see README and
10# COPYING for terms of use.
11
12## Place generated object files (.o) into the same directory as their source
13## files, in order to avoid collisions when non-recursive make is used.
14AUTOMAKE_OPTIONS = subdir-objects
15
16ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
17
18## Additional files for the distribution archive
19EXTRA_DIST = \
20  BUILDING \
21  CONTRIBUTE \
22  TODO \
23  LICENSE \
24  CMakeLists.txt \
25  cmake_coap_config.h.in \
26  cmake/Config.cmake.in \
27  cmake/FindMbedTLS.cmake \
28  cmake/FindTinyDTLS.cmake \
29  coap_config.h.lwip \
30  coap_config.h.riot \
31  coap_config.h.windows \
32  libcoap-$(LIBCOAP_API_VERSION).pc.in \
33  libcoap-$(LIBCOAP_API_VERSION).map \
34  libcoap-$(LIBCOAP_API_VERSION).sym \
35  examples/coap_list.h \
36  examples/getopt.c \
37  include/coap$(LIBCOAP_API_VERSION)/coap_internal.h \
38  include/coap$(LIBCOAP_API_VERSION)/coap_riot.h \
39  include/coap$(LIBCOAP_API_VERSION)/coap_asn1_internal.h \
40  include/coap$(LIBCOAP_API_VERSION)/coap_async_internal.h \
41  include/coap$(LIBCOAP_API_VERSION)/coap_block_internal.h \
42  include/coap$(LIBCOAP_API_VERSION)/coap_cache_internal.h \
43  include/coap$(LIBCOAP_API_VERSION)/coap_dtls_internal.h \
44  include/coap$(LIBCOAP_API_VERSION)/coap_io_internal.h \
45  include/coap$(LIBCOAP_API_VERSION)/coap_net_internal.h \
46  include/coap$(LIBCOAP_API_VERSION)/coap_pdu_internal.h \
47  include/coap$(LIBCOAP_API_VERSION)/coap_resource_internal.h \
48  include/coap$(LIBCOAP_API_VERSION)/coap_session_internal.h \
49  include/coap$(LIBCOAP_API_VERSION)/coap_subscribe_internal.h \
50  include/coap$(LIBCOAP_API_VERSION)/coap_tcp_internal.h \
51  include/coap$(LIBCOAP_API_VERSION)/coap.h.in \
52  include/coap$(LIBCOAP_API_VERSION)/coap.h.windows \
53  include/coap$(LIBCOAP_API_VERSION)/coap.h.windows.in \
54  include/coap$(LIBCOAP_API_VERSION)/lwippools.h \
55  include/coap$(LIBCOAP_API_VERSION)/uthash.h \
56  include/coap$(LIBCOAP_API_VERSION)/utlist.h \
57  src/coap_io_riot.c \
58  tests/test_error_response.h \
59  tests/test_encode.h \
60  tests/test_options.h \
61  tests/test_pdu.h \
62  tests/test_sendqueue.h \
63  tests/test_session.h \
64  tests/test_tls.h \
65  tests/test_uri.h \
66  tests/test_wellknown.h \
67  win32/coap-client/coap-client.vcxproj \
68  win32/coap-client/coap-client.vcxproj.filters \
69  win32/coap-rd/coap-rd.vcxproj \
70  win32/coap-rd/coap-rd.vcxproj.filters \
71  win32/coap-server/coap-server.vcxproj \
72  win32/coap-server/coap-server.vcxproj.filters \
73  win32/libcoap.sln \
74  win32/libcoap.vcxproj \
75  win32/libcoap.vcxproj.filters \
76  win32/testdriver/testdriver.vcxproj \
77  win32/testdriver/testdriver.vcxproj.filters \
78  win32/testdriver/testdriver.vcxproj.user
79
80AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include $(WARNING_CFLAGS) $(DTLS_CFLAGS) -std=c99 $(EXTRA_CFLAGS)
81
82SUBDIRS = $(subdirs) . man doc tests examples
83
84## Define a libtool archive target "libcoap-@LIBCOAP_NAME_SUFFIX@.la", with
85## @LIBCOAP_NAME_SUFFIX@ substituted into the generated Makefile at configure
86## time.
87## The libtool archive file (.la) will be installed into the directory named
88## by the predefined variable $(bindir), along with the actual shared library
89## file (.so).
90lib_LTLIBRARIES = libcoap-@LIBCOAP_NAME_SUFFIX@.la
91
92libcoap_@LIBCOAP_NAME_SUFFIX@_la_CFLAGS = \
93  -fPIC \
94  -fPIE \
95  $(AM_CFLAGS)
96
97## Define the source file list for the "libcoap.la" target.
98## Note that it is not necessary to list header files which are already listed
99## elsewhere in a _HEADERS variable assignment.
100libcoap_@LIBCOAP_NAME_SUFFIX@_la_SOURCES = \
101  src/address.c \
102  src/async.c \
103  src/block.c \
104  src/coap_asn1.c \
105  src/coap_cache.c \
106  src/coap_debug.c \
107  src/coap_event.c \
108  src/coap_hashkey.c \
109  src/coap_gnutls.c \
110  src/coap_io.c \
111  src/coap_mbedtls.c \
112  src/coap_notls.c \
113  src/coap_openssl.c \
114  src/coap_prng.c \
115  src/coap_session.c \
116  src/coap_tcp.c \
117  src/coap_time.c \
118  src/coap_tinydtls.c \
119  src/encode.c \
120  src/mem.c \
121  src/net.c \
122  src/option.c \
123  src/pdu.c \
124  src/resource.c \
125  src/str.c \
126  src/subscribe.c \
127  src/uri.c
128
129## Define the list of public header files and their install location.
130## The API version is appended to the install folder to being able to
131## co-install various versions of libcoap.
132libcoap_includedir = $(includedir)/coap$(LIBCOAP_API_VERSION)/
133
134# If there is a API change to something $(LIBCOAP_API_VERSION) > 1 the install
135# prefix for the header files has to change to not conflict the older version
136# if the user want's to install both versions. There will be something used like
137# libcoap_include_HEADERS = \
138#  $(top_srcdir)/include/coap-$(LIBCOAP_API_VERSION)/*
139
140libcoap_include_HEADERS = \
141  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/address.h \
142  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/async.h \
143  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/block.h \
144  $(top_builddir)/include/coap$(LIBCOAP_API_VERSION)/coap.h \
145  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_cache.h \
146  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_debug.h \
147  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_dtls.h \
148  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_event.h \
149  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_forward_decls.h \
150  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_hashkey.h \
151  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_io.h \
152  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_mutex.h \
153  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_session.h \
154  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_time.h \
155  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/encode.h \
156  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/libcoap.h \
157  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/mem.h \
158  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/net.h \
159  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/option.h \
160  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/pdu.h \
161  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_prng.h \
162  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/resource.h \
163  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/str.h \
164  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/subscribe.h \
165  $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/uri.h
166
167## Instruct libtool to include API version information in the generated shared
168## library file (.so). The library ABI version will later defined in configure.ac,
169## so that all version information is kept in one place.
170libcoap_@LIBCOAP_NAME_SUFFIX@_la_LDFLAGS =					\
171  -version-info $(LT_LIBCOAP_CURRENT):$(LT_LIBCOAP_REVISION):$(LT_LIBCOAP_AGE)	\
172  @libcoap_SYMBOLS@ \
173  $(DTLS_LIBS) \
174  -pie
175
176## Collect symbols here we want to ignore while building the helper files
177## libcoap-$(LIBCOAP_API_VERSION).{map,sym} for the linker.
178CTAGS_IGNORE=-I " \
179coap_pdu_from_pbuf \
180"
181
182# This helper is called by libcoap-$(LIBCOAP_API_VERSION).{map,sym} to see if
183# configure has detected a usable version of the ctags program and aborts if not.
184check_ctags:
185	@if [ "$(CTAGS_PROG)" = "" ]; then \
186		echo ;\
187		echo "There was no ctags program found by the configure script!" ;\
188		echo "ctags is needed for running this target! Please note the warning about the missed ctags program of the configure script." ;\
189		echo ;\
190		exit 1;\
191	fi
192
193## Helper target to generate the symbol table needed by libtool.
194## The .map format is used when ld supports linker scripts, otherwise
195## it must fall back to a plain symbol file.
196update-map-file: libcoap-$(LIBCOAP_API_VERSION).map libcoap-$(LIBCOAP_API_VERSION).sym
197
198libcoap-$(LIBCOAP_API_VERSION).map: check_ctags $(libcoap_include_HEADERS)
199	( echo "VER_$(LIBCOAP_API_VERSION) {" ; \
200	echo "global:" ; \
201	$(CTAGS_PROG) $(CTAGS_IGNORE) -f - --c-kinds=p $(libcoap_include_HEADERS) | awk '/^coap_/ { print "  " $$1 ";" }' | sort -u ; \
202	echo "local:" ; \
203	echo "  *;" ; \
204	echo "};" ) > $(top_builddir)/$@.new
205	mv $(top_builddir)/$@.new $(top_builddir)/$@
206
207libcoap-$(LIBCOAP_API_VERSION).sym: check_ctags $(libcoap_include_HEADERS)
208	( $(CTAGS_PROG) $(CTAGS_IGNORE) -f - --c-kinds=p $(libcoap_include_HEADERS) | awk '/^coap_/ { print $$1 }' | sort -u ) \
209	> $(top_builddir)/$@.new
210	mv $(top_builddir)/$@.new $(top_builddir)/$@
211
212## Install the generated pkg-config file (.pc) into the expected location for
213## architecture-dependent package configuration information.  Occasionally,
214## pkg-config files are also used for architecture-independent data packages,
215## in which case the correct install location would be $(datadir)/pkgconfig.
216pkgconfigdir = $(libdir)/pkgconfig
217pkgconfig_DATA = libcoap-$(LIBCOAP_NAME_SUFFIX).pc
218
219## Define an independent executable script for inclusion in the distribution
220## archive.  However, it will not be installed on an end user's system due to
221## the noinst_ prefix.
222dist_noinst_SCRIPTS = autogen.sh
223
224## Set up a common library that causes linking against the common library
225## to link with the actual library with (D)TLS support
226if BUILD_ADD_DEFAULT_NAMES
227install-exec-hook:
228	(cd $(DESTDIR)$(libdir) ; \
229	if [ -f libcoap-$(LIBCOAP_NAME_SUFFIX).so ] ; then \
230		rm -f libcoap-$(LIBCOAP_API_VERSION).so ; \
231		$(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).so libcoap-$(LIBCOAP_API_VERSION).so ; \
232	fi ; \
233	rm -f libcoap-$(LIBCOAP_API_VERSION).a ; \
234	rm -f libcoap-$(LIBCOAP_API_VERSION).la ; \
235	$(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).a libcoap-$(LIBCOAP_API_VERSION).a ; \
236	$(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).la libcoap-$(LIBCOAP_API_VERSION).la ; \
237	$(MKDIR_P) $(DESTDIR)$(pkgconfigdir) ; \
238	cd $(DESTDIR)$(pkgconfigdir) ; \
239	rm -f libcoap-$(LIBCOAP_API_VERSION).pc ; \
240	$(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).pc libcoap-$(LIBCOAP_API_VERSION).pc)
241
242uninstall-hook:
243	(cd $(DESTDIR)$(libdir) ; \
244	rm -f libcoap-$(LIBCOAP_API_VERSION).a ; \
245	rm -f libcoap-$(LIBCOAP_API_VERSION).la ; \
246	rm -f libcoap-$(LIBCOAP_API_VERSION).so ; \
247	cd $(DESTDIR)$(pkgconfigdir) ; \
248	rm -f libcoap-$(LIBCOAP_API_VERSION).pc)
249endif # BUILD_ADD_DEFAULT_NAMES
250
251## various *-local targets
252## Remove the helper files for the linker and the pkg-config file if there
253## is 'make distclean' called. NOTE: To re create the *.{map,sym} files you
254## need to call the target update-map-file after the configure script was
255## running!
256clean-local:
257	-find \( -name '*.gcda' -o -name '*.gcno' -o -name '*.gcov' \) -delete
258
259distclean-local:
260	@rm -f src/*.o src/*.lo
261	rm -f libcoap-$(LIBCOAP_API_VERSION).map
262	rm -f libcoap-$(LIBCOAP_API_VERSION).sym
263	rm -f libcoap-$(LIBCOAP_NAME_SUFFIX).pc
264	@echo
265	@echo "     ---> Please note the following important advice! <---"
266	@echo "     The files libcoap-$(LIBCOAP_API_VERSION).{map,sym} are removed by the distclean target!"
267	@echo "     To regenerate this two files you need to call 'make update-map-file' first before any"
268	@echo "     other Make target. Otherwise the build of libcoap will fail!"
269	@echo
270
271## Ensure we have actual *.{map,sym} files if we create a release tarball.
272dist-local: update-map-file
273
274## Finaly some phony targets, just to ensure those targets are always buildable
275## no matter if the user has created same called files.
276.PHONY: update-map-file check_ctags
277
278