configure.ac revision 264789
1104862Srum4_define([maj_ver], [0]) 2104862Srum4_define([med_ver], [4]) 3114402Srum4_define([min_ver], [0]) 4104862Srum4_define([so_version], [maj_ver:med_ver]) 5104862Srum4_define([ucl_version], [maj_ver.med_ver.min_ver]) 6104862Sru 7104862SruAC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl]) 8104862SruAC_CONFIG_SRCDIR([configure.ac]) 9104862SruAM_INIT_AUTOMAKE([1.11 foreign silent-rules -Wall -Wportability no-dist-gzip dist-xz]) 10104862Sru 11151497SruUCL_VERSION=ucl_version 12104862SruSO_VERSION=so_version 13104862Sru 1479543SruAC_SUBST(UCL_VERSION) 15104862SruAC_SUBST(SO_VERSION) 1618099Spst 17104862SruAC_PROG_CC_C99 1818099SpstAM_PROG_CC_C_O 19104862SruAM_PROG_AR 20151497SruLT_INIT 2118099SpstAC_CONFIG_MACRO_DIR([m4]) 22151497SruAC_CONFIG_HEADERS([config.h]) 23104862Sru 24104862SruAC_C_CONST 25104862SruAC_TYPE_SIZE_T 26104862Sru 27104862SruAC_CHECK_HEADERS_ONCE([fcntl.h unistd.h]) 28104862SruAC_TYPE_OFF_T 29104862SruAC_FUNC_MMAP 30104862SruAC_CHECK_HEADERS_ONCE([fcntl.h]) 31104862SruAC_CHECK_HEADERS_ONCE([sys/types.h]) 32104862SruAC_CHECK_HEADERS_ONCE([sys/stat.h]) 33104862SruAC_CHECK_HEADERS_ONCE([sys/param.h]) 3418099SpstAC_CHECK_HEADERS_ONCE([sys/mman.h]) 35104862SruAC_CHECK_HEADERS_ONCE([stdlib.h]) 36104862SruAC_CHECK_HEADERS_ONCE([stddef.h]) 37104862SruAC_CHECK_HEADERS_ONCE([stdarg.h]) 38104862SruAC_CHECK_HEADERS_ONCE([stdbool.h]) 39104862SruAC_CHECK_HEADERS_ONCE([stdint.h]) 40151497SruAC_CHECK_HEADERS_ONCE([string.h]) 41151497SruAC_CHECK_HEADERS_ONCE([unistd.h]) 42151497SruAC_CHECK_HEADERS_ONCE([ctype.h]) 43104862SruAC_CHECK_HEADERS_ONCE([errno.h]) 44104862SruAC_CHECK_HEADERS_ONCE([limits.h]) 45104862SruAC_CHECK_HEADERS_ONCE([libgen.h]) 46104862SruAC_CHECK_HEADERS_ONCE([stdio.h]) 47104862SruAC_CHECK_HEADERS_ONCE([float.h]) 4818099SpstAC_CHECK_HEADERS_ONCE([math.h]) 49104862Sru 50104862Srudnl Example of default-disabled feature 51104862SruAC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], 52104862Sru [Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [], 53104862Sru [enable_urls=no]) 5418099SpstAC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex], 55114402Sru [Enable regex checking for schema @<:@default=yes@:>@]), [], 56114402Sru [enable_regex=yes]) 57114402SruAC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures], 58114402Sru [Enable signatures check (requires openssl) @<:@default=no@:>@]), [], 59114402Sru [enable_signatures=no]) 60114402SruAC_ARG_ENABLE([utils], 61114402Sru AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]), 62114402Sru [case "${enableval}" in 63114402Sru yes) utils=true ;; 64114402Sru no) utils=false ;; 65114402Sru *) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;; 66114402Sru esac],[utils=false]) 67114402SruAM_CONDITIONAL([UTILS], [test x$utils = xtrue]) 68114402Sru 69114402SruAS_IF([test "x$enable_signatures" = "xyes"], [ 70114402Sru AC_SEARCH_LIBS([EVP_MD_CTX_create], [crypto], [ 71114402Sru AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).]) 72114402Sru LIBCRYPTO_LIB="-lcrypto" 73114402Sru LIBS_EXTRA="${LIBS_EXTRA} -lcrypto" 74114402Sru ], [AC_MSG_ERROR([unable to find the EVP_MD_CTX_create() function])]) 75104862Sru]) 76114402SruAC_SUBST(LIBCRYPTO_LIB) 77104862SruAC_PATH_PROG(PANDOC, pandoc, [/non/existent]) 78104862Sru 79114402SruAC_SEARCH_LIBS([clock_gettime], [rt], [], [ 80104862Sru AC_CHECK_HEADER([mach/mach_time.h], [ 8118099Spst AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin]) 82114402Sru ], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])]) 83114402Sru]) 84114402SruAC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])]) 85114402Sru 86114402SruAS_IF([test "x$enable_regex" = "xyes"], [ 87114402Sru AC_CHECK_HEADER([regex.h], [ 88114402Sru AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.]) 89114402Sru AC_SEARCH_LIBS([regexec], [regex], [ 90114402Sru AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [ 91114402Sru LIBREGEX_LIB="-lregex" 92114402Sru LIBS_EXTRA="${LIBS_EXTRA} -lregex" 93114402Sru ] 94114402Sru )], 95114402Sru [AC_MSG_ERROR([unable to find the regexec() function])])], 96114402Sru [AC_MSG_ERROR([unable to find the regex.h header]) 9718099Spst ], 98104862Sru [#include <sys/types.h>]) 99104862Sru]) 100104862SruAC_SUBST(LIBREGEX_LIB) 101104862Sru 102104862SruAS_IF([test "x$enable_urls" = "xyes"], [ 103114402Sru AC_CHECK_HEADER([fetch.h], [ 104104862Sru AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.]) 105104862Sru AC_CHECK_LIB(fetch, fetchXGet, [ 106114402Sru AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).]) 107114402Sru LIBFETCH_LIBS="-lfetch" 108114402Sru have_libfetch="yes" 109114402Sru LIBS_EXTRA="${LIBS_EXTRA} -lfetch" 110114402Sru ]) 11118099Spst ], [],[ 112104862Sru #include <stdio.h> 113114402Sru #ifdef HAVE_SYS_PARAM_H 114114402Sru #include <sys/param.h> 115114402Sru #endif 116114402Sru ]) 117114402Sru AC_SUBST(LIBFETCH_LIBS) 118114402Sru 119114402Sru AS_IF([ test "x$have_libfetch" != "xyes"], [ 12018099Spst dnl Fallback to libcurl 121104862Sru PKG_CHECK_MODULES([CURL], [libcurl], [ 122114402Sru AC_DEFINE(CURL_FOUND, 1, [Use libcurl]) 123114402Sru LIBS_EXTRA="${LIBS_EXTRA} -lcurl"], 124104862Sru [AC_MSG_ERROR([unable to find neither libfetch nor libcurl])]) 125114402Sru ]) 126114402Sru AC_SUBST(CURL_FOUND) 127114402Sru AC_SUBST(CURL_LIBS) 128104862Sru AC_SUBST(CURL_CFLAGS) 129104862Sru]) 130114402Sru 131114402SruAC_SUBST(LIBS_EXTRA) 132114402Sru 133114402SruAC_MSG_CHECKING(for GCC atomic builtins) 134114402SruAC_LINK_IFELSE([ 135114402Sru AC_LANG_SOURCE([[ 136104862Sru int main() { 137104862Sru volatile unsigned long val = 1; 138114402Sru __sync_synchronize(); 139104862Sru __sync_val_compare_and_swap(&val, 1, 0); 14018099Spst __sync_add_and_fetch(&val, 1); 141114402Sru __sync_sub_and_fetch(&val, 1); 14218099Spst return 0; 143104862Sru } 144114402Sru ]]) 145114402Sru], 146114402Sru[ 147114402Sru AC_MSG_RESULT([yes]) 148114402Sru AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics]) 149114402Sru], 150114402Sru[ 151114402Sru AC_MSG_RESULT([no]) 152114402Sru AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics]) 153114402Sru AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing]) 154114402Sru]) 155114402Sru 156114402SruAC_CONFIG_FILES(Makefile \ 157114402Sru src/Makefile \ 158114402Sru tests/Makefile \ 159114402Sru utils/Makefile \ 160114402Sru doc/Makefile \ 161104862Sru libucl.pc) 162104862SruAC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 163114402SruAC_OUTPUT 16418099Spst