xref: /freebsd/contrib/libucl/configure.ac (revision 4bf5485791b743cece52e2defa8c8efdf389b57a)
197bd480fSBaptiste Daroussinm4_define([maj_ver], [0])
2*4bf54857SBaptiste Daroussinm4_define([med_ver], [6])
3*4bf54857SBaptiste Daroussinm4_define([min_ver], [1])
4*4bf54857SBaptiste Daroussinm4_define([so_version], [3:0:1])
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])
9*4bf54857SBaptiste DaroussinAM_INIT_AUTOMAKE([1.11 foreign -Wall -Wportability no-dist-gzip dist-xz])
10*4bf54857SBaptiste 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])
5097bd480fSBaptiste Daroussin
5197bd480fSBaptiste Daroussindnl Example of default-disabled feature
52b04a7a0bSBaptiste DaroussinAC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls],
53b04a7a0bSBaptiste Daroussin	[Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [],
54b04a7a0bSBaptiste Daroussin	[enable_urls=no])
55b04a7a0bSBaptiste DaroussinAC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex],
56b04a7a0bSBaptiste Daroussin	[Enable regex checking for schema @<:@default=yes@:>@]), [],
57b04a7a0bSBaptiste Daroussin	[enable_regex=yes])
5897bd480fSBaptiste DaroussinAC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures],
59b04a7a0bSBaptiste Daroussin	[Enable signatures check (requires openssl) @<:@default=no@:>@]), [],
60b04a7a0bSBaptiste Daroussin	[enable_signatures=no])
61*4bf54857SBaptiste DaroussinAC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua],
62*4bf54857SBaptiste Daroussin	[Enable lua API build (requires lua libraries and headers) @<:@default=no@:>@]), [],
63*4bf54857SBaptiste Daroussin	[enable_lua=no])
6497bd480fSBaptiste DaroussinAC_ARG_ENABLE([utils],
65b04a7a0bSBaptiste Daroussin	AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]),
6697bd480fSBaptiste Daroussin	[case "${enableval}" in
6797bd480fSBaptiste Daroussin  		yes) utils=true ;;
6897bd480fSBaptiste Daroussin  		no)  utils=false ;;
6997bd480fSBaptiste Daroussin  		*) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;;
7097bd480fSBaptiste Daroussin	esac],[utils=false])
7197bd480fSBaptiste DaroussinAM_CONDITIONAL([UTILS], [test x$utils = xtrue])
7297bd480fSBaptiste Daroussin
7397bd480fSBaptiste DaroussinAS_IF([test "x$enable_signatures" = "xyes"], [
7497bd480fSBaptiste Daroussin	AC_SEARCH_LIBS([EVP_MD_CTX_create], [crypto], [
7597bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).])
76b04a7a0bSBaptiste Daroussin		LIBCRYPTO_LIB="-lcrypto"
7797bd480fSBaptiste Daroussin		LIBS_EXTRA="${LIBS_EXTRA} -lcrypto"
7897bd480fSBaptiste Daroussin		], [AC_MSG_ERROR([unable to find the EVP_MD_CTX_create() function])])
7997bd480fSBaptiste Daroussin])
80b04a7a0bSBaptiste DaroussinAC_SUBST(LIBCRYPTO_LIB)
8197bd480fSBaptiste DaroussinAC_PATH_PROG(PANDOC, pandoc, [/non/existent])
8297bd480fSBaptiste Daroussin
8397bd480fSBaptiste DaroussinAC_SEARCH_LIBS([clock_gettime], [rt], [], [
8497bd480fSBaptiste Daroussin	AC_CHECK_HEADER([mach/mach_time.h], [
8597bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin])
8697bd480fSBaptiste Daroussin	], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])])
8797bd480fSBaptiste Daroussin])
8897bd480fSBaptiste DaroussinAC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])])
8997bd480fSBaptiste Daroussin
90b04a7a0bSBaptiste DaroussinAS_IF([test "x$enable_regex" = "xyes"], [
9197bd480fSBaptiste Daroussin	AC_CHECK_HEADER([regex.h], [
9297bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.])
93b04a7a0bSBaptiste Daroussin		AC_SEARCH_LIBS([regexec], [regex], [
94b04a7a0bSBaptiste Daroussin			AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [
95b04a7a0bSBaptiste Daroussin				LIBREGEX_LIB="-lregex"
96b04a7a0bSBaptiste Daroussin				LIBS_EXTRA="${LIBS_EXTRA} -lregex"
97b04a7a0bSBaptiste Daroussin				]
98b04a7a0bSBaptiste Daroussin			)],
99b04a7a0bSBaptiste Daroussin			[AC_MSG_ERROR([unable to find the regexec() function])])],
100b04a7a0bSBaptiste Daroussin			[AC_MSG_ERROR([unable to find the regex.h header])
10197bd480fSBaptiste Daroussin		],
10297bd480fSBaptiste Daroussin		[#include <sys/types.h>])
103b04a7a0bSBaptiste Daroussin])
104b04a7a0bSBaptiste DaroussinAC_SUBST(LIBREGEX_LIB)
10597bd480fSBaptiste Daroussin
106*4bf54857SBaptiste DaroussinAS_IF([test "x$enable_lua" = "xyes"], [
107*4bf54857SBaptiste Daroussin	AX_PROG_LUA([5.1], [], [
108*4bf54857SBaptiste Daroussin		AX_LUA_HEADERS([
109*4bf54857SBaptiste Daroussin			AX_LUA_LIBS([
110*4bf54857SBaptiste Daroussin				AC_DEFINE(HAVE_LUA, 1, [Define to 1 for lua support.])
111*4bf54857SBaptiste Daroussin				with_lua="yes"
112*4bf54857SBaptiste Daroussin			], [AC_MSG_ERROR([unable to find the lua libraries])
113*4bf54857SBaptiste Daroussin			])
114*4bf54857SBaptiste Daroussin		], [AC_MSG_ERROR([unable to find the lua header files])
115*4bf54857SBaptiste Daroussin		])
116*4bf54857SBaptiste Daroussin	], [AC_MSG_ERROR([unable to find the lua interpreter])])
117*4bf54857SBaptiste Daroussin], [with_lua="no"])
118*4bf54857SBaptiste Daroussin
119*4bf54857SBaptiste DaroussinAM_CONDITIONAL([LUA_SUB], [test "$with_lua" = "yes"])
120*4bf54857SBaptiste Daroussin
12197bd480fSBaptiste DaroussinAS_IF([test "x$enable_urls" = "xyes"], [
12297bd480fSBaptiste Daroussin	AC_CHECK_HEADER([fetch.h], [
12397bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.])
12497bd480fSBaptiste Daroussin		AC_CHECK_LIB(fetch, fetchXGet, [
12597bd480fSBaptiste Daroussin			AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).])
12697bd480fSBaptiste Daroussin			LIBFETCH_LIBS="-lfetch"
12797bd480fSBaptiste Daroussin			have_libfetch="yes"
12897bd480fSBaptiste Daroussin			LIBS_EXTRA="${LIBS_EXTRA} -lfetch"
12997bd480fSBaptiste Daroussin		])
13097bd480fSBaptiste Daroussin	], [],[
13197bd480fSBaptiste Daroussin	#include <stdio.h>
13297bd480fSBaptiste Daroussin	#ifdef HAVE_SYS_PARAM_H
13397bd480fSBaptiste Daroussin	#include <sys/param.h>
13497bd480fSBaptiste Daroussin	#endif
13597bd480fSBaptiste Daroussin	])
13697bd480fSBaptiste Daroussin	AC_SUBST(LIBFETCH_LIBS)
13797bd480fSBaptiste Daroussin
13897bd480fSBaptiste Daroussin	AS_IF([ test "x$have_libfetch" != "xyes"], [
13997bd480fSBaptiste Daroussin		dnl Fallback to libcurl
14097bd480fSBaptiste Daroussin		PKG_CHECK_MODULES([CURL], [libcurl], [
14197bd480fSBaptiste Daroussin			AC_DEFINE(CURL_FOUND, 1, [Use libcurl])
14297bd480fSBaptiste Daroussin			LIBS_EXTRA="${LIBS_EXTRA} -lcurl"],
14397bd480fSBaptiste Daroussin		[AC_MSG_ERROR([unable to find neither libfetch nor libcurl])])
14497bd480fSBaptiste Daroussin	])
14597bd480fSBaptiste Daroussin	AC_SUBST(CURL_FOUND)
14697bd480fSBaptiste Daroussin	AC_SUBST(CURL_LIBS)
14797bd480fSBaptiste Daroussin	AC_SUBST(CURL_CFLAGS)
14897bd480fSBaptiste Daroussin])
14997bd480fSBaptiste Daroussin
15097bd480fSBaptiste DaroussinAC_SUBST(LIBS_EXTRA)
15197bd480fSBaptiste Daroussin
152b04a7a0bSBaptiste DaroussinAC_MSG_CHECKING(for GCC atomic builtins)
153b04a7a0bSBaptiste DaroussinAC_LINK_IFELSE([
154b04a7a0bSBaptiste Daroussin	AC_LANG_SOURCE([[
155b04a7a0bSBaptiste Daroussin		int main() {
156b04a7a0bSBaptiste Daroussin			volatile unsigned long val = 1;
157b04a7a0bSBaptiste Daroussin			__sync_synchronize();
158b04a7a0bSBaptiste Daroussin			__sync_val_compare_and_swap(&val, 1, 0);
159b04a7a0bSBaptiste Daroussin			__sync_add_and_fetch(&val, 1);
160b04a7a0bSBaptiste Daroussin			__sync_sub_and_fetch(&val, 1);
161b04a7a0bSBaptiste Daroussin			return 0;
162b04a7a0bSBaptiste Daroussin		}
163b04a7a0bSBaptiste Daroussin	]])
164b04a7a0bSBaptiste Daroussin],
165b04a7a0bSBaptiste Daroussin[
166b04a7a0bSBaptiste Daroussin	AC_MSG_RESULT([yes])
167b04a7a0bSBaptiste Daroussin	AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics])
168b04a7a0bSBaptiste Daroussin],
169b04a7a0bSBaptiste Daroussin[
170b04a7a0bSBaptiste Daroussin	AC_MSG_RESULT([no])
171b04a7a0bSBaptiste Daroussin	AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics])
172b04a7a0bSBaptiste Daroussin	AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing])
173b04a7a0bSBaptiste Daroussin])
174b04a7a0bSBaptiste Daroussin
17597bd480fSBaptiste DaroussinAC_CONFIG_FILES(Makefile \
17697bd480fSBaptiste Daroussin	src/Makefile \
177*4bf54857SBaptiste Daroussin	lua/Makefile
17897bd480fSBaptiste Daroussin	tests/Makefile \
17997bd480fSBaptiste Daroussin	utils/Makefile \
18097bd480fSBaptiste Daroussin	doc/Makefile \
181*4bf54857SBaptiste Daroussin	lua/libucl.rockspec \
18297bd480fSBaptiste Daroussin	libucl.pc)
18397bd480fSBaptiste DaroussinAC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
18497bd480fSBaptiste DaroussinAC_OUTPUT
185