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