forked from LibreDWG/libredwg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
828 lines (763 loc) · 27.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
dnl configure.ac
dnl Copyright (C) 2010, 2014-2015, 2018-2021 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],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[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])
dnl parallel-tests:
dnl: error: using '$(srcdir)' in TESTS is currently broken: '$(srcdir)/libredwg.spec'
dnl info-in-builddir might be an option for GH #211
AM_INIT_AUTOMAKE([1.14 gnu no-define serial-tests dist-xz info-in-builddir])
# Keep this in sync with what is passed in AC_INIT
TARBALL_VERSION_FILE=".tarball-version"
dnl Define these substitutions here to keep all version information in
dnl one place. For information on how to properly maintain the library
dnl version information, refer to the libtool manual, section "Updating
dnl library version information":
dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([LIBREDWG_SO_VERSION], [0:12:0])
AC_SUBST([TARBALL_VERSION_FILE])
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])
AC_MSG_CHECKING([git version])
AC_MSG_RESULT($PACKAGE_VERSION)
AC_MSG_CHECKING([so version-info])
AC_MSG_RESULT($LIBREDWG_SO_VERSION)
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
dnl AC_PROG_RANLIB: in LT_INIT
LT_INIT
AC_CHECK_PROGS([BASH], [bash])
if test x$enable_shared = xyes; then
AC_DEFINE([ENABLE_SHARED],1,[Define to 1 if a shared library will be built])
LTEXEC="\${top_builddir}/libtool --mode=execute"
fi
AM_CONDITIONAL([ENABLE_SHARED], [test "x$enable_shared" = xyes])
AC_SUBST(LTEXEC)
AC_C_INLINE
AC_C_RESTRICT
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]))
AC_CHECK_LIB([xml2],[newXMLEntity],
[have_libxml2=yes;
XML2_LIBS=-lxml2;
AC_SUBST([XML2_CFLAGS])
AC_SUBST([XML2_LIBS])
],
[if pkg-config --exists libpcre2; then
have_libxml2=yes;
XML2_CFLAGS=`pkg-config libxml-2.0 --cflags`
XML2_LIBS=`pkg-config libxml-2.0 --libs`
else
AC_MSG_WARN([libxml-2.0 for test/xmlsuite not found])
fi])
AM_CONDITIONAL([HAVE_LIBXML2], [test x$have_libxml2 = xyes])
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 stddef.h unistd.h malloc.h wchar.h ctype.h \
float.h limits.h \
libgen.h getopt.h alloca.h valgrind/valgrind.h])
AC_CHECK_HEADER_STDBOOL
AX_INCLUDE_STRCASECMP
# 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
case $CFLAGS in
*-fsanitize=undefined*) ax_cv_have_aligned_access_required=yes ;;
*-fsanitize=*,undefined*) ax_cv_have_aligned_access_required=yes ;;
esac
case $CC in
*-fsanitize=undefined*) ax_cv_have_aligned_access_required=yes ;;
*-fsanitize=*,undefined*) ax_cv_have_aligned_access_required=yes ;;
esac
AX_CHECK_ALIGNED_ACCESS_REQUIRED
case $CC in
*-fsanitize=address*) HAVE_ASAN=yes ;;
*-fsanitize=*,address*) HAVE_ASAN=yes ;;
esac
case $CC in
*-fsanitize=leak*) HAVE_ASAN=yes ;;
*-fsanitize=*,leak*) HAVE_ASAN=yes ;;
esac
case $CFLAGS in
*-fsanitize=address*) HAVE_ASAN=yes ;;
*-fsanitize=*,address*) HAVE_ASAN=yes ;;
esac
case $CFLAGS in
*-fsanitize=leak*) HAVE_ASAN=yes ;;
*-fsanitize=*,leak*) HAVE_ASAN=yes ;;
esac
AC_SUBST(HAVE_ASAN)
AM_CONDITIONAL([HAVE_ASAN], [test -n "$HAVE_ASAN"])
AC_TYPE_SIZE_T
AC_TYPE_INT16_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
dnl AX_GCC_BUILTIN(__builtin_offsetof)
AC_DEFINE([_POSIX_C_SOURCE],[200809L],[Needed for strdup])
AC_DEFINE([__XSI_VISIBLE],[700],[Needed for cygwin strdup])
AX_IS_RELEASE([git-directory])
dnl ability to override with a .git dir, to test release features
AC_ARG_ENABLE([release],AS_HELP_STRING([--enable-release],[
Override IS_RELEASE with .git dir present (default: $ax_is_release).]),
[ax_is_release=yes
AC_MSG_RESULT(IS_RELEASE override with --enable-release)])
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
enable_Werror=no
ax_enable_compile_warnings=yes
dnl This is too intrusive for our DWG_TYPE_* switches
ax_cv_check_cflags__Wswitch_enum=no
if test x$enable_shared = xyes -a x$ac_compiler_gnu = xyes; then
AX_COMPILER_FLAGS([WARN_CFLAGS],[AM_LDFLAGS],[$ax_is_release],
[-fno-common -fvisibility=hidden -fno-semantic-interposition -fno-strict-aliasing \
-fno-delete-null-pointer-checks -fno-strict-overflow])
else
AX_COMPILER_FLAGS([WARN_CFLAGS],[AM_LDFLAGS],[$ax_is_release],
[-fno-common -fvisibility=hidden -fno-strict-aliasing -fno-delete-null-pointer-checks -fno-strict-overflow])
fi
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 AX_GCC_FUNC_ATTRIBUTE(visibility)
AX_GCC_FUNC_ATTRIBUTE(gnu_format)
AX_GCC_FUNC_ATTRIBUTE(ms_format)
AX_GCC_FUNC_ATTRIBUTE(format)
AX_GCC_FUNC_ATTRIBUTE(malloc)
AX_GCC_FUNC_ATTRIBUTE(returns_nonnull)
AX_GCC_FUNC_ATTRIBUTE(noreturn)
dnl until we can make a release, favor no -O2 optims.
dnl it's fast enough and better for debugging.
dnl if test x$ac_compiler_gnu = xyes; then
dnl CFLAGS="$CFLAGS -fno-omit-frame-pointer"
dnl 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])
CFLAGS="$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_FUNC_ALLOCA
dnl broken for cross-compiling
dnl AC_FUNC_STRTOD
AC_CHECK_FUNC([strtod],[],
AC_MSG_ERROR([C89 strtod not found. Ignore for now]))
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.]))
AC_CHECK_FUNCS([scandir],[],
AC_MSG_WARN([BSD/POSIX scandir not found. No helper unit_testing_all.sh]))
AC_CHECK_FUNCS([floor sqrt])
AC_CHECK_LIB([m],[floor])
AC_CHECK_LIB([m],[sqrt])
AC_CHECK_FUNCS([sincos])
AC_CHECK_FUNCS([memchr memmove strcasecmp strchr strstr strrchr strtol strtoul strtoull strnlen])
AC_CHECK_FUNCS([memmem],[],
AC_MSG_WARN([memmem not found. Using a slower workaround.]))
AC_CHECK_FUNCS([wcslen wcsnlen wcscpy wcscmp wcsstr])
dnl try the secure extensions
$as_echo '#define __STDC_WANT_LIB_EXT1__ 1' >>confdefs.h
AC_CHECK_FUNCS([sscanf_s],[],
AC_MSG_WARN([No secure sscanf_s found. dwgfuzz -add will produce false positives.]))
dnl and undo it
$GREP -v '__STDC_WANT_LIB_EXT1__' confdefs.h > confdefs.h.tmp
mv confdefs.h.tmp confdefs.h
dnl mingw-w64 7.0 bug with _FORTIFY_SOURCE, need -lssp
case $LD in
*-w64-mingw32*)
AC_MSG_CHECKING([-lssp hack for mingw])
case $CFLAGS in
*-fstack-protector*)
AC_MSG_RESULT([yes])
;;
*) CFLAGS="$CFLAGS -fstack-protector"
LDFLAGS="$LDFLAGS -fstack-protector"
AC_MSG_RESULT([-fstack-protector added])
;;
esac
;;
esac
dnl x86_64-mingw-w64-gcc-9.2 is seriously broken, and not just mingw-w64
dnl --enable-debug sets DEBUG_CLASSES, will crash acad import
AC_MSG_CHECKING([--enable-debug])
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[
Enable unstable DEBUG_CLASSES (default: no).]),
[if test x$ac_compiler_gnu = xyes; then
CFLAGS="`echo $CFLAGS|sed 's,-O2,,'` -fno-omit-frame-pointer"
fi
CFLAGS="$CFLAGS -DDEBUG_CLASSES"]
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no (default)]))
AM_CONDITIONAL([ENABLE_DEBUG], [test x$enable_debug = xyes])
AX_ADD_FORTIFY_SOURCE
AX_RESTRICT
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_SUBST(DISABLE_WRITE, 0)
AC_MSG_RESULT([no (default)])],
[AC_SUBST(DISABLE_WRITE, 1)
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.])]
))
dnl --disable-dxf only useful for faster debug/test cycles
AC_MSG_CHECKING([--disable-dxf])
AC_ARG_ENABLE([dxf],AS_HELP_STRING([--disable-dxf],[
Disable DXF, JSON and other in/out modules (default: no).]),[],[enable_dxf=yes])
AM_CONDITIONAL([DISABLE_DXF], [test x$enable_dxf = xno])
AS_IF([test x$enable_dxf = xno],
AC_DEFINE([DISABLE_DXF],1,[Define to disable DXF, JSON and other in/out modules.])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no (default)]))
dnl --disable-json only useful for slim libraries (i.e. SolveSpace)
AC_MSG_CHECKING([--disable-json])
AC_ARG_ENABLE([json],AS_HELP_STRING([--disable-json],[
Disable JSON and GeoJSON in/out modules (default: no).]),[],[enable_json=yes])
AM_CONDITIONAL([DISABLE_JSON], [test x$enable_json = xno])
AS_IF([test x$enable_json = xno],
AC_DEFINE([DISABLE_JSON],1,[Define to disable JSON and GeoJSON in/out modules.])
AC_SUBST(DISABLE_JSON, 1)
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no (default)]))
dnl --disable-bindings
AC_MSG_CHECKING([--disable-bindings])
AC_ARG_ENABLE([bindings],AS_HELP_STRING([--disable-bindings],[
Disable SWIG bindings (default: no).]),[],[enable_bindings=yes])
AM_CONDITIONAL([DISABLE_BINDINGS], [test x$enable_bindings = xno])
AS_IF([test x$enable_bindings = xno],
AC_DEFINE([DISABLE_BINDINGS],1,[Define to disable bindings.])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no (default)]))
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")
AC_CHECK_PROGS([GPERF], [gperf])
if test -n "$GPERF"
then
AC_MSG_CHECKING([GPERF version])
[GPERF_VERSION=`"$GPERF" --version | head -n1 2>&1 | sed 's,GNU gperf ,,'`]
GPERF_MINOR="`echo $GPERF_VERSION | cut -f2 -d.`"
case $GPERF_VERSION in
1.*) GPERF_VERSION=$((100+$GPERF_MINOR)) ;;
2.*) GPERF_VERSION=$((200+$GPERF_MINOR)) ;;
3.*) GPERF_VERSION=$((300+$GPERF_MINOR)) ;;
4.*) GPERF_VERSION=$((400+$GPERF_MINOR)) ;;
esac
AC_MSG_RESULT([$GPERF_VERSION])
AC_DEFINE_UNQUOTED([GPERF_VERSION],[$GPERF_VERSION],
[versions earlier than 301 will have no size_t])
fi
AC_SUBST(GPERF)
AC_SUBST(GPERF_VERSION)
AM_CONDITIONAL(HAVE_GPERF, test -n "$GPERF")
AC_MSG_CHECKING([for latest clang-format])
CLANG_FORMAT=
for clangfmt in clang-format{,-mp}{,-devel,-{12,11,10,9,8,7,6,5,4,3}{,.9,.8,.7,.6,.5,.4,.3,.2,.1,.0}}
do
if which "$clangfmt" &>/dev/null; then
CLANG_FORMAT="$clangfmt"
break
fi
done
if test -z "$CLANG_FORMAT"; then
if which indent &>/dev/null; then
CLANG_FORMAT="indent"
else
CLANG_FORMAT=echo
fi
fi
AC_MSG_RESULT($CLANG_FORMAT)
AC_SUBST(CLANG_FORMAT)
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])
CFLAGS="$CFLAGS -D_WINE_MSVCRT"
fi
fi
AM_CONDITIONAL([HAVE_WINE], [test -n "$WINE"])
AM_CONDITIONAL([HAVE_CYGWIN], [test x$host_os = xcygwin32 -o x$host_os" = "xcygwin64])
if test -n "$HAVE_ASAN"
then
HAVE_ASAN_OR_LINUX=1
elif test x$host_os = xlinux-gnu
then
HAVE_ASAN_OR_LINUX=1
fi
AM_CONDITIONAL([HAVE_ASAN_OR_LINUX],[test -n "$HAVE_ASAN_OR_LINUX"])
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 and tests @<:@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 ($PYTHON)]) ;;
esac], [enable_python=check; AC_MSG_RESULT([check (default)]) ])
if test x$cross_compiling = xno -a x$enable_bindings = xyes; 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
dnl ls -al /usr/bin/python* >&6
if test x$enable_python = xyes; then
dnl die on error
AM_PATH_PYTHON([2.7])
else
dnl skip on error
AM_PATH_PYTHON
PYTHON_NOVERSIONCHECK=1
fi
SWIG_PYTHON
AC_CHECK_PROGS([PATCH], [patch])
fi
dnl swig not required for perl, we ship swig_perl.c
dnl AX_SWIG_ENABLE_CXX
dnl SWIG_MULTI_MODULE_SUPPORT
else
AC_MSG_WARN([disabled swig bindings])
if test x$enable_python != xno; then
if test x$enable_python = xyes; then
dnl die on error
AM_PATH_PYTHON([2.7])
else
dnl skip on error
AM_PATH_PYTHON
PYTHON_NOVERSIONCHECK=1
fi
fi
fi
if test x$enable_python != xno && test -n "$XML2_LIBS"; then
AC_MSG_CHECKING([for the libxml2 Python package])
ac_python_libxml2_result=`$PYTHON -c "import libxml2" 2>&1`
if test $? -eq 0; then
ac_have_python_libxml2=1
AC_MSG_RESULT([yes])
else
ac_have_python_libxml2=
AC_MSG_RESULT([no])
AC_MSG_WARN([disable test/xmlsuite.
The import error was:
$ac_python_libxml2_result])
fi
fi
AM_CONDITIONAL([HAVE_PYTHON_LIBXML2], [test x$ac_have_python_libxml2 = x1])
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])
if test -n "$PERL"; then
AC_MSG_CHECKING([PERL version])
[PERL_VERSION=`"$PERL" -e'print $^V' 2>&1`]
AC_MSG_RESULT([$PERL_VERSION])
AM_RUN_LOG([$PERL -V:cc])
dnl --enable-perl-install=vendor. default: site
AS_IF([test x$enable_bindings = xyes],
[AC_MSG_CHECKING([for --with-perl-install=])
AC_ARG_WITH(perl-install,
AS_HELP_STRING([--with-perl-install=],
[Where to install the perl bindings, vendor,arch,yes,no or @<:@default=site@:>@]),
[case "${with_perl_install}" in
vendor) with_perl_install=vendor; AC_MSG_RESULT([vendor]) ;;
yes|site) with_perl_install=site; AC_MSG_RESULT([site]) ;;
perl) with_perl_install=perl; AC_MSG_RESULT([perl]) ;;
no) with_perl_install=no; AC_MSG_RESULT([no]) ;;
*) AC_MSG_RESULT([invalid ${with_perl_install}: vendor,site,yes,perl,no]) ;;
esac],
[with_perl_install=site; AC_MSG_RESULT([site (default)]) ])
]
)
fi
AC_SUBST([with_perl_install])
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_VERSION"])
AM_CONDITIONAL([HAVE_PERL], [test -n "$PERL"])
dnl only needed with python bindings
AM_CONDITIONAL([HAVE_PATCH], [test -n "$PATCH"])
dnl AC_MSG_WARN([srcdir: $srcdir ac_builddir: $ac_builddir builddir: $builddir])
AM_CONDITIONAL([HAVE_INSRCDIR], [test x"$srcdir" = x"."])
AC_CHECK_PROGS([PICAT], [picat])
if test -n "$PICAT"; then
AC_MSG_CHECKING([PICAT version])
[picat_version=`"$PICAT" --version 2>&1 | grep 'Picat version' | cut -c15-`]
AC_MSG_RESULT([$picat_version])
fi
AM_CONDITIONAL([HAVE_PICAT], [test -n "$PICAT"])
dnl GNU parallel, skip the old non-perl version from moreutils so far
AC_CHECK_PROGS([PARALLEL], [parallel])
logs_all=logs-all-serial.sh.in
if test -n "$PARALLEL"; then
AC_MSG_CHECKING([PARALLEL version])
parallel_version=`"$PARALLEL" --version 2>&1 | head -n1 | cut -c14-`
case $parallel_version in
20* ) logs_all=logs-all-parallel.sh.in
;;
*invalid* )
PARALLEL=
parallel_version="skip old moreutils version, need GNU parallel"
#TODO
#logs_all=logs-all-parallel-old.sh.in
esac
AC_MSG_RESULT([$parallel_version])
fi
AM_CONDITIONAL([HAVE_PARALLEL], [test -n "$PARALLEL"])
dnl coreutils timeout
AC_CHECK_PROGS([TIMEOUT], [timeout])
if test -n "$TIMEOUT"; then
AC_MSG_CHECKING([TIMEOUT version])
[timeout_version=`"$TIMEOUT" --version 2>&1 | grep '^timeout ' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
AC_MSG_RESULT([$timeout_version])
TIMEOUT_10="$TIMEOUT 10"
TIMEOUT_30="$TIMEOUT 30"
fi
AM_CONDITIONAL([HAVE_TIMEOUT], [test -n "$TIMEOUT"])
AC_SUBST([TIMEOUT_10])
AC_SUBST([TIMEOUT_30])
dnl build-aux/missing catches an outdated /usr/bin/makeinfo 4.8 on darwin 10.11
dnl the texi2any version >6 is needed for @indentedblock
case $host_os in
darwin*)
if test -f /opt/local/bin/makeinfo ; then
MAKEINFO=/opt/local/bin/makeinfo
else
AC_CHECK_PROGS([MAKEINFO], [makeinfo])
fi
;;
*) AC_CHECK_PROGS([MAKEINFO], [makeinfo])
;;
esac
if test -n "$MAKEINFO"; then
AC_MSG_CHECKING([MAKEINFO version])
dnl either old makeinfo or new texi2any (preferred)
[makeinfo_version=`"$MAKEINFO" --version 2>&1 | $GREP 'texinfo' | cut -d' ' -f4`]
AC_SUBST([makeinfo_version])
AC_MSG_RESULT([$makeinfo_version])
fi
AM_CONDITIONAL([HAVE_MAKEINFO], [test -n "$MAKEINFO"])
if test x$enable_debug = xyes; then
JSON_SED_NAN="\$SED -i -e's/ nan/ \"nan\"/g;'"
else
JSON_SED_NAN="true"
fi
AC_SUBST([JSON_SED_NAN])
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -n "$DOXYGEN"; then
AC_MSG_CHECKING([DOXYGEN version])
[doxygen_version=`"$DOXYGEN" --version 2>&1`]
AC_MSG_RESULT([$doxygen_version])
fi
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AC_CHECK_PROGS([JQ], [jq])
if test -n "$JQ"; then
AC_MSG_CHECKING([JQ version])
[jq_version=`"$JQ" --version 2>&1 | grep 'jq-' | cut -c4-`]
AC_MSG_RESULT([$jq_version])
fi
AM_CONDITIONAL([HAVE_JQ], [test -n "$JQ"])
case $host_os in
darwin*) DSYMUTIL=dsymutil ;;
mingw*) DSYMUTIL=rem ;;
windows*) DSYMUTIL=rem ;;
*) DSYMUTIL='#' ;;
esac
AC_SUBST([DSYMUTIL])
AC_CHECK_PROGS([SHELLCHECK], [shellcheck])
AM_CONDITIONAL([HAVE_SHELLCHECK], [test -n "$SHELLCHECK"])
AC_CHECK_PROGS([RPMLINT], [rpmlint])
AM_CONDITIONAL([HAVE_RPMLINT], [test -n "$RPMLINT"])
AC_CHECK_PROGS([GEOJSONHINT], [geojsonhint])
if [ test -z "$GEOJSONHINT" ]; then
dnl fallback to npm i -g geojson-validation
AC_CHECK_PROGS([GJV], [gjv])
GEOJSONLINT="$GJV"
else
GEOJSONLINT="$GEOJSONHINT"
fi
AC_SUBST([GEOJSONLINT])
dnl SVG validation
AC_CHECK_PROGS([JING], [jing])
case $host_os in
mingw*) RUN_JING=rem ;;
windows*) RUN_JING=rem ;;
*) RUN_JING=":" ;;
esac
dnl LaTeXML has a broken svg11-basic.rng
dnl The zip from http://yupotan.sppd.ne.jp/relax-ng/svg11/ is correct.
dnl Needs to be installed into /usr/local/share/relaxng/svg11/
dnl See https://github.com/brucemiller/LaTeXML/issues/1237
if test -n "$JING"
then
AC_MSG_CHECKING([for a working relaxng svg11-basic.rng])
if test -e "/usr/local/share/relaxng/svg11/svg11-basic.rng"
then
try_jing="$JING /usr/local/share/relaxng/svg11/svg11-basic.rng"
AC_MSG_RESULT([$try_jing])
elif test -e "/usr/share/perl5/vendor_perl/LaTeXML/resources/RelaxNG/svg/svg11-basic.rng"
then
try_jing="$JING /usr/share/perl5/vendor_perl/LaTeXML/resources/RelaxNG/svg/svg11-basic.rng"
AC_MSG_RESULT([$try_jing])
else
LATEXPM=`$PERL -MLaTeXML -e'print $INC{"LaTeXML.pm"}'`
if test -e "$LATEXPM" -a -e "`dirname $LATEXPM`/LaTeXML/resources/RelaxNG/svg/svg11-basic.rng"
then
try_jing="$JING `dirname $LATEXPM`/LaTeXML/resources/RelaxNG/svg/svg11-basic.rng"
AC_MSG_RESULT([$try_jing])
else
AC_MSG_RESULT([none])
JING=
fi
fi
AC_MSG_CHECKING([whether the svg validator works (maybe broken LaTeXML)])
cat <<_ACEOF >try.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1" baseProfile="basic"
width="100%" height="100%"
viewBox="-2680430.068109 -1672547.179548 3540706.089899 2726367.694617">
<path id="dwg-object-45" d="M 2680800.926721,1053089.884765 L 2680880.107866,1053201.295796"
style="fill:none;stroke:black;stroke-width:0.1px" />
</svg>
_ACEOF
if $try_jing try.svg
then
RUN_JING="$try_jing"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_RESULT(m4_normalize([
Use the zip from http://yupotan.sppd.ne.jp/relax-ng/svg11/
and unpack it into /usr/local/share/relaxng/svg11/
]))
JING=
fi
rm try.svg 2>/dev/null
fi
AC_SUBST([RUN_JING])
AM_CONDITIONAL([HAVE_JING], [test -n "$JING"])
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])
AX_VALGRIND_CHECK()
if test -n "$VALGRIND"; then
if test -n "$VALGRIND"; then
AC_MSG_CHECKING([VALGRIND version])
[valgrind_version=`"$VALGRIND" --version 2>&1 | sed 's,valgrind-,,'`]
AC_MSG_RESULT([$valgrind_version])
fi
AC_MSG_CHECKING([for Valgrind suppressions])
case $host_os in
linux*) VALGRIND_SUPPRESSIONS_FILE=valgrind-linux.supp ;;
darwin*) VALGRIND_SUPPRESSIONS_FILE=valgrind-darwin.supp ;;
esac
if test -n $VALGRIND_SUPPRESSIONS_FILE; then
VALGRIND_SUPPRESSIONS="--suppressions=\$(abs_top_srcdir)/\$(VALGRIND_SUPPRESSIONS_FILE)"
AC_MSG_RESULT([$VALGRIND_SUPPRESSIONS_FILE])
else
AC_MSG_RESULT([none])
fi
fi
else
AC_MSG_WARN([disabled valgrind: cross-compiled])
enable_valgrind=no
AX_VALGRIND_CHECK()
fi
AC_SUBST(VALGRIND_SUPPRESSIONS)
AC_SUBST(VALGRIND_SUPPRESSIONS_FILE)
dnl Write it out
AC_CONFIG_FILES([
Makefile
src/Makefile
doc/Makefile
programs/Makefile
examples/Makefile
bindings/Makefile
bindings/python/Makefile
test/Makefile
test/xmlsuite/Makefile
test/unit-testing/Makefile
libredwg.pc
])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/footer])])
AM_COND_IF([HAVE_PERL], [AC_CONFIG_FILES([bindings/perl/Makefile.PL])])
AC_CONFIG_FILES([programs/dwgfilter], [chmod +x programs/dwgfilter])
AC_CONFIG_FILES([programs/alive.test], [chmod +x programs/alive.test])
AC_CONFIG_FILES([programs/dxf.test], [chmod +x programs/dxf.test])
AC_CONFIG_FILES([programs/json.test], [chmod +x programs/json.test])
AC_CONFIG_FILES([programs/svg.test], [chmod +x programs/svg.test])
AC_CONFIG_FILES([logs-all.sh:$logs_all], [chmod +x logs-all.sh])
AC_CONFIG_FILES([log], [chmod +x log])
AC_CONFIG_FILES([dwg], [chmod +x dwg])
AC_CONFIG_FILES([dxf], [chmod +x dxf])
AC_CONFIG_FILES([json], [chmod +x json])
AC_CONFIG_FILES([svg], [chmod +x svg])
AC_CONFIG_FILES([rw], [chmod +x rw])
AC_CONFIG_FILES([dynapi_test_all.sh], [chmod +x dynapi_test_all.sh])
if test "x$ac_cv_func_scandir" = xyes; then
AC_CONFIG_FILES([unit_testing_all.sh], [chmod +x unit_testing_all.sh])
fi
AC_OUTPUT
dnl configure.ac ends here