1# configure.ac for the libcoap package 2# 3# Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org> 4# Copyright (C) 2015-2018 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 library libcoap. Please see README for terms 10# of use. 11# 12# Please run 'autogen.sh' to let autoconf produce a configure script. 13 14# Define the libcoap software version here. Note! The libtool versions are 15# defined later. 16m4_define([libcoap_major_version], [4]) 17m4_define([libcoap_minor_version], [3]) 18m4_define([libcoap_micro_version], [4]) 19 20# define an appending release state if needed, for example for pre-releases 21# like 'alpha' or 'rc1', for a full release keep the value empty! 22m4_define([libcoap_release_state], []) 23 24# concatenate the full libcoap version string 25m4_define([libcoap_version], [m4_format([%s.%s.%s%s], libcoap_major_version, libcoap_minor_version, libcoap_micro_version, libcoap_release_state)]) 26 27AC_INIT([libcoap], [libcoap_version], [libcoap-developers@lists.sourceforge.net], [libcoap], [https://libcoap.net/]) 28AC_PREREQ([2.64]) 29AM_INIT_AUTOMAKE([1.10 -Wall no-define no-dist-gzip dist-bzip2]) 30PKG_PROG_PKG_CONFIG([0.20]) 31AM_SILENT_RULES([yes]) 32AC_HEADER_ASSERT 33 34# Generate one configuration header file for building the library itself with 35# an auto generated template. We need later a second one 36# (include/coap$LIBCOAP_API_VERSION/libcoap.h) that will be installed alongside the library. 37AC_CONFIG_HEADERS([coap_config.h]) 38 39AC_PROG_CC 40AM_PROG_CC_C_O 41AC_PROG_SED 42AC_CONFIG_MACRO_DIR([m4]) 43m4_pattern_allow([AM_PROG_AR]) 44AM_PROG_AR 45AC_PROG_LN_S 46AC_PROG_MKDIR_P 47 48AC_C_BIGENDIAN 49 50# enable the automatically build of shared and static libraries 51LT_INIT([shared static]) 52 53# Setting the libtool versioning 54################################################################################### 55# # 56# To set the version of the library, libtool provides the -version-info # 57# parameter, which accepts three numbers, separated by colons, that are called # 58# respectively, current, revision and age. Both their name and their behavior, # 59# nowadays, have to be considered fully arbitrary, as the explanation provided # 60# in the official documentation is confusing to say the least, and can be, in # 61# some cases, considered completely wrong. # 62# https://autotools.io/libtool/version.html # 63# # 64################################################################################### 65# 66# How to work with the libtool versioning? 67# 68# Follow the following steps from top to bottom. This means always start at point 1 69# if you plan to make a release and change the values. 70# Every new library starts with a version 'current' (short 'c') = 0 71# 'revision' (short 'r') = 0 72# 'age' (short 'a') = 0 73# 74# Update the libtool versioning only after the release of a public release of libcoap. 75# Go through the following checklist from top to bottom and check your needs, following 76# the reminded changes if you can say "Yes" for specific check. 77# 78# 1. Only existing code has changed, no functional changes 79# If the library source code has changed but *no* new symbols were added at all 80# since the last update, then increment revision (c:r:a becomes c:r+1:a). 81# This is usually happen if the existing source of a function was changed for 82# bug fixing e.g. 83# 84# --> Increase the 'LT_LIBCOAP_REVISION' value with *every* new software release 85# within one release cycle. 86# 87# 2. Interfaces were added, functions have changed or are removed 88# If any interfaces [exported functions or data] have been added, got internal 89# changes that implies a different behavior or removed and by this the visible 90# symbols have changed since the last update, increment current, and set 91# revision to 0 (c:r:a becomes c+1:r=0:a). 92# 93# --> Increase the 'LT_LIBCOAP_CURRENT' value whenever as an interface has been added 94# or removed. This implies also a API change! You mostly have to change the 95# 'libcoap_major_version' or at least 'libcoap_minor_version' then too! 96# --> Set 'LT_LIBCOAP_REVISION' to 0. 97# 98# 3. Interfaces were added but none removed or changed 99# If any interfaces have been added since the last public release and non of the 100# existing interfaces were removed and existing interfaces have not changed internal 101# functionality then the new library is backward compatible. Existing binaries can 102# use the new library the same than as the existing old library without loosing 103# existing functionality or breakage. 104# Increase age by 1 (c:r:a becomes c:r:a+1). 105# 106# --> Increase the 'LT_LIBCOAP_AGE' value only if the changes made to the ABI are 107# backward compatible. 108# 109# 4. Interfaces were removed or have functional changes 110# If any interfaces within the library have been removed since the last public 111# release or got some internal changes that let the interface act different than 112# before, then set age to 0. The library isn't backwards compatible. 113# 114# --> Set 'LT_LIBCOAP_AGE' to 0. 115 116# The following explanation may help to understand the above rules a bit better: 117# consider that there are three possible kinds of reactions from users of your 118# library to changes in a shared library: 119# 120# 1. Programs using the previous version may use the new version as drop-in 121# replacement, and programs using the new version can also work with the 122# previous one. In other words, no recompiling nor relinking is needed. In this 123# case, bump 'LT_LIBCOAP_REVISION' only, don't touch 'LT_LIBCOAP_CURRENT' nor 124# 'LT_LIBCOAP_AGE'. 125# 126# 2. Programs using the previous version may use the new version 127# as drop-in replacement, but programs using the new version may use APIs not 128# present in the previous one. In other words, a program linking against the new 129# version may fail with 'unresolved symbols' if linking against the old version 130# at runtime: set 'LT_LIBCOAP_REVISION' to 0, bump 'LT_LIBCOAP_CURRENT' and 131# 'LT_LIBCOAP_AGE'. 132# 133# 3. Programs may need to be changed, recompiled, and relinked in 134# order to use the new version. Bump 'LT_LIBCOAP_CURRENT', 135# set 'LT_LIBCOAP_REVISION' and 'LT_LIBCOAP_AGE' to 0. 136 137# To add to the confusion, if LIBCOAP_SO_VERSION is set to 3:0:1 (c:r:a), then the 138# .so version naming ends up as 2.1.0 (c-a:a:r) (as decided by libtool). 139 140# 141# CAUTION 142# 143# You will need to manually update VERSION and LIBCOAP_ABI_VERSION in CMakeLists.txt 144# if changes are made to libcoap_xx_version and LT_LIBCOAP_xx respectively. 145# 146 147LT_LIBCOAP_CURRENT=4 148LT_LIBCOAP_REVISION=1 149LT_LIBCOAP_AGE=1 150LIBCOAP_SO_VERSION=$LT_LIBCOAP_CURRENT.$LT_LIBCOAP_REVISION.$LT_LIBCOAP_AGE 151 152# Announce the libtool version 153AC_SUBST(LT_LIBCOAP_CURRENT) 154AC_SUBST(LT_LIBCOAP_REVISION) 155AC_SUBST(LT_LIBCOAP_AGE) 156AC_SUBST(LIBCOAP_SO_VERSION) 157 158# Defining the API Version 159LIBCOAP_API_VERSION=3 160 161# calculate the ABI version naming as calculated by libtool 162m4_pattern_allow(LT_TEMP) 163LT_TEMP=$LT_LIBCOAP_CURRENT 164LT_TEMP=`expr $LT_TEMP - $LT_LIBCOAP_AGE` 165if test "$LT_TEMP" != "$LIBCOAP_API_VERSION" ; then 166 AC_MSG_ERROR([==> API version ($LIBCOAP_API_VERSION) does not match base of ABI ($LT_TEMP.$LT_LIBCOAP_AGE.$LT_LIBCOAP_REVISION) version.]) 167fi 168LIBCOAP_ABI_VERSION=$LT_TEMP.$LT_LIBCOAP_AGE.$LT_LIBCOAP_REVISION 169AC_SUBST(LIBCOAP_ABI_VERSION) 170AC_SUBST(LIBCOAP_API_VERSION) 171 172# Define a numeric version string 173m4_define([version_number], 174 [m4_format([%u%03u%03u], 175 libcoap_major_version, 176 libcoap_minor_version, 177 libcoap_micro_version)]) 178LIBCOAP_VERSION=version_number 179AC_SUBST(LIBCOAP_VERSION) 180 181# Adding some default warning options for code QS 182# see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html 183# and http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html 184WARNING_CFLAGS="\ 185-pedantic \ 186-Wall \ 187-Wcast-qual \ 188-Wextra \ 189-Wformat-security \ 190-Winline \ 191-Wmissing-declarations \ 192-Wmissing-prototypes \ 193-Wnested-externs \ 194-Wpointer-arith \ 195-Wshadow \ 196-Wstrict-prototypes \ 197-Wswitch-default \ 198-Wswitch-enum \ 199-Wunused \ 200-Wwrite-strings \ 201" 202 203# check whether or not the compiler supports -Wlogical-op (clang does not...) 204AX_CHECK_COMPILE_FLAG([-Wlogical-op], [WARNING_CFLAGS="$WARNING_CFLAGS -Wlogical-op"],,[-Werror]) 205AX_CHECK_COMPILE_FLAG([-fdiagnostics-color], [CFLAGS="$CFLAGS -fdiagnostics-color"],,[-Werror]) 206AX_CHECK_COMPILE_FLAG([-Wunused-result], [WARNING_CFLAGS="$WARNING_CFLAGS -Wunused-result"]) 207 208# clang 14+ generates dwarf-5, which is not currently supported by valgrind 209if test "x$CC" = "xclang"; then 210 WARNING_CFLAGS="$WARNING_CFLAGS -gdwarf-4" 211fi 212 213AC_SUBST([WARNING_CFLAGS]) 214 215AX_CHECK_LINK_FLAG([-Wl,--version-script=${srcdir}/libcoap-${LIBCOAP_API_VERSION}.map], 216 [libcoap_SYMBOLS="-Wl,--version-script=\$(srcdir)/libcoap-\$(LIBCOAP_API_VERSION).map"], 217 [libcoap_SYMBOLS="-export-symbols \$(top_builddir)/libcoap-\$(LIBCOAP_API_VERSION).sym"]) 218 219AC_SUBST(libcoap_SYMBOLS) 220 221# configure options 222# __documentation__ 223 224AC_ARG_ENABLE([documentation], 225 [AS_HELP_STRING([--enable-documentation], 226 [Enable building all the documentation [default=yes]])], 227 [build_documentation="$enableval"], 228 [build_documentation="yes"]) 229 230AM_CONDITIONAL(BUILD_DOCUMENTATION, [test "x$build_documentation" = "xyes"]) 231 232doxygen_version_required=1.7.0 233dot_version_required=2.26.0 234 235AC_ARG_ENABLE([doxygen], 236 [AS_HELP_STRING([--enable-doxygen], 237 [Enable building the doxygen documentation [default=yes]])], 238 [build_doxygen="$enableval"], 239 [build_doxygen="yes"]) 240 241if test -z "$enable_doxygen"; then 242 if test "x$enable_documentation" = "xno"; then 243 build_doxygen="no" 244 fi 245fi 246 247if test "x$build_doxygen" = "xyes"; then 248 # Check for doxygen 249 AC_PATH_PROGS([DOXYGEN], [doxygen]) 250 if test -z "$DOXYGEN"; then 251 if test "x$build_doxygen" = "xyes"; then 252 AC_MSG_WARN([==> You want to build the doxygen documentation but doxygen was not found!]) 253 AC_MSG_ERROR([==> Install the package that contains doxygen or disable the doxygen documentation using '--disable-doxygen'.]) 254 fi 255 else 256 AC_MSG_CHECKING([for compatible doxygen version (>= $doxygen_version_required)]) 257 doxygen_version=`$DOXYGEN --version` 258 AS_VERSION_COMPARE([$doxygen_version], 259 [$doxygen_version_required], 260 [AC_MSG_RESULT([no]) 261 DOXYGEN=""], 262 [AC_MSG_RESULT([yes $doxygen_version])], 263 [AC_MSG_RESULT([yes $doxygen_version])]) 264 if test "x$DOXYGEN" = "x" -a "x$build_doxygen" = "xyes"; then 265 AC_MSG_WARN([==> Doxygen $doxygen_version too old. Doxygen >= $doxygen_version_required required for documentation build.]) 266 AC_MSG_ERROR([==> Install required doxygen version or disable the doxygen documentation using '--disable-doxygen'.]) 267 else 268 # we found doxygen and the version is valid 269 # now checking dot (needed for graphics) 270 AC_PATH_PROG([DOT], [dot]) 271 if test "x$DOT" = "x"; then 272 AC_MSG_WARN([==> dot not found - continuing without DOT support]) 273 AC_MSG_WARN([==> The libcoap html documentation will be build without DOT graphics!]) 274 HAVE_DOT="NO" 275 USE_CALL_GRAPH="NO" 276 else 277 AC_MSG_CHECKING([for compatible dot version (>= $dot_version_required)]) 278 case $host in 279 *-freebsd1*) 280 # csh and tcsh have a different output redirection than more recent shells 281 # cmd >& file # Redirect both stdout and stderr to file. 282 # cmd >>& file # Append both stdout and stderr to file. 283 # cmd1 | cmd2 # pipe stdout to cmd2 284 # cmd1 |& cmd2 # pipe stdout and stderr to cmd2 285 # Using an explicit call with the default always available C-shell on FreeBSD, 286 # the user may have installed another shell from a port which we don't know here 287 dot_version=`export DOT=$DOT && csh -c '$DOT -V |& cut -f5 -d" "'` 288 ;; 289 290 *) 291 dot_version=`$DOT -V 2>&1 | cut -f5 -d" "` 292 ;; 293 294 esac 295 AS_VERSION_COMPARE([$dot_version], 296 [$dot_version_required], 297 [AC_MSG_RESULT([no]) 298 DOT=""], 299 [AC_MSG_RESULT([yes $dot_version])], 300 [AC_MSG_RESULT([yes $dot_version])]) 301 if test "x$DOT" = "x" -a "x$build_doxygen" = "xyes"; then 302 AC_MSG_WARN([==> Graphviz dot $dot_version too old. Graphviz >= $dot_version_required required for doxygen build.]) 303 AC_MSG_ERROR([==> Install required graphviz version or disable the doxygen documentation using '--disable-doxygen'.]) 304 fi 305 # we found dot and the version is valid 306 HAVE_DOT="YES" 307 # let doxygen create caller graphics 308 # see http://www.stack.nl/~dimitri/doxygen/manual/config.html#cfg_call_graph 309 USE_CALL_GRAPH="YES" 310 # exporting the tests to doc/Doxygen(.in) 311 AC_SUBST(HAVE_DOT) 312 AC_SUBST(USE_CALL_GRAPH) 313 fi 314 fi 315 fi 316fi 317AM_CONDITIONAL(BUILD_DOXYGEN, [test "x$build_doxygen" = "xyes"]) 318 319AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) 320AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])]) 321 322# __manpages__ 323 324AC_ARG_ENABLE([manpages], 325 [AS_HELP_STRING([--enable-manpages], 326 [Enable building the manpages [default=yes]])], 327 [build_manpages="$enableval"], 328 [build_manpages="yes"]) 329 330if test -z "$enable_manpages"; then 331 if test "x$enable_documentation" = "xno"; then 332 build_manpages="no" 333 fi 334fi 335 336if test "x$build_manpages" = "xyes"; then 337 AC_ARG_VAR([A2X], [a2x command]) 338 AC_PATH_PROG([A2X], [a2x]) 339 if test "x$A2X" = "x"; then 340 AC_MSG_WARN([==> You want to build the manpages, but a2x was not found!]) 341 AC_MSG_ERROR([==> Install the package that contains a2x (mostly asciidoc) or disable the build of the manpages using '--disable-manpages'.]) 342 build_manpages="no" 343 else 344 AX_CHECK_A2X_TO_MANPAGE([], [ 345 AC_MSG_RESULT([no]) 346 AC_MSG_WARN([==> You want to build the manpages with a2x, but manpage formatting does not work!]) 347 AC_MSG_ERROR([==> Install the packages that contains the docbook DTD and XSL stylesheets (presumably docbook, docbook-xml) or disable the build of the manpages using '--disable-manpages'.]) 348 build_manpages="no" 349 ]) 350 fi 351fi 352AM_CONDITIONAL(BUILD_MANPAGES, [test "x$build_manpages" = "xyes"]) 353 354# configure options 355# __dtls__ 356# The Datagram Transport Layer Security (DTLS) feature needs cryptography 357# functions. 358# We currently support the GnuTLS and OpenSSL library. The user can preselect 359# the cryptography library that should be used by adding '--with-gnutls' or 360# '--with-openssl'. 361# If the user isn't using a selection we first search for GnuTLS and fallback 362# to OpenSSL if the GnuTLS library couldn't be found. 363 364gnutls_version_required=3.3.0 365openssl_version_required=1.1.0 366mbedtls_version_required=2.7.10 367tinydtls_version_required=0.8.6 368 369AC_ARG_ENABLE([dtls], 370 [AS_HELP_STRING([--enable-dtls], 371 [Enable building with DTLS support [default=yes]])], 372 [build_dtls="$enableval"], 373 [build_dtls="yes"]) 374 375AC_ARG_WITH([gnutls], 376 [AS_HELP_STRING([--with-gnutls], 377 [Use GnuTLS for DTLS functions])], 378 [with_gnutls="$withval"], 379 [with_gnutls="no"]) 380 381AC_ARG_WITH([openssl], 382 [AS_HELP_STRING([--with-openssl], 383 [Use OpenSSL for DTLS functions])], 384 [with_openssl="$withval"], 385 [with_openssl="no"]) 386 387AC_ARG_WITH([mbedtls], 388 [AS_HELP_STRING([--with-mbedtls], 389 [Use Mbed TLS for DTLS functions])], 390 [with_mbedtls="$withval"], 391 [with_mbedtls="no"]) 392 393AC_ARG_WITH([tinydtls], 394 [AS_HELP_STRING([--with-tinydtls], 395 [Use TinyDTLS for DTLS functions])], 396 [with_tinydtls="$withval"], 397 [with_tinydtls="no"]) 398 399AC_ARG_WITH([submodule-tinydtls], 400 [AS_HELP_STRING([--with-submodule-tinydtls], 401 [Use the TinyDTLS provided in the git submodule over the system-provided version [default=fallback to submodule if --with-tinydtls is explicitly set and no system-provided version was found])])], 402 [with_submodule_tinydtls="$withval"], 403 [with_submodule_tinydtls="explicit_fallback"]) 404 405if test "x$with_gnutls" = "xyes" -o "x$with_openssl" = "xyes" -o "x$with_mbedtls" = "xyes" -o "x$with_tinydtls" = "xyes"; then 406 if test "x$build_dtls" = "xno"; then 407 # Give an advice that '--with_gnutls', '--with_openssl', '--with-mbedtls' or '--with-tinydtls' was used but 408 # DTLS support isn't configured. 409 AC_MSG_WARN([==> Using the configure options '--with-gnutls', '--with-openssl', '--with-mbedtls' or '--with-tinydtls' without '--enable-dtls' is useless and will be ignored.]) 410 fi 411fi 412if test "x$with_submodule_tinydtls" = "xyes"; then 413 if test "x$with_tinydtls" = "xno"; then 414 # Give an advice that '--with-submodule-tinydtls' is useless if tinydtls is not also enabled. 415 AC_MSG_WARN([==> Using the configure option '--with-submodule-tinydtls' without '--with-tinydtls' is useless and it will be ignored.]) 416 fi 417fi 418 419# O.K. the user hasn't de-selected DTLS 420if test "x$build_dtls" = "xyes"; then 421 # The user can't select multiple crypto libraries. 422 TLSCOUNT=0 423 if test "x$with_gnutls" = "xyes"; then 424 TLSCOUNT=`expr $TLSCOUNT + 1` 425 fi 426 if test "x$with_openssl" = "xyes"; then 427 TLSCOUNT=`expr $TLSCOUNT + 1` 428 fi 429 if test "x$with_mbedtls" = "xyes"; then 430 TLSCOUNT=`expr $TLSCOUNT + 1` 431 fi 432 if test "x$with_tinydtls" = "xyes"; then 433 TLSCOUNT=`expr $TLSCOUNT + 1` 434 fi 435 if test "$TLSCOUNT" -gt 1; then 436 AC_MSG_ERROR([==> You can't use more than 1 of the options '--with-gnutls', '--with-openssl', '--with-mbedtls' or '--with-tinydtls' at the same time while '--enable-dtls' is selected! 437 ==> Please note, the option '--enable-dtls' is turned on by default if not explicitly disabled!]) 438 fi 439 440 # Check for all possible usable and supported SSL crypto libraries 441 # GnuTLS 442 PKG_CHECK_MODULES([GnuTLS], 443 [gnutls], 444 [have_gnutls="yes"], 445 [have_gnutls="no"]) 446 447 # OpenSSL 448 PKG_CHECK_MODULES([OpenSSL], 449 [openssl], 450 [have_openssl="yes"], 451 [have_openssl="no"]) 452 453 # Mbed TLS [does not have mbedtls.pc pkg-config file] 454 AC_CHECK_LIB(mbedtls, mbedtls_version_get_string, 455 [have_mbedtls="yes"; MbedTLS_CFLAGS="" ; MbedTLS_LIBS="-lmbedtls -lmbedcrypto -lmbedx509"], 456 [have_mbedtls="no"], -lmbedx509 -lmbedcrypto) 457 if test "x$have_mbedtls" = "xyes"; then 458 if test "x$cross_compiling" = "xyes" ; then 459 # Have no option but to do this 460 mbedtls_version=$mbedtls_version_required 461 else 462 # Get actual library version 463 AC_LANG_PUSH(C) 464 local_MbedTLS_save_LIBS=$LIBS 465 LIBS="$MbedTLS_LIBS $LIBS" 466 AC_LINK_IFELSE([dnl 467 AC_LANG_SOURCE( 468 [[#include <stdio.h> 469 #include <mbedtls/version.h> 470 int main () { 471 char str[20]; 472 mbedtls_version_get_string(str); 473 fprintf(stdout,"%s\n",str); 474 return 0; 475 }]])], 476 [mbedtls_version=$(./conftest$EXEEXT)], 477 [AC_MSG_WARN(Failed to determine Mbed TLS version) 478 have_mbedtls=no]) 479 LIBS=$local_MbedTLS_save_LIBS 480 AC_LANG_POP(C) 481 fi 482 fi 483 484 if test "${TinyDTLS_CFLAGS+set}" = "set"; then 485 tinydtls_cflags_overridden="yes" 486 fi 487 if test "${TinyDTLS_LIBS+set}" = "set"; then 488 tinydtls_libs_overridden="yes" 489 fi 490 # TinyDTLS 491 PKG_CHECK_MODULES([TinyDTLS], 492 [tinydtls], 493 [have_tinydtls="yes"], 494 [have_tinydtls="no"]) 495 496 # TBD ? 497 498 # The user wants to use explicit GnuTLS if '--with-gnutls' was set. 499 if test "x$with_gnutls" = "xyes"; then 500 # Some more sanity checking. 501 if test "x$have_gnutls" != "xyes"; then 502 AC_MSG_ERROR([==> You want to build libcoap with DTLS support by the GnuTLS library but pkg-config file 'gnutls.pc' could not be found! 503 Install the package(s) that contains the development files for GnuTLS, 504 or select a different TLS library or disable the DTLS support using '--disable-dtls'.]) 505 fi 506 AC_MSG_NOTICE([The use of GnuTLS was explicitly requested with configure option '--with-gnutls'!]) 507 508 # check for valid GnuTLS version 509 gnutls_version=`$PKG_CONFIG --modversion gnutls` 510 AX_CHECK_GNUTLS_VERSION 511 have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script 512 have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script 513 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 514 fi 515 516 # The user wants to use explicit OpenSSL if '--with-openssl was set'. 517 if test "x$with_openssl" = "xyes"; then 518 # Some more sanity checking. 519 if test "x$have_openssl" != "xyes"; then 520 AC_MSG_ERROR([==> You want to build libcoap with DTLS support by the OpenSSL library but pkg-config file 'openssl.pc' could not be found! 521 Install the package(s) that contains the development files for OpenSSL, 522 or select a different TLS library or disable the DTLS support using '--disable-dtls'.]) 523 fi 524 AC_MSG_NOTICE([The use of OpenSSL was explicitly requested with configure option '--with-openssl'!]) 525 526 # check for valid OpenSSL version 527 openssl_version=`$PKG_CONFIG --modversion openssl` 528 AX_CHECK_OPENSSL_VERSION 529 have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script 530 have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script 531 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 532 fi 533 534 # The user wants to use explicit Mbed TLS if '--with-mbedtls was set'. 535 if test "x$with_mbedtls" = "xyes"; then 536 # Some more sanity checking. 537 if test "x$have_mbedtls" != "xyes"; then 538 AC_MSG_ERROR([==> You want to build libcoap with DTLS support by the Mbed TLS library but library 'mbedtls' could not be found! 539 Install the package(s) that contains the development files for Mbed TLS, 540 or select a different TLS library or disable the DTLS support using '--disable-dtls'.]) 541 fi 542 AC_MSG_NOTICE([The use of Mbed TLS was explicitly requested with configure option '--with-mbedtls'!]) 543 544 # check for valid Mbed TLS version (mbedtls.pc does not exist - hmm) 545 # mbedtls_version determined previously 546 AX_CHECK_MBEDTLS_VERSION 547 have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script 548 have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script 549 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 550 fi 551 552 # The user wants to use explicit TinyDTLS if '--with-tinydtls was set'. 553 if test "x$with_tinydtls" = "xyes" ; then 554 AC_MSG_NOTICE([The use of TinyDTLS was explicitly requested with configure option '--with-tinydtls'!]) 555 if [ test "x$have_tinydtls" = "xno" ] && [ test "x$with_submodule_tinydtls" = "xexplicit_fallback" ] || [ test "x$with_submodule_tinydtls" = "xyes" ]; then 556 AC_MSG_NOTICE([Using TinyDTLS submodule over system-provided version because either "--with-submodule-tinydtls" was set or no system-provided TinyDTLS was found.]) 557 if test -e "$srcdir/ext/tinydtls/dtls.h"; then 558 AC_CONFIG_SUBDIRS([ext/tinydtls]) 559 if test "x$enable_shared" = "xyes"; then 560 auto_TinyDTLS_LIBS="-L\$(top_builddir)/ext/tinydtls -ltinydtls" 561 else 562 # Needed as TinyDTLS compiling does not recognize --disable-shared 563 # and still builds libtinydtls.so which gets linked in otherwise 564 auto_TinyDTLS_LIBS="-L\$(top_builddir)/ext/tinydtls -l:libtinydtls.a" 565 fi 566 have_submodule_tinydtls="yes" 567 568 auto_TinyDTLS_CFLAGS="-I \$(top_srcdir)/ext -I \$(top_srcdir)/ext/tinydtls" 569 570 if test "x$tinydtls_cflags_overridden" != "xyes"; then 571 TinyDTLS_CFLAGS="$auto_TinyDTLS_CFLAGS" 572 fi 573 if test "x$tinydtls_libs_overridden" != "xyes"; then 574 TinyDTLS_LIBS="$auto_TinyDTLS_LIBS" 575 fi 576 # 'git submodule update' may be required 577 AC_DEFINE(HAVE_DTLS_SET_LOG_HANDLER, [1], [Define to 1 if TinyDTLS has dtls_set_log_handler.]) 578 else 579 AC_MSG_ERROR([==> You want to build libcoap with DTLS support using the TinyDTLS submodule library but no suitable version could be found! 580 Check whether you have updated the TinyDTLS git submodule, use the system-provided version if available (set '--with-submodule-tinydtls=no'), 581 select a different TLS library or disable the DTLS support using '--disable-dtls'.]) 582 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 583 have_submodule_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 584 fi 585 elif test "x$have_tinydtls" = "xyes"; then 586 AC_MSG_NOTICE([Using system-provided TinyDTLS]) 587 tinydtls_version=`$PKG_CONFIG --modversion tinydtls` 588 AX_CHECK_TINYDTLS_VERSION 589 AC_CHECK_LIB(tinydtls,dtls_set_log_handler,AC_DEFINE(HAVE_DTLS_SET_LOG_HANDLER, [1], [Define to 1 if TinyDTLS has dtls_set_log_handler.])) 590 else 591 AC_MSG_ERROR([==> You want to build libcoap with DTLS support using the TinyDTLS library but no suitable version could be found! 592 Use the submodule TinyDTLS version (set '--with-submodule-tinydtls=yes' and update the git submodule), 593 ensure that you have a system-provided version of TinyDTLS that can be found using pkg-config (older versions can not), 594 select a different TLS library or disable the DTLS support using '--disable-dtls'.]) 595 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 596 fi 597 598 have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script 599 have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script 600 have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script 601 fi 602 603 if test "$TLSCOUNT" -eq 0; then 604 # The user hasn't requested the use of a specific cryptography library 605 # we try first GnuTLS for usability ... 606 if test "x$have_gnutls" = "xyes"; then 607 gnutls_version=`$PKG_CONFIG --modversion gnutls` 608 AX_CHECK_GNUTLS_VERSION 609 AC_MSG_NOTICE([Using auto selected library GnuTLS for DTLS support!]) 610 with_gnutls_auto="yes" 611 have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script 612 have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script 613 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 614 615 # ... and if not found check OpenSSL is suitable. 616 elif test "x$have_openssl" = "xyes"; then 617 openssl_version=`$PKG_CONFIG --modversion openssl` 618 AX_CHECK_OPENSSL_VERSION 619 AC_MSG_NOTICE([Using auto selected library OpenSSL for DTLS support!]) 620 with_openssl_auto="yes" 621 have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script 622 have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script 623 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 624 625 # ... and if not found check Mbed TLS is suitable. 626 elif test "x$have_mbedtls" = "xyes"; then 627 # Mbed TLS [does not have mbedtls.pc pkg-config file] 628 # mbedtls_version determined previously 629 AX_CHECK_MBEDTLS_VERSION 630 AC_MSG_NOTICE([Using auto selected library Mbed TLS for DTLS support!]) 631 with_mbedtls_auto="yes" 632 have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script 633 have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script 634 have_tinydtls="no" # don't confuse AC_MSG_RESULT at the end of the script 635 636 elif [ test "x$with_tinydtls" = "xyes" ] && [ test "x$have_tinydtls" = "xyes" ]; then 637 AC_MSG_NOTICE([Using auto selected library TinyDTLS for DTLS support!]) 638 tinydtls_version=`$PKG_CONFIG --modversion tinydtls` 639 AX_CHECK_TINYDTLS_VERSION 640 with_tinydtls_auto="yes" 641 have_gnutls="no" # don't confuse AC_MSG_RESULT at the end of the script 642 have_mbedtls="no" # don't confuse AC_MSG_RESULT at the end of the script 643 have_openssl="no" # don't confuse AC_MSG_RESULT at the end of the script 644 645 646 # Note that the TinyDTLS submodule is used only when explicitly requested. 647 # Giving out an error message if we haven't found at least one crypto library. 648 else 649 AC_MSG_ERROR([==> Option '--enable-dtls' is set but none of the needed cryptography libraries GnuTLS, OpenSSL, Mbed TLS or TinyDTLS could be found! 650 Install at least one of the package(s) that contains the development files for GnuTLS (>= $gnutls_version_required), OpenSSL(>= $openssl_version_required), Mbed TLS(>= $mbedtls_version_required), or TinyDTLS(>= $tinydtls_version_required) 651 or disable the DTLS support using '--disable-dtls'.]) 652 fi 653 fi 654 655 # Saving the DTLS related Compiler flags. 656 if test "x$with_gnutls" = "xyes" -o "x$with_gnutls_auto" = "xyes"; then 657 DTLS_CFLAGS="$GnuTLS_CFLAGS" 658 DTLS_LIBS="$GnuTLS_LIBS" 659 AC_DEFINE(COAP_WITH_LIBGNUTLS, [1], [Define to 1 if the system has libgnutls28.]) 660 fi 661 if test "x$with_openssl" = "xyes" -o "x$with_openssl_auto" = "xyes"; then 662 DTLS_CFLAGS="$OpenSSL_CFLAGS" 663 DTLS_LIBS="$OpenSSL_LIBS" 664 AC_DEFINE(COAP_WITH_LIBOPENSSL, [1], [Define to 1 if the system has libssl1.1.]) 665 fi 666 if test "x$with_mbedtls" = "xyes" -o "x$with_mbedtls_auto" = "xyes"; then 667 DTLS_CFLAGS="$MbedTLS_CFLAGS" 668 DTLS_LIBS="$MbedTLS_LIBS" 669 AC_DEFINE(COAP_WITH_LIBMBEDTLS, [1], [Define to 1 if the system has libmbedtls2.7.10.]) 670 fi 671 if test "x$with_tinydtls" = "xyes" -o "x$with_tinydtls_auto" = "xyes"; then 672 DTLS_CFLAGS="$TinyDTLS_CFLAGS" 673 DTLS_LIBS="$TinyDTLS_LIBS" 674 AC_DEFINE(COAP_WITH_LIBTINYDTLS, [1], [Define to 1 if the system has libtinydtls.]) 675 fi 676 AC_SUBST(DTLS_CFLAGS) 677 AC_SUBST(DTLS_LIBS) 678fi 679 680# Define the Library name extension for the TLS the library was linked against 681if test "x$with_openssl" = "xyes" -o "x$with_openssl_auto" = "xyes"; then 682 LIBCOAP_DTLS_LIB_EXTENSION_NAME=-openssl 683elif test "x$with_gnutls" = "xyes" -o "x$with_gnutls_auto" = "xyes"; then 684 LIBCOAP_DTLS_LIB_EXTENSION_NAME=-gnutls 685elif test "x$with_mbedtls" = "xyes" -o "x$with_mbedtls_auto" = "xyes"; then 686 LIBCOAP_DTLS_LIB_EXTENSION_NAME=-mbedtls 687elif test "x$with_tinydtls" = "xyes"; then 688 LIBCOAP_DTLS_LIB_EXTENSION_NAME=-tinydtls 689else 690 LIBCOAP_DTLS_LIB_EXTENSION_NAME=-notls 691 AC_DEFINE(HAVE_NOTLS, [1], [Define to 1 if libcoap has no tls library support.]) 692fi 693AM_CONDITIONAL(HAVE_NOTLS, [test "x$LIBCOAP_DTLS_LIB_EXTENSION_NAME" = "x-notls"]) 694 695LIBCOAP_NAME_SUFFIX="$LIBCOAP_API_VERSION$LIBCOAP_DTLS_LIB_EXTENSION_NAME" 696 697AC_SUBST(LIBCOAP_NAME_SUFFIX) 698AC_SUBST(LIBCOAP_DTLS_LIB_EXTENSION_NAME) 699AC_SUBST([DOLLAR_SIGN],[$]) 700 701# configure options 702# __OSCORE__ 703# Support for Object Security according to RFC 8613. 704AC_ARG_ENABLE([oscore], 705 [AS_HELP_STRING([--enable-oscore], 706 [Enable building with OSCORE support [default=yes]])], 707 [build_oscore="$enableval"], 708 [build_oscore="yes"]) 709 710if test "x$build_oscore" = "xyes"; then 711 if test "x$LIBCOAP_DTLS_LIB_EXTENSION_NAME" = "x-notls"; then 712 AC_MSG_WARN([==> --enable-oscore requires crypto support from TLS library or OS]) 713 fi 714fi 715 716if test "x$build_oscore" = "xyes"; then 717 AC_DEFINE(COAP_OSCORE_SUPPORT, [1], [Define to 1 to build with OSCORE support.]) 718fi 719AM_CONDITIONAL(COAP_OSCORE_SUPPORT, [test "x$build_oscore" = "xyes"]) 720 721# configure options 722# __tests__ 723AC_ARG_ENABLE([tests], 724 [AS_HELP_STRING([--enable-tests], 725 [Enable building the binary testsuite. Requires --enable-static [default=no]])], 726 [build_tests="$enableval"], 727 [build_tests="no"]) 728 729if test "x$build_tests" = "xyes"; then 730 PKG_CHECK_MODULES([CUNIT], 731 [cunit], 732 [have_cunit=yes 733 AC_DEFINE(HAVE_LIBCUNIT, [1], [Define to 1 if the system has libcunit.])], 734 [have_cunit=no 735 AC_MSG_WARN([==> You want to build the testing binary but the pkg-config file cunit.pc could not be found or installed CUnit version is too old!]) 736 AC_MSG_ERROR([==> Install the package(s) that contains the development files for CUnit or disable the testing binary using '--disable-tests'.]) 737 ]) 738 if test "x$enable_static" = "xno"; then 739 enable_static=yes 740 AC_MSG_WARN([--enable-tests requires --enable-static which is now enabled.]) 741 fi 742fi 743AM_CONDITIONAL(HAVE_CUNIT, [test "x$CUNIT_LIBS" != "x"]) 744 745# configure options 746# __examples__ 747AC_ARG_ENABLE([examples], 748 [AS_HELP_STRING([--enable-examples], 749 [Enable building the example binaries [default=yes]])], 750 [build_examples="$enableval"], 751 [build_examples="yes"]) 752 753AM_CONDITIONAL(BUILD_EXAMPLES, [test "x$build_examples" = "xyes"]) 754 755# configure options 756# __examples-source 757AC_ARG_ENABLE([examples-source], 758 [AS_HELP_STRING([--enable-examples-source], 759 [Enable installing example source to DATAROOTDIR/libcoap/examples [default=yes]])], 760 [build_examples_source="$enableval"], 761 [build_examples_source="yes"]) 762 763AM_CONDITIONAL(BUILD_EXAMPLES_SOURCE, [test "x$build_examples_source" = "xyes"]) 764 765# configure options 766# __gcov__ 767AC_ARG_ENABLE([gcov], 768 [AS_HELP_STRING([--enable-gcov], 769 [Enable building with gcov test coverage support [default=no]])], 770 [build_gcov="$enableval"], 771 [build_gcov="no" 772 AC_MSG_WARN([gcov is disabled]) 773 ]) 774 775if test "x$build_gcov" = "xyes"; then 776 if test "x$GCC" != "xyes"; then 777 AC_MSG_ERROR([Currently, gcov is assumed to work with GCC-compatible compilers only.]) 778 else 779 AX_CHECK_COMPILE_FLAG([-fprofile-arcs], [CFLAGS="$CFLAGS -fprofile-arcs"]) 780 AX_CHECK_COMPILE_FLAG([-ftest-coverage], [CFLAGS="$CFLAGS -ftest-coverage"]) 781 # FIXME: clang complains about '--coverage' 782 AX_CHECK_COMPILE_FLAG([--coverage], [CFLAGS="$CFLAGS --coverage -O0" LDFLAGS="$LDFLAGS --coverage"]) 783 fi 784fi 785 786# configure options 787# __license-install__ 788AC_ARG_ENABLE([license-install], 789 [AS_HELP_STRING([--enable-license-install], 790 [Enable installing LICENSE to DOCDIR [default=yes]])], 791 [build_license_install="$enableval"], 792 [build_license_install="yes"]) 793 794AM_CONDITIONAL(BUILD_LICENSE_INSTALL, [test "x$build_license_install" = "xyes"]) 795 796# configure options 797# __ipv4__ 798AC_ARG_ENABLE([ipv4], 799 [AS_HELP_STRING([--enable-ipv4-support], 800 [Enable building with support for IPv4 packets [default=yes]])], 801 [build_ipv4_support="$enableval"], 802 [build_ipv4_support="yes"]) 803 804AS_IF([test "x$build_ipv4_support" = "xyes"], 805 [AC_DEFINE(COAP_IPV4_SUPPORT, [1], [Define to build support for IPv4 packets.])]) 806 807# configure options 808# __ipv6__ 809AC_ARG_ENABLE([ipv6], 810 [AS_HELP_STRING([--enable-ipv6-support], 811 [Enable building with support for IPv6 packets [default=yes]])], 812 [build_ipv6_support="$enableval"], 813 [build_ipv6_support="yes"]) 814 815AS_IF([test "x$build_ipv6_support" = "xyes"], 816 [AC_DEFINE(COAP_IPV6_SUPPORT, [1], [Define to build support for IPv6 packets.])]) 817 818# configure options 819# __af_unix__ 820AC_ARG_ENABLE([af_unix], 821 [AS_HELP_STRING([--enable-af-unix-support], 822 [Enable building with support for Unix socket packets [default=yes]])], 823 [build_af_unix_support="$enableval"], 824 [build_af_unix_support="yes"]) 825 826AS_IF([test "x$build_af_unix_support" = "xyes"], 827 [AC_DEFINE(COAP_AF_UNIX_SUPPORT, [1], [Define to build support for Unix socket packets.])]) 828 829# configure options 830# __tcp__ 831AC_ARG_ENABLE([tcp], 832 [AS_HELP_STRING([--enable-tcp], 833 [Enable building with TCP support [default=yes]])], 834 [build_tcp="$enableval"], 835 [build_tcp="yes"]) 836 837AC_DEFINE(COAP_DISABLE_TCP, [0], [Define to 1 to build without TCP support.]) 838AS_IF([test "x$build_tcp" != "xyes"], [AC_DEFINE(COAP_DISABLE_TCP, [1])]) 839AC_SUBST(COAP_DISABLE_TCP) 840 841# configure options 842# __websockets__ 843AC_ARG_ENABLE([websockets], 844 [AS_HELP_STRING([--enable-websockets], 845 [Enable building with WebSockets support [default=yes]])], 846 [build_ws="$enableval"], 847 [build_ws="yes"]) 848 849if test "x$build_ws" = "xyes"; then 850 if test "x$build_tcp" != "xyes"; then 851 build_ws=no 852 AC_MSG_WARN([--enable-websockets requires --enable-tcp, so --enable-websockets ignored.]) 853 fi 854fi 855 856AS_IF([test "x$build_ws" = "xyes"], 857 [AC_DEFINE(COAP_WS_SUPPORT, [1], [Define to 1 to build with WebSockets support.])]) 858AC_SUBST(COAP_WS_SUPPORT) 859 860# configure options 861# __async__ 862AC_ARG_ENABLE([async], 863 [AS_HELP_STRING([--enable-async], 864 [Enable building with support for async separate responses [default=yes]])], 865 [build_async="$enableval"], 866 [build_async="yes"]) 867 868AS_IF([test "x$build_async" = "xyes"], 869 [AC_DEFINE(COAP_ASYNC_SUPPORT, [1], [Define to 1 to build with support for async separate responses.])]) 870 871# configure options 872# __observe_persist__ 873AC_ARG_ENABLE([async], 874 [AS_HELP_STRING([--enable-observe-persist], 875 [Enable building with support for persisting observes over a server restart [default=yes]])], 876 [build_observe_persist="$enableval"], 877 [build_observe_persist="yes"]) 878 879AS_IF([test "x$build_observe_persist" = "xyes"], 880 [AC_DEFINE(COAP_WITH_OBSERVE_PERSIST, [1], [Define to 1 to build support for persisting observes.])]) 881 882# configure options 883# __q_block__ 884# Support for Q-Block according to RFC 9177. 885AC_ARG_ENABLE([q-block], 886 [AS_HELP_STRING([--enable-q-block], 887 [Enable building with Q-Block support [default=yes]])], 888 [build_q_block="$enableval"], 889 [build_q_block="yes"]) 890 891AS_IF([test "x$build_q_block" = "xyes"], 892 [AC_DEFINE(COAP_Q_BLOCK_SUPPORT, [1], [Define to 1 to build with Q-Block support.])]) 893 894# configure options 895# __add_default_names__ 896AC_ARG_ENABLE([add-default-names], 897 [AS_HELP_STRING([--enable-add-default-names], 898 [Enable adding libraries / examples with default names [default=yes]])], 899 [build_add_default_names="$enableval"], 900 [build_add_default_names="yes"]) 901 902AM_CONDITIONAL(BUILD_ADD_DEFAULT_NAMES, [test "x$build_add_default_names" = "xyes"]) 903 904# end configure options 905####################### 906 907########################################### 908# from configure options independent checks 909 910# Check for (ex)ctags binary 911# The needed ctags binary name differs on FreeBSD and Linux, on Linux 912# systems we search for 'ctags', on FreeBSD for 'exctags' 913case $host in 914 # FreeBSD has exctags from the ctags port 915 *-freebsd1*) 916 AC_ARG_VAR([CTAGS_PROG],[the 'exctags' program to use for make target 'update-map-file']) 917 AC_PATH_PROG([CTAGS_PROG],[exctags]) 918 ;; 919 920 *) 921 # Linux distributions have exuberant-ctags 922 AC_ARG_VAR([CTAGS_PROG],[the 'ctags' program to use for make target 'update-map-file']) 923 AC_PATH_PROG([CTAGS_PROG],[ctags]) 924 ;; 925 926esac 927 928if test "x$CTAGS_PROG" = "x"; then 929 AC_MSG_NOTICE([==> Note: '(ex)ctags' command not found!]) 930 AC_MSG_WARN([==> Without ctags you will be unable to run the target 'update-map-file'!]) 931 AC_MSG_WARN([==> This is no problem if you just want to build the library libcoap.]) 932else 933 if test "`$CTAGS_PROG --help | grep '\--<LANG>-kinds'`" = ""; then 934 AC_MSG_NOTICE([==> Note: Your ctags binary does not support '--c-kinds'!]) 935 AC_MSG_NOTICE([==> Most likely, you are using the GNU Emacs ctag and not exuberant ctag.]) 936 AC_MSG_WARN([==> This option is required for the target 'update-map-file'.]) 937 AC_MSG_WARN([==> which is not a problem if you just want to build the library libcoap.]) 938 fi 939fi 940 941# Checks for header files. 942AC_CHECK_HEADERS([assert.h arpa/inet.h limits.h netdb.h netinet/in.h \ 943 pthread.h errno.h winsock2.h ws2tcpip.h \ 944 stdlib.h string.h strings.h sys/socket.h sys/time.h \ 945 time.h unistd.h sys/unistd.h sys/ioctl.h net/if.h ifaddrs.h]) 946 947# For epoll, need two headers (sys/epoll.h sys/timerfd.h), but set up one #define 948AC_CHECK_HEADER([sys/epoll.h]) 949AC_CHECK_HEADER([sys/timerfd.h]) 950if test "x$ac_cv_header_sys_epoll_h" = "xyes" -a "x$ac_cv_header_sys_timerfd_h" = "xyes"; then 951 have_epoll="yes" 952 AC_ARG_WITH([epoll], 953 [AS_HELP_STRING([--with-epoll], 954 [Use epoll for I/O handling [if O/S supports it]])], 955 [with_epoll="$withval"], 956 [with_epoll="yes"]) 957else 958 have_epoll="no" 959 if test "x$with_epoll" = "xyes"; then 960 AC_MSG_WARN([==> Underlying O/S does not support epoll - --with-epoll ignored.]) 961 with_epoll="no" 962 fi 963fi 964 965if test "x$with_epoll" = "xyes"; then 966 AC_DEFINE(COAP_EPOLL_SUPPORT, 1, [Define to 1 if the system has epoll support.]) 967fi 968 969AC_ARG_ENABLE([small-stack], 970 [AS_HELP_STRING([--enable-small-stack], 971 [Use small-stack if the available stack space is restricted [default=no]])], 972 [enable_small_stack="$enableval"], 973 [enable_small_stack="no"]) 974 975if test "x$enable_small_stack" = "xyes"; then 976 AC_DEFINE(COAP_CONSTRAINED_STACK, 1, [Define to 1 if the system has small stack size.]) 977fi 978 979AC_ARG_ENABLE([server-mode], 980 [AS_HELP_STRING([--enable-server-mode], 981 [Enable CoAP server mode supporting code [default=yes]])], 982 [enable_server_mode="$enableval"], 983 [enable_server_mode="yes"]) 984 985if test "x$enable_server_mode" = "xyes"; then 986 AC_DEFINE(COAP_SERVER_SUPPORT, 1, [Define to 1 if libcoap supports server mode code.]) 987fi 988AM_CONDITIONAL(HAVE_SERVER_SUPPORT, [test "x$enable_server_mode" = "xyes"]) 989 990AC_ARG_ENABLE([client-mode], 991 [AS_HELP_STRING([--enable-client-mode], 992 [Enable CoAP client mode supporting code [default=yes]])], 993 [enable_client_mode="$enableval"], 994 [enable_client_mode="yes"]) 995 996if test "x$enable_client_mode" = "xyes"; then 997 AC_DEFINE(COAP_CLIENT_SUPPORT, 1, [Define to 1 if libcoap supports client mode code.]) 998fi 999AM_CONDITIONAL(HAVE_CLIENT_SUPPORT, [test "x$enable_client_mode" = "xyes"]) 1000if test "x$enable_server_mode" != "xyes" -a "x$enable_client_mode" != "xyes" ; then 1001 AC_MSG_ERROR([==> One or both of '--enable-server-mode' and '--enable-client-mode' need to be set!]) 1002fi 1003 1004AC_ARG_ENABLE([max-logging-level], 1005 [AS_HELP_STRING([--enable-max-logging-level], 1006 [Only build logging code up to and including the specified logging level [default=8]])], 1007 [enable_max_logging_level="$enableval"], 1008 [enable_max_logging_level="8"]) 1009 1010if test "x$enable_max_logging_level" != "x8"; then 1011 case x$enable_max_logging_level in 1012 x0) ;; 1013 x1) ;; 1014 x2) ;; 1015 x3) ;; 1016 x4) ;; 1017 x5) ;; 1018 x6) ;; 1019 x7) ;; 1020 *) 1021 AC_MSG_ERROR([--emable-max-logging-level must have a value of 0 through 8 inclusive]) 1022 ;; 1023 esac 1024 AC_DEFINE_UNQUOTED([COAP_MAX_LOGGING_LEVEL], [$enable_max_logging_level], [Define to level if max logging level is not 8]) 1025fi 1026 1027# Checks for typedefs, structures, and compiler characteristics. 1028AC_TYPE_SIZE_T 1029AC_TYPE_SSIZE_T 1030 1031# Checks for library functions. 1032AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo \ 1033 strnlen malloc pthread_mutex_lock getrandom random if_nametoindex]) 1034 1035# Check if -lsocket -lnsl is required (specifically Solaris) 1036AC_SEARCH_LIBS([socket], [socket]) 1037AC_SEARCH_LIBS([inet_ntop], [nsl]) 1038 1039# Check if clock_gettime() requires librt, when available 1040AC_SEARCH_LIBS([clock_gettime], [rt]) 1041 1042#check for struct cmsghdr 1043AC_CHECK_TYPES([struct cmsghdr],,,[ 1044AC_INCLUDES_DEFAULT 1045#include <sys/socket.h>]) 1046 1047AC_MSG_CHECKING([operating system]) 1048 1049# Set up here some extra platform depended defines and variables. 1050# The "ADDITIONAL_CFLAGS" is need as this stand-alone definition 1051# for the doxygen part. 1052case $host in 1053 *-linux* | *-uclinux*) 1054 AC_MSG_RESULT([Linux]) 1055 ADDITIONAL_CFLAGS="-D_GNU_SOURCE" 1056 1057 # Not yet needed but if some code definitions have to depend on the platform. 1058 #AC_DEFINE(OS_LINUX, 1, [Linux backend]) 1059 #AC_SUBST(OS_LINUX) 1060 ;; 1061 1062 *-cygwin*) 1063 AC_MSG_RESULT([Cygwin]) 1064 ADDITIONAL_CFLAGS="-D_GNU_SOURCE -D_CYGWIN_ENV" 1065 LDFLAGS="-no-undefined $LDFLAGS" 1066 ;; 1067 1068 *-solaris*) 1069 AC_MSG_RESULT([Solaris]) 1070 # set _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED to enable XPG4v2 (POSIX 2004) 1071 # set __EXTENSION__ to shut up feature test macros that restrict -std=c99 1072 # to only C99 (and nothing newer) 1073 ADDITIONAL_CFLAGS="-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=600 -D__EXTENSIONS__=1" 1074 ;; 1075 1076 *-darwin*) 1077 AC_MSG_RESULT([Darwin]) 1078 ADDITIONAL_CFLAGS="-D_GNU_SOURCE" 1079 1080 AC_DEFINE(__APPLE_USE_RFC_3542, 1, [Define this to 1 for ancillary data on MacOS]) 1081 1082 # Not yet needed but if some code definitions have to depend on the platform. 1083 #AC_DEFINE(OS_MACOS, 1, [MacOS backend]) 1084 #AC_SUBST(OS_MACOS) 1085 ;; 1086 1087 *-freebsd1*) 1088 AC_MSG_RESULT([FreeBSD-1x]) 1089 ADDITIONAL_CFLAGS="-D_GNU_SOURCE" 1090 ;; 1091 1092 *kfreebsd*) 1093 AC_MSG_RESULT([kFreeBSD]) 1094 ADDITIONAL_CFLAGS="-D_GNU_SOURCE" 1095 ;; 1096 1097 *mingw*) 1098 AC_MSG_RESULT([MinGW]) 1099 ADDITIONAL_CFLAGS="-D_GNU_SOURCE -Wno-format -Wno-format-security" 1100 LIBS="${LIBS} -lws2_32" 1101 ;; 1102 1103 *) 1104 AC_MSG_WARN([==> Currently unsupported operating system '${host}' !]) 1105 AC_MSG_ERROR([==> If you can provide patches to support your operating system please write to 'libcoap-developers@lists.sourceforge.net'.]) 1106esac 1107 1108# Exporting the PREDEFINED_CFLAGS definition 1109PREDEFINED_CFLAGS=`echo $ADDITIONAL_CFLAGS | $SED -e 's/-D//g'` 1110AC_SUBST(PREDEFINED_CFLAGS) 1111 1112# And finally combining the CFLAGS together ... 1113CFLAGS="$CFLAGS $ADDITIONAL_CFLAGS" 1114 1115# Override the various template files, currently just makefiles and the 1116# pkgconfig *.pc file. 1117# Later if the API version is changing don't forget to change the 1118# libcoap-$LIBCOAP_API_VERSION.pc.in file too!! You will have to change 1119# the 'Cflags' variable to something like 1120# Cflags: -I${includedir}/coap-@LIBCOAP_API_VERSION@ 1121# 1122AC_CONFIG_FILES([ 1123Makefile 1124coap_config.h.riot 1125coap_config.h.windows 1126doc/Makefile 1127examples/Makefile 1128examples/lwip/config/coap_config.h 1129include/coap$LIBCOAP_API_VERSION/coap.h 1130include/coap$LIBCOAP_API_VERSION/coap.h.riot 1131include/coap$LIBCOAP_API_VERSION/coap.h.windows 1132man/coap.txt 1133man/coap_address.txt 1134man/coap_async.txt 1135man/coap_attribute.txt 1136man/coap_block.txt 1137man/coap_cache.txt 1138man/coap_context.txt 1139man/coap_deprecated.txt 1140man/coap_encryption.txt 1141man/coap_endpoint_client.txt 1142man/coap_endpoint_server.txt 1143man/coap_handler.txt 1144man/coap_init.txt 1145man/coap_io.txt 1146man/coap_keepalive.txt 1147man/coap_logging.txt 1148man/coap_lwip.txt 1149man/coap_observe.txt 1150man/coap_oscore.txt 1151man/coap_pdu_access.txt 1152man/coap_pdu_setup.txt 1153man/coap_persist.txt 1154man/coap_recovery.txt 1155man/coap_resource.txt 1156man/coap_session.txt 1157man/coap_string.txt 1158man/coap_tls_library.txt 1159man/coap_uri.txt 1160man/coap_websockets.txt 1161man/coap-client.txt 1162man/coap-oscore-conf.txt 1163man/coap-server.txt 1164man/coap-rd.txt 1165man/Makefile 1166tests/test_common.h 1167tests/Makefile 1168tests/oss-fuzz/Makefile.ci 1169libcoap-$LIBCOAP_NAME_SUFFIX.pc:libcoap-$LIBCOAP_API_VERSION.pc.in 1170]) 1171 1172AC_OUTPUT 1173 1174LIBCOAP_BUILD=`git describe --tags --dirty --always` 1175if test "x$LIBCOAP_BUILD" = "x"; then 1176 LIBCOAP_BUILD=$PACKAGE_VERSION 1177fi 1178 1179AC_MSG_RESULT([ 1180libcoap Configuration Summary: 1181 libcoap package version : "$PACKAGE_VERSION" 1182 libcoap package source : "$LIBCOAP_BUILD" 1183 libcoap API version : "$LIBCOAP_API_VERSION" 1184 libcoap ABI version : "$LIBCOAP_ABI_VERSION" 1185 libcoap libtool SO version : "$LIBCOAP_SO_VERSION" 1186 libcoap DTLS lib extn : "$LIBCOAP_DTLS_LIB_EXTENSION_NAME" 1187 host system : "$host"]); 1188if test "x$enable_server_mode" = "xyes"; then 1189 AC_MSG_RESULT([ build with server support : "yes"]) 1190else 1191 AC_MSG_RESULT([ build with server support : "no"]) 1192fi 1193if test "x$enable_client_mode" = "xyes"; then 1194 AC_MSG_RESULT([ build with client support : "yes"]) 1195else 1196 AC_MSG_RESULT([ build with client support : "no"]) 1197fi 1198if test "x$build_ipv4" != "xno"; then 1199 AC_MSG_RESULT([ build with IPv4 support : "yes"]) 1200else 1201 AC_MSG_RESULT([ build with IPv4 support : "no"]) 1202fi 1203if test "x$build_ipv6" != "xno"; then 1204 AC_MSG_RESULT([ build with IPv6 support : "yes"]) 1205else 1206 AC_MSG_RESULT([ build with IPv6 support : "no"]) 1207fi 1208if test "x$build_af_unix" != "xno"; then 1209 AC_MSG_RESULT([ build with Unix socket support : "yes"]) 1210else 1211 AC_MSG_RESULT([ build with Unix socket support : "no"]) 1212fi 1213if test "x$build_tcp" != "xno"; then 1214 AC_MSG_RESULT([ build with TCP support : "yes"]) 1215else 1216 AC_MSG_RESULT([ build with TCP support : "no"]) 1217fi 1218if test "x$with_gnutls" = "xyes" -o "x$with_gnutls_auto" = "xyes"; then 1219 AC_MSG_RESULT([ build DTLS support : "yes"]) 1220 AC_MSG_RESULT([ --> GnuTLS around : "yes" (found GnuTLS $gnutls_version)]) 1221 AC_MSG_RESULT([ GNUTLS_CFLAGS : "$GnuTLS_CFLAGS"]) 1222 AC_MSG_RESULT([ GNUTLS_LIBS : "$GnuTLS_LIBS"]) 1223fi 1224if test "x$with_openssl" = "xyes" -o "x$with_openssl_auto" = "xyes"; then 1225 AC_MSG_RESULT([ build DTLS support : "yes"]) 1226 AC_MSG_RESULT([ --> OpenSSL around : "yes" (found OpenSSL $openssl_version)]) 1227 AC_MSG_RESULT([ OPENSSL_CFLAGS : "$OpenSSL_CFLAGS"]) 1228 AC_MSG_RESULT([ OPENSSL_LIBS : "$OpenSSL_LIBS"]) 1229fi 1230if test "x$with_mbedtls" = "xyes" -o "x$with_mbedtls_auto" = "xyes"; then 1231 AC_MSG_RESULT([ build DTLS support : "yes"]) 1232 AC_MSG_RESULT([ --> Mbed TLS around : "yes" (found Mbed TLS $mbedtls_version)]) 1233 AC_MSG_RESULT([ MBEDTLS_CFLAGS : "$MbedTLS_CFLAGS"]) 1234 AC_MSG_RESULT([ MBEDTLS_LIBS : "$MbedTLS_LIBS"]) 1235fi 1236if test "x$with_tinydtls" = "xyes"; then 1237 AC_MSG_RESULT([ build DTLS support : "yes"]) 1238 if test "x$have_submodule_tinydtls" = "xyes"; then 1239 AC_MSG_RESULT([ --> TinyDTLS around : "yes" (submodule)]) 1240 else 1241 AC_MSG_RESULT([ --> TinyDTLS around : "yes (found TinyDTLS $tinydtls_version)"]) 1242 fi 1243 AC_MSG_RESULT([ TinyDTLS_CFLAGS : "$DTLS_CFLAGS"]) 1244 AC_MSG_RESULT([ TinyDTLS_LIBS : "$DTLS_LIBS"]) 1245fi 1246if test "x$build_dtls" != "xyes"; then 1247 AC_MSG_RESULT([ build DTLS support : "no"]) 1248fi 1249if test "x$build_add_default_names" = "xyes"; then 1250 AC_MSG_RESULT([ add default names : "yes"]) 1251else 1252 AC_MSG_RESULT([ add default names : "no"]) 1253fi 1254if test "x$build_observe_persist" = "xyes"; then 1255 AC_MSG_RESULT([ build Observe Persist : "yes"]) 1256else 1257 AC_MSG_RESULT([ build Observe Persist : "no"]) 1258fi 1259if test "x$have_epoll" = "xyes"; then 1260 AC_MSG_RESULT([ build using epoll : "$with_epoll"]) 1261fi 1262AC_MSG_RESULT([ enable small stack size : "$enable_small_stack"]) 1263if test "x$build_async" != "xno"; then 1264 AC_MSG_RESULT([ enable separate responses : "yes"]) 1265else 1266 AC_MSG_RESULT([ enable separate responses : "no"]) 1267fi 1268if test "x$build_oscore" != "xno"; then 1269 AC_MSG_RESULT([ enable OSCORE support : "yes"]) 1270else 1271 AC_MSG_RESULT([ enable OSCORE support : "no"]) 1272fi 1273if test "x$build_q_block" != "xno"; then 1274 AC_MSG_RESULT([ enable Q-Block support : "yes"]) 1275else 1276 AC_MSG_RESULT([ enable Q-Block support : "no"]) 1277fi 1278if test "x$enable_max_logging_level" != "x8"; then 1279 AC_MSG_RESULT([ enable max logging level : "$enable_max_logging_level"]) 1280else 1281 AC_MSG_RESULT([ enable max logging level : "none"]) 1282fi 1283if test "x$build_doxygen" = "xyes"; then 1284 AC_MSG_RESULT([ build doxygen pages : "yes"]) 1285 AC_MSG_RESULT([ --> Doxygen around : "yes" ($DOXYGEN $doxygen_version)]) 1286 if test "x$DOT" = "x"; then 1287 AC_MSG_RESULT([ --> dot around : "no" (DOT not found!)]) 1288 else 1289 AC_MSG_RESULT([ --> dot around : "yes" ($DOT $dot_version)]) 1290 fi 1291else 1292 if test "x$build_doxygen" = "xno"; then 1293 AC_MSG_RESULT([ build doxygen pages : "no"]) 1294 fi 1295fi 1296if test "x$build_manpages" = "xyes"; then 1297 AC_MSG_RESULT([ build man pages : "yes"]) 1298else 1299 AC_MSG_RESULT([ build man pages : "no"]) 1300fi 1301if test "x$build_tests" = "xyes"; then 1302 AC_MSG_RESULT([ build unit test binary : "yes"]) 1303else 1304 AC_MSG_RESULT([ build unit test binary : "no"]) 1305fi 1306if test "x$build_examples" = "xyes"; then 1307 AC_MSG_RESULT([ build examples : "yes"]) 1308else 1309 AC_MSG_RESULT([ build examples : "no"]) 1310fi 1311if test "x$build_examples_source" = "xyes"; then 1312 AC_MSG_RESULT([ install examples source : "yes"]) 1313else 1314 AC_MSG_RESULT([ install examples source : "no"]) 1315fi 1316if test "x$build_gcov" = "xyes"; then 1317 AC_MSG_RESULT([ build with gcov support : "yes"]) 1318else 1319 AC_MSG_RESULT([ build with gcov support : "no"]) 1320fi 1321if test "x$enable_shared" = "xyes"; then 1322 AC_MSG_RESULT([ build shared library : "yes"]) 1323else 1324 AC_MSG_RESULT([ build shared library : "no"]) 1325fi 1326if test "x$enable_static" = "xyes"; then 1327 AC_MSG_RESULT([ build static library : "yes"]) 1328else 1329 AC_MSG_RESULT([ build static library : "no"]) 1330fi 1331