1m4_define([maj_ver], [0]) 2m4_define([med_ver], [8]) 3m4_define([min_ver], [1]) 4m4_define([so_version], [6:0:1]) 5m4_define([ucl_version], [maj_ver.med_ver.min_ver]) 6 7AC_INIT([libucl],[ucl_version],[https://github.com/vstakhov/libucl],[libucl]) 8AC_CONFIG_SRCDIR([configure.ac]) 9AM_INIT_AUTOMAKE([1.11 foreign -Wall -Wportability no-dist-gzip dist-xz]) 10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 11 12UCL_VERSION=ucl_version 13SO_VERSION=so_version 14 15AC_SUBST(UCL_VERSION) 16AC_SUBST(SO_VERSION) 17 18AC_PROG_CC_C99 19AM_PROG_CC_C_O 20AM_PROG_AR 21LT_INIT 22AC_CONFIG_MACRO_DIR([m4]) 23AC_CONFIG_HEADERS([config.h]) 24 25AC_C_CONST 26AC_TYPE_SIZE_T 27 28AC_CHECK_HEADERS_ONCE([fcntl.h unistd.h]) 29AC_TYPE_OFF_T 30AC_FUNC_MMAP 31AC_CHECK_HEADERS_ONCE([fcntl.h]) 32AC_CHECK_HEADERS_ONCE([sys/types.h]) 33AC_CHECK_HEADERS_ONCE([sys/stat.h]) 34AC_CHECK_HEADERS_ONCE([sys/param.h]) 35AC_CHECK_HEADERS_ONCE([sys/mman.h]) 36AC_CHECK_HEADERS_ONCE([stdlib.h]) 37AC_CHECK_HEADERS_ONCE([stddef.h]) 38AC_CHECK_HEADERS_ONCE([stdarg.h]) 39AC_CHECK_HEADERS_ONCE([stdbool.h]) 40AC_CHECK_HEADERS_ONCE([stdint.h]) 41AC_CHECK_HEADERS_ONCE([string.h]) 42AC_CHECK_HEADERS_ONCE([strings.h]) 43AC_CHECK_HEADERS_ONCE([unistd.h]) 44AC_CHECK_HEADERS_ONCE([ctype.h]) 45AC_CHECK_HEADERS_ONCE([errno.h]) 46AC_CHECK_HEADERS_ONCE([limits.h]) 47AC_CHECK_HEADERS_ONCE([libgen.h]) 48AC_CHECK_HEADERS_ONCE([stdio.h]) 49AC_CHECK_HEADERS_ONCE([float.h]) 50AC_CHECK_HEADERS_ONCE([math.h]) 51AC_CHECK_HEADERS_ONCE([endian.h sys/endian.h machine/endian.h]) 52 53dnl Example of default-disabled feature 54AC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls], 55 [Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [], 56 [enable_urls=no]) 57AC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex], 58 [Enable regex checking for schema @<:@default=yes@:>@]), [], 59 [enable_regex=yes]) 60AC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures], 61 [Enable signatures check (requires openssl) @<:@default=no@:>@]), [], 62 [enable_signatures=no]) 63AC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua], 64 [Enable lua API build (requires lua libraries and headers) @<:@default=no@:>@]), [], 65 [enable_lua=no]) 66AC_ARG_ENABLE([utils], 67 AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]), 68 [case "${enableval}" in 69 yes) utils=true ;; 70 no) utils=false ;; 71 *) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;; 72 esac],[utils=false]) 73AM_CONDITIONAL([UTILS], [test x$utils = xtrue]) 74 75AS_IF([test "x$enable_signatures" = "xyes"], [ 76 AC_SEARCH_LIBS([CRYPTO_new_ex_data], [crypto], [ 77 AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).]) 78 LIBCRYPTO_LIB="-lcrypto" 79 LIBS_EXTRA="${LIBS_EXTRA} -lcrypto" 80 ], [AC_MSG_ERROR([unable to find the CRYPTO_new_ex_data() function])]) 81]) 82AC_SUBST(LIBCRYPTO_LIB) 83AC_PATH_PROG(PANDOC, pandoc, [/non/existent]) 84 85AC_SEARCH_LIBS([clock_gettime], [rt], [], [ 86 AC_CHECK_HEADER([mach/mach_time.h], [ 87 AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin]) 88 ], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])]) 89]) 90AC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])]) 91 92AS_IF([test "x$enable_regex" = "xyes"], [ 93 AC_CHECK_HEADER([regex.h], [ 94 AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.]) 95 AC_SEARCH_LIBS([regexec], [regex], [ 96 AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [ 97 LIBREGEX_LIB="-lregex" 98 LIBS_EXTRA="${LIBS_EXTRA} -lregex" 99 ] 100 )], 101 [AC_MSG_ERROR([unable to find the regexec() function])])], 102 [AC_MSG_ERROR([unable to find the regex.h header]) 103 ], 104 [#include <sys/types.h>]) 105]) 106AC_SUBST(LIBREGEX_LIB) 107 108AS_IF([test "x$enable_lua" = "xyes"], [ 109 AX_PROG_LUA([5.1], [], [ 110 AX_LUA_HEADERS([ 111 AX_LUA_LIBS([ 112 AC_DEFINE(HAVE_LUA, 1, [Define to 1 for lua support.]) 113 with_lua="yes" 114 ], [AC_MSG_ERROR([unable to find the lua libraries]) 115 ]) 116 ], [AC_MSG_ERROR([unable to find the lua header files]) 117 ]) 118 ], [AC_MSG_ERROR([unable to find the lua interpreter])]) 119], [with_lua="no"]) 120 121AM_CONDITIONAL([LUA_SUB], [test "$with_lua" = "yes"]) 122 123AS_IF([test "x$enable_urls" = "xyes"], [ 124 AC_CHECK_HEADER([fetch.h], [ 125 AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.]) 126 AC_CHECK_LIB(fetch, fetchXGet, [ 127 AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).]) 128 LIBFETCH_LIBS="-lfetch" 129 have_libfetch="yes" 130 LIBS_EXTRA="${LIBS_EXTRA} -lfetch" 131 ]) 132 ], [],[ 133 #include <stdio.h> 134 #ifdef HAVE_SYS_PARAM_H 135 #include <sys/param.h> 136 #endif 137 ]) 138 AC_SUBST(LIBFETCH_LIBS) 139 140 AS_IF([ test "x$have_libfetch" != "xyes"], [ 141 dnl Fallback to libcurl 142 PKG_CHECK_MODULES([CURL], [libcurl], [ 143 AC_DEFINE(CURL_FOUND, 1, [Use libcurl]) 144 LIBS_EXTRA="${LIBS_EXTRA} -lcurl"], 145 [AC_MSG_ERROR([unable to find neither libfetch nor libcurl])]) 146 ]) 147 AC_SUBST(CURL_FOUND) 148 AC_SUBST(CURL_LIBS) 149 AC_SUBST(CURL_CFLAGS) 150]) 151 152AC_SUBST(LIBS_EXTRA) 153 154AC_MSG_CHECKING(for GCC atomic builtins) 155AC_LINK_IFELSE([ 156 AC_LANG_SOURCE([[ 157 int main() { 158 volatile unsigned long val = 1; 159 __sync_synchronize(); 160 __sync_val_compare_and_swap(&val, 1, 0); 161 __sync_add_and_fetch(&val, 1); 162 __sync_sub_and_fetch(&val, 1); 163 return 0; 164 } 165 ]]) 166], 167[ 168 AC_MSG_RESULT([yes]) 169 AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics]) 170], 171[ 172 AC_MSG_RESULT([no]) 173 AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics]) 174 AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing]) 175]) 176 177AX_CODE_COVERAGE 178 179AC_CONFIG_FILES(Makefile \ 180 src/Makefile \ 181 lua/Makefile 182 tests/Makefile \ 183 utils/Makefile \ 184 doc/Makefile \ 185 lua/libucl.rockspec \ 186 libucl.pc) 187AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) 188AC_OUTPUT 189