-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
333 lines (284 loc) · 10.3 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
dnl Process this file with autoconf to produce a configure script.
AC_INIT([mdbtools],[1.0.0],[https://github.com/mdbtools/mdbtools/issues],[],[https://github.com/mdbtools/mdbtools])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR(src/extras/mdb-dump.c)
AM_INIT_AUTOMAKE([foreign dist-zip])
MDBTOOLS_VERSION_MAJOR=1
MDBTOOLS_VERSION_MINOR=0
MDBTOOLS_VERSION_MICRO=0
# Update these numbers with every release
# See https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
VERSION_INFO=4:0:1
AC_SUBST(VERSION_INFO)
AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC(gcc)
AC_PROG_CXX
AX_TLS([FOO=bar], AC_MSG_ERROR([$CC does not support thread-local storage. A newer compiler is required.]))
dnl Checks for programs.
AC_PROG_MAKE_SET
m4_pattern_allow([AM_PROG_AR], [AM_PROG_AR])
LT_INIT([win32-dll])
AC_PROG_LEX([noyywrap])
AC_PROG_YACC
dnl Checks for header files.
AC_CHECK_HEADERS(fcntl.h limits.h unistd.h xlocale.h)
AC_CHECK_LIB(mswstr, DBLCMapStringW)
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[
#define _GNU_SOURCE
#include <errno.h>]])
dnl Checks for library functions.
VL_LIB_READLINE
AC_CHECK_FUNCS(strptime fmemopen gmtime_r reallocf wcstombs_l mbstowcs_l vasprintf vasnprintf)
AM_GCC_ATTRIBUTE_ALIAS
dnl Enable large files on 32-bit systems
AC_SYS_LARGEFILE
dnl no optional stuff by default
OPTDIRS=""
dnl ---------------------------------------------------------------------
dnl Compile time options
dnl ---------------------------------------------------------------------
sql=true
AC_MSG_CHECKING( Are we using flex )
if test "x$LEX" = "xflex"; then
LFLAGS="$LFLAGS -i -8"
AC_MSG_RESULT( yes );
else
AC_MSG_RESULT( no - SQL engine disable);
sql=false
fi
if $YACC -V | grep "bison.* 3[.]" >/dev/null 2>&1; then
if $YACC -Wno-conflicts-sr -V >/dev/null 2>&1; then
YFLAGS="$YFLAGS -Wno-conflicts-sr"
fi
if $YACC -Wno-yacc -V >/dev/null 2>&1; then
YFLAGS="$YFLAGS -Wno-yacc"
fi
else
AC_MSG_WARN([Bison 3.0+ is not available: SQL disabled.])
sql=false
fi
if test "x$sql" = "xtrue"; then
CFLAGS="$CFLAGS -DSQL"
OPTDIRS="$OPTDIRS sql"
fi
AM_CONDITIONAL(SQL, test x$sql = xtrue)
AC_SUBST(SQL)
AC_SUBST(LFLAGS)
CFLAGS="$CFLAGS -Wall -Werror"
LOCALE_T=locale_t
AS_CASE([$host],
[*mingw*], [LDFLAGS="$LDFLAGS -no-undefined" LOCALE_T=_locale_t], [])
AC_SUBST(LOCALE_T)
dnl See if iconv is present and wanted
AC_ARG_ENABLE(iconv,
AS_HELP_STRING([--disable-iconv], [do not use iconv for character conversions (use locale.h where possible)]),
[enable_iconv=$enableval], [enable_iconv=yes])
HAVE_ICONV_H=0
if test "$enable_iconv" = "yes"; then
AM_ICONV
# Use the "working iconv" test instead of the "iconv" ($am_cv_func_iconv) test
# so that our HAVE_ICONV_H substitution variable has the same value as the HAVE_ICONV
# C macro
if test "$am_func_iconv" = "yes"; then
HAVE_ICONV_H=1
fi
fi
AC_SUBST(HAVE_ICONV_H)
dnl Fuzz testing
AC_ARG_ENABLE([fuzz-testing], AS_HELP_STRING([--enable-fuzz-testing], [enable fuzz testing (requires Clang 6 or later)]), [
AC_MSG_CHECKING([whether $CC accepts -fsanitize=fuzzer])
tmp_saved_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS -fsanitize=fuzzer"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[
AC_MSG_RESULT(yes)
OPTDIRS="$OPTDIRS fuzz"
fuzzer=yes],
AC_MSG_RESULT(no)
AC_MSG_FAILURE([-fsanitize=fuzzer not supported (Required with --enable-fuzz-testing)]))
_AC_LANG_PREFIX[]FLAGS=$tmp_saved_flags
], [fuzzer=no])
AM_CONDITIONAL([FUZZER_ENABLED], test "x$fuzzer" = "xyes")
AC_ARG_VAR([LIB_FUZZING_ENGINE], [Location of prebuilt fuzzing engine library])
AC_SUBST([LIB_FUZZING_ENGINE])
dnl Enable -Wl,--as-needed by default to prevent overlinking
AC_ARG_ENABLE([as-needed],
AS_HELP_STRING([--disable-as-needed],[disable overlinking protection]),
[enable_as_needed=$enableval], [enable_as_needed=yes])
if test "x$enable_as_needed" != "xno"; then
AC_MSG_CHECKING([whether $LD accepts --as-needed])
case `$LD --as-needed -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
LDFLAGS="$LDFLAGS -Wl,--as-needed"
AC_MSG_RESULT([yes])
;;
*)
AC_MSG_RESULT([no])
;;
esac
fi
dnl check for iODBC
AC_ARG_WITH(iodbc,
AS_HELP_STRING([--with-iodbc=/path/to/iodbc], [build odbc driver against iODBC]))
if test "$with_iodbc"; then
HAVE_ODBC=true
ODBC_CFLAGS=$(iodbc-config --prefix="$with_iodbc" --cflags)
ODBC_LIBS=$(iodbc-config --prefix="$with_iodbc" --libs)
ODBC_LDFLAGS=""
OLDLDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $ODBC_LIBS"
AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, [FOO=bar],
AC_MSG_ERROR([Could not find SQLGetPrivateProfileString in -liodbcinst]))
LDFLAGS=$OLDLDFLAGS
fi
dnl check for unixODBC
AC_ARG_WITH(unixodbc,
AS_HELP_STRING([--with-unixodbc=/path/to/unixodbc], [build odbc driver against unixODBC]))
if test "$with_unixodbc"; then
HAVE_ODBC=true
ODBC_CFLAGS="-I$with_unixodbc/include"
ODBC_LIBS="-L$with_unixodbc/$libdir"
dnl SIZEOF_LONG_INT and HAVE_LONG_LONG are required by some versions of unixODBC
dnl https://github.com/lurcher/unixODBC/issues/40
AC_CHECK_SIZEOF([long int])
AC_CHECK_TYPES([long long])
OLDLDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $ODBC_LIBS"
AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, [ODBC_LIBS="$ODBC_LIBS -lodbcinst"],
AC_MSG_ERROR([Could not find SQLGetPrivateProfileString in -lodbcinst]))
LDFLAGS=$OLDLDFLAGS
OLDLDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[AC_MSG_RESULT(yes)
ODBC_LDFLAGS="-Wl,-Bsymbolic-functions"],
[AC_MSG_RESULT(no)
ODBC_LDFLAGS=""])
LDFLAGS=$OLDLDFLAGS
fi
AM_CONDITIONAL([UNIXODBC], test "$with_unixodbc")
if test "x$HAVE_ODBC" = "xtrue"; then
if test "x$sql" != "xtrue" ; then
AC_MSG_ERROR([ODBC requires flex and bison for the SQL engine])
fi
OLDCFLAGS=$CFLAGS
CFLAGS="$CFLAGS $ODBC_CFLAGS"
AC_CHECK_HEADERS(odbcinst.h iodbcinst.h)
CFLAGS=$OLDCFLAGS
AC_SUBST(ODBC_CFLAGS)
AC_SUBST(ODBC_LIBS)
AC_SUBST(ODBC_LDFLAGS)
OPTDIRS="$OPTDIRS odbc"
fi
dnl Testing presence of pkg-config
AC_MSG_CHECKING([pkg-config m4 macros])
if test m4_ifdef([PKG_CHECK_MODULES], [yes], [no]) = yes; then
AC_MSG_RESULT([yes]);
else
AC_MSG_RESULT([no]);
AC_MSG_ERROR([
pkg-config is required.
See pkg-config.freedesktop.org])
fi
dnl See if GLib is present and wanted
AC_ARG_ENABLE(glib,
AS_HELP_STRING([--disable-glib], [do not link with GLib]),
[enable_glib=$enableval], [enable_glib=yes])
if test "$enable_glib" = "yes"; then
GLIB_PACKAGE=glib-2.0
PKG_CHECK_MODULES([GLIB], [$GLIB_PACKAGE], HAVE_GLIB=true, HAVE_GLIB=false)
if test "x$HAVE_GLIB" = "xtrue"; then
GLIB_CFLAGS="$GLIB_CFLAGS -DHAVE_GLIB=1"
AC_CHECK_LIB($GLIB_PACKAGE, g_memdup2, [GLIB_CFLAGS="$GLIB_CFLAGS -DHAVE_G_MEMDUP2=1"])
AC_SUBST(GLIB_PACKAGE)
else
enable_glib=no
fi
fi
AM_CONDITIONAL(FAKE_GLIB, test "x$enable_glib" != "xyes")
dnl Set up substitution variables
if test "$ac_cv_header_xlocale_h" = "yes"; then
HAVE_XLOCALE_H=1
else
HAVE_XLOCALE_H=0
fi
AC_SUBST(HAVE_XLOCALE_H)
if test "$enable_glib" = "yes"; then
GLIB_INCLUDE_HEADER=glib.h
else
GLIB_INCLUDE_HEADER=mdbfakeglib.h
fi
AC_SUBST(GLIB_INCLUDE_HEADER)
AC_SUBST([OPTDIRS])
AC_CONFIG_FILES([src/Makefile include/mdbtools.h])
##################################################
# Check for txt2man
##################################################
AC_ARG_ENABLE(man,
AS_HELP_STRING([--disable-man], [disable man generation]),
enable_man="$enableval", [enable_man=yes])
if test "$enable_man" = yes; then
if ! which gawk > /dev/null; then
AC_MSG_ERROR([Could not find GNU awk. Install it or configure with --disable-man if you are not interested in manuals.])
fi
fi
AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" = yes)
##################################################
# Check for bash-completion.
##################################################
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
[Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
[],
[with_bash_completion_dir=yes])
if test "x$with_bash_completion_dir" = "xyes"; then
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
[BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
else
BASH_COMPLETION_DIR="$with_bash_completion_dir"
fi
AC_SUBST([BASH_COMPLETION_DIR])
AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"])
AC_CONFIG_FILES([
libmdb.pc
libmdbsql.pc
src/util/Makefile
src/util/bash-completion/Makefile
src/extras/Makefile
Makefile
include/Makefile
src/libmdb/Makefile
src/sql/Makefile
src/odbc/Makefile
src/fuzz/Makefile
doc/Makefile
include/mdbver.h])
AC_OUTPUT
##################################################
# Print summary
##################################################
bold_red=$(tput bold 2>/dev/null)$(tput setf 4 2>/dev/null)
bold_green=$(tput bold 2>/dev/null)$(tput setf 2 2>/dev/null)
bold=$(tput bold 2>/dev/null)
reset=$(tput sgr0 2>/dev/null)
AC_MSG_NOTICE([])
AC_MSG_NOTICE([${bold}MDB Tools $VERSION - Configuration summary${reset}])
AC_MSG_NOTICE([])
if test x$sql = xtrue; then summary=${bold_green}enabled; else summary=${bold_red}disabled; fi
AC_MSG_NOTICE([ SQL : ${summary}${reset}])
if test x$HAVE_ODBC = xtrue; then summary=${bold_green}enabled; else summary=${bold_red}disabled; fi
AC_MSG_NOTICE([ ODBC : ${summary}${reset}])
if test x$enable_glib = xyes; then summary=${bold_green}enabled; else summary=${bold_red}disabled; fi
AC_MSG_NOTICE([ GLib : ${summary}${reset}])
if test x$enable_iconv = xyes; then summary=${bold_green}enabled; else summary=${bold_red}disabled; fi
AC_MSG_NOTICE([ iconv : ${summary}${reset}])
if test x$enable_man = xyes; then summary=${bold_green}enabled; else summary=${bold_red}disabled; fi
AC_MSG_NOTICE([ man pages : ${summary}${reset}])
if test "x$with_bash_completion_dir" != "xno"; then summary=${bold_green}enabled; else summary=${bold_red}disabled; fi
AC_MSG_NOTICE([ bash-completion : ${summary}${reset}])
AC_MSG_NOTICE([])