Files
libcoap/configure.ac
T
Carsten Schoenert 96d875ab7a CFLAGS: reorder the various CFLAGS inside the files
Doing up some housekeeping around the used CFLAGS.
To be more generic put the default declaration for additional warning
CFLAGS into configure.ac and clean up the Makefile.am's.

There are the default CFLAGS variable that is a global variable if not
re adjusted inside the different targets.

The second variable for CFLAGS is the AM_CFLAGS definition that is used
inside a Makefile as a global variable.

There is also the possibility to graduate the CFLAGS for a single
target. But currently there are nothing more than one target within each
Makefile so we can set for now the target specific CFLAGS to the
AM_CFLAGS.

A new variable called WARNING_CFLAGS is inside the configure.ac created,
this variable holds all the warnings flags inside. The Makefile.am's are
taking the values and is setting the variable AM_CFLAGS which is used in
the target specific CFLAGS. Also the options 'DWITH_POSIX' and
'D_GNU_SOURCE' are now appended to the CFLAGS if the configure script is
detecting a *-[uc]linux* system.
2015-03-03 19:21:43 +01:00

300 lines
11 KiB
Plaintext

# configure.ac for the libcoap package
#
# Copyright (C) 2010-2015 Olaf Bergmann <bergmann@tzi.org>
# (C) 2015 Carsten Schoenert <c.schoenert@t-online.de>
#
# Please run 'autogen.sh' to let autoconf produce a configure script.
# Define the libcoap software version here. Note! The libtool versions are
# defined later.
m4_define([libcoap_major_version], [4])
m4_define([libcoap_minor_version], [1])
m4_define([libcoap_micro_version], [2])
m4_define([libcoap_version],[libcoap_major_version.libcoap_minor_version.libcoap_micro_version])
AC_INIT([libcoap], [libcoap_version], [libcoap-developers@lists.sourceforge.net], [libcoap], [http://libcoap.sourceforge.net/])
AC_PREREQ([2.59])
AM_INIT_AUTOMAKE([1.10 -Wall no-define])
# Generate one configuration header file for building the library itself with
# an autogenerated template. We need later a second one (include/libcoap.h)
# that will be installed alongside the library.
AC_CONFIG_HEADERS([coap_config.h])
AC_PROG_CC
AM_PROG_CC_C_O
AM_PROG_AR
AC_CONFIG_MACRO_DIR([m4])
# enable the automatically build of shared and static libraries, the unit
# tests needs the static library
LT_INIT([shared static])
# Setting the libtool versioning
###################################################################################
# #
# To set the version of the library, libtool provides the -version-info #
# parameter, which accepts three numbers, separated by colons, that are called #
# respectively, current, revision and age. Both their name and their behaviour, #
# nowadays, have to be considered fully arbitrary, as the explanation provided #
# in the official documentation is confusing to say the least, and can be, in #
# some cases, considered completely wrong. #
# https://autotools.io/libtool/version.html #
# #
###################################################################################
#
# How to work with the libtool versioning?
#
# Follow the followings steps from top to bottom. This means allways start at point 1
# if you plan to make a release and change the values.
# Every new library starts with a version 'current' (short 'c') = 0
# 'revision' (short 'r') = 0
# 'age' (short 'a') = 0
#
# Update the libtool versioning only immediately before a public release of libcoap.
#
# 1. If the library source code has changed at all since the last update, then
# increment revision (c:r:a becomes c:r+1:a).
# --> Increase the 'LT_LIBCOAP_REVISION' value with *everey* new software release.
#
# 2. If any interfaces [exported functions or data] have been added, removed, or
# changed since the last update, increment current, and set revision to 0
# (c:r:a becomes c+1:r=0:a).
# --> Increase the 'LT_LIBCOAP_CURRENT' value whenever as an interface has been added,
# removed or changed. This implies also a API change! You mostly have to change
# the 'libcoap_major_version' then too!
# --> Set 'LT_LIBCOAP_REVISION' to 0.
#
# 3. If any interfaces have been added since the last public release, then increment
# age (c:r:a becomes c:r:a+1). Adding new interfaces will make the library allways
# backwards compatable.
# --> Increase the 'LT_LIBCOAP_AGE' value only if the changes made to the ABI are
# backward compatible.
#
# 4. If any interfaces whitin the library have been removed since the last public
# release, then set age to 0.
# --> Set 'LT_LIBCOAP_AGE' to 0.
LT_LIBCOAP_CURRENT=0
LT_LIBCOAP_REVISION=0
LT_LIBCOAP_AGE=0
LIBCOAP_SO_VERSION=$LT_LIBCOAP_CURRENT.$LT_LIBCOAP_REVISION.$LT_LIBCOAP_AGE
# Announce the libtool version
AC_SUBST(LT_LIBCOAP_CURRENT)
AC_SUBST(LT_LIBCOAP_REVISION)
AC_SUBST(LT_LIBCOAP_AGE)
AC_SUBST(LIBCOAP_SO_VERSION)
# Defining the API Version
LIBCOAP_API_VERSION=1.0
AC_SUBST(LIBCOAP_API_VERSION)
# Adding some default warning options for code QS
# see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
# and http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
WARNING_CFLAGS="\
-pedantic \
-Wall \
-Wextra \
-Wformat-security \
-Winline \
-Wlogical-op \
-Wmissing-declarations \
-Wmissing-prototypes \
-Wnested-externs \
-Wpointer-arith \
-Wshadow \
-Wstrict-prototypes \
-Wswitch-default \
-Wswitch-enum \
-Wunused \
-Wunused-result \
"
AC_SUBST([WARNING_CFLAGS])
# configure options
# __documentation__
AC_ARG_ENABLE([documentation],
[AC_HELP_STRING([--enable-documentation],
[Enable building the documentation (default=yes)])],
[build_documentation="$enableval"],
[build_documentation="yes"])
if test "x$build_documentation" = "xyes"; then
# Check for doxygen
AC_PATH_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN"; then
if test "x$build_documentation" = "xyes"; then
AC_MSG_WARN([==> Doxygen not found - continuing without Doxygen support])
AC_MSG_WARN([==> The libcoap html documentation will not be build!])
doxygen_version="not found"
fi
else
AC_MSG_CHECKING([for compatible doxygen version])
doxygen_version=`$DOXYGEN --version`
AS_VERSION_COMPARE([$doxygen_version], [1.7.0],
[AC_MSG_RESULT([no])
DOXYGEN=""],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([yes])])
if test "x$DOXYGEN" = "x" -a "x$build_documentation" = "xyes"; then
AC_MSG_ERROR([==> Doxygen $doxygen_version too old. Doxygen 1.7+ required for documentation build.])
AC_MSG_ERROR([==> Install required doxygen version or disable the documentation using --disable-documentation])
else
# we found doxygen and the version is valid
DOC_DIR=doc
AC_SUBST(DOC_DIR)
# now checking dot (needed for graphics)
AC_PATH_PROG([DOT], [dot])
if test "x$DOT" = "x"; then
AC_MSG_WARN([==> dot not found - continuing without DOT support])
AC_MSG_WARN([==> The libcoap html documentation will be build without DOT graphics!])
HAVE_DOT="NO"
else
AC_MSG_CHECKING([for compatible dot version])
dot_version=`$DOT -V 2>&1|$GREP -oP '(?<=version\W)@<:@0-9.@:>@*(?=\W(.*))'`
AS_VERSION_COMPARE([$dot_version], [2.26.0],
[AC_MSG_RESULT([no])
DOT=""],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([yes])])
if test "x$DOT" = "x" -a "x$build_documentation" = "xyes"; then
AC_MSG_WARN([==> Graphviz dot $dot_version too old. Graphviz 2.26+ required for documentation build.])
AC_MSG_ERROR([==> Install required graphviz version or disable the documentation using --disable-documentation])
fi
# we found dot and the version is valid
HAVE_DOT="YES"
# exporting the test to doc/Doxygen(.in)
AC_SUBST(HAVE_DOT)
fi
fi
fi
fi
AM_CONDITIONAL([HAVE_DOXYGEN],
[test -n "$DOXYGEN"])AM_COND_IF([HAVE_DOXYGEN],
[AC_CONFIG_FILES([doc/Doxyfile])])
# configure options
# __tests__
AC_ARG_ENABLE([tests],
[AC_HELP_STRING([--enable-tests],
[Enable building the tests (default=no)])],
[build_tests="$enableval"],
[build_tests="no"])
if test "x$build_tests" = "xyes"; then
# CUnit ships not version within the pkgconfig file cunit.pc so we have to do some more work here
# Check for CUnit header files
AC_CHECK_HEADERS([CUnit/CUnit.h],
[],
[AC_MSG_WARN([==> You want to build the testing binary but the needed header files for CUnit could not be found!])
AC_MSG_ERROR([==> Install the package that contains the headers or disable the testing binary using --disable-tests.])
])
# Check now for libcunit
save_LIBS="$LIBS"
LIBS=""
CUNIT_LIBS=""
have_cunit=no
AC_SEARCH_LIBS([CU_add_suite],
[cunit],
[CUNIT_LIBS="$LIBS"
AC_DEFINE(HAVE_LIBCUNIT, [1], [Define if the system has libcunit])
],
[AC_MSG_WARN([==> You want to build the testing binary but the needed library 'libcunit' for linking could not be found!])
AC_MSG_ERROR([==> Install the package that contains the library or disable the testing binary using --disable-tests.])
])
LIBS="$save_LIBS"
AC_SUBST(CUNIT_LIBS)
HAVE_CUNIT="YES"
fi
AM_CONDITIONAL(HAVE_CUNIT, [test "x$CUNIT_LIBS" != "x"])
# Check for ctags
AC_ARG_VAR([CTAGS_PROG],[the 'ctag' program to use for make target 'update-map-file'])
AC_PATH_PROG([CTAGS_PROG],[ctags],[])
if test "x$CTAGS_PROG" = "x"; then
AC_MSG_NOTICE([==> Note: 'ctags' command not found!])
AC_MSG_WARN([==> Without ctags you will be unable to run the target 'update-map-file'!])
AC_MSG_WARN([==> This is no problem if you just want to build the library libcoap.])
fi
# Checks for header files.
AC_CHECK_HEADERS([assert.h arpa/inet.h limits.h netdb.h netinet/in.h \
stdlib.h string.h strings.h sys/socket.h sys/time.h \
time.h unistd.h sys/unistd.h syslog.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo \
strnlen])
AC_MSG_CHECKING([operating system])
case $host in
*-linux* | *-uclinux*)
AC_MSG_RESULT([Linux])
backend="linux"
CFLAGS="$CFLAGS -D_GNU_SOURCE -DWITH_POSIX"
;;
*)
AC_MSG_WARN([==> Currently unsupported operating system!])
AC_MSG_ERROR([==> If you can provide patches to support your operating system please write to 'libcoap-developers@lists.sourceforge.net'.])
esac
case $backend in
linux)
AC_DEFINE(OS_LINUX, 1, [Linux backend])
AC_SUBST(OS_LINUX)
;;
esac
# Override the various template files, currently just makefiles and the
# pkgconfig *.pc file.
# Later if the API version is changing dont forget to change the
# libcoap-$LIBCOAP_API_VERSION.pc.in file too!! You will have to change
# the 'Cflags' variable to something like
# Cflags: -I${includedir}/coap-@LIBCOAP_API_VERSION@
#
AC_CONFIG_FILES([
Makefile
doc/Makefile
tests/Makefile
libcoap-$LIBCOAP_API_VERSION.pc:libcoap-$LIBCOAP_API_VERSION.pc.in
])
AC_OUTPUT
AC_MSG_RESULT([
libcoap configuration summary:
libcoap package version : "$PACKAGE_VERSION"
libcoap library version : "$LIBCOAP_SO_VERSION"
libcoap API version : "$LIBCOAP_API_VERSION"
host system : "$host"]);
if test "x$build_documentation" = "xyes" -a "x$DOXYGEN" != "x"; then
AC_MSG_RESULT([ build documentation : "yes"])
AC_MSG_RESULT([ --> Doxygen around : "yes" ($DOXYGEN $doxygen_version)])
if test "x$DOT" = "x"; then
AC_MSG_RESULT([ --> dot around : "no" (DOT not found!)])
else
AC_MSG_RESULT([ --> dot around : "yes" ($DOT $dot_version)])
fi
else
if test "x$build_documentation" = "xno"; then
AC_MSG_RESULT([ build documentation : "no"])
fi
fi
if test "x$build_tests" = "xyes"; then
AC_MSG_RESULT([ build unit test binary : "yes"])
else
AC_MSG_RESULT([ build unit test binary : "no"])
fi