197bd480fSBaptiste Daroussinm4_define([maj_ver], [0]) 28e3b1ab2SBaptiste Daroussinm4_define([med_ver], [7]) 3*39ee7a7aSBaptiste Daroussinm4_define([min_ver], [3]) 4*39ee7a7aSBaptiste Daroussinm4_define([so_version], [5:0:2]) 597bd480fSBaptiste Daroussinm4_define([ucl_version], [maj_ver.med_ver.min_ver]) 697bd480fSBaptiste Daroussin 797bd480fSBaptiste DaroussinAC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl]) 897bd480fSBaptiste DaroussinAC_CONFIG_SRCDIR([configure.ac]) 94bf54857SBaptiste DaroussinAM_INIT_AUTOMAKE([1.11 foreign -Wall -Wportability no-dist-gzip dist-xz]) 104bf54857SBaptiste Daroussinm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 1197bd480fSBaptiste Daroussin 1297bd480fSBaptiste DaroussinUCL_VERSION=ucl_version 1397bd480fSBaptiste DaroussinSO_VERSION=so_version 1497bd480fSBaptiste Daroussin 1597bd480fSBaptiste DaroussinAC_SUBST(UCL_VERSION) 1697bd480fSBaptiste DaroussinAC_SUBST(SO_VERSION) 1797bd480fSBaptiste Daroussin 1897bd480fSBaptiste DaroussinAC_PROG_CC_C99 1997bd480fSBaptiste DaroussinAM_PROG_CC_C_O 2097bd480fSBaptiste DaroussinAM_PROG_AR 2197bd480fSBaptiste DaroussinLT_INIT 2297bd480fSBaptiste DaroussinAC_CONFIG_MACRO_DIR([m4]) 2397bd480fSBaptiste DaroussinAC_CONFIG_HEADERS([config.h]) 2497bd480fSBaptiste Daroussin 2597bd480fSBaptiste DaroussinAC_C_CONST 2697bd480fSBaptiste DaroussinAC_TYPE_SIZE_T 2797bd480fSBaptiste Daroussin 2897bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([fcntl.h unistd.h]) 2997bd480fSBaptiste DaroussinAC_TYPE_OFF_T 3097bd480fSBaptiste DaroussinAC_FUNC_MMAP 3197bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([fcntl.h]) 3297bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([sys/types.h]) 3397bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([sys/stat.h]) 3497bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([sys/param.h]) 3597bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([sys/mman.h]) 3697bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stdlib.h]) 3797bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stddef.h]) 3897bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stdarg.h]) 3997bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stdbool.h]) 4097bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stdint.h]) 4197bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([string.h]) 4297bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([unistd.h]) 4397bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([ctype.h]) 4497bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([errno.h]) 4597bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([limits.h]) 4697bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([libgen.h]) 4797bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stdio.h]) 4897bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([float.h]) 4997bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([math.h]) 50*39ee7a7aSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([endian.h sys/endian.h machine/endian.h]) 5197bd480fSBaptiste Daroussin 5297bd480fSBaptiste Daroussindnl Example of default-disabled feature 53b04a7a0bSBaptiste DaroussinAC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], 54b04a7a0bSBaptiste Daroussin [Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [], 55b04a7a0bSBaptiste Daroussin [enable_urls=no]) 56b04a7a0bSBaptiste DaroussinAC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex], 57b04a7a0bSBaptiste Daroussin [Enable regex checking for schema @<:@default=yes@:>@]), [], 58b04a7a0bSBaptiste Daroussin [enable_regex=yes]) 5997bd480fSBaptiste DaroussinAC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures], 60b04a7a0bSBaptiste Daroussin [Enable signatures check (requires openssl) @<:@default=no@:>@]), [], 61b04a7a0bSBaptiste Daroussin [enable_signatures=no]) 624bf54857SBaptiste DaroussinAC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua], 634bf54857SBaptiste Daroussin [Enable lua API build (requires lua libraries and headers) @<:@default=no@:>@]), [], 644bf54857SBaptiste Daroussin [enable_lua=no]) 6597bd480fSBaptiste DaroussinAC_ARG_ENABLE([utils], 66b04a7a0bSBaptiste Daroussin AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]), 6797bd480fSBaptiste Daroussin [case "${enableval}" in 6897bd480fSBaptiste Daroussin yes) utils=true ;; 6997bd480fSBaptiste Daroussin no) utils=false ;; 7097bd480fSBaptiste Daroussin *) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;; 7197bd480fSBaptiste Daroussin esac],[utils=false]) 7297bd480fSBaptiste DaroussinAM_CONDITIONAL([UTILS], [test x$utils = xtrue]) 7397bd480fSBaptiste Daroussin 7497bd480fSBaptiste DaroussinAS_IF([test "x$enable_signatures" = "xyes"], [ 7597bd480fSBaptiste Daroussin AC_SEARCH_LIBS([EVP_MD_CTX_create], [crypto], [ 7697bd480fSBaptiste Daroussin AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).]) 77b04a7a0bSBaptiste Daroussin LIBCRYPTO_LIB="-lcrypto" 7897bd480fSBaptiste Daroussin LIBS_EXTRA="${LIBS_EXTRA} -lcrypto" 7997bd480fSBaptiste Daroussin ], [AC_MSG_ERROR([unable to find the EVP_MD_CTX_create() function])]) 8097bd480fSBaptiste Daroussin]) 81b04a7a0bSBaptiste DaroussinAC_SUBST(LIBCRYPTO_LIB) 8297bd480fSBaptiste DaroussinAC_PATH_PROG(PANDOC, pandoc, [/non/existent]) 8397bd480fSBaptiste Daroussin 8497bd480fSBaptiste DaroussinAC_SEARCH_LIBS([clock_gettime], [rt], [], [ 8597bd480fSBaptiste Daroussin AC_CHECK_HEADER([mach/mach_time.h], [ 8697bd480fSBaptiste Daroussin AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin]) 8797bd480fSBaptiste Daroussin ], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])]) 8897bd480fSBaptiste Daroussin]) 8997bd480fSBaptiste DaroussinAC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])]) 9097bd480fSBaptiste Daroussin 91b04a7a0bSBaptiste DaroussinAS_IF([test "x$enable_regex" = "xyes"], [ 9297bd480fSBaptiste Daroussin AC_CHECK_HEADER([regex.h], [ 9397bd480fSBaptiste Daroussin AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.]) 94b04a7a0bSBaptiste Daroussin AC_SEARCH_LIBS([regexec], [regex], [ 95b04a7a0bSBaptiste Daroussin AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [ 96b04a7a0bSBaptiste Daroussin LIBREGEX_LIB="-lregex" 97b04a7a0bSBaptiste Daroussin LIBS_EXTRA="${LIBS_EXTRA} -lregex" 98b04a7a0bSBaptiste Daroussin ] 99b04a7a0bSBaptiste Daroussin )], 100b04a7a0bSBaptiste Daroussin [AC_MSG_ERROR([unable to find the regexec() function])])], 101b04a7a0bSBaptiste Daroussin [AC_MSG_ERROR([unable to find the regex.h header]) 10297bd480fSBaptiste Daroussin ], 10397bd480fSBaptiste Daroussin [#include <sys/types.h>]) 104b04a7a0bSBaptiste Daroussin]) 105b04a7a0bSBaptiste DaroussinAC_SUBST(LIBREGEX_LIB) 10697bd480fSBaptiste Daroussin 1074bf54857SBaptiste DaroussinAS_IF([test "x$enable_lua" = "xyes"], [ 1084bf54857SBaptiste Daroussin AX_PROG_LUA([5.1], [], [ 1094bf54857SBaptiste Daroussin AX_LUA_HEADERS([ 1104bf54857SBaptiste Daroussin AX_LUA_LIBS([ 1114bf54857SBaptiste Daroussin AC_DEFINE(HAVE_LUA, 1, [Define to 1 for lua support.]) 1124bf54857SBaptiste Daroussin with_lua="yes" 1134bf54857SBaptiste Daroussin ], [AC_MSG_ERROR([unable to find the lua libraries]) 1144bf54857SBaptiste Daroussin ]) 1154bf54857SBaptiste Daroussin ], [AC_MSG_ERROR([unable to find the lua header files]) 1164bf54857SBaptiste Daroussin ]) 1174bf54857SBaptiste Daroussin ], [AC_MSG_ERROR([unable to find the lua interpreter])]) 1184bf54857SBaptiste Daroussin], [with_lua="no"]) 1194bf54857SBaptiste Daroussin 1204bf54857SBaptiste DaroussinAM_CONDITIONAL([LUA_SUB], [test "$with_lua" = "yes"]) 1214bf54857SBaptiste Daroussin 12297bd480fSBaptiste DaroussinAS_IF([test "x$enable_urls" = "xyes"], [ 12397bd480fSBaptiste Daroussin AC_CHECK_HEADER([fetch.h], [ 12497bd480fSBaptiste Daroussin AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.]) 12597bd480fSBaptiste Daroussin AC_CHECK_LIB(fetch, fetchXGet, [ 12697bd480fSBaptiste Daroussin AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).]) 12797bd480fSBaptiste Daroussin LIBFETCH_LIBS="-lfetch" 12897bd480fSBaptiste Daroussin have_libfetch="yes" 12997bd480fSBaptiste Daroussin LIBS_EXTRA="${LIBS_EXTRA} -lfetch" 13097bd480fSBaptiste Daroussin ]) 13197bd480fSBaptiste Daroussin ], [],[ 13297bd480fSBaptiste Daroussin #include <stdio.h> 13397bd480fSBaptiste Daroussin #ifdef HAVE_SYS_PARAM_H 13497bd480fSBaptiste Daroussin #include <sys/param.h> 13597bd480fSBaptiste Daroussin #endif 13697bd480fSBaptiste Daroussin ]) 13797bd480fSBaptiste Daroussin AC_SUBST(LIBFETCH_LIBS) 13897bd480fSBaptiste Daroussin 13997bd480fSBaptiste Daroussin AS_IF([ test "x$have_libfetch" != "xyes"], [ 14097bd480fSBaptiste Daroussin dnl Fallback to libcurl 14197bd480fSBaptiste Daroussin PKG_CHECK_MODULES([CURL], [libcurl], [ 14297bd480fSBaptiste Daroussin AC_DEFINE(CURL_FOUND, 1, [Use libcurl]) 14397bd480fSBaptiste Daroussin LIBS_EXTRA="${LIBS_EXTRA} -lcurl"], 14497bd480fSBaptiste Daroussin [AC_MSG_ERROR([unable to find neither libfetch nor libcurl])]) 14597bd480fSBaptiste Daroussin ]) 14697bd480fSBaptiste Daroussin AC_SUBST(CURL_FOUND) 14797bd480fSBaptiste Daroussin AC_SUBST(CURL_LIBS) 14897bd480fSBaptiste Daroussin AC_SUBST(CURL_CFLAGS) 14997bd480fSBaptiste Daroussin]) 15097bd480fSBaptiste Daroussin 15197bd480fSBaptiste DaroussinAC_SUBST(LIBS_EXTRA) 15297bd480fSBaptiste Daroussin 153b04a7a0bSBaptiste DaroussinAC_MSG_CHECKING(for GCC atomic builtins) 154b04a7a0bSBaptiste DaroussinAC_LINK_IFELSE([ 155b04a7a0bSBaptiste Daroussin AC_LANG_SOURCE([[ 156b04a7a0bSBaptiste Daroussin int main() { 157b04a7a0bSBaptiste Daroussin volatile unsigned long val = 1; 158b04a7a0bSBaptiste Daroussin __sync_synchronize(); 159b04a7a0bSBaptiste Daroussin __sync_val_compare_and_swap(&val, 1, 0); 160b04a7a0bSBaptiste Daroussin __sync_add_and_fetch(&val, 1); 161b04a7a0bSBaptiste Daroussin __sync_sub_and_fetch(&val, 1); 162b04a7a0bSBaptiste Daroussin return 0; 163b04a7a0bSBaptiste Daroussin } 164b04a7a0bSBaptiste Daroussin ]]) 165b04a7a0bSBaptiste Daroussin], 166b04a7a0bSBaptiste Daroussin[ 167b04a7a0bSBaptiste Daroussin AC_MSG_RESULT([yes]) 168b04a7a0bSBaptiste Daroussin AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics]) 169b04a7a0bSBaptiste Daroussin], 170b04a7a0bSBaptiste Daroussin[ 171b04a7a0bSBaptiste Daroussin AC_MSG_RESULT([no]) 172b04a7a0bSBaptiste Daroussin AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics]) 173b04a7a0bSBaptiste Daroussin AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing]) 174b04a7a0bSBaptiste Daroussin]) 175b04a7a0bSBaptiste Daroussin 17697bd480fSBaptiste DaroussinAC_CONFIG_FILES(Makefile \ 17797bd480fSBaptiste Daroussin src/Makefile \ 1784bf54857SBaptiste Daroussin lua/Makefile 17997bd480fSBaptiste Daroussin tests/Makefile \ 18097bd480fSBaptiste Daroussin utils/Makefile \ 18197bd480fSBaptiste Daroussin doc/Makefile \ 1824bf54857SBaptiste Daroussin lua/libucl.rockspec \ 18397bd480fSBaptiste Daroussin libucl.pc) 18497bd480fSBaptiste DaroussinAC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 18597bd480fSBaptiste DaroussinAC_OUTPUT 186