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