xref: /freebsd/contrib/libucl/configure.ac (revision a0409676120c1e558d0ade943019934e0f15118d)
197bd480fSBaptiste Daroussinm4_define([maj_ver], [0])
2d9f0ce31SBaptiste Daroussinm4_define([med_ver], [8])
3*a0409676SBaptiste Daroussinm4_define([min_ver], [1])
4*a0409676SBaptiste Daroussinm4_define([so_version], [6: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])
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])
4211dd9ed6SBaptiste DaroussinAC_CHECK_HEADERS_ONCE([strings.h])
4397bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([unistd.h])
4497bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([ctype.h])
4597bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([errno.h])
4697bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([limits.h])
4797bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([libgen.h])
4897bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([stdio.h])
4997bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([float.h])
5097bd480fSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([math.h])
5139ee7a7aSBaptiste DaroussinAC_CHECK_HEADERS_ONCE([endian.h sys/endian.h machine/endian.h])
5297bd480fSBaptiste Daroussin
5397bd480fSBaptiste Daroussindnl Example of default-disabled feature
54b04a7a0bSBaptiste DaroussinAC_ARG_ENABLE([urls], AS_HELP_STRING([--enable-urls],
55b04a7a0bSBaptiste Daroussin	[Enable URLs fetch (requires libfetch or libcurl) @<:@default=no@:>@]), [],
56b04a7a0bSBaptiste Daroussin	[enable_urls=no])
57b04a7a0bSBaptiste DaroussinAC_ARG_ENABLE([regex], AS_HELP_STRING([--enable-regex],
58b04a7a0bSBaptiste Daroussin	[Enable regex checking for schema @<:@default=yes@:>@]), [],
59b04a7a0bSBaptiste Daroussin	[enable_regex=yes])
6097bd480fSBaptiste DaroussinAC_ARG_ENABLE([signatures], AS_HELP_STRING([--enable-signatures],
61b04a7a0bSBaptiste Daroussin	[Enable signatures check (requires openssl) @<:@default=no@:>@]), [],
62b04a7a0bSBaptiste Daroussin	[enable_signatures=no])
634bf54857SBaptiste DaroussinAC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua],
644bf54857SBaptiste Daroussin	[Enable lua API build (requires lua libraries and headers) @<:@default=no@:>@]), [],
654bf54857SBaptiste Daroussin	[enable_lua=no])
6697bd480fSBaptiste DaroussinAC_ARG_ENABLE([utils],
67b04a7a0bSBaptiste Daroussin	AS_HELP_STRING([--enable-utils], [Build and install utils @<:@default=no@:>@]),
6897bd480fSBaptiste Daroussin	[case "${enableval}" in
6997bd480fSBaptiste Daroussin  		yes) utils=true ;;
7097bd480fSBaptiste Daroussin  		no)  utils=false ;;
7197bd480fSBaptiste Daroussin  		*) AC_MSG_ERROR([bad value ${enableval} for --enable-utils]) ;;
7297bd480fSBaptiste Daroussin	esac],[utils=false])
7397bd480fSBaptiste DaroussinAM_CONDITIONAL([UTILS], [test x$utils = xtrue])
7497bd480fSBaptiste Daroussin
7597bd480fSBaptiste DaroussinAS_IF([test "x$enable_signatures" = "xyes"], [
76*a0409676SBaptiste Daroussin	AC_SEARCH_LIBS([CRYPTO_new_ex_data], [crypto], [
7797bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if you have the 'crypto' library (-lcrypto).])
78b04a7a0bSBaptiste Daroussin		LIBCRYPTO_LIB="-lcrypto"
7997bd480fSBaptiste Daroussin		LIBS_EXTRA="${LIBS_EXTRA} -lcrypto"
80*a0409676SBaptiste Daroussin		], [AC_MSG_ERROR([unable to find the CRYPTO_new_ex_data() function])])
8197bd480fSBaptiste Daroussin])
82b04a7a0bSBaptiste DaroussinAC_SUBST(LIBCRYPTO_LIB)
8397bd480fSBaptiste DaroussinAC_PATH_PROG(PANDOC, pandoc, [/non/existent])
8497bd480fSBaptiste Daroussin
8597bd480fSBaptiste DaroussinAC_SEARCH_LIBS([clock_gettime], [rt], [], [
8697bd480fSBaptiste Daroussin	AC_CHECK_HEADER([mach/mach_time.h], [
8797bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_MACH_MACH_TIME_H, 1, [Define to 1 on Darwin])
8897bd480fSBaptiste Daroussin	], [AC_MSG_ERROR([unable to find clock_gettime or mach_absolute_time])])
8997bd480fSBaptiste Daroussin])
9097bd480fSBaptiste DaroussinAC_SEARCH_LIBS([remainder], [m], [], [AC_MSG_ERROR([unable to find remainder() function])])
9197bd480fSBaptiste Daroussin
92b04a7a0bSBaptiste DaroussinAS_IF([test "x$enable_regex" = "xyes"], [
9397bd480fSBaptiste Daroussin	AC_CHECK_HEADER([regex.h], [
9497bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.])
95b04a7a0bSBaptiste Daroussin		AC_SEARCH_LIBS([regexec], [regex], [
96b04a7a0bSBaptiste Daroussin			AS_IF([test "x$ac_cv_search_regexec" = "x-lregex"], [
97b04a7a0bSBaptiste Daroussin				LIBREGEX_LIB="-lregex"
98b04a7a0bSBaptiste Daroussin				LIBS_EXTRA="${LIBS_EXTRA} -lregex"
99b04a7a0bSBaptiste Daroussin				]
100b04a7a0bSBaptiste Daroussin			)],
101b04a7a0bSBaptiste Daroussin			[AC_MSG_ERROR([unable to find the regexec() function])])],
102b04a7a0bSBaptiste Daroussin			[AC_MSG_ERROR([unable to find the regex.h header])
10397bd480fSBaptiste Daroussin		],
10497bd480fSBaptiste Daroussin		[#include <sys/types.h>])
105b04a7a0bSBaptiste Daroussin])
106b04a7a0bSBaptiste DaroussinAC_SUBST(LIBREGEX_LIB)
10797bd480fSBaptiste Daroussin
1084bf54857SBaptiste DaroussinAS_IF([test "x$enable_lua" = "xyes"], [
1094bf54857SBaptiste Daroussin	AX_PROG_LUA([5.1], [], [
1104bf54857SBaptiste Daroussin		AX_LUA_HEADERS([
1114bf54857SBaptiste Daroussin			AX_LUA_LIBS([
1124bf54857SBaptiste Daroussin				AC_DEFINE(HAVE_LUA, 1, [Define to 1 for lua support.])
1134bf54857SBaptiste Daroussin				with_lua="yes"
1144bf54857SBaptiste Daroussin			], [AC_MSG_ERROR([unable to find the lua libraries])
1154bf54857SBaptiste Daroussin			])
1164bf54857SBaptiste Daroussin		], [AC_MSG_ERROR([unable to find the lua header files])
1174bf54857SBaptiste Daroussin		])
1184bf54857SBaptiste Daroussin	], [AC_MSG_ERROR([unable to find the lua interpreter])])
1194bf54857SBaptiste Daroussin], [with_lua="no"])
1204bf54857SBaptiste Daroussin
1214bf54857SBaptiste DaroussinAM_CONDITIONAL([LUA_SUB], [test "$with_lua" = "yes"])
1224bf54857SBaptiste Daroussin
12397bd480fSBaptiste DaroussinAS_IF([test "x$enable_urls" = "xyes"], [
12497bd480fSBaptiste Daroussin	AC_CHECK_HEADER([fetch.h], [
12597bd480fSBaptiste Daroussin		AC_DEFINE(HAVE_FETCH_H, 1, [Define to 1 if you have the <fetch.h> header file.])
12697bd480fSBaptiste Daroussin		AC_CHECK_LIB(fetch, fetchXGet, [
12797bd480fSBaptiste Daroussin			AC_DEFINE(HAVE_LIBFETCH, 1, [Define to 1 if you have the 'fetch' library (-lfetch).])
12897bd480fSBaptiste Daroussin			LIBFETCH_LIBS="-lfetch"
12997bd480fSBaptiste Daroussin			have_libfetch="yes"
13097bd480fSBaptiste Daroussin			LIBS_EXTRA="${LIBS_EXTRA} -lfetch"
13197bd480fSBaptiste Daroussin		])
13297bd480fSBaptiste Daroussin	], [],[
13397bd480fSBaptiste Daroussin	#include <stdio.h>
13497bd480fSBaptiste Daroussin	#ifdef HAVE_SYS_PARAM_H
13597bd480fSBaptiste Daroussin	#include <sys/param.h>
13697bd480fSBaptiste Daroussin	#endif
13797bd480fSBaptiste Daroussin	])
13897bd480fSBaptiste Daroussin	AC_SUBST(LIBFETCH_LIBS)
13997bd480fSBaptiste Daroussin
14097bd480fSBaptiste Daroussin	AS_IF([ test "x$have_libfetch" != "xyes"], [
14197bd480fSBaptiste Daroussin		dnl Fallback to libcurl
14297bd480fSBaptiste Daroussin		PKG_CHECK_MODULES([CURL], [libcurl], [
14397bd480fSBaptiste Daroussin			AC_DEFINE(CURL_FOUND, 1, [Use libcurl])
14497bd480fSBaptiste Daroussin			LIBS_EXTRA="${LIBS_EXTRA} -lcurl"],
14597bd480fSBaptiste Daroussin		[AC_MSG_ERROR([unable to find neither libfetch nor libcurl])])
14697bd480fSBaptiste Daroussin	])
14797bd480fSBaptiste Daroussin	AC_SUBST(CURL_FOUND)
14897bd480fSBaptiste Daroussin	AC_SUBST(CURL_LIBS)
14997bd480fSBaptiste Daroussin	AC_SUBST(CURL_CFLAGS)
15097bd480fSBaptiste Daroussin])
15197bd480fSBaptiste Daroussin
15297bd480fSBaptiste DaroussinAC_SUBST(LIBS_EXTRA)
15397bd480fSBaptiste Daroussin
154b04a7a0bSBaptiste DaroussinAC_MSG_CHECKING(for GCC atomic builtins)
155b04a7a0bSBaptiste DaroussinAC_LINK_IFELSE([
156b04a7a0bSBaptiste Daroussin	AC_LANG_SOURCE([[
157b04a7a0bSBaptiste Daroussin		int main() {
158b04a7a0bSBaptiste Daroussin			volatile unsigned long val = 1;
159b04a7a0bSBaptiste Daroussin			__sync_synchronize();
160b04a7a0bSBaptiste Daroussin			__sync_val_compare_and_swap(&val, 1, 0);
161b04a7a0bSBaptiste Daroussin			__sync_add_and_fetch(&val, 1);
162b04a7a0bSBaptiste Daroussin			__sync_sub_and_fetch(&val, 1);
163b04a7a0bSBaptiste Daroussin			return 0;
164b04a7a0bSBaptiste Daroussin		}
165b04a7a0bSBaptiste Daroussin	]])
166b04a7a0bSBaptiste Daroussin],
167b04a7a0bSBaptiste Daroussin[
168b04a7a0bSBaptiste Daroussin	AC_MSG_RESULT([yes])
169b04a7a0bSBaptiste Daroussin	AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Has gcc/MSVC atomic intrinsics])
170b04a7a0bSBaptiste Daroussin],
171b04a7a0bSBaptiste Daroussin[
172b04a7a0bSBaptiste Daroussin	AC_MSG_RESULT([no])
173b04a7a0bSBaptiste Daroussin	AC_DEFINE([HAVE_ATOMIC_BUILTINS], [0], [Has gcc/MSVC atomic intrinsics])
174b04a7a0bSBaptiste Daroussin	AC_MSG_WARN([Libucl references could be thread-unsafe because atomic builtins are missing])
175b04a7a0bSBaptiste Daroussin])
176b04a7a0bSBaptiste Daroussin
177d9f0ce31SBaptiste DaroussinAX_CODE_COVERAGE
178d9f0ce31SBaptiste Daroussin
17997bd480fSBaptiste DaroussinAC_CONFIG_FILES(Makefile \
18097bd480fSBaptiste Daroussin	src/Makefile \
1814bf54857SBaptiste Daroussin	lua/Makefile
18297bd480fSBaptiste Daroussin	tests/Makefile \
18397bd480fSBaptiste Daroussin	utils/Makefile \
18497bd480fSBaptiste Daroussin	doc/Makefile \
1854bf54857SBaptiste Daroussin	lua/libucl.rockspec \
18697bd480fSBaptiste Daroussin	libucl.pc)
18797bd480fSBaptiste DaroussinAC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
18897bd480fSBaptiste DaroussinAC_OUTPUT
189