configure.ac revision 264789
166458Sdfrm4_define([maj_ver], [0]) 281077Speterm4_define([med_ver], [4]) 366458Sdfrm4_define([min_ver], [0]) 466458Sdfrm4_define([so_version], [maj_ver:med_ver]) 5107204Smarcelm4_define([ucl_version], [maj_ver.med_ver.min_ver]) 666458Sdfr 7115084SmarcelAC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl]) 894381SdfrAC_CONFIG_SRCDIR([configure.ac]) 983198SdfrAM_INIT_AUTOMAKE([1.11 foreign silent-rules -Wall -Wportability no-dist-gzip dist-xz]) 1083198Sdfr 1183198SdfrUCL_VERSION=ucl_version 1283198SdfrSO_VERSION=so_version 1366458Sdfr 1466458SdfrAC_SUBST(UCL_VERSION) 1566458SdfrAC_SUBST(SO_VERSION) 1666458Sdfr 1766458SdfrAC_PROG_CC_C99 18100118SjhbAM_PROG_CC_C_O 19100118SjhbAM_PROG_AR 2066458SdfrLT_INIT 2166458SdfrAC_CONFIG_MACRO_DIR([m4]) 22100118SjhbAC_CONFIG_HEADERS([config.h]) 2366458Sdfr 2466458SdfrAC_C_CONST 2566458SdfrAC_TYPE_SIZE_T 2666458Sdfr 2766458SdfrAC_CHECK_HEADERS_ONCE([fcntl.h unistd.h]) 2866458SdfrAC_TYPE_OFF_T 2966458SdfrAC_FUNC_MMAP 3066458SdfrAC_CHECK_HEADERS_ONCE([fcntl.h]) 3166458SdfrAC_CHECK_HEADERS_ONCE([sys/types.h]) 3266458SdfrAC_CHECK_HEADERS_ONCE([sys/stat.h]) 3366458SdfrAC_CHECK_HEADERS_ONCE([sys/param.h]) 3466458SdfrAC_CHECK_HEADERS_ONCE([sys/mman.h]) 3566458SdfrAC_CHECK_HEADERS_ONCE([stdlib.h]) 3666458SdfrAC_CHECK_HEADERS_ONCE([stddef.h]) 37105312SiwasakiAC_CHECK_HEADERS_ONCE([stdarg.h]) 3866458SdfrAC_CHECK_HEADERS_ONCE([stdbool.h]) 3966458SdfrAC_CHECK_HEADERS_ONCE([stdint.h]) 4066458SdfrAC_CHECK_HEADERS_ONCE([string.h]) 4166458SdfrAC_CHECK_HEADERS_ONCE([unistd.h]) 4266458SdfrAC_CHECK_HEADERS_ONCE([ctype.h]) 4366458SdfrAC_CHECK_HEADERS_ONCE([errno.h]) 4466458SdfrAC_CHECK_HEADERS_ONCE([limits.h]) 4566458SdfrAC_CHECK_HEADERS_ONCE([libgen.h]) 4666458SdfrAC_CHECK_HEADERS_ONCE([stdio.h]) 4766458SdfrAC_CHECK_HEADERS_ONCE([float.h]) 4866458SdfrAC_CHECK_HEADERS_ONCE([math.h]) 4966458Sdfr 5066458Sdfrdnl Example of default-disabled feature 5166458SdfrAC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], 5266458Sdfr [Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [], 5366458Sdfr [enable_urls=no]) 5466458SdfrAC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex], 5566458Sdfr [Enable regex checking for schema @<:@default=yes@:>@]), [], 5666458Sdfr [enable_regex=yes]) 5766458SdfrAC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures], 5866458Sdfr [Enable signatures check (requires openssl) @<:@default=no@:>@]), [], 5966458Sdfr [enable_signatures=no]) 6066458SdfrAC_ARG_ENABLE([utils], 6166458Sdfr AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]), 6266458Sdfr [case "${enableval}" in 6366458Sdfr yes) utils=true ;; 6474032Sdfr no) utils=false ;; 6574032Sdfr *) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;; 6684132Sdfr esac],[utils=false]) 6774032SdfrAM_CONDITIONAL([UTILS], [test x$utils = xtrue]) 6876161Sjhb 6981050SyokotaAS_IF([test "x$enable_signatures" = "xyes"], [ 7081050Syokota AC_SEARCH_LIBS([EVP_MD_CTX_create], [crypto], [ 7181050Syokota AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).]) 72105891Sjhb LIBCRYPTO_LIB="-lcrypto" 73 LIBS_EXTRA="${LIBS_EXTRA} -lcrypto" 74 ], [AC_MSG_ERROR([unable to find the EVP_MD_CTX_create() function])]) 75]) 76AC_SUBST(LIBCRYPTO_LIB) 77AC_PATH_PROG(PANDOC, pandoc, [/non/existent]) 78 79AC_SEARCH_LIBS([clock_gettime], [rt], [], [ 80 AC_CHECK_HEADER([mach/mach_time.h], [ 81 AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin]) 82 ], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])]) 83]) 84AC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])]) 85 86AS_IF([test "x$enable_regex" = "xyes"], [ 87 AC_CHECK_HEADER([regex.h], [ 88 AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.]) 89 AC_SEARCH_LIBS([regexec], [regex], [ 90 AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [ 91 LIBREGEX_LIB="-lregex" 92 LIBS_EXTRA="${LIBS_EXTRA} -lregex" 93 ] 94 )], 95 [AC_MSG_ERROR([unable to find the regexec() function])])], 96 [AC_MSG_ERROR([unable to find the regex.h header]) 97 ], 98 [#include <sys/types.h>]) 99]) 100AC_SUBST(LIBREGEX_LIB) 101 102AS_IF([test "x$enable_urls" = "xyes"], [ 103 AC_CHECK_HEADER([fetch.h], [ 104 AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.]) 105 AC_CHECK_LIB(fetch, fetchXGet, [ 106 AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).]) 107 LIBFETCH_LIBS="-lfetch" 108 have_libfetch="yes" 109 LIBS_EXTRA="${LIBS_EXTRA} -lfetch" 110 ]) 111 ], [],[ 112 #include <stdio.h> 113 #ifdef HAVE_SYS_PARAM_H 114 #include <sys/param.h> 115 #endif 116 ]) 117 AC_SUBST(LIBFETCH_LIBS) 118 119 AS_IF([ test "x$have_libfetch" != "xyes"], [ 120 dnl Fallback to libcurl 121 PKG_CHECK_MODULES([CURL], [libcurl], [ 122 AC_DEFINE(CURL_FOUND, 1, [Use libcurl]) 123 LIBS_EXTRA="${LIBS_EXTRA} -lcurl"], 124 [AC_MSG_ERROR([unable to find neither libfetch nor libcurl])]) 125 ]) 126 AC_SUBST(CURL_FOUND) 127 AC_SUBST(CURL_LIBS) 128 AC_SUBST(CURL_CFLAGS) 129]) 130 131AC_SUBST(LIBS_EXTRA) 132 133AC_MSG_CHECKING(for GCC atomic builtins) 134AC_LINK_IFELSE([ 135 AC_LANG_SOURCE([[ 136 int main() { 137 volatile unsigned long val = 1; 138 __sync_synchronize(); 139 __sync_val_compare_and_swap(&val, 1, 0); 140 __sync_add_and_fetch(&val, 1); 141 __sync_sub_and_fetch(&val, 1); 142 return 0; 143 } 144 ]]) 145], 146[ 147 AC_MSG_RESULT([yes]) 148 AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics]) 149], 150[ 151 AC_MSG_RESULT([no]) 152 AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics]) 153 AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing]) 154]) 155 156AC_CONFIG_FILES(Makefile \ 157 src/Makefile \ 158 tests/Makefile \ 159 utils/Makefile \ 160 doc/Makefile \ 161 libucl.pc) 162AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 163AC_OUTPUT 164