1# Makefile.am for libcoap 2# 3# Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org> 4# Copyright (C) 2015-2017 Carsten Schoenert <c.schoenert@t-online.de> 5# Copyright (C) 2018-2023 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 18LIBCOAP_PACKAGE_BUILD = @DOLLAR_SIGN@(shell git describe --tags --dirty --always 2>/dev/null || echo @PACKAGE_VERSION@) 19 20## Source files specifically for OSCORE 21libcoap_OSCORE_sources = \ 22 src/oscore/oscore.c \ 23 src/oscore/oscore_cbor.c \ 24 src/oscore/oscore_context.c \ 25 src/oscore/oscore_cose.c \ 26 src/oscore/oscore_crypto.c 27 28## Additional files for the distribution archive 29EXTRA_DIST = \ 30 BUILDING \ 31 CONTRIBUTE \ 32 TODO \ 33 LICENSE \ 34 CMakeLists.txt \ 35 cmake_coap_config.h.in \ 36 cmake/Config.cmake.in \ 37 cmake/FindMbedTLS.cmake \ 38 cmake/FindTinyDTLS.cmake \ 39 coap_config.h.contiki \ 40 coap_config.h.riot \ 41 coap_config.h.windows \ 42 libcoap-$(LIBCOAP_API_VERSION).pc.in \ 43 libcoap-$(LIBCOAP_API_VERSION).map \ 44 libcoap-$(LIBCOAP_API_VERSION).sym \ 45 examples/coap_list.h \ 46 examples/getopt.c \ 47 examples/contiki/coap_config.h \ 48 examples/contiki/Makefile \ 49 examples/contiki/Makefile.contiki \ 50 examples/contiki/project-conf.h \ 51 examples/contiki/README \ 52 examples/contiki/server.c \ 53 examples/lwip/client.c \ 54 examples/lwip/client-coap.c \ 55 examples/lwip/client-coap.h \ 56 examples/lwip/Makefile \ 57 examples/lwip/README \ 58 examples/lwip/server.c \ 59 examples/lwip/server-coap.c \ 60 examples/lwip/server-coap.h \ 61 examples/lwip/config/coap_config.h \ 62 examples/lwip/config/coap_config.h.in \ 63 examples/lwip/config/lwipopts.h \ 64 examples/lwip/config/lwippools.h \ 65 examples/riot/examples_libcoap_client/client-coap.c \ 66 examples/riot/examples_libcoap_client/client-coap.h \ 67 examples/riot/examples_libcoap_client/Kconfig \ 68 examples/riot/examples_libcoap_client/main.c \ 69 examples/riot/examples_libcoap_client/Makefile \ 70 examples/riot/examples_libcoap_client/Makefile.ci \ 71 examples/riot/examples_libcoap_client/README.md \ 72 examples/riot/examples_libcoap_server/main.c \ 73 examples/riot/examples_libcoap_server/Makefile \ 74 examples/riot/examples_libcoap_server/Makefile.ci \ 75 examples/riot/examples_libcoap_server/README.md \ 76 examples/riot/examples_libcoap_server/server-coap.c \ 77 examples/riot/examples_libcoap_server/server-coap.h \ 78 examples/riot/examples_libcoap_server/Kconfig \ 79 examples/riot/Makefile \ 80 examples/riot/pkg_libcoap/Kconfig \ 81 examples/riot/pkg_libcoap/Makefile \ 82 examples/riot/pkg_libcoap/Makefile.dep \ 83 examples/riot/pkg_libcoap/Makefile.include \ 84 examples/riot/pkg_libcoap/Makefile.libcoap \ 85 examples/riot/README \ 86 Makefile.libcoap \ 87 include/coap$(LIBCOAP_API_VERSION)/coap_internal.h \ 88 include/coap$(LIBCOAP_API_VERSION)/coap_riot.h \ 89 include/coap$(LIBCOAP_API_VERSION)/coap_asn1_internal.h \ 90 include/coap$(LIBCOAP_API_VERSION)/coap_async_internal.h \ 91 include/coap$(LIBCOAP_API_VERSION)/coap_block_internal.h \ 92 include/coap$(LIBCOAP_API_VERSION)/coap_cache_internal.h \ 93 include/coap$(LIBCOAP_API_VERSION)/coap_crypto_internal.h \ 94 include/coap$(LIBCOAP_API_VERSION)/coap_debug_internal.h \ 95 include/coap$(LIBCOAP_API_VERSION)/coap_dtls_internal.h \ 96 include/coap$(LIBCOAP_API_VERSION)/coap_hashkey_internal.h \ 97 include/coap$(LIBCOAP_API_VERSION)/coap_io_internal.h \ 98 include/coap$(LIBCOAP_API_VERSION)/coap_layers_internal.h \ 99 include/coap$(LIBCOAP_API_VERSION)/coap_mutex_internal.h \ 100 include/coap$(LIBCOAP_API_VERSION)/coap_net_internal.h \ 101 include/coap$(LIBCOAP_API_VERSION)/coap_netif_internal.h \ 102 include/coap$(LIBCOAP_API_VERSION)/coap_oscore_internal.h \ 103 include/coap$(LIBCOAP_API_VERSION)/coap_pdu_internal.h \ 104 include/coap$(LIBCOAP_API_VERSION)/coap_resource_internal.h \ 105 include/coap$(LIBCOAP_API_VERSION)/coap_session_internal.h \ 106 include/coap$(LIBCOAP_API_VERSION)/coap_subscribe_internal.h \ 107 include/coap$(LIBCOAP_API_VERSION)/coap_tcp_internal.h \ 108 include/coap$(LIBCOAP_API_VERSION)/coap_uri_internal.h \ 109 include/coap$(LIBCOAP_API_VERSION)/coap_uthash_internal.h \ 110 include/coap$(LIBCOAP_API_VERSION)/coap_utlist_internal.h \ 111 include/coap$(LIBCOAP_API_VERSION)/coap_ws_internal.h \ 112 include/coap$(LIBCOAP_API_VERSION)/coap.h.in \ 113 include/coap$(LIBCOAP_API_VERSION)/coap.h.riot \ 114 include/coap$(LIBCOAP_API_VERSION)/coap.h.riot.in \ 115 include/coap$(LIBCOAP_API_VERSION)/coap.h.windows \ 116 include/coap$(LIBCOAP_API_VERSION)/coap.h.windows.in \ 117 include/oscore/oscore_cbor.h \ 118 include/oscore/oscore_context.h \ 119 include/oscore/oscore_cose.h \ 120 include/oscore/oscore_crypto.h \ 121 include/oscore/oscore.h \ 122 src/coap_io_contiki.c \ 123 src/coap_io_lwip.c \ 124 src/coap_io_riot.c \ 125 tests/test_error_response.h \ 126 tests/test_encode.h \ 127 tests/test_options.h \ 128 tests/test_oscore.h \ 129 tests/test_pdu.h \ 130 tests/test_sendqueue.h \ 131 tests/test_session.h \ 132 tests/test_tls.h \ 133 tests/test_uri.h \ 134 tests/test_wellknown.h \ 135 win32/coap-client/coap-client.vcxproj \ 136 win32/coap-client/coap-client.vcxproj.filters \ 137 win32/coap-rd/coap-rd.vcxproj \ 138 win32/coap-rd/coap-rd.vcxproj.filters \ 139 win32/coap-server/coap-server.vcxproj \ 140 win32/coap-server/coap-server.vcxproj.filters \ 141 win32/libcoap.sln \ 142 win32/libcoap.vcxproj \ 143 win32/libcoap.vcxproj.filters \ 144 win32/testdriver/testdriver.vcxproj \ 145 win32/testdriver/testdriver.vcxproj.filters \ 146 win32/testdriver/testdriver.vcxproj.user 147 148# This is a mirror of files depending on COAP_OSCORE_SUPPORT included in src as per 149# libcoap_@LIBCOAP_NAME_SUFFIX@_la_SOURCES 150if !COAP_OSCORE_SUPPORT 151EXTRA_DIST += $(libcoap_OSCORE_sources) 152 153endif # !COAP_OSCORE_SUPPORT 154 155AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include $(WARNING_CFLAGS) \ 156 $(DTLS_CFLAGS) -std=c99 $(EXTRA_CFLAGS) \ 157 -DLIBCOAP_PACKAGE_BUILD='"$(LIBCOAP_PACKAGE_BUILD)"' 158 159SUBDIRS = $(subdirs) . man doc tests examples 160 161## Define a libtool archive target "libcoap-@LIBCOAP_NAME_SUFFIX@.la", with 162## @LIBCOAP_NAME_SUFFIX@ substituted into the generated Makefile at configure 163## time. 164## The libtool archive file (.la) will be installed into the directory named 165## by the predefined variable $(bindir), along with the actual shared library 166## file (.so). 167lib_LTLIBRARIES = libcoap-@LIBCOAP_NAME_SUFFIX@.la 168 169libcoap_@LIBCOAP_NAME_SUFFIX@_la_CFLAGS = \ 170 -fPIC \ 171 -fPIE \ 172 $(AM_CFLAGS) 173 174## Define the source file list for the "libcoap.la" target. 175## Note that it is not necessary to list header files which are already listed 176## elsewhere in a _HEADERS variable assignment. 177libcoap_@LIBCOAP_NAME_SUFFIX@_la_SOURCES = \ 178 src/coap_address.c \ 179 src/coap_asn1.c \ 180 src/coap_async.c \ 181 src/coap_block.c \ 182 src/coap_cache.c \ 183 src/coap_debug.c \ 184 src/coap_dtls.c \ 185 src/coap_encode.c \ 186 src/coap_event.c \ 187 src/coap_hashkey.c \ 188 src/coap_gnutls.c \ 189 src/coap_io.c \ 190 src/coap_layers.c \ 191 src/coap_mbedtls.c \ 192 src/coap_mem.c \ 193 src/coap_net.c \ 194 src/coap_netif.c \ 195 src/coap_notls.c \ 196 src/coap_openssl.c \ 197 src/coap_option.c \ 198 src/coap_oscore.c \ 199 src/coap_pdu.c \ 200 src/coap_prng.c \ 201 src/coap_resource.c \ 202 src/coap_session.c \ 203 src/coap_str.c \ 204 src/coap_subscribe.c \ 205 src/coap_tcp.c \ 206 src/coap_time.c \ 207 src/coap_tinydtls.c \ 208 src/coap_uri.c \ 209 src/coap_ws.c 210 211if COAP_OSCORE_SUPPORT 212libcoap_@LIBCOAP_NAME_SUFFIX@_la_SOURCES += $(libcoap_OSCORE_sources) 213 214endif # COAP_OSCORE_SUPPORT 215 216## Define the list of public header files and their install location. 217## The API version is appended to the install folder to being able to 218## co-install various versions of libcoap. 219libcoap_includedir = $(includedir)/coap$(LIBCOAP_API_VERSION)/ 220 221# If there is a API change to something $(LIBCOAP_API_VERSION) > 1 the install 222# prefix for the header files has to change to not conflict the older version 223# if the user want's to install both versions. There will be something used like 224# libcoap_include_HEADERS = \ 225# $(top_srcdir)/include/coap-$(LIBCOAP_API_VERSION)/* 226 227libcoap_include_HEADERS = \ 228 $(top_builddir)/include/coap$(LIBCOAP_API_VERSION)/coap.h \ 229 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/libcoap.h \ 230 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_address.h \ 231 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_async.h \ 232 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_block.h \ 233 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_cache.h \ 234 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_debug.h \ 235 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_dtls.h \ 236 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_encode.h \ 237 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_event.h \ 238 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_forward_decls.h \ 239 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_io.h \ 240 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_mem.h \ 241 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_net.h \ 242 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_option.h \ 243 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_oscore.h \ 244 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_pdu.h \ 245 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_prng.h \ 246 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_resource.h \ 247 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_session.h \ 248 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_str.h \ 249 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_subscribe.h \ 250 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_time.h \ 251 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_uri.h \ 252 $(top_srcdir)/include/coap$(LIBCOAP_API_VERSION)/coap_ws.h 253 254## Instruct libtool to include API version information in the generated shared 255## library file (.so). The library ABI version will later defined in configure.ac, 256## so that all version information is kept in one place. 257libcoap_@LIBCOAP_NAME_SUFFIX@_la_LDFLAGS = \ 258 -version-info $(LT_LIBCOAP_CURRENT):$(LT_LIBCOAP_REVISION):$(LT_LIBCOAP_AGE) \ 259 @libcoap_SYMBOLS@ \ 260 $(DTLS_LIBS) \ 261 -pie 262 263## Collect symbols here we want to ignore while building the helper files 264## libcoap-$(LIBCOAP_API_VERSION).{map,sym} for the linker. 265CTAGS_IGNORE=-I " \ 266coap_pdu_from_pbuf \ 267coap_lwip_dump_memory_pools \ 268coap_lwip_set_input_wait_handler \ 269coap_print_contiki_prefix \ 270" 271 272# This helper is called by libcoap-$(LIBCOAP_API_VERSION).{map,sym} to see if 273# configure has detected a usable version of the ctags program and aborts if not. 274check_ctags: 275 @if [ "$(CTAGS_PROG)" = "" ]; then \ 276 echo ;\ 277 echo "There was no ctags program found by the configure script!" ;\ 278 echo "ctags is needed for running this target! Please note the warning about the missed ctags program of the configure script." ;\ 279 echo ;\ 280 exit 1;\ 281 fi 282 283## Helper target to generate the symbol table needed by libtool. 284## The .map format is used when ld supports linker scripts, otherwise 285## it must fall back to a plain symbol file. 286update-map-file: libcoap-$(LIBCOAP_API_VERSION).map libcoap-$(LIBCOAP_API_VERSION).sym 287 288libcoap-$(LIBCOAP_API_VERSION).map: check_ctags $(libcoap_include_HEADERS) 289 ( echo "VER_$(LIBCOAP_API_VERSION) {" ; \ 290 echo "global:" ; \ 291 $(CTAGS_PROG) $(CTAGS_IGNORE) -f - --c-kinds=p $(libcoap_include_HEADERS) | awk '/^coap_/ { print " " $$1 ";" }' | LC_ALL=C sort -u ; \ 292 echo "local:" ; \ 293 echo " *;" ; \ 294 echo "};" ) > $(top_builddir)/$@.new 295 mv $(top_builddir)/$@.new $(top_builddir)/$@ 296 297libcoap-$(LIBCOAP_API_VERSION).sym: check_ctags $(libcoap_include_HEADERS) 298 ( $(CTAGS_PROG) $(CTAGS_IGNORE) -f - --c-kinds=p $(libcoap_include_HEADERS) | awk '/^coap_/ { print $$1 }' | LC_ALL=C sort -u ) \ 299 > $(top_builddir)/$@.new 300 mv $(top_builddir)/$@.new $(top_builddir)/$@ 301 302## Install the generated pkg-config file (.pc) into the expected location for 303## architecture-dependent package configuration information. Occasionally, 304## pkg-config files are also used for architecture-independent data packages, 305## in which case the correct install location would be $(datadir)/pkgconfig. 306pkgconfigdir = $(libdir)/pkgconfig 307pkgconfig_DATA = libcoap-$(LIBCOAP_NAME_SUFFIX).pc 308 309## Define an independent executable script for inclusion in the distribution 310## archive. However, it will not be installed on an end user's system due to 311## the noinst_ prefix. 312dist_noinst_SCRIPTS = autogen.sh 313 314## Set up a common library that causes linking against the common library 315## to link with the actual library with (D)TLS support 316if BUILD_ADD_DEFAULT_NAMES 317install-exec-hook: 318 (cd $(DESTDIR)$(libdir) ; \ 319 if [ -f libcoap-$(LIBCOAP_NAME_SUFFIX).so ] ; then \ 320 rm -f libcoap-$(LIBCOAP_API_VERSION).so ; \ 321 $(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).so libcoap-$(LIBCOAP_API_VERSION).so ; \ 322 fi ; \ 323 rm -f libcoap-$(LIBCOAP_API_VERSION).a ; \ 324 rm -f libcoap-$(LIBCOAP_API_VERSION).la ; \ 325 $(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).a libcoap-$(LIBCOAP_API_VERSION).a ; \ 326 $(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).la libcoap-$(LIBCOAP_API_VERSION).la ; \ 327 $(MKDIR_P) $(DESTDIR)$(pkgconfigdir) ; \ 328 cd $(DESTDIR)$(pkgconfigdir) ; \ 329 rm -f libcoap-$(LIBCOAP_API_VERSION).pc ; \ 330 $(LN_S) libcoap-$(LIBCOAP_NAME_SUFFIX).pc libcoap-$(LIBCOAP_API_VERSION).pc) 331 332uninstall-hook: 333 (cd $(DESTDIR)$(libdir) ; \ 334 rm -f libcoap-$(LIBCOAP_API_VERSION).a ; \ 335 rm -f libcoap-$(LIBCOAP_API_VERSION).la ; \ 336 rm -f libcoap-$(LIBCOAP_API_VERSION).so ; \ 337 cd $(DESTDIR)$(pkgconfigdir) ; \ 338 rm -f libcoap-$(LIBCOAP_API_VERSION).pc) 339endif # BUILD_ADD_DEFAULT_NAMES 340 341## various *-local targets 342## Remove the helper files for the linker and the pkg-config file if there 343## is 'make distclean' called. NOTE: To re create the *.{map,sym} files you 344## need to call the target update-map-file after the configure script was 345## running! 346clean-local: 347 -find \( -name '*.gcda' -o -name '*.gcno' -o -name '*.gcov' \) -delete 348 349distclean-local: 350 @rm -f src/*.o src/*.lo 351 rm -f libcoap-$(LIBCOAP_API_VERSION).map 352 rm -f libcoap-$(LIBCOAP_API_VERSION).sym 353 rm -f libcoap-$(LIBCOAP_NAME_SUFFIX).pc 354 @echo 355 @echo " ---> Please note the following important advice! <---" 356 @echo " The files libcoap-$(LIBCOAP_API_VERSION).{map,sym} are removed by the distclean target!" 357 @echo " To regenerate this two files you need to call 'make update-map-file' first before any" 358 @echo " other Make target. Otherwise the build of libcoap will fail!" 359 @echo 360 361## Ensure we have actual *.{map,sym} files if we create a release tarball. 362dist-local: update-map-file 363 364## Finaly some phony targets, just to ensure those targets are always buildable 365## no matter if the user has created same called files. 366.PHONY: update-map-file check_ctags 367 368