diff options
Diffstat (limited to 'm4')
-rw-r--r-- | m4/am-common.m4 | 375 | ||||
-rw-r--r-- | m4/am-enable-threads.m4 | 44 | ||||
-rw-r--r-- | m4/am-host.m4 | 44 | ||||
-rw-r--r-- | m4/am-with-opentracing.m4 | 71 |
4 files changed, 534 insertions, 0 deletions
diff --git a/m4/am-common.m4 b/m4/am-common.m4 new file mode 100644 index 0000000..11c310b --- /dev/null +++ b/m4/am-common.m4 @@ -0,0 +1,375 @@ +dnl am-common.m4 by Miroslav Zagorac <mzagorac@haproxy.com> +dnl +AC_DEFUN([AX_TYPE_BOOL_T], [AC_CHECK_TYPE([bool_t], [unsigned char])]) +AC_DEFUN([AX_TYPE_UNCHAR], [AC_CHECK_TYPE([unchar], [unsigned char])]) +AC_DEFUN([AX_TYPE_USHORT], [AC_CHECK_TYPE([ushort], [unsigned short])]) +AC_DEFUN([AX_TYPE_ULONG], [AC_CHECK_TYPE([ulong], [unsigned long])]) +AC_DEFUN([AX_TYPE_UINT], [AC_CHECK_TYPE([uint], [unsigned int])]) + +AC_DEFUN([AX_VARIABLES_STORE], [ + _saved_cppflags="${CPPFLAGS}" + _saved_cflags="${CFLAGS}" + _saved_cxxflags="${CXXFLAGS}" + _saved_ldflags="${LDFLAGS}" + _saved_libs="${LIBS}" +]) + +AC_DEFUN([AX_VARIABLES_RESTORE], [ + CPPFLAGS="${_saved_cppflags}" + CFLAGS="${_saved_cflags}" + CXXFLAGS="${_saved_cxxflags}" + LDFLAGS="${_saved_ldflags}" + LIBS="${_saved_libs}" +]) + +AC_DEFUN([AX_VARIABLES_INIT], [ + SET_CPPFLAGS= + SET_CFLAGS= + SET_CXXFLAGS= + SET_LDFLAGS= + SET_LIBS= +]) + +AC_DEFUN([AX_VARIABLES_SET], [ + CPPFLAGS="${CPPFLAGS} ${SET_CPPFLAGS}" + CFLAGS="${CFLAGS} ${SET_CFLAGS}" + CXXFLAGS="${CXXFLAGS} ${SET_CXXFLAGS}" + LDFLAGS="${LDFLAGS} ${SET_LDFLAGS}" + LIBS="${LIBS} ${SET_LIBS}" +]) + +dnl Check which options the C compiler supports. +dnl +AC_DEFUN([AX_PROG_CC_SET], [ + _var_cflags= + _loop_cflags= + + AX_VARIABLES_STORE + + case "${CC}" in + *gcc*) + _var_cflags="\ + -Wall \ + -Wextra \ + -Waggregate-return \ + -Wbad-function-cast \ + -Wcast-align \ + -Wchar-subscripts \ + -Wcomment \ + -Wfloat-equal \ + -Wimplicit \ + -Winline \ + -Wmain \ + -Wmissing-braces \ + -Wmissing-declarations \ + -Wmissing-noreturn \ + -Wmissing-prototypes \ + -Wnested-externs \ + -Wparentheses \ + -Wpointer-arith \ + -Wreturn-type \ + -Wsequence-point \ + -Wshadow \ + -Wstrict-prototypes \ + -Wswitch \ + -Wtrigraphs \ + -Wundef \ + -Wuninitialized \ + -Wunused \ + -Wwrite-strings" + if test "${enable_debug}" = "yes"; then + _var_cflags="${_var_cflags} \ + -Wformat=2" + else + _var_cflags="${_var_cflags} \ + -Wformat-security \ + -Wformat-y2k" + fi + ;; + cc|clang) + case "${host_os}" in + *solaris*) + _var_cflags="-xCC" + ;; + *freebsd1?.*) + _var_cflags= + ;; + esac + ;; + esac + + TMP_CFLAGS="${CFLAGS}" + AC_LANG_PUSH([C]) + for _loop_cflags in ${_var_cflags} $1; do + AC_MSG_CHECKING([whether ${CC} accepts ${_loop_cflags}]) + CFLAGS="${TMP_CFLAGS} ${_loop_cflags}" + AC_TRY_COMPILE([], [], + [AC_MSG_RESULT([ yes]) + SET_CFLAGS="${SET_CFLAGS} ${_loop_cflags}"], + [AC_MSG_RESULT([ no])] + ) + done + AC_LANG_POP([C]) + CFLAGS="${TMP_CFLAGS}" + + AX_VARIABLES_RESTORE +]) + +dnl Check which options the C++ compiler supports. +dnl +AC_DEFUN([AX_PROG_CXX_SET], [ + _var_cxxflags= + _loop_cxxflags= + + AX_VARIABLES_STORE + + case "${CXX}" in + c++|clang++) + case "${host_os}" in + *freebsd1?.*) + _var_cxxflags="-Wno-extern-c-compat" + ;; + esac + ;; + *g++*) + _var_cxxflags="\ + -Wall \ + -Wextra \ + -Wcast-align \ + -Wchar-subscripts \ + -Wcomment \ + -Wfloat-equal \ + -Winline \ + -Wmain \ + -Wmissing-braces \ + -Wmissing-declarations \ + -Wmissing-noreturn \ + -Wparentheses \ + -Wpointer-arith \ + -Wreturn-type \ + -Wsequence-point \ + -Wshadow \ + -Wswitch \ + -Wtrigraphs \ + -Wundef \ + -Wuninitialized \ + -Wunused \ + -Wwrite-strings \ + \ + -Wconditionally-supported \ + -Wnamespaces \ + -Wno-invalid-offsetof \ + -Wno-terminate \ + -Wnoexcept \ + -Wold-style-cast \ + -Woverloaded-virtual \ + -Wsign-promo \ + -Wsized-deallocation \ + -Wstrict-null-sentinel \ + -Wuseless-cast \ + -Wvirtual-inheritance \ + -Wzero-as-null-pointer-constant" + if test "${enable_debug}" = "yes"; then + _var_cxxflags="${_var_cxxflags} \ + -Waggregate-return \ + -Wformat=2 \ + -Wmultiple-inheritance \ + -Wtemplates" + else + _var_cxxflags="${_var_cxxflags} \ + -Wformat-security \ + -Wformat-y2k" + fi + ;; + CC) + case "${host_os}" in + *solaris*) + _var_cxxflags= + ;; + esac + ;; + esac + + TMP_CXXFLAGS="${CXXFLAGS}" + AC_LANG_PUSH([C++]) + for _loop_cxxflags in ${_var_cxxflags} $1; do + AC_MSG_CHECKING([whether ${CXX} accepts ${_loop_cxxflags}]) + CXXFLAGS="${TMP_CXXFLAGS} ${_loop_cxxflags}" + AC_TRY_COMPILE([], [], + [AC_MSG_RESULT([ yes]) + SET_CXXFLAGS="${SET_CXXFLAGS} ${_loop_cxxflags}"], + [AC_MSG_RESULT([ no])] + ) + done + AC_LANG_POP([C++]) + CXXFLAGS="${TMP_CXXFLAGS}" + + AX_VARIABLES_RESTORE +]) + +dnl Check whether the C++ compiler has noexcept specifier. +dnl +AC_DEFUN([AX_CHECK_NOEXCEPT], [ + AC_MSG_CHECKING([whether the C++ compiler (${CXX}) has noexcept specifier]) + AC_LANG_PUSH([C++]) + AC_TRY_COMPILE([], + [void (*fp)() noexcept(false);], + [AC_MSG_RESULT([ yes])], + [CXXFLAGS="-std=gnu++11" + AC_MSG_RESULT([ no])] + ) + AC_LANG_POP([C++]) +]) + +dnl Check whether the C compiler has __DATE__ macro. +dnl +AC_DEFUN([AX_CHECK___DATE__], [ + AC_MSG_CHECKING([whether the C compiler (${CC}) has __DATE__ macro]) + AC_TRY_COMPILE([], + [char *test=__DATE__;], + [AC_MSG_RESULT([ yes])], + [AC_DEFINE_UNQUOTED([__DATE__], ["`date`"], [Define if your C compiled doesn't have __DATE__ macro.]) + AC_MSG_RESULT([ no])] + ) +]) + +dnl Check whether the C compiler has __func__ variable. +dnl +AC_DEFUN([AX_CHECK___FUNC__], [ + AC_MSG_CHECKING([whether the C compiler (${CC}) has __func__ variable]) + AC_TRY_COMPILE([#include <stdio.h>], + [printf ("%s", __func__);], + [AC_MSG_RESULT([ yes])], + [AC_DEFINE_UNQUOTED([__func__], ["__unknown__"], [Define if your C compiler doesn't have __func__ variable.]) + AC_MSG_RESULT([ no])] + ) +]) + +dnl Check whether the C compiler defines __STDC__. +dnl +AC_DEFUN([AX_CHECK___STDC__], [ + AC_MSG_CHECKING([whether the C compiler (${CC}) defines __STDC__]) + AC_TRY_COMPILE([], + [#ifndef __STDC__ + test_stdc (); + #endif], + [AC_MSG_RESULT([ yes]) + AC_DEFINE_UNQUOTED([ANSI_FUNC], [1], [Define if you use an ANSI C compiler.]) + stdc_defined="yes"], + [AC_MSG_RESULT([ no])] + ) +]) + +dnl +dnl +AC_DEFUN([AX_PROG_PKGCONFIG], [ + AC_CHECK_PROG(PKG_CONFIG, [pkg-config], [yes], [no], [], []) + test "${PKG_CONFIG}" = "no" && AC_MSG_ERROR([pkg-config not found]) +]) + +dnl +dnl +AC_DEFUN([AX_PATH_PKGCONFIG], [ + PKG_CONFIG_PATH= + _pc_prefix="${ac_default_prefix}" + # ovdje se ne smije zamijeniti $n sa ${n} jer su to argumenti m4 funkcije AX_PATH_PKGCONFIG + test "$1" = "yes" -o "$1" = "check" || _pc_prefix="$1" + + for _loop_path in \ + ${_pc_prefix}/lib \ + ${_pc_prefix}/lib/i386-linux-gnu \ + ${_pc_prefix}/lib/x86_64-linux-gnu \ + ${_pc_prefix}/amd64 \ + ${_pc_prefix}/lib32 \ + ${_pc_prefix}/lib64 \ + ${_pc_prefix}/share + do + test -d "${_loop_path}/pkgconfig" && \ + PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}${_loop_path}/pkgconfig" + done + AC_MSG_NOTICE([PKG_CONFIG_PATH=${PKG_CONFIG_PATH}]) +]) + +dnl Check whether the C compiler has __attribute__ keyword. +dnl +AC_DEFUN([AX_CHECK___ATTRIBUTE__], [ + AC_MSG_CHECKING([whether the C compiler (${CC}) has __attribute__ keyword]) + AC_TRY_COMPILE([void t1 () __attribute__ ((noreturn)); void t1 () { return; };], + [t1 ();], + [AC_MSG_RESULT([ yes]) + AC_DEFINE_UNQUOTED([__ATTRIBUTE__], [1], [Define if your C compiler has __attribute__ keyword.])], + [AC_MSG_RESULT([ no])] + ) +]) + +AC_DEFUN([AX_ENABLE_DEBUG], [ + AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], [compile with debugging symbols/functions])], + [if test "${enableval}" = "yes"; then + AC_DEFINE([DEBUG], [1], [Define to 1 if you want to include debugging options.]) + CFLAGS="${CFLAGS} -g -O0" + CXXFLAGS="${CXXFLAGS} -g -O0" + fi] + ) +]) + +AC_DEFUN([AX_ENABLE_GPROF], [ + AC_ARG_ENABLE([gprof], + [AS_HELP_STRING([--enable-gprof], [enable profiling with gprof])], + [if test "${enableval}" = "yes"; then + AC_DEFINE([GPROF], [1], [Define to 1 if you want to enable profiling with gprof.]) + CFLAGS="${CFLAGS} -pg" + CXXFLAGS="${CXXFLAGS} -pg" + LDFLAGS="${LDFLAGS} -pg" + fi] + ) +]) + +AC_DEFUN([AX_VARIABLE_SET], [ +_am_cache_test () +{ + _c= + + if test -n "${2}"; then + for _c in ${2}; do test "${_c}" = "${3}" && return 1; done + eval "${1}=\"${2} ${3}\"" + else + eval "${1}=\"${3}\"" + fi +} + + _am_var_resolved= + # ovdje se ne smije zamijeniti $n sa ${n} jer su to argumenti m4 funkcije AX_VARIABLE_SET + for _am_var_loop in $2; do + _am_cache_test _am_var_resolved "${_am_var_resolved}" "${_am_var_loop}" + done + $1=${_am_var_resolved} +]) + +AC_DEFUN([AX_SHOW_CONFIG], [ + eval "bindir=${bindir}" + eval "datadir=${datadir}" + eval "sysconfdir=${sysconfdir}" + eval "mandir=${mandir}" + + echo + echo "${PACKAGE_NAME} configuration:" + echo "--------------------------------------------------" + echo " package version : ${PACKAGE_VERSION}" + echo " library version : ${LIB_VERSION}" + echo " host operating system : ${host}" + echo " source code location : ${srcdir}" + echo " C compiler : ${CC}" + echo " C++ compiler : ${CXX}" + echo " preprocessor flags : ${CPPFLAGS}" + echo " C compiler flags : ${CFLAGS}" + echo " C++ compiler flags : ${CXXFLAGS}" + echo " linker flags : ${LDFLAGS}" + echo " libraries : ${LIBS}" + echo " configure options : ${ac_configure_args}" + echo " binary install path : ${bindir}" + echo " data install path : ${datadir}" + echo " configuration file path : ${sysconfdir}" + echo " man page install path : ${mandir}" + echo +]) diff --git a/m4/am-enable-threads.m4 b/m4/am-enable-threads.m4 new file mode 100644 index 0000000..629325f --- /dev/null +++ b/m4/am-enable-threads.m4 @@ -0,0 +1,44 @@ +dnl am-enable-threads.m4 by Miroslav Zagorac <mzagorac@haproxy.com> +dnl +AC_DEFUN([AX_ENABLE_THREADS], [ + AC_ARG_ENABLE([threads], + [AS_HELP_STRING([--enable-threads], [enable threads @<:@default=yes@:>@])], + [enable_threads="${enableval}"], + [enable_threads=yes] + ) + + if test "${enable_threads}" != "no"; then + HAVE_THREADS= + THREADS_CFLAGS= + THREADS_CPPFLAGS= + THREADS_LDFLAGS= + THREADS_LIBS= + + AX_VARIABLES_STORE + + LDFLAGS="${LDFLAGS} ${THREADS_LDFLAGS}" + CPPFLAGS="${CPPFLAGS} ${THREADS_CPPFLAGS}" + + AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([THREADS library not found])]) + AC_CHECK_HEADER([pthread.h], [], [AC_MSG_ERROR([THREADS library headers not found])]) + + HAVE_THREADS=yes + THREADS_LIBS="-lpthread" + + AC_DEFINE([USE_THREADS], [1], [Define to 1 for multi-thread support.]) + AC_DEFINE([_REENTRANT], [1], [Define to 1 for multi-thread support.]) + + AX_VARIABLES_RESTORE + + AC_MSG_NOTICE([THREADS environment variables:]) + AC_MSG_NOTICE([ THREADS_CFLAGS=${THREADS_CFLAGS}]) + AC_MSG_NOTICE([ THREADS_CPPFLAGS=${THREADS_CPPFLAGS}]) + AC_MSG_NOTICE([ THREADS_LDFLAGS=${THREADS_LDFLAGS}]) + AC_MSG_NOTICE([ THREADS_LIBS=${THREADS_LIBS}]) + + AC_SUBST([THREADS_CFLAGS]) + AC_SUBST([THREADS_CPPFLAGS]) + AC_SUBST([THREADS_LDFLAGS]) + AC_SUBST([THREADS_LIBS]) + fi +]) diff --git a/m4/am-host.m4 b/m4/am-host.m4 new file mode 100644 index 0000000..07d6353 --- /dev/null +++ b/m4/am-host.m4 @@ -0,0 +1,44 @@ +dnl am-host.m4 by Miroslav Zagorac <mzagorac@haproxy.com> +dnl +AC_DEFUN([AX_HOST], [ + dnl Get current date and time. + dnl + DATE=`date` + + dnl Get cannonical host. + dnl + AC_CANONICAL_HOST + AC_DEFINE_UNQUOTED([OSTYPE], ["${host}"], [Guessed OS type.]) + + dnl Posix variants + dnl + AC_USE_SYSTEM_EXTENSIONS + + dnl because ${${host_os%-*}##*-} does not work on stupid bash... + dnl + _host_os=${host_os%-*} + _host_os=${_host_os##*-} + + case "${host_os}" in + *osf*) + test "${stdc_defined}" = "yes" || \ + AC_DEFINE([__STDC__], [1], [Define to 1 if you use ANSI C compiler.]) + AC_DEFINE([_REENTRANT], [1], [Define to 1 only for OSF Unix.]) + AC_DEFINE([ANSI_FUNC], [1], [Define to 1 if you use ANSI C compiler.]) + AC_DEFINE([OSF], [1], [Define to 1 for OSF Unix.]) + ;; + + *solaris*) + AC_DEFINE([ANSI_FUNC], [1], [Define to 1 if you use ANSI C compiler.]) + AC_DEFINE([SOLARIS], [1], [Define to 1 for Solaris UNIX system.]) + ;; + + *sunos*) + AC_DEFINE([SUNOS], [1], [Define to 1 for SUNOS UNIX system.]) + ;; + + *linux*) + AC_DEFINE([LINUX], [1], [Define to 1 for Linux system.]) + ;; + esac +]) diff --git a/m4/am-with-opentracing.m4 b/m4/am-with-opentracing.m4 new file mode 100644 index 0000000..3bdb5ee --- /dev/null +++ b/m4/am-with-opentracing.m4 @@ -0,0 +1,71 @@ +dnl am-with-opentracing.m4 by Miroslav Zagorac <mzagorac@haproxy.com> +dnl +AC_DEFUN([AX_WITH_OPENTRACING], [ + AC_ARG_WITH([opentracing], + [AS_HELP_STRING([--with-opentracing@<:@=DIR@:>@], [use OPENTRACING library @<:@default=yes@:>@])], + [with_opentracing="${withval}"], + [with_opentracing=yes] + ) + + AX_CHECK_NOEXCEPT([]) + + if test "${with_opentracing}" != "no"; then + HAVE_OPENTRACING= + OPENTRACING_CFLAGS= + OPENTRACING_CXXFLAGS= + OPENTRACING_CPPFLAGS= + OPENTRACING_LDFLAGS= + OPENTRACING_LIBS="-lopentracing" + + if test -n "${with_opentracing}" -a "${with_opentracing}" != "yes" -a "${with_opentracing}" != "yes"; then + OPENTRACING_CPPFLAGS="-I${with_opentracing}/include" + + if test "${with_opentracing}" != "/usr"; then + if test "`uname`" = "Linux"; then + OPENTRACING_LDFLAGS="-L${with_opentracing}/lib -Wl,--rpath,${with_opentracing}/lib" + elif test "`uname`" = "FreeBSD"; then + OPENTRACING_LDFLAGS="-L${with_opentracing}/lib -Wl,-rpath -Wl,${with_opentracing}/lib" + else + OPENTRACING_LDFLAGS="-L${with_opentracing}/lib -R${with_opentracing}/lib" + fi + fi + fi + + AX_VARIABLES_STORE + + LIBS="${LDFLAGS} ${OPENTRACING_LIBS}" + LDFLAGS="${LDFLAGS} ${OPENTRACING_LDFLAGS}" + CFLAGS="${CFLAGS} ${OPENTRACING_CFLAGS}" + CXXFLAGS="${CXXFLAGS} ${OPENTRACING_CXXFLAGS}" + CPPFLAGS="${CPPFLAGS} ${OPENTRACING_CPPFLAGS}" + + AC_LANG_PUSH([C++]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM( + [[#include <opentracing/dynamic_load.h>]], + [[std::string e;] [auto a = opentracing::DynamicallyLoadTracingLibrary("", e);]] + )], + [], + [AC_MSG_ERROR([OPENTRACING library not found])] + ) + AC_CHECK_HEADER([opentracing/version.h], [], [AC_MSG_ERROR([OPENTRACING library headers not found])]) + AC_LANG_POP([C++]) + + HAVE_OPENTRACING=yes + + AX_VARIABLES_RESTORE + + AC_MSG_NOTICE([OPENTRACING environment variables:]) + AC_MSG_NOTICE([ OPENTRACING_CFLAGS=${OPENTRACING_CFLAGS}]) + AC_MSG_NOTICE([ OPENTRACING_CXXFLAGS=${OPENTRACING_CXXFLAGS}]) + AC_MSG_NOTICE([ OPENTRACING_CPPFLAGS=${OPENTRACING_CPPFLAGS}]) + AC_MSG_NOTICE([ OPENTRACING_LDFLAGS=${OPENTRACING_LDFLAGS}]) + AC_MSG_NOTICE([ OPENTRACING_LIBS=${OPENTRACING_LIBS}]) + + AC_SUBST([OPENTRACING_CFLAGS]) + AC_SUBST([OPENTRACING_CXXFLAGS]) + AC_SUBST([OPENTRACING_CPPFLAGS]) + AC_SUBST([OPENTRACING_LDFLAGS]) + AC_SUBST([OPENTRACING_LIBS]) + fi +]) |