twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

configure.ac (11673B)


      1 #                                               -*- Autoconf -*-
      2 # Process this file with autoconf to produce a configure script.
      3 #
      4 #  This file is part of TALER
      5 #  Copyright (C) 2014-2025 Taler Systems SA
      6 #
      7 #  TALER is free software; you can redistribute it and/or modify it under the
      8 #  terms of the GNU General Public License as published by the Free Software
      9 #  Foundation; either version 3, or (at your option) any later version.
     10 #
     11 #  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     12 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     13 #  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     14 #
     15 #  You should have received a copy of the GNU General Public License along with
     16 #  TALER; see the file COPYING.  If not, If not, see <http://www.gnu.org/license>
     17 #
     18 #
     19 AC_PREREQ([2.71])
     20 AC_INIT([taler-twister],[1.1.0],[taler-bug@gnunet.org])
     21 AC_CONFIG_SRCDIR([src/twister/taler-twister.c])
     22 AC_CONFIG_HEADERS([twister_config.h])
     23 # support for non-recursive builds
     24 AM_INIT_AUTOMAKE([subdir-objects 1.9 tar-pax])
     25 
     26 # pretty build rules
     27 AM_SILENT_RULES([yes])
     28 
     29 AC_CONFIG_MACRO_DIR([m4])
     30 
     31 LT_INIT
     32 
     33 AC_MSG_CHECKING([whether to compile documentation ONLY])
     34 AC_ARG_ENABLE([only-doc],
     35   [AS_HELP_STRING([--enable-only-doc], [only compile Taler documentation])],
     36   [doc_only=${enableval}],
     37   [doc_only=no])
     38 
     39 
     40 AC_MSG_RESULT($doc_only)
     41 AM_CONDITIONAL([DOC_ONLY], [test "$doc_only" = "yes"])
     42 
     43 if test "$doc_only" != yes
     44 then
     45 
     46 # Checks for programs.
     47 
     48 AC_PROG_CC
     49 
     50 CFLAGS="-Wall $CFLAGS"
     51 
     52 # Checks for header files.
     53 AC_CHECK_HEADERS([stdint.h stdlib.h string.h unistd.h])
     54 
     55 
     56 # Require minimum libgcrypt version
     57 need_libgcrypt_version=1.6.1
     58 AC_DEFINE_UNQUOTED([NEED_LIBGCRYPT_VERSION], ["$need_libgcrypt_version"],
     59                                              [minimum version of libgcrypt required])
     60 AM_PATH_LIBGCRYPT([$need_libgcrypt_version])
     61 
     62 
     63 # Check for GNUnet's libgnunetutil.
     64 libgnunetutil=0
     65 AC_MSG_CHECKING([for libgnunetutil])
     66 AC_ARG_WITH(gnunet,
     67             [AS_HELP_STRING([--with-gnunet=PFX], [base of GNUnet installation])],
     68             [AC_MSG_RESULT([given as $with_gnunet])],
     69             [AC_MSG_RESULT(not given)
     70              with_gnunet=yes])
     71 AS_CASE([$with_gnunet],
     72         [yes], [],
     73         [no], [AC_MSG_ERROR([--with-gnunet is required])],
     74         [LDFLAGS="-L$with_gnunet/lib $LDFLAGS"
     75          CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"])
     76 AC_CHECK_HEADERS([gnunet/gnunet_util_lib.h],
     77  [AC_CHECK_LIB([gnunetutil], [GNUNET_SCHEDULER_run], libgnunetutil=1)])
     78 AS_IF([test $libgnunetutil != 1],
     79   [AC_MSG_ERROR([[
     80 ***
     81 *** You need libgnunetutil to build this program.
     82 *** This library is part of GNUnet, available at
     83 ***   https://gnunet.org
     84 *** ]])])
     85 
     86 # Check for GNUnet's libgnunetjson.
     87 libgnunetjson=0
     88 AC_MSG_CHECKING([for libgnunetjson])
     89 AC_ARG_WITH(gnunet,
     90             [AS_HELP_STRING([--with-gnunet=PFX], [base of GNUnet installation])],
     91             [AC_MSG_RESULT([given as $with_gnunet])],
     92             [AC_MSG_RESULT(not given)
     93              with_gnunet=yes])
     94 AS_CASE([$with_gnunet],
     95         [yes], [],
     96         [no], [AC_MSG_ERROR([--with-gnunet is required])],
     97         [LDFLAGS="-L$with_gnunet/lib $LDFLAGS"
     98          CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"])
     99 AC_CHECK_HEADERS([gnunet/gnunet_json_lib.h],
    100  [AC_CHECK_LIB([gnunetjson], [GNUNET_JSON_parse], libgnunetjson=1)])
    101 AS_IF([test $libgnunetjson != 1],
    102   [AC_MSG_ERROR([[
    103 ***
    104 *** You need libgnunetjson to build this program.
    105 *** Make sure you have libjansson installed while
    106 *** building GNUnet.
    107 *** ]])])
    108 
    109 
    110 # Save before checking libcurl
    111 CFLAGS_SAVE=$CFLAGS
    112 LDFLAGS_SAVE=$LDFLAGS
    113 LIBS_SAVE=$LIBS
    114 
    115 # check for libcurl
    116 LIBCURL_CHECK_CONFIG(,7.34.0,[curl=1],[curl=0])
    117 
    118 # cURL must support CURLINFO_TLS_SESSION, version >= 7.34
    119 AS_IF([test "x$curl" = x1],[
    120  AC_CHECK_HEADER([curl/curl.h],
    121   [AC_CHECK_DECLS(CURLINFO_TLS_SESSION,[curl=1],[curl=0],[[#include <curl/curl.h>]])],
    122   [curl=0])
    123 ])
    124 
    125 # libcurl should be mutually exclusive
    126 AS_IF([test "$curl" = 1],
    127       AM_CONDITIONAL(HAVE_LIBCURL, true)
    128       AC_DEFINE([HAVE_LIBCURL],[1],[Have libcurl])
    129       [LIBCURL_LIBS="-lcurl"],
    130       [AC_MSG_ERROR([FATAL: No libcurl])])
    131 
    132 AC_SUBST([LIBCURL_LIBS])
    133 
    134 
    135 # Check for GNUnet's libgnunetcurl.
    136 libgnunetcurl=0
    137 AC_MSG_CHECKING([for libgnunetcurl])
    138 AC_ARG_WITH(gnunet,
    139             [AS_HELP_STRING([--with-gnunet=PFX], [base of GNUnet installation])],
    140             [AC_MSG_RESULT([given as $with_gnunet])],
    141             [AC_MSG_RESULT(not given)
    142              with_gnunet=yes])
    143 AS_CASE([$with_gnunet],
    144         [yes], [],
    145         [no], [AC_MSG_ERROR([--with-gnunet is required])],
    146         [LDFLAGS="-L$with_gnunet/lib $LDFLAGS"
    147          CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"])
    148 AC_CHECK_HEADERS([gnunet/gnunet_curl_lib.h],
    149  [AC_CHECK_LIB([gnunetcurl], [GNUNET_CURL_get_select_info], libgnunetcurl=1)])
    150 AS_IF([test $libgnunetcurl != 1],
    151   [AC_MSG_ERROR([[
    152 ***
    153 *** You need libgnunetcurl to build this program.
    154 *** Make sure you have libcurl installed while
    155 *** building GNUnet.
    156 *** ]])])
    157 
    158 
    159 # check for libmicrohttpd
    160 microhttpd=0
    161 AC_MSG_CHECKING([for microhttpd])
    162 AC_ARG_WITH([microhttpd],
    163             [AS_HELP_STRING([--with-microhttpd=PFX], [base of microhttpd installation])],
    164             [AC_MSG_RESULT([given as $with_microhttpd])],
    165             [AC_MSG_RESULT([not given])
    166              with_microhttpd=yes])
    167 AS_CASE([$with_microhttpd],
    168         [yes], [],
    169         [no], [AC_MSG_ERROR([--with-microhttpd is required])],
    170         [LDFLAGS="-L$with_microhttpd/lib $LDFLAGS"
    171          CPPFLAGS="-I$with_microhttpd/include $CPPFLAGS"])
    172 AC_CHECK_LIB(microhttpd,MHD_start_daemon,
    173   [AC_CHECK_HEADER([microhttpd.h],[microhttpd=1])])
    174 AC_CHECK_DECL([MHD_DAEMON_INFO_CURRENT_CONNECTIONS],,[microhttpd=0],[[#include <microhttpd.h>]])
    175 AS_IF([test $microhttpd = 0],
    176   [AC_MSG_ERROR([[
    177 ***
    178 *** You need libmicrohttpd >= 0.9.39 to build this program.
    179 *** ]])])
    180 
    181 
    182 # check for libjansson (Jansson JSON library)
    183 jansson=0
    184 AC_MSG_CHECKING([for jansson])
    185 AC_ARG_WITH([jansson],
    186             [AS_HELP_STRING([--with-jansson=PFX], [base of jansson installation])],
    187             [AC_MSG_RESULT([given as $with_jansson])],
    188             [AC_MSG_RESULT([not given])
    189              with_jansson=yes])
    190 AS_CASE([$with_jansson],
    191         [yes], [],
    192         [no], [AC_MSG_ERROR([--with-jansson is required])],
    193         [LDFLAGS="-L$with_jansson/lib $LDFLAGS"
    194          CPPFLAGS="-I$with_jansson/include $CPPFLAGS"])
    195 AC_CHECK_LIB(jansson,json_pack,
    196   [AC_CHECK_HEADER([jansson.h],[jansson=1])])
    197 AS_IF([test $jansson = 0],
    198   [AC_MSG_ERROR([[
    199 ***
    200 *** You need libjansson to build this program.
    201 *** ]])])
    202 
    203 
    204 TALER_LIB_LDFLAGS="-export-dynamic -no-undefined"
    205 TALER_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined"
    206 
    207 AC_SUBST(TALER_LIB_LDFLAGS)
    208 AC_SUBST(TALER_PLUGIN_LDFLAGS)
    209 
    210 CFLAGS_SAVE=$CFLAGS
    211 LDFLAGS_SAVE=$LDFLAGS
    212 LIBS_SAVE="$LIBS"
    213 
    214 
    215 # test for zlib
    216 SAVE_LDFLAGS=$LDFLAGS
    217 SAVE_CPPFLAGS=$CPPFLAGS
    218 AC_ARG_WITH(zlib,
    219 	    [  --with-zlib[[=DIR]] use libz in DIR],
    220 	    [AS_IF([test "$withval" = "no"],
    221 		   [AC_MSG_ERROR([Twister requires zlib])],
    222 		   [test "$withval" != "yes"],
    223 		   [
    224 		     Z_DIR=$withval
    225 		     CPPFLAGS="${CPPFLAGS} -I$withval/include"
    226 		     LDFLAGS="${LDFLAGS} -L$withval/lib"
    227 		   ])
    228 	    ])
    229 AC_CHECK_HEADER(zlib.h,
    230 		[],
    231 	       	[AC_MSG_ERROR([GNUnet requires zlib])])
    232 AC_CHECK_LIB(z, compress2,
    233 	     [
    234 	      AC_DEFINE([HAVE_ZLIB], [], [Have compression library])
    235 	      if test "x${Z_DIR}" != "x"; then
    236 		      Z_CFLAGS="-I${Z_DIR}/include"
    237 		      Z_LIBS="-L${Z_DIR}/lib -lz"
    238 	      else
    239 		      Z_LIBS="-lz"
    240 	      fi],
    241 	      [AC_MSG_ERROR([Twister requires zlib])])
    242 AC_SUBST(Z_CFLAGS)
    243 AC_SUBST(Z_LIBS)
    244 
    245 
    246 # should developer logic be compiled (not-for-production code)?
    247 AC_MSG_CHECKING(whether to compile developer logic)
    248 AC_ARG_ENABLE([developer-mode],
    249    [AS_HELP_STRING([--enable-developer-mode], [enable compiling developer code])],
    250    [enable_developer=${enableval}],
    251    [enable_developer=yes])
    252 AC_MSG_RESULT($enable_developer)
    253 AM_CONDITIONAL([HAVE_DEVELOPER], [test "x$enable_developer" = "xyes"])
    254 enable_dev=1
    255 AS_IF([test "x$enableval" = "xno"], [enable_dev=0])
    256 # developer-logic requires a more recent MHD than usual.
    257 AC_CHECK_DECL([MHD_OPTION_NOTIFY_CONNECTION],,[enable_dev=0],[[#include <microhttpd.h>]])
    258 AC_DEFINE_UNQUOTED([HAVE_DEVELOPER],[$enable_dev],[1 if developer logic is enabled, 0 otherwise])
    259 
    260 
    261 
    262 # Adam shostack suggests the following for Windows:
    263 # -D_FORTIFY_SOURCE=2 -fstack-protector-all
    264 AC_ARG_ENABLE(gcc-hardening,
    265    AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
    266 [if test x$enableval = xyes; then
    267     CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all"
    268     CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
    269     CFLAGS="$CFLAGS --param ssp-buffer-size=1"
    270     LDFLAGS="$LDFLAGS -pie"
    271 fi])
    272 
    273 
    274 # Linker hardening options
    275 # Currently these options are ELF specific - you can't use this with MacOSX
    276 AC_ARG_ENABLE(linker-hardening,
    277   AS_HELP_STRING(--enable-linker-hardening, enable linker security fixups),
    278 [if test x$enableval = xyes; then
    279    LDFLAGS="$LDFLAGS -z relro -z now"
    280 fi])
    281 
    282 
    283 # logging
    284 extra_logging=0
    285 AC_ARG_ENABLE([logging],
    286    AS_HELP_STRING([--enable-logging@<:@=value@:>@],[Enable logging calls. Possible values: yes,no,verbose ('yes' is the default)]),
    287    [AS_IF([test "x$enableval" = "xyes"], [],
    288           [test "x$enableval" = "xno"], [AC_DEFINE([GNUNET_CULL_LOGGING],[],[Define to cull all logging calls])],
    289           [test "x$enableval" = "xverbose"], [extra_logging=1]
    290           [test "x$enableval" = "xveryverbose"], [extra_logging=2])
    291    ], [])
    292 AC_DEFINE_UNQUOTED([GNUNET_EXTRA_LOGGING],[$extra_logging],[1 if extra logging is enabled, 2 for very verbose extra logging, 0 otherwise])
    293 
    294 # gcov compilation
    295 AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
    296 AC_ARG_ENABLE([coverage],
    297               AS_HELP_STRING([--enable-coverage],
    298                              [compile the library with code coverage support]),
    299               [use_gcov=${enableval}],
    300               [use_gcov=no])
    301 AC_MSG_RESULT($use_gcov)
    302 AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
    303 
    304 # version info
    305 AC_PATH_PROG(gitcommand, git)
    306 AC_MSG_CHECKING(for source being under a VCS)
    307 git_version=
    308 AS_IF([test ! "X$gitcommand" = "X"],
    309 [
    310   git_version=$(cd $srcdir ; git rev-list --full-history --all --abbrev-commit | head -n 1 2>/dev/null)
    311 ])
    312 AS_IF([test "X$git_version" = "X"],
    313   [
    314     vcs_name="no"
    315     vcs_version="\"release\""
    316   ],
    317   [
    318     vcs_name="yes, git-svn"
    319     vcs_version="\"git-$git_version\""
    320   ])
    321 AC_MSG_RESULT($vcs_name)
    322 
    323 AC_MSG_CHECKING(VCS version)
    324 AC_MSG_RESULT($vcs_version)
    325 AC_DEFINE_UNQUOTED(VCS_VERSION, [$vcs_version], [VCS revision/hash or tarball version])
    326 
    327 
    328 # Checks for typedefs, structures, and compiler characteristics.
    329 AC_TYPE_PID_T
    330 AC_TYPE_SIZE_T
    331 AC_TYPE_UINT16_T
    332 AC_TYPE_UINT32_T
    333 AC_TYPE_UINT64_T
    334 AC_TYPE_INTMAX_T
    335 AC_TYPE_UINTMAX_T
    336 
    337 # Checks for library functions.
    338 AC_CHECK_FUNCS([strdup])
    339 
    340 
    341 AC_ARG_ENABLE([[doc]],
    342   [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], ,
    343     [enable_doc=yes])
    344 test "x$enable_doc" = "xno" || enable_doc=yes
    345 AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = "xyes"])
    346 
    347 
    348 else
    349 
    350 # logic if doc_only is set, make sure conditionals are still defined
    351 AM_CONDITIONAL([HAVE_LIBCURL], [false])
    352 AM_CONDITIONAL([HAVE_DEVELOPER], [false])
    353 AM_CONDITIONAL([USE_COVERAGE], [false])
    354 AM_CONDITIONAL([ENABLE_DOC], [true])
    355 
    356 
    357 # end of 'doc_only'
    358 fi
    359 
    360 AC_CONFIG_FILES([Makefile
    361                  doc/Makefile
    362                  src/Makefile
    363                  src/include/Makefile
    364                  src/twister/Makefile
    365                  src/test/Makefile
    366                  ])
    367 AC_OUTPUT