forked from eryar/libredwg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
336 lines (299 loc) · 10.8 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
334
335
336
dnl configure.ac
dnl Copyright (C) 2010, 2014-2015, 2018 Free Software Foundation, Inc.
dnl
dnl This program is free software, licensed under the terms of the GNU
dnl General Public License as published by the Free Software Foundation,
dnl either version 3 of the License, or (at your option) any later version.
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ([2.61])
AC_INIT([LibreDWG],[0.4.924],[libredwg@gnu.org],,
[https://savannah.gnu.org/projects/libredwg/])
AC_CONFIG_AUX_DIR([build-aux])
dnl for older systems use this:
dnl AM_INIT_AUTOMAKE([1.11.6 gnu no-define])
AM_INIT_AUTOMAKE([1.12.2 gnu no-define serial-tests dist-xz])
AC_CONFIG_MACRO_DIR([m4])
# Check if automake supports 'pretty' builds, if so enable them by default
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl create a config.h file (Automake will add -DHAVE_CONFIG_H)
AM_CONFIG_HEADER([src/config.h])
ISODATE=`date +%Y-%m-%d`
AC_SUBST(ISODATE)
AC_CANONICAL_HOST
dnl Checks for programs
PKG_PROG_PKG_CONFIG
AC_PROG_CC
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_LIBTOOL
LT_INIT
dnl Checks for libraries
AC_CHECK_LIB([ps],[PS_open_file],
libredwg_have_libps=yes,
libredwg_have_libps=no)
dnl `pcre2-config --libs8`
AC_CHECK_LIB([pcre2-8],[pcre2_config_8],
[libredwg_have_libpcre2=yes; PCRE2_LIBS=-lpcre2-8],
[if pkg-config --exists libpcre2; then
libredwg_have_libpcre2=yes;
PCRE2_CFLAGS=`pkg-config libpcre2 --cflags`
PCRE2_LIBS=`pkg-config libpcre2 --libs`
else
AC_MSG_WARN([libpcre2 for dwggrep not found])
fi])
AC_CHECK_LIB([pcre2-16],[pcre2_config_16],
[libredwg_have_libpcre2_16=yes])
if test yes = "$libredwg_have_libpcre2_16"; then
AC_DEFINE([HAVE_PCRE2_16],1,[Define to 1 if -lpcre2-16 is used also])
PCRE2_LIBS="$PCRE2_LIBS -lpcre2-16"
fi
AC_SUBST([PCRE2_CFLAGS])
AC_SUBST([PCRE2_LIBS])
dnl PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], [],
dnl AC_MSG_ERROR([Install libxml-2.0 first]))
if pkg-config --exists libxml-2.0; then
XML2_CFLAGS=`pkg-config libxml-2.0 --cflags`
XML2_LIBS=`pkg-config libxml-2.0 --libs`
fi
AC_SUBST([XML2_CFLAGS])
AC_SUBST([XML2_LIBS])
dnl Checks for header files
AC_HEADER_STDC
dnl Avoid rpl_malloc when cross-compiling. we don't need malloc.h
dnl We just want to know if it's needed
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
AC_CHECK_HEADERS([stdlib.h string.h unistd.h malloc.h wchar.h ctype.h \
libgen.h getopt.h])
AX_INCLUDE_STRCASECMP
AC_CHECK_HEADER([dejagnu.h], [],
AC_MSG_WARN([Couldn't find dejagnu.h. skip test/testcases]))
AM_CONDITIONAL([HAVE_DEJAGNU], [test x$ac_cv_header_dejagnu_h = xyes])
# Don't bother testing for libps headers if libps is not available.
if test yes = "$libredwg_have_libps" ; then
AC_CHECK_HEADERS([libps/pslib.h])
fi
AM_CONDITIONAL([HAVE_LIBPS],[test "x$libredwg_have_libps" = xyes &&
test "x$ac_cv_header_libps_pslib_h" = xyes])
if test yes = "$libredwg_have_libpcre2"; then
AC_CHECK_HEADERS([pcre2.h],[],[],[#define PCRE2_CODE_UNIT_WIDTH 8])
else
AC_MSG_WARN([Couldn't find pcre2.h. No regex support in dwggrep])
fi
dnl Checks for typedefs, structures, and compiler characteristics
AC_PROG_CC_C99
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_INT32_T
AC_TYPE_UINT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT64_T
AC_CHECK_SIZEOF([size_t])
dnl AC_CHECK_TYPE([wchar_t],[],[],[[#include <wchar.h>]])
if test x$ac_cv_header_wchar_h = xyes; then
AX_COMPILE_CHECK_SIZEOF([wchar_t], [#include <wchar.h>])
fi
AC_DEFINE([_POSIX_C_SOURCE],[200809L],[Needed for strdup])
AC_DEFINE([__XSI_VISIBLE],[700],[Needed for cygwin strdup])
AX_IS_RELEASE([git-directory])
if test x$ax_is_release = xyes; then
AC_DEFINE([IS_RELEASE],1,[Define to 1 if this is a release,
skipping unstable DWG features, unknown DWG versions and objects.])
fi
AM_CONDITIONAL([IS_RELEASE], [test x$ax_is_release = xyes])
dnl Disable unwanted warnings here. These should be fixed before 1.0
enable_Werror=no
ax_enable_compile_warnings=yes
AX_COMPILER_FLAGS([AM_CFLAGS],[AM_LDFLAGS],[$ax_is_release],[-fvisibility=hidden])
dnl if test x$ax_cv_check_cflags__Wunused_but_set_variable = xyes; then
dnl WARN_CFLAGS="$WARN_CFLAGS -Wno-unused-but-set-variable"
dnl fi
dnl if test x$ax_cv_check_cflags__Wunused_variable = xyes; then
dnl WARN_CFLAGS="$WARN_CFLAGS -Wno-unused-variable"
dnl fi
AC_CACHE_CHECK([for __attribute__((visibility("default")))],
ac_cv_attribute_visibility_default, [
ac_cv_attribute_visibility_default=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[ int __attribute__ ((visibility ("default"))) foo (void) { return 1; } ]], [])],
[ac_cv_attribute_visibility_default=yes])
])
if test x$ac_cv_attribute_visibility_default = xyes;
then
AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY_DEFAULT, 1,
[Define if __attribute__((visibility("default"))) is supported.])
fi
dnl until we can make a release, favor no -O2 optims.
dnl it's fast enough and better for debugging.
if test x$ac_compiler_gnu = xyes; then
CFLAGS="-g -fno-omit-frame-pointer"
else
CFLAGS="-g"
fi
if test "x$ac_cv_prog_cc_c99" = "xno"; then
AC_MSG_WARN([This compiler ${CC} has no c99 support])
else
AC_DEFINE([HAVE_C99], 1,
[Defined to 1 when the compiler supports c99, mostly (...) macros])
if test "x$ac_cv_prog_cc_c99" != "x"; then
AC_MSG_RESULT([added $ac_cv_prog_cc_c99 to CFLAGS])
AM_CFLAGS="$AM_CFLAGS $ac_cv_prog_cc_c99"
fi
fi
AC_SUBST(HAVE_C99)
dnl Checks for library functions
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNC([strdup],[],
AC_MSG_ERROR([strdup not found. Check your _POSIX_C_SOURCE vs ANSI settings.]))
AC_CHECK_FUNCS([getopt_long],[],
AC_MSG_WARN([getopt_long not found. programs will not accept long options.]))
AC_CHECK_FUNCS([basename],[],
AC_MSG_WARN([basename not found. The default outfile will be unexpected.]))
AC_CHECK_FUNCS([strcasestr],[],
AC_MSG_WARN([strcasestr not found. Using a slower workaround.]))
dnl Feature: --disable-write
AC_MSG_CHECKING([--disable-write])
AC_ARG_ENABLE([write],AS_HELP_STRING([--disable-write],[
Disable write support (default: no).]),[],[enable_write=yes])
AM_CONDITIONAL([USE_WRITE], [test x$enable_write != xno])
AS_IF([test x$enable_write != xno],
AC_DEFINE([USE_WRITE],1,[Undefine to disable write support.])
AC_MSG_RESULT([no (default)]),
AC_MSG_RESULT([yes]))
dnl Feature: --enable-trace
AC_MSG_CHECKING([--enable-trace])
AC_ARG_ENABLE([trace],AS_HELP_STRING([--enable-trace],[
Enable runtime tracing (default: no). When enabled, the environment
variable LIBREDWG_TRACE is consulted on the first decode/encode attempt.
Its value is an integer: 0 (no output) through 9 (full verbosity).]),
AC_DEFINE([USE_TRACING],1,[Define to 1 to enable runtime tracing support.])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no (default)]))
AC_CHECK_FUNCS([setenv],[],
AS_IF([test x$enable_trace = xyes],
[AC_MSG_WARN([setenv not found. --enable-trace is limited with cmdline apps.
Only -v args are taken for verbosity not the LIBREDWG_TRACE env var.])],
[AC_MSG_RESULT([setenv not needed. no --enable-trace.])]
))
AC_MSG_CHECKING([for --enable-gcov])
AC_ARG_ENABLE(gcov,
AS_HELP_STRING([--enable-gcov],
[turn on test coverage @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_gcov=true ; gcov=gcov ;;
no) enable_gcov=false ;;
*) enable_gcov=true ; gcov="${enableval}" ;;
esac], [enable_gcov=false ])
if test "x$enable_gcov" = "xtrue" ; then
dnl if test "$GCC" = yes; then
dnl AC_MSG_ERROR([gcov only works if gcc is used])
dnl fi
dnl You might need the compiler-specific gcov: e.g. gcov-mp-6
GCOV="$gcov"
AC_MSG_RESULT([gcov=$gcov])
AC_SUBST(GCOV)
GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
AC_SUBST(GCOV_CFLAGS)
dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
dnl links in -lgcov, so we do it explicitly here for the same effect
GCOV_LIBS=-lgcov
AC_SUBST(GCOV_LIBS)
else
AC_MSG_RESULT([no (default)])
fi
AM_CONDITIONAL(ENABLE_GCOV, test "x$enable_gcov" = "xtrue")
dnl Check for mingw, cross and wine
AM_CONDITIONAL([HAVE_MINGW], [test "x$host_os" = "xmingw32"])
AM_CONDITIONAL([HAVE_MINGW_CROSS],
[test "x$host_os" = "xmingw32" -a "x$build_os" != "xmingw32"])
if test "x$host_os" = "xmingw32" -a "x$build_os" != "xmingw32"; then
cross_compiling=yes
AC_CHECK_PROGS([WINE], [wine])
if test -z "$WINE"; then
AC_MSG_WARN([wine not found - cannot check cross-compiled executables])
else
AC_MSG_RESULT([wine found - test with make check-wine])
AM_CFLAGS="$AM_CFLAGS -D_WINE_MSVCRT"
fi
fi
AM_CONDITIONAL([HAVE_WINE], [test -n "$WINE"])
dnl Optional SWIG + python bindings
dnl Feature: --disable-python or --enable-python=python3.6
AC_MSG_CHECKING([for --disable-python])
AC_ARG_ENABLE(python,
AS_HELP_STRING([--disable-python],
[Disable python bindings @<:@default=check@:>@]),
[case "${enableval}" in
yes) enable_python=yes; AC_MSG_RESULT([enabled]) ;;
no) enable_python=no; AC_MSG_RESULT([disabled]) ;;
*) enable_python=yes ; PYTHON="${enableval}"; AC_MSG_RESULT([enabled]) ;;
esac], [enable_python=check; AC_MSG_RESULT([check]) ])
if test x$cross_compiling = xno; then
AX_PKG_SWIG([1.3.17], [],
AC_MSG_WARN([SWIG is required for python bindings. disabled]))
if test -n "$SWIG" -a x$enable_python != xno; then
AM_PATH_PYTHON([2.7])
SWIG_PYTHON
fi
dnl swig not required for perl, we ship swig_perl.c
if test -n "$PERL"; then
ac_cv_perl="$PERL"
AC_CACHE_VAL([ac_cv_perl],$PERL)
else
ac_cv_perl=perl
fi
AC_PATH_PROG([PERL], [$ac_cv_perl])
AM_RUN_LOG([$PERL --version])
AM_RUN_LOG([$PERL -V:cc])
dnl AX_SWIG_ENABLE_CXX
dnl SWIG_MULTI_MODULE_SUPPORT
else
AC_MSG_WARN([disabled swig bindings: cross-compiled])
fi
AM_CONDITIONAL([HAVE_SWIG_PYTHON],
[test -n "$SWIG" && test -n "$PYTHON_VERSION"])
AM_CONDITIONAL([HAVE_PYTHON],
[test x$enable_python != xno])
AM_CONDITIONAL([HAVE_SWIG_PERL],
[test -n "$SWIG" && test -n "$PERL"])
AM_CONDITIONAL([HAVE_PERL],
[test -n "$PERL"])
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
dnl help2man only by the maintainer
if test x$cross_compiling = xno; then
dnl check for valgrind
case $host_os in
darwin*)
enable_valgrind_helgrind=no
enable_valgrind_drd=no
;;
esac
dnl passes only on some systems. --enable-valgrind-sgcheck
AX_VALGRIND_DFLT([sgcheck], [off])
else
AC_MSG_WARN([disabled valgrind: cross-compiled])
enable_valgrind=no
fi
AX_VALGRIND_CHECK()
dnl Write it out
AC_CONFIG_FILES([
Makefile
src/Makefile
doc/Makefile
programs/Makefile
examples/Makefile
bindings/Makefile
bindings/python/Makefile
test/Makefile
test/testcases/Makefile
test/xmlsuite/Makefile
test/unit-testing/Makefile
])
AC_OUTPUT
dnl configure.ac ends here