forked from opencog/link-grammar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1150 lines (967 loc) · 36.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
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
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# This file is processed by the Windows build system using confvar.bat.
# It assumes AC_INIT is the first command, with no blank lines before
# it and with a blank line after it. If this things are changed, change
# confvar.bat accordingly.
#
# Don't end the URLs with a slash even if it appears in the official address,
# because we may append a component. Also, they cannot include "!".
AC_INIT([link-grammar],[5.12.5],[https://github.com/opencog/link-grammar],[],
[https://opencog.github.io/link-grammar-website])
# Check whether we want to set defaults for CFLAGS and CXXFLAGS
AC_MSG_CHECKING([whether configure should try to set CFLAGS/CXXFLAGS])
AS_IF([test "x${CFLAGS+set}" = "xset" || test "x${CXXFLAGS+set}" = "xset"], [
enable_flags_setting=no
: ${CFLAGS="-g -O3"}
: ${CXXFLAGS="-g -O3"}
], [
enable_flags_setting=yes
dnl Set to -g -O3 here so AC_PROG_CC and AC_PROG_CXX do not add -g -O2
CFLAGS="-g -O3"
CXXFLAGS="-g -O3"
])
AC_MSG_RESULT([${enable_flags_setting}])
DISCUSSION_GROUP=https://groups.google.com/d/forum/link-grammar
AC_SUBST(DISCUSSION_GROUP)
OVERVIEW=https://en.wikipedia.org/wiki/Link_grammar
AC_SUBST(OVERVIEW)
# Set release number
dnl This is derived from "Versioning" chapter of info libtool documentation.
PACKAGE=link-grammar
dnl 4a) Increment when removing or changing interfaces.
LINK_MAJOR_VERSION=5
dnl 4a) 5) Increment when adding interfaces.
dnl 6) Set to zero when removing or changing interfaces.
LINK_MINOR_VERSION=12
dnl 3) Increment when interfaces not changed at all,
dnl only bug fixes or internal changes made.
dnl 4b) Set to zero when adding, removing or changing interfaces.
LINK_MICRO_VERSION=5
dnl
dnl Set this too
MAJOR_VERSION_PLUS_MINOR_VERSION=`expr $LINK_MAJOR_VERSION + $LINK_MINOR_VERSION`
dnl
VERSION=$LINK_MAJOR_VERSION.$LINK_MINOR_VERSION.$LINK_MICRO_VERSION
# Version info for libraries = CURRENT:REVISION:AGE
VERSION_INFO=$MAJOR_VERSION_PLUS_MINOR_VERSION:$LINK_MICRO_VERSION:$LINK_MINOR_VERSION
AC_SUBST(VERSION_INFO)
AC_SUBST(LINK_MAJOR_VERSION)
AC_SUBST(LINK_MINOR_VERSION)
AC_SUBST(LINK_MICRO_VERSION)
AM_INIT_AUTOMAKE([foreign subdir-objects])
# When maintainer-mode is enabled, downstream users sometimes trip
# trip over automake issues. See bug #649.
AM_MAINTAINER_MODE([disable])
# AM_MAINTAINER_MODE([enable])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR($PACKAGE)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)])
dnl "Undefined AX_ macro" is checked in autogen.sh, so if this message
dnl is changed here it should be changed there too.
m4_pattern_forbid([^AX_(COMPILER_VENDOR|TLS|PKG_SWIG)\b],
[Undefined AX_ macro. Please install the "autoconf-archive" package.])
m4_pattern_forbid([^PKG_],
[Undefined PKG_ macro. Please install the "pkg-config"
package (may be also named "pkgconf" or "pkgconfig").])
# OS checks, including Win32
AC_CANONICAL_HOST
dnl Checks for programs.
# The following echoes locate the bug described in issue
# https://github.com/opencog/link-grammar/issues/1361
AS_ECHO_N(["Hello World! Where am I?\n"])
AC_PROG_CC
AS_ECHO_N(["Hah! I think I found where you are hiding!\n"])
AC_PROG_CXX
AX_COMPILER_VENDOR
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
LT_INIT([win32-dll])
PKG_PROG_PKG_CONFIG
test -z "$PKG_CONFIG" &&
AC_MSG_ERROR([No pkg-config program found. Please install the "pkg-config"
package (may be also named "pkgconf" or "pkgconfig").])
AC_PROG_LEX(noyywrap)
(test -z "$LEX" || test "$LEX" == ':') &&
AC_MSG_ERROR([No flex/lex program found. Please install the "flex" or
"btyacc" package.])
# ====================================================================
# Check for specific OSs
AC_MSG_CHECKING([for native Win32])
case "$host_os" in
*cygwin* | *msys* | *mingw* | *pw32 | *cegcc*)
native_win32=yes
;;
*)
native_win32=no
;;
esac
AC_MSG_RESULT([$native_win32])
AM_CONDITIONAL(OS_WIN32, test "x$native_win32" = "xyes")
AC_MSG_CHECKING([for Cygwin])
case "$host_os" in
*cygwin*)
cygwin=yes
;;
*)
cygwin=no
;;
esac
AC_MSG_RESULT([$cygwin])
AM_CONDITIONAL(OS_CYGWIN, test "x$cygwin" = "xyes")
AC_MSG_CHECKING([for NetBSD])
case "$host_os" in
*netbsd*)
netbsd=yes
;;
*)
netbsd=no
;;
esac
AC_MSG_RESULT([$netbsd])
AM_CONDITIONAL(OS_NETBSD, test "x$netbsd" = "xyes")
AC_MSG_CHECKING([for FreeBSD])
case "$host_os" in
*freebsd*)
freebsd=yes
;;
*)
freebsd=no
;;
esac
AC_MSG_RESULT([$freebsd])
AM_CONDITIONAL(OS_FREEBSD, test "x$freebsd" = "xyes")
HOST_OS="$host_os"
AC_SUBST(HOST_OS)
# ====================================================================
# FreeBSD work-around. Apparently, the AX_PTHREAD autoconf macro
# fails to include -lstdthreads in its results. See bug report
# https://github.com/opencog/link-grammar/issues/1355
# So we hack, and explicitly set it here.
if test -n "$ax_pthread_ok" -a "x$freebsd" = "xyes"; then
PTHREAD_LIBS="${PTHREAD_LIBS} -lstdthreads"
fi
# ====================================================================
# The below says "use the C compiler for all remaining tests".
# That way, if g++ is not installed, configure won't crap out
# (with a mystery error about not finding regex.h)
AC_LANG([C])
CXXFLAGS="${CXXFLAGS} -Wall"
# The std=c11 flag provides the proper float-pt math decls working,
# e.g. fmax However, it also undefined _BSD_SOURCE, etc. which is
# needed to get fileno, strdup, etc. and so it needs to be manually
# enabled again.
# Setting -D_POSIX_SOURCE messes up compilation on FreeBSD by
# hiding strdup, etc. again.
# Final solution: enable std=c11, explicitly turn on BSD and SVID and
# GNU, but do NOT turn on POSIX.
CFLAGS="-std=c11 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -D_ISOC11_SOURCE ${CFLAG_VISIBILITY} ${CFLAGS}"
CXXFLAGS="-std=c++17 ${CFLAG_VISIBILITY} ${CXXFLAGS}"
# _BSD_SOURCE and _SVID_SOURCE are deprecated in glibc>=2.20. _DEFAULT_SOURCE
# is used there instead, but _BSD_SOURCE and _SVID_SOURCE can still be
# specified (no effect). So just add it.
CFLAGS="-D_DEFAULT_SOURCE ${CFLAGS}"
CXXFLAGS="-D_DEFAULT_SOURCE ${CXXFLAGS}"
#
# After setting the compiler's C standard and flags,
# we can check for supported features.
#
# Check for keywords to support pointer argument rejection
# in #define ARRAY_SIZE (utilities.h).
AX_GCC_BUILTIN(__builtin_types_compatible_p)
AC_C_TYPEOF
AC_CHECK_FUNCS(strndup strtok_r sigaction malloc_trim asprintf)
AC_CHECK_FUNCS(aligned_alloc posix_memalign _aligned_malloc)
# For the Wordgraph display code.
AC_FUNC_FORK
AC_CHECK_FUNCS(prctl)
AC_FUNC_ALLOCA
# Check for a keyword for Thread Local Storage declaration.
# If found - define TLS to it.
lg_tls=no
AX_TLS(,:)
test "$ac_cv_tls" != "none" && lg_tls=yes
AX_PTHREAD
if test -n "$ax_pthread_ok"; then
CC="${PTHREAD_CC:-CC}"
dnl #CCX="${PTHREAD_CC:-CCX}"
dnl Currently, libtool uses --nostdlib when linking shared libraries,
dnl which causes the -pthread flag to be ignored. Try to work around that
dnl by explicitly specifying the pthread library unless it is already set.
if test -z "$PTHREAD_LIBS"; then
PTHREAD_LIBS=-lpthread
fi
fi
# Check if we can use C11 threads functions.
AC_CHECK_HEADERS_ONCE([threads.h])
# If the visibility __attribute__ is supported, define HAVE_VISIBILITY
# and a variable CFLAG_VISIBILITY, to be added to CFLAGS/CXXFLAGS.
LG_C_ATTRIBUTE_VISIBILITY
# CentOS-7 (at least) needs these to expose the C99 format and
# limit macros in C++ source code. They are needed for minisat.
AC_DEFINE(__STDC_FORMAT_MACROS)
AC_DEFINE(__STDC_LIMIT_MACROS)
# End of checks for C compiler supported features.
if test x${native_win32} = xyes; then
# We need the shlwapi for PathRemoveFileSpecA().
LDFLAGS="${LDFLAGS} -lshlwapi"
# By default, MinGW doesn't know about %zu, which we use a lot, even
# on systems which have MSVC14, which has c99 stdio (printf prints
# "zu"). Add __USE_MINGW_ANSI_STDIO in order to solve that.
AC_DEFINE(__USE_MINGW_ANSI_STDIO, 1)
AC_DEFINE(__printf__, gnu_printf)
# Only running on Vista and on is supported.
AC_DEFINE(NTDDI_VERSION, NTDDI_VISTA)
AC_DEFINE(_WIN32_WINNT, _WIN32_WINNT_VISTA)
fi
# ====================================================================
dnl For locale_t
AC_MSG_CHECKING(for locale_t in locale.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <locale.h>], [locale_t lt = NULL])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_LOCALE_T_IN_LOCALE_H], 1, [Define to 1 if locale_t is defined in locale.h]),
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for locale_t in xlocale.h)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <xlocale.h>], [locale_t lt = NULL])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_LOCALE_T_IN_XLOCALE_H], 1, [Define to 1 if locale_t is defined in xlocale.h]),
AC_MSG_RESULT(no)
)
)
# We will try to include it for a possible prototype of strtod_l()
# (like in BSD).
AC_CHECK_HEADERS([xlocale.h])
# ====================================================================
# For stdatomic.h -- missing in gcc-4.8 (Ubuntu Trusty 14.04)
# Its used in the Java bindings, to avoid an ugly server-init race.
AC_MSG_CHECKING(for stdatomic.h)
AC_CHECK_HEADER([stdatomic.h],
[AC_DEFINE([HAVE_STDATOMIC_H], 1, [Define to 1 if stdatomic.h exists])],
[],
[#include <stdatomic.h>
])
# ====================================================================
# Debugging
AC_ARG_ENABLE( debug,
[ --enable-debug compile with debugging flags set],
[],
[enable_debug=no])
if test "x$enable_debug" = "xyes"
then
# Only bash supports double-backslash... Well, dash does too...
# But not the NetBSD sh, so use sed instead.
# CFLAGS="${CFLAGS//-O[[2-9]]} -g"
# CXXFLAGS="${CXXFLAGS//-O[[2-9]]} -g"
CFLAGS=`AS_ECHO(["${CFLAGS}"]) | $SED "s/-O[[2-9]]//g"`
CXXFLAGS=`AS_ECHO(["${CXXFLAGS}"]) | $SED "s/-O[[2-9]]//g"`
AC_DEFINE(DEBUG,1)
fi
# ====================================================================
AC_ARG_ENABLE( mudflap,
[ --enable-mudflap compile with mudflap checking],
[],
[enable_mudflap=no])
if test "x$enable_mudflap" = "xyes"
then
CFLAGS="-fmudflap ${CFLAGS}"
LDFLAGS="-lmudflap ${LDFLAGS}"
fi
# ====================================================================
AC_ARG_ENABLE( profile,
[ --enable-profile compile with profiling set],
[],
[enable_profile=no]
)
if test "x$enable_profile" = "xyes"
then
CFLAGS="-pg ${CFLAGS}"
LDFLAGS="-pg ${LDFLAGS}"
fi
# ====================================================================
# Java now enabled by default
AC_ARG_ENABLE( java-bindings,
[ --disable-java-bindings disable build of java bindings (default is enabled)],
[],
[enable_java_bindings=yes])
# Python is now enabled by default
define([PYTHON3_REQUIRED], [3.4])
AC_ARG_ENABLE( python-bindings,
[ --disable-python-bindings
disable build of python bindings (default is enabled)],
[],
[enable_python_bindings=yes]
)
# Perl now disabled by default
AC_ARG_ENABLE( perl-bindings,
[AS_HELP_STRING([--enable-perl-bindings],
[create perl bindings to the link-grammar library] (disabled by default))],
[],
[enable_perl_bindings=no]
)
# ====================================================================
# SAT solver is disabled by default. Its always slower than the
# regular parser.
#
# First try to use the minisat system library.
# If the library or the headers are not found, use the bundled library
AC_ARG_ENABLE( sat-solver,
[ --disable-sat-solver disable use of the Boolean SAT parser
(default is disabled)
--enable-sat-solver[[=ARG]]
enable use of the Boolean SAT parser
ARG=yes: Use the system minisat library,
if possible
ARG=bundled: Use the bundled minisat library],
[if test "x$enableval" = xbundled; then
use_minisat_bundled_library=yes
enable_sat_solver=yes
fi], [enable_sat_solver=no])
AS_IF([test "x$enable_sat_solver" = xyes], [
# We want to check for C++; the easiest way to do this is to
# use c++ to compile stdio.h and bomb if it fails.
AC_LANG([C++])
AC_CHECK_HEADER([stdio.h],,
[AC_MSG_ERROR([C++ compiler not found; it is needed for the SAT parser])])
PKG_CHECK_MODULES([ZLIB], [zlib])
CPPFLAGS_SAVE="$CPPFLAGS"
if test -z "$use_minisat_bundled_library"; then
# Check if we can link with the system's minisat2 library.
# If this is not possible, arrange for using the bundled minisat2
# library code by setting use_minisat_bundled_library=yes.
dnl FIXME: Allow using --with-minisat2=DIR
dnl and/or specifying specific include/library locations.
minisat_headers="-isystem /usr/include/minisat"
CPPFLAGS="$CPPFLAGS $minisat_headers $ZLIB_CFLAGS"
AC_CHECK_LIB(minisat, main, [MINISAT_LIBS=-lminisat],
[ use_minisat_bundled_library=yes ]
[AC_MSG_NOTICE([No system minisat2 library found - using the bundled library])])
if test -z "$use_minisat_bundled_library"; then
AC_CHECK_HEADER([minisat/core/Solver.h], [MINISAT_INCLUDES="$minisat_headers"],
[ use_minisat_bundled_library=yes ]
[AC_MSG_NOTICE([System minisat2 headers not found in $CPPFLAGS - using the bundled library])])
fi
fi
dnl Note that the above checks may find the need to use the bundled library
dnl code even if it wasn't specifically requested.
if test -n "$use_minisat_bundled_library"; then
use_minisat_bundled_library=' (using the bundled minisat library)'
AC_DEFINE(HAVE_MKLIT, 1)
else
dnl We are going to use the system's minisat2 library.
dnl Adapt to slight variations in minisat2.2 code.
# The function for making a literal can be Lit() or mkLit()
AC_CHECK_DECL([mkLit(Var, bool)], [AC_DEFINE(HAVE_MKLIT, 1, [Define if exists])], [],
[#include <minisat/core/Solver.h>]
[using namespace Minisat;]
[Solver x;])
# setPolarity() second argument can be bool or lbool
AC_CHECK_DECL([x.Solver::setPolarity(Var, bool)],
[AC_MSG_NOTICE([Found setPolarity bool])]
[AC_DEFINE(HAVE_SETPOLARITY_BOOL, 1, [Define if setPolarity has bool argument])],
[AC_MSG_NOTICE([Supposing setPolarity lbool])],
[#include <minisat/core/Solver.h>]
[using namespace Minisat;]
[Solver x;])
AC_SUBST(MINISAT_LIBS)
AC_SUBST(MINISAT_INCLUDES)
fi
AC_LANG([C])
CPPFLAGS="$CPPFLAGS_SAVE"
AC_DEFINE(USE_SAT_SOLVER, 1, [Define for compilation])
])
AM_CONDITIONAL(LIBMINISAT_BUNDLED, test -n "$use_minisat_bundled_library")
AM_CONDITIONAL(WITH_SAT_SOLVER, test "x$enable_sat_solver" = xyes)
# ====================================================================
AC_ARG_ENABLE( wordgraph_display,
[AS_HELP_STRING([--disable-wordgraph-display],
[disable graphical display of the Wordgraph (default is enabled)])],
[],
[enable_wordgraph_display=yes]
)
if test "x$enable_wordgraph_display" = "xyes"
then
AC_DEFINE(USE_WORDGRAPH_DISPLAY, 1, [Define for compilation])
fi
AM_CONDITIONAL(WITH_ANYSPLIT, test x${enable_wordgraph_display} = xyes)
# ====================================================================
# Couldn't use AX_LIB_SQLITE3 since it is currently (04/2021) buggy.
AC_CHECK_HEADER([sqlite3.h], [SQLiteFound=yes], SQLiteFound=no)
if test "${SQLiteFound}" = yes; then
PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.0.0, [SQLiteFound=yes],
[SQLiteFound=nopc])
fi
# On macOS, the sqlite3 library exists but the .pc file may not exist.
if test "${SQLiteFound}" = nopc; then
AC_CHECK_LIB(sqlite3, sqlite3_open, [SQLITE3_LIBS=-lsqlite3])
fi
if test -n "${SQLITE3_LIBS}"; then
AC_DEFINE(HAVE_SQLITE3, 1, [Support sqlite3 dictionary])
SQLiteFound=yes
else
SQLiteFound=no
fi
AM_CONDITIONAL(HAVE_SQLITE3, test "${SQLiteFound}" = yes)
AC_SUBST(SQLITE3_LIBS)
AC_SUBST(SQLITE3_CFLAGS)
# ====================================================================
# The AtomSpace dictionary backend
# TODO - use pkg_config for find the libs.
# TODO - do NOT specify -lpersist-rocks -lpersist-cog here,
# they need to be dynamically loaded instead (for proper
# initialization of the shared library ctors these contain).
# Alternately, if they are found, then wrap them with
# "-Wl,--no-as-needed"
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([opencog/atomspace/AtomSpace.h], [AtomSpaceFound=yes], AtomSpaceFound=no)
AC_LANG_POP()
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([opencog/nlp/types/atom_types.h], [NLPTypesFound=yes], NLPTypesFound=no)
AC_LANG_POP()
AM_CONDITIONAL(HAVE_ATOMSPACE, test x${AtomSpaceFound} = xyes)
AM_CONDITIONAL(HAVE_NLPTYPES, test x${NLPTypesFound} = xyes)
HaveAtomese=no
if test x"${AtomSpaceFound}" = xyes && test x"${NLPTypesFound}" = xyes; then
HaveAtomese=yes
AC_DEFINE(HAVE_ATOMESE, 1, [Define for compilation])
ATOMSPACE_LIBS="-latom_types -lnlp-types -lstorage-types -lsexpr -lpersist-flow -Wl,--no-as-needed -lpersist-rocks -lpersist-monospace -lpersist-cog -lpersist-cog-simple -lpersist-file -Wl,--as-needed -lpersist -latomspace -L/usr/local/lib/opencog/"
fi
AC_SUBST(ATOMSPACE_LIBS)
# ====================================================================
# Set Default Spell Checker settings
do_aspell=yes
# ASpell Support is handled here
AC_ARG_ENABLE([aspell], [AS_HELP_STRING([--disable-aspell],
[Build without ASpell support (default is enabled)])],
[do_aspell="${enableval}"])
AM_CONDITIONAL(WITH_ASPELL, test x${do_aspell} = xyes)
# Hunspell Support is handled here
do_hunspell=yes
AC_ARG_ENABLE([hunspell], [AS_HELP_STRING([--disable-hunspell],
[Build without HunSpell support (default is enabled)])],
[do_hunspell="${enableval}"])
AM_CONDITIONAL(WITH_HUNSPELL, test x${do_hunspell} = xyes)
case "$host_os$host_cpu" in
*mingw*64)
default_hunspell_dictdir=/mingw64/share/myspell/dicts
;;
*mingw*32)
# Not checked
default_hunspell_dictdir=/mingw32/share/myspell/dicts
;;
darwin*)
default_hunspell_dictdir=/Library/Spelling
;;
*)
default_hunspell_dictdir=/usr/share/myspell/dicts
;;
esac
AC_ARG_WITH([hunspell-dictdir], AS_HELP_STRING([--with-hunspell-dictdir=DIR],
[Use DIR to find HunSpell files (the default is system dependent)]),
[], [with_hunspell_dictdir=$default_hunspell_dictdir])
# ====================================================================
# 2015-08: The current default for speller is hunspell, since aspell is not
# yet thread safe. Jan 2018 - aspell still not thread-safe...
HunSpellDictDir=
HunSpellFound=no
if test x"$do_hunspell" = xyes; then
HunSpellFound=no
# First, look for the libraries.
PKG_CHECK_MODULES([HUNSPELL], [hunspell], [HunSpellFound=yes], [HunSpellFound=no])
save_cpp_flags=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS} ${HUNSPELL_CFLAGS}"
AC_CHECK_HEADER([hunspell.h], [HunSpellFound=yes], HunSpellFound=no)
CPPFLAGS=$save_cpp_flags
if test "x${HunSpellFound}" = "xyes"; then
AC_DEFINE(HAVE_HUNSPELL, 1, [Define for compilation])
AC_SUBST(HUNSPELL_LIBS)
AC_SUBST(HUNSPELL_CFLAGS)
# Now, look for the dictionaries.
HunSpellDictDir=$with_hunspell_dictdir
if test "$native_win32" = yes; then
# Convert to native format with forward slashes
# (allow spaces in DIR when using --with-hunspell-dictdir="DIR").
case $HunSpellDictDir in
*\ *)
file_format=dos
;;
*)
file_format=windows
;;
esac
HunSpellDictDir=`cygpath --$file_format --mixed "$HunSpellDictDir"`
fi
if ! test -d "$HunSpellDictDir" ; then
if test "$withval" = yes; then
AC_MSG_WARN([Default HunSpell directory "$HunSpellDictDir" not found. Use --with_hunspell_dictdir=DIR to change it.])
else
AC_MSG_WARN([HunSpell directory "$HunSpellDictDir" not found.])
fi
HunSpellDictDir_status=' (not found)'
fi
AC_DEFINE_UNQUOTED(HUNSPELL_DICT_DIR, "$HunSpellDictDir", [Defining the dictionary path])
# If hunspell enabled and found, then do NOT do aspell
do_aspell=no
fi
fi
AM_CONDITIONAL(HAVE_HUNSPELL, test x${HunSpellFound} = xyes)
ASpellFound=no
if test "$do_aspell" = yes ; then
PKG_CHECK_MODULES([ASPELL], [aspell], [ASpellFound=yes], [ASpellFound=no])
save_cpp_flags=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS} ${ASPELL_CFLAGS}"
AC_CHECK_HEADER([aspell.h], [ASpellFound=yes], ASpellFound=no)
AC_CHECK_LIB(aspell, new_aspell_config, [], [ASpellFound=no])
CPPFLAGS=$save_cpp_flags
if test "x${ASpellFound}" = "xyes"; then
AC_DEFINE(HAVE_ASPELL, 1, [Define for compilation])
AC_SUBST(ASPELL_LIBS)
AC_SUBST(ASPELL_CFLAGS)
fi
fi
AM_CONDITIONAL(HAVE_ASPELL, test x${ASpellFound} = xyes)
# ====================================================================
# Enable editline by default
AC_ARG_ENABLE( editline,
[ --disable-editline disable use of editline],
[],
[enable_editline=yes])
edlin=no
wedlin=no
if test "x$enable_editline" = "xyes"; then
PKG_CHECK_MODULES([LIBEDIT], [libedit], [edlin=yes], [edlin=no])
if test "x${edlin}" = "xyes"; then
AM_CONDITIONAL(HAVE_EDITLINE, true)
AC_DEFINE(HAVE_EDITLINE, 1, [Define for compilation])
# Now test for widechar support
AC_CHECK_LIB(edit, history_winit, [wedlin=yes], [wedlin=no])
if test "x${wedlin}" = "xyes"; then
AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, true)
AC_DEFINE(HAVE_WIDECHAR_EDITLINE, 1, [Define for compilation])
else
AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, false)
fi
else
AM_CONDITIONAL(HAVE_EDITLINE, false)
AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, false)
fi
else
AM_CONDITIONAL(HAVE_EDITLINE, false)
AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, false)
fi
# ====================================================================
# Configure a regex library that supports UTF-8 and a POSIX features.
dnl AC_CHECK_HEADERS defines HAVE_FILENAME_H if found.
AC_ARG_WITH([regexlib],
[AS_HELP_STRING([--with-regexlib=pcre2|tre|regex|c|c++],
[use the specified regex library (pcre2 is the
default unless --disable-pcre2 is specified).
The use of PCRE2 is strongly recommended.])],
[],
[with_regexlib=pcre2])
AC_ARG_ENABLE(pcre2,
[AS_HELP_STRING([--disable-pcre2],
[disable the use of the PCRE2 regex library
(default is enabled)])],
[test "$with_regexlib" = pcre2 && with_regexlib=],
[check_pcre2=1])
pcre2_message='PCRE2 is strongly recommended. If you wish to compile without this, then say "configure --disable-pcre2"'
lgregexlib=--with-regexlib="$with_regexlib"
case "$with_regexlib" in
'')
break
;;
pcre2)
PKG_CHECK_MODULES([PCRE2], [libpcre2-8], [],
[AS_BOX(m4_normalize($pcre2_message))]
[AC_MSG_ERROR([$lgregexlib: libpcre2-8 not found])])
;;
tre)
AC_CHECK_HEADERS([tre/regex.h], ,
[AC_MSG_ERROR([$lgregexlib: tre/regex.h not found])])
PKG_CHECK_MODULES([TRE], [tre], [],
[AC_MSG_ERROR([$lgregexlib: libtre not found])])
;;
regex)
AC_CHECK_HEADERS([regex.h], ,[AC_MSG_ERROR([No regex.h header found])])
AC_CHECK_LIB([regex], [regexec], [REGEX_LIBS=-lregex],
[AC_MSG_ERROR([$lgregexlib: regexec() not found])])
;;
c|C)
AC_CHECK_HEADERS([regex.h], ,[AC_MSG_ERROR([No regex.h header found])])
AC_CHECK_FUNCS(regexec, [REGEX_LIBS=-lc],
[AC_MSG_ERROR([$lgregexlib: regexec() not found])])
;;
c++|C++)
regexlib_cxx=1
AC_DEFINE(USE_CXXREGEX, 1)
;;
*)
AC_MSG_ERROR([$lgregexlib: Library not configurable (see configure --help)])
;;
esac
AM_CONDITIONAL(WITH_CXXREGEX, test -n "$regexlib_cxx")
if test -z "$REGEX_LIBS"; then
AC_MSG_NOTICE([Checking for REGEX implementation:])
fi
# Find the first regex library according to this order:
# libpcre2-8, libtre, libregex, libc.
if test -n "$regexlib_cxx"; then
AC_MSG_RESULT([... using C++ regex])
else
if test -z "$REGEX_LIBS" -a -n "$check_pcre2"; then
PKG_CHECK_MODULES([PCRE2], [libpcre2-8], [
AC_DEFINE([HAVE_PCRE2_H], 1)
REGEX_LIBS=$PCRE2_LIBS
REGEX_CFLAGS=$PCRE2_CFLAGS
], [AC_MSG_RESULT([... missing libpcre2-8, continuing])])
fi
if test -z "$REGEX_LIBS"; then
AC_CHECK_HEADER([tre/regex.h],
[PKG_CHECK_MODULES([REGEX], [tre],
[AC_DEFINE([HAVE_TRE_REGEX_H], 1)],
[AC_MSG_RESULT([... missing libtre, continuing])])])
fi
if test -z "$REGEX_LIBS"; then
AC_CHECK_HEADERS([regex.h],
[AC_CHECK_LIB([regex], [regex], [REGEX_LIBS=-lregex],
[AC_MSG_RESULT([... libregex not found, continuing])]
[AC_CHECK_FUNCS([regexec], [REGEX_LIBS=-lc])])],
[AC_MSG_ERROR([No regex.h header found])])
fi
if test -n "$REGEX_LIBS"; then
AC_MSG_RESULT([... found REGEX implementation: $REGEX_LIBS])
test "x$REGEX_LIBS" = x-lc && REGEX_LIBS=
test -n "$REGEX_CFLAGS" && CFLAGS="$CFLAGS $REGEX_CFLAGS"
else
AC_MSG_ERROR([No REGEX implementation found])
fi
fi
AC_SUBST(REGEX_LIBS)
AC_SUBST(REGEX_CFLAGS)
# =====================================================================
# Find the location of the jni.h file.
JNIfound=no
if test "x$enable_java_bindings" = "xyes"; then
absolute_srcdir=`(cd "$srcdir"; pwd)`
JAVA_SRCDIR=$absolute_srcdir/bindings/java
if test "$native_win32" = yes; then
# javac needs a Windows path
JAVA_SRCDIR=`cygpath -w "$JAVA_SRCDIR"`
# The standard location of Windows Java is under "\Program Files".
# However, automake is unable to handle spaces in a filename even
# when quoted (e.g. "-I '$JAVA_HOME/include'"). As a workaround,
# convert $JAVA_HOME to a short DOS path.
test -n "${JAVA_HOME}" && JAVA_HOME=`cygpath --dos --mixed "$JAVA_HOME"`
# win32/jni_md.h:34:9: error: ‘__int64’ does not name a type
JAVA_CPPFLAGS=-D__int64=int64_t
fi
AC_SUBST(JAVA_SRCDIR)
pushdef([AC_MSG_ERROR])
define([AC_MSG_ERROR],
[AC_MSG_NOTICE([$1])])
AX_JNI_INCLUDE_DIR
popdef([AC_MSG_ERROR])
if test -n "$JNI_INCLUDE_DIRS"; then
JNIfound=yes
fi
for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
do
JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$JNI_INCLUDE_DIR"
done
AC_SUBST(JAVA_CPPFLAGS)
# This allows jni-client.c to be built
AM_CONDITIONAL(HAVE_JAVA, test x${JNIfound} = xyes)
# For now, we assume that if the ant tool is there, then the javac and
# jar compiler/packager are installed as well. These are needed to build
# the jar file and install it.
AC_CHECK_PROG(ANTfound, ant, yes, no)
AM_CONDITIONAL(HAVE_ANT, test x${ANTfound} = xyes)
# If Maven is found then use it to install the jar library
# into the local maven repository
AC_CHECK_PROG(MVNfound, mvn, yes, no)
AM_CONDITIONAL(HAVE_MVN, test x${MVNfound} = xyes)
else
AM_CONDITIONAL(HAVE_JAVA, false)
AM_CONDITIONAL(HAVE_ANT, false)
AM_CONDITIONAL(HAVE_MVN, false)
fi
# ===================================================================
PerlFound=no
if test "x$enable_perl_bindings" = "xyes"; then
# Look for the perl bits and pieces...
# AX_PERL_EXT isn't working for me ...
# AX_PATH_EXT
AC_MSG_CHECKING([for Perl XS include directory])
if test -z "$PERL_EXT_INC" ; then
PERL_EXT_INC=`perl -MConfig -e 'print $Config{archlib}'`
fi
test -z "$PERL_EXT_INC" && PERL_EXT_INC=no
AC_MSG_RESULT([$PERL_EXT_INC])
PERL_CFLAGS="-I${PERL_EXT_INC} -I${PERL_EXT_INC}/CORE"
AC_SUBST(PERL_EXT_INC)
AC_SUBST(PERL_CFLAGS)
# PERL_EXT_LIB is where to install, typically /usr/local/lib/perl/5.14.2
# or similar.
AC_MSG_CHECKING([for Perl extensions destination directory])
if test -z "$PERL_EXT_LIB" ; then
PERL_EXT_LIB=`perl -MConfig -e 'print $Config{sitearchexp}'`
fi
test -z "$PERL_EXT_LIB" && PERL_EXT_LIB=no
AC_MSG_RESULT([$PERL_EXT_LIB])
AC_SUBST(PERL_EXT_LIB)
save_cpp_flags=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS} ${PERL_CFLAGS}"
AC_CHECK_HEADER([EXTERN.h], [PerlFound=yes], [PerlFound=no])
AM_CONDITIONAL(HAVE_PERL, test x${PerlFound} = xyes)
CPPFLAGS=$save_cpp_flags
else
AM_CONDITIONAL(HAVE_PERL, false)
fi
# ===================================================================
# Find python things.
dnl AX_PYTHON_DEVEL uses AC_MSG_ERROR in case it doesn't find things.
dnl Temporarily make AC_MSG_ERROR a soft error (to be restored by popdef()).
pushdef([AC_MSG_ERROR])
define([AC_MSG_ERROR],
lg_python_unusable=yes
[AC_MSG_NOTICE([$1])])
PythonFound=no
if test "x$enable_python_bindings" = xyes; then
AM_PATH_PYTHON(PYTHON3_REQUIRED, [PythonFound=yes])
AX_PYTHON_DEVEL()
AX_COMPARE_VERSION($PYTHON_VERSION, [ge], 'PYTHON3_REQUIRED',,
[lg_python_unusable=yes])
if test -n "$lg_python_unusable"; then
dnl Use the message from AX_PYTHON_DEVEL, but with " instead of ''
dnl so (for debug) we can know it is from here.
AC_MSG_NOTICE([
this package requires Python >= ]'PYTHON3_REQUIRED'[
If you have it installed, but it isn't the default Python
interpreter in your system path, please pass the PYTHON_VERSION
variable to configure. See "configure --help" for reference.
])
PythonFound=no
PYTHON_VERSION= # Avoid confusion
fi
if test x$PythonFound = xyes; then
PythonFound=$PYTHON_VERSION
lg_display_PYTHON=" ($PYTHON)"
PYTHON_CPPFLAGS=$PYTHON_CPPFLAGS
PYTHON_LIBS=$PYTHON_LIBS
PYTHON_LDFLAGS=$PYTHON_LDFLAGS
pythondir=$pythondir
AC_SUBST(PYTHON_CPPFLAGS)
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_LDFLAGS)
AC_SUBST(pythondir)
fi
fi
AM_CONDITIONAL(HAVE_PYTHON, test x$PythonFound != xno)
AC_SUBST(PYTHON)
AC_SUBST(pythondir)
# Formerly both python2 and python3 bindings got generated. This caused a
# redefinition of the preprocessor symbol HAVE_PYTHON and generates a lot
# of compiler warnings, so it got discarded here. Now we generate only
# python3 bindings, but since we don't use this definition, it is still
# discarded here.
# Note: "sed -i" cannot be used because it is not portable.
$SED '/HAVE_PYTHON/d' confdefs.h >confdefs.h.bak && mv confdefs.h.bak confdefs.h
popdef([AC_MSG_ERROR])
if test x$enable_python_bindings = xyes; then
if test x$PythonFound = xno; then
AC_MSG_NOTICE(
[Python binding is enabled, but an appropriate Python version
could not be configured (minimum version: PYTHON3_REQUIRED).])
fi
fi
# ===================================================================
# swig is needed for compiling the Perl and Python bindings ...
# ... well, actually, no, it's not. 'make dist' is currently set up to
# package all of the files generated by swig, so the user does not need
# to actually install it. However, swig is needed to create the package,
# and also needed to build from a GitHub pull.
if ! test -s "$srcdir/bindings/python/lg_python_wrap.cc"; then
AM_COND_IF(HAVE_PYTHON, [swig_required="$swig_required Python"])
fi
if ! test -s "$srcdir/bindings/perl/lg_perl_wrap.cc"; then
AM_COND_IF(HAVE_PERL, [swig_required="$swig_required Perl"])
fi
if test -n "$swig_required"; then
AX_PKG_SWIG(2.0.0,, [AC_MSG_ERROR(['swig' is required to create bindings for: $swig_required])])
AX_SWIG_ENABLE_CXX
SWIGfound="$SWIG"
else
SWIGfound=no
fi
# "swig -swiglib" on MinGW64 (swig 4.02) gives the following 2 lines
# C:\msys64\mingw64\bin\Lib
# C:/msys64/mingw64/share/swig/4.0.2
# This breaks the Makefiles at the place SWIG_LIB is set.
# However, since we don't use SWIG_LIB, we can solve that by clearing it.
SWIG_LIB=
AM_CONDITIONAL(HAVE_SWIG, test -n "$SWIG")
# ====================================================================
# check compiler flags
AC_DEFUN([LINK_CC_TRY_FLAG], [
AC_MSG_CHECKING([whether $CC supports $1])
link_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror $1"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ ]])], [link_cc_flag=yes], [link_cc_flag=no])
CFLAGS="$link_save_CFLAGS"
if test "x$link_cc_flag" = "xyes"; then
ifelse([$2], , :, [$2])
else
ifelse([$3], , :, [$3])
fi
AC_MSG_RESULT([$link_cc_flag])
])
dnl Use lots of warning flags with with gcc and compatible compilers
dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked. So there's no need to do anything
dnl else. If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)
dnl MAYBE_WARN works for C++ and C, while MAYBE_WARN_C is for C only.
MAYBE_WARN_CXX="-Wall -Wextra \
-Wsign-compare \
-Wpointer-arith -Wwrite-strings -Wmissing-declarations \
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
-Wstrict-aliasing -Winit-self -Wshadow \
-Wno-missing-field-initializers -Wno-unused-parameter \
-Wno-attributes -Wno-long-long -Winline"
MAYBE_WARN_C="-Wstrict-prototypes -Wmissing-prototypes -Wformat-signedness \
-Wnested-externs -Wold-style-definition -Werror-implicit-function-declaration"