1# This file is processed by the Windows build system using confvar.bat. It 2# assumes AC_INIT is the first command, with no blank lines before it and with 3# a blank line after it. If this things are changed, change confvar.bat 4# accordingly. 5# Don't end the URLs with a slash even if it appears in the official address, 6# because we may append a component. Also, they cannot include "!". 7AC_INIT([link-grammar],[5.8.0],[https://github.com/opencog/link-grammar],, 8 [https://www.abisource.com/projects/link-grammar]) 9 10DISCUSSION_GROUP=https://groups.google.com/d/forum/link-grammar 11AC_SUBST(DISCUSSION_GROUP) 12OVERVIEW=https://en.wikipedia.org/wiki/Link_grammar 13AC_SUBST(OVERVIEW) 14 15dnl Set release number 16dnl This is derived from "Versioning" chapter of info libtool documentation. 17PACKAGE=link-grammar 18dnl 4a) Increment when removing or changing interfaces. 19LINK_MAJOR_VERSION=5 20dnl 4a) 5) Increment when adding interfaces. 21dnl 6) Set to zero when removing or changing interfaces. 22LINK_MINOR_VERSION=8 23dnl 3) Increment when interfaces not changed at all, 24dnl only bug fixes or internal changes made. 25dnl 4b) Set to zero when adding, removing or changing interfaces. 26LINK_MICRO_VERSION=0 27dnl 28dnl Set this too 29MAJOR_VERSION_PLUS_MINOR_VERSION=`expr $LINK_MAJOR_VERSION + $LINK_MINOR_VERSION` 30dnl 31VERSION=$LINK_MAJOR_VERSION.$LINK_MINOR_VERSION.$LINK_MICRO_VERSION 32# Version info for libraries = CURRENT:REVISION:AGE 33VERSION_INFO=$MAJOR_VERSION_PLUS_MINOR_VERSION:$LINK_MICRO_VERSION:$LINK_MINOR_VERSION 34 35AC_SUBST(VERSION_INFO) 36AC_SUBST(LINK_MAJOR_VERSION) 37AC_SUBST(LINK_MINOR_VERSION) 38AC_SUBST(LINK_MICRO_VERSION) 39 40AM_INIT_AUTOMAKE([foreign subdir-objects]) 41AM_MAINTAINER_MODE([enable]) 42 43AC_CONFIG_MACRO_DIR([m4]) 44 45AC_CONFIG_SRCDIR($PACKAGE) 46 47m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)]) 48 49dnl "Undefined AX_ macro" is checked in autogen.sh, so if this message 50dnl is changed here it should be changed there too. 51m4_pattern_forbid([^AX_(COMPILER_VENDOR|TLS|CHECK_ZLIB|PKG_SWIG)\b], 52 [Undefined AX_ macro. Please install the "autoconf-archive" package.]) 53 54# OS checks, including Win32 55AC_CANONICAL_HOST 56dnl Checks for programs. 57AC_PROG_CC 58AC_PROG_CXX 59AX_COMPILER_VENDOR 60AC_PROG_CPP 61AM_PROG_LEX 62AC_PROG_INSTALL 63#AC_PROG_LIBTOOL 64AC_PROG_LN_S 65AC_PROG_MAKE_SET 66AC_HEADER_STDC 67LT_INIT([win32-dll]) 68PKG_PROG_PKG_CONFIG 69 70# The below says "use the C compiler for all remaining tests". 71# That way, if g++ is not installed, configure won't crap out 72# (with a mystery error about not finding regex.h) 73AC_LANG([C]) 74 75AC_C_CONST 76 77AC_CHECK_FUNCS(strndup strtok_r) 78AC_CHECK_FUNCS(aligned_alloc posix_memalign _aligned_malloc) 79 80AC_FUNC_ALLOCA 81 82# For the Wordgraph display code 83AC_FUNC_FORK 84AC_CHECK_FUNCS(prctl) 85 86dnl CentOS-7 (at least) needs these to expose the C99 format and 87dnl limit macros in C++ source code. They are needed for minisat. 88AC_DEFINE(__STDC_FORMAT_MACROS) 89AC_DEFINE(__STDC_LIMIT_MACROS) 90 91dnl Check for a keyword for Thread Local Storage declaration. 92dnl If found - define TLS to it. 93lg_tls=no 94AX_TLS(,:) 95test "$ac_cv_tls" != "none" && lg_tls=yes 96 97dnl Check for specific OSs 98# ==================================================================== 99 100AC_MSG_CHECKING([for native Win32]) 101case "$host_os" in 102 *cygwin* | *msys* | *mingw* | *pw32 | *cegcc*) 103 native_win32=yes 104 ;; 105 *) 106 native_win32=no 107 ;; 108esac 109AC_MSG_RESULT([$native_win32]) 110AM_CONDITIONAL(OS_WIN32, test "x$native_win32" = "xyes") 111 112AC_MSG_CHECKING([for Cygwin]) 113case "$host_os" in 114 *cygwin*) 115 cygwin=yes 116 ;; 117 *) 118 cygwin=no 119 ;; 120esac 121AC_MSG_RESULT([$cygwin]) 122AM_CONDITIONAL(OS_CYGWIN, test "x$cygwin" = "xyes") 123 124AC_MSG_CHECKING([for 64-bit Apple OSX]) 125case "$host_os" in 126 darwin*) 127 apple_osx=yes 128 ;; 129 *) 130 apple_osx=no 131 ;; 132esac 133AC_MSG_RESULT([$apple_osx]) 134AM_CONDITIONAL(OS_X, test "x$apple_osx" = "xyes") 135 136HOST_OS="$host_os" 137AC_SUBST(HOST_OS) 138# ==================================================================== 139 140CFLAGS="${CFLAGS} -O3" 141CXXFLAGS="${CXXFLAGS} -O3 -Wall" 142 143# The std=c11 flag provides the proper float-pt math decls working, 144# e.g. fmax However, it also undefined _BSD_SOURCE, etc. which is 145# needed to get fileno, strdup, etc. and so it needs to be manually 146# enabled again. 147 148# Setting -D_POSIX_SOURCE messes up compilation on FreeBSD by 149# hiding strdup, etc. again. 150 151# Final solution: enable std=c11, explicitly turn on BSD and SVID and 152# GNU, but do NOT turn on POSIX. 153 154CFLAGS="-std=c11 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -D_ISOC11_SOURCE ${CFLAGS}" #" 155CXXFLAGS="-std=c++11 ${CXXFLAGS}" #" 156 157if test x${native_win32} = xyes; then 158 # We need the shlwapi for PathRemoveFileSpecA(). 159 LDFLAGS="${LDFLAGS} -lshlwapi" 160 161 # By default, MinGW doesn't know about %zu, which we use a lot, even 162 # on systems which have MSVC14, which has c99 stdio (printf prints 163 # "zu"). Add __USE_MINGW_ANSI_STDIO in order to solve that. 164 AC_DEFINE(__USE_MINGW_ANSI_STDIO, 1) 165 AC_DEFINE(__printf__, gnu_printf) 166 167 # Only running on Vista and on is supported. 168 AC_DEFINE(NTDDI_VERSION, NTDDI_VISTA) 169 AC_DEFINE(_WIN32_WINNT, _WIN32_WINNT_VISTA) 170fi 171 172# _BSD_SOURCE and _SVID_SOURCE are deprecated in glibc>=2.20. _DEFAULT_SOURCE 173# is used there instead, but _BSD_SOURCE and _SVID_SOURCE can still be 174# specified (no effect). So just add it. 175CFLAGS="-D_DEFAULT_SOURCE ${CFLAGS}" 176CXXFLAGS="-D_DEFAULT_SOURCE ${CXXFLAGS}" 177 178# ==================================================================== 179 180dnl For locale_t 181AC_MSG_CHECKING(for locale_t in locale.h) 182AC_LINK_IFELSE( 183[AC_LANG_PROGRAM([#include <locale.h>], [locale_t lt = NULL])], 184AC_MSG_RESULT(yes) 185AC_DEFINE([HAVE_LOCALE_T_IN_LOCALE_H], 1, [Define to 1 if locale_t is defined in locale.h]), 186AC_MSG_RESULT(no) 187 AC_MSG_CHECKING(for locale_t in xlocale.h) 188 AC_LINK_IFELSE( 189 [AC_LANG_PROGRAM([#include <xlocale.h>], [locale_t lt = NULL])], 190 AC_MSG_RESULT(yes) 191 AC_DEFINE([HAVE_LOCALE_T_IN_XLOCALE_H], 1, [Define to 1 if locale_t is defined in xlocale.h]), 192 AC_MSG_RESULT(no) 193 ) 194) 195 196# We will try to include it for a possible prototype of strtod_l() 197# (like in BSD). 198AC_CHECK_HEADERS([xlocale.h]) 199 200# ==================================================================== 201 202dnl For stdatomic.h -- missing in gcc-4.8 (Ubuntu Trusty 14.04) 203dnl Its used in the Java bindings, to avoid an ugly server-init race. 204AC_MSG_CHECKING(for stdatomic.h) 205AC_CHECK_HEADER([stdatomic.h], 206 [AC_DEFINE([HAVE_STDATOMIC_H], 1, [Define to 1 if stdatomic.h exists])], 207 [], 208 [#include <stdatomic.h> 209 ]) 210 211# ==================================================================== 212# Debugging 213 214AC_ARG_ENABLE( debug, 215 [ --enable-debug compile with debugging flags set], 216 [], 217 [enable_debug=no]) 218 219if test "x$enable_debug" = "xyes" 220then 221 # Only bash supports double-backslash... Well, dash does too... 222 # But not the NetBSD sh, so use sed instead. 223 # CFLAGS="${CFLAGS//-O[[2-9]]} -g" 224 # CXXFLAGS="${CXXFLAGS//-O[[2-9]]} -g" 225 CFLAGS=`echo -g ${CFLAGS} |sed "s/-O[[2-9]]//g"` 226 CXXFLAGS=`echo -g ${CXXFLAGS} |sed "s/-O[[2-9]]//g"` 227 LDFLAGS="-g ${LDFLAGS}" 228 AC_DEFINE(DEBUG,1) 229fi 230 231# ==================================================================== 232 233AC_ARG_ENABLE( mudflap, 234 [ --enable-mudflap compile with mudflap checking], 235 [], 236 [enable_mudflap=no]) 237 238if test "x$enable_mudflap" = "xyes" 239then 240 CFLAGS="${CFLAGS} -fmudflap" 241 LDFLAGS="${LDFLAGS} -fmudflap -lmudflap" 242fi 243 244# ==================================================================== 245 246AC_ARG_ENABLE( profile, 247 [ --enable-profile compile with profiling set], 248 [], 249 [enable_profile=no] 250) 251if test "x$enable_profile" = "xyes" 252then 253 CFLAGS="${CFLAGS} -pg" 254 LDFLAGS="${LDFLAGS} -pg" 255fi 256 257# ==================================================================== 258# Java now enabled by default 259AC_ARG_ENABLE( java-bindings, 260 [ --disable-java-bindings disable build of java bindings (default is enabled)], 261 [], 262 [enable_java_bindings=yes]) 263 264# Python is now enabled by default 265define([PYTHON3_REQUIRED], [3.4]) 266AC_ARG_ENABLE( python-bindings, 267 [ --disable-python-bindings 268 disable build of python bindings (default is enabled)], 269 [], 270 [enable_python_bindings=yes] 271) 272 273# Perl now disabled by default 274AC_ARG_ENABLE( perl-bindings, 275 [AS_HELP_STRING([--enable-perl-bindings], 276 [create perl bindings to the link-grammar library] (disabled by default))], 277 [], 278 [enable_perl_bindings=no] 279) 280 281# ==================================================================== 282# SAT solver now enabled by default 283# First try to use the minisat system library. 284# If the library or the headers are not found, use the bundled library 285 286AC_ARG_ENABLE( sat-solver, 287 [ --disable-sat-solver disable use of the Boolean SAT parser 288 (default is enabled) 289 --enable-sat-solver[[=ARG]] 290 enable use of the Boolean SAT parser 291 ARG=yes (default): Use the system minisat library 292 if possible 293 ARG=bundled: Use the bundled minisat library], 294 [if test "x$enableval" = xbundled; then 295 use_minisat_bundled_library=yes 296 enable_sat_solver=yes 297 fi], [enable_sat_solver=yes]) 298 299if test "x$enable_sat_solver" = xyes; then 300 # The sat-solver code is in C++; so the link-grammar library should now 301 # directly require libstdc++ instead of indirectly depend on its 302 # availability via the minisat2 library. 303 #test x${apple_osx} = xyes || AC_CHECK_LIB(stdc++, main) 304 305 # We want to check for C++; the easiest way to do this is to 306 # use c++ to compile stdio.h and bomb if it fails. 307 AC_LANG([C++]) 308 AC_CHECK_HEADER([stdio.h],, 309 [AC_MSG_ERROR([C++ compiler not found; it is needed for the SAT parser])]) 310 311 dnl 1. Abort and notify if no zlib.h. 2. Adapt for non-standard location. 312 AC_MSG_NOTICE([The minisat2 headers include zlib.h]) 313 dnl The bundled library doesn't actually need -lz 314 AX_CHECK_ZLIB([ZLIB_CPPFLAGS="-isystem $ZLIB_HOME/include"], 315 [AC_MSG_NOTICE([No zlib library found - not building sat solver]) 316 enable_sat_solver=no]) 317fi 318 319# If zlib not found, then don't continue with minisat. 320if test "x$enable_sat_solver" = xyes; then 321 test "x$ZLIB_CPPFLAGS" = "x-isystem /usr/include" && ZLIB_CPPFLAGS= 322 323 CPPFLAGS_SAVE="$CPPFLAGS" 324 325 if test -z "$use_minisat_bundled_library"; then 326 # Check if we can link with the system's minisat2 library. 327 # If this is not possible, arrange for using the bundled minisat2 328 # library code by setting use_minisat_bundled_library=yes. 329 330 dnl FIXME: Allow using --with-minisat2=DIR 331 dnl and/or specifying specific include/library locations. 332 minisat_headers="-isystem /usr/include/minisat" 333 CPPFLAGS="$CPPFLAGS $minisat_headers $ZLIB_CPPFLAGS" 334 335 AC_CHECK_LIB(minisat, main, [MINISAT_LIBS=-lminisat], 336 [ use_minisat_bundled_library=yes ] 337 [AC_MSG_NOTICE([No system minisat2 library found - using the bundled library])]) 338 339 if test -z "$use_minisat_bundled_library"; then 340 AC_CHECK_HEADER([minisat/core/Solver.h], [MINISAT_INCLUDES="$minisat_headers"], 341 [ use_minisat_bundled_library=yes ] 342 [AC_MSG_NOTICE([System minisat2 headers not found in $CPPFLAGS - using the bundled library])]) 343 fi 344 fi 345 346 dnl Note that the above checks may find the need to use the bundled library 347 dnl code even if it wasn't specifically requested. 348 349 if test -n "$use_minisat_bundled_library"; then 350 use_minisat_bundled_library=' (using the bundled minisat library)' 351 AC_DEFINE(HAVE_MKLIT, 1) 352 else 353 dnl We are going to use the system's minisat2 library. 354 dnl Adapt to slight variations in minisat2.2 code. 355 356 # The function for making a literal can be Lit() or mkLit() 357 AC_CHECK_DECL([mkLit(Var, bool)], [AC_DEFINE(HAVE_MKLIT, 1, [Define if exists])], [], 358 [#include <minisat/core/Solver.h>] 359 [using namespace Minisat;] 360 [Solver x;]) 361 # setPolarity() second argument can be bool or lbool 362 AC_CHECK_DECL([x.Solver::setPolarity(Var, bool)], 363 [AC_MSG_NOTICE([Found setPolarity bool])] 364 [AC_DEFINE(HAVE_SETPOLARITY_BOOL, 1, [Define if setPolarity has bool argument])], 365 [AC_MSG_NOTICE([Supposing setPolarity lbool])], 366 [#include <minisat/core/Solver.h>] 367 [using namespace Minisat;] 368 [Solver x;]) 369 370 AC_SUBST(MINISAT_LIBS) 371 AC_SUBST(MINISAT_INCLUDES) 372 fi 373 374 AC_LANG([C]) 375 CPPFLAGS="$CPPFLAGS_SAVE" 376 AC_DEFINE(USE_SAT_SOLVER, 1, [Define for compilation]) 377 AC_SUBST(ZLIB_CPPFLAGS) 378fi 379 380AM_CONDITIONAL(LIBMINISAT_BUNDLED, test -n "$use_minisat_bundled_library") 381AM_CONDITIONAL(WITH_SAT_SOLVER, test "x$enable_sat_solver" = xyes) 382 383# ==================================================================== 384 385AC_ARG_ENABLE( wordgraph_display, 386 [AS_HELP_STRING([--disable-wordgraph-display], 387 [disable graphical display of the Wordgraph (default is enabled)])], 388 [], 389 [enable_wordgraph_display=yes] 390) 391if test "x$enable_wordgraph_display" = "xyes" 392then 393 AC_DEFINE(USE_WORDGRAPH_DISPLAY, 1, [Define for compilation]) 394fi 395 396AM_CONDITIONAL(WITH_ANYSPLIT, test x${enable_wordgraph_display} = xyes) 397 398dnl ==================================================================== 399 400AC_CHECK_HEADER([sqlite3.h], [SQLiteFound=yes], SQLiteFound=no) 401 402# If sqlite3 and pkg-config are not found on MacOS, then 403# recommend that user install MacPorts http://www.macports.org/ 404if test "x${SQLiteFound}" = "xyes"; then 405 PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.0.0, [SQLiteFound=yes], [SQLiteFound=no]) 406fi 407 408# Don't set the CPPFLAGS unless we can find the library too. 409# Which is insane, of course, except that some Apple OSX systems 410# appear to be broken... have header files but no libs ... 411if test "x${SQLiteFound}" = "xyes"; then 412 AC_DEFINE(HAVE_SQLITE, 1, [Define for compilation]) 413fi 414AM_CONDITIONAL(HAVE_SQLITE, test x${SQLiteFound} = xyes) 415AC_SUBST(SQLITE3_LIBS) 416AC_SUBST(SQLITE3_CFLAGS) 417 418 419# ==================================================================== 420# Set Default Spell Checker settings 421 422do_aspell=yes 423# ASpell Support is handled here 424AC_ARG_ENABLE([aspell], [AS_HELP_STRING([--disable-aspell], 425 [Build without ASpell support (default is enabled)])], 426 [do_aspell="${enableval}"]) 427 428AM_CONDITIONAL(WITH_ASPELL, test x${do_aspell} = xyes) 429 430# Hunspell Support is handled here 431do_hunspell=yes 432AC_ARG_ENABLE([hunspell], [AS_HELP_STRING([--disable-hunspell], 433 [Build without HunSpell support (default is enabled)])], 434 [do_hunspell="${enableval}"]) 435 436AM_CONDITIONAL(WITH_HUNSPELL, test x${do_hunspell} = xyes) 437 438case "$host_os$host_cpu" in 439 *mingw*64) 440 default_hunspell_dictdir=/mingw64/share/myspell/dicts 441 ;; 442 *mingw*32) 443 # Not checked 444 default_hunspell_dictdir=/mingw32/share/myspell/dicts 445 ;; 446 darwin*) 447 default_hunspell_dictdir=/Library/Spelling 448 ;; 449 *) 450 default_hunspell_dictdir=/usr/share/myspell/dicts 451 ;; 452esac 453AC_ARG_WITH([hunspell-dictdir], [AS_HELP_STRING([--with-hunspell-dictdir=DIR], 454 [Use DIR to find HunSpell files (default=$default_hunspell_dictdir])], 455 [], with_hunspell_dictdir=) 456 457# ==================================================================== 458 459# 2015-08: The current default for speller is hunspell, since aspell is not 460# yet thread safe. Jan 2018 - aspell still not thread-safe... 461 462HunSpellDictDir= 463HunSpellFound=no 464if test x"$do_hunspell" = xyes; then 465 HunSpellFound=no 466 467 # First, look for the libraries. 468 PKG_CHECK_MODULES([HUNSPELL], [hunspell], [HunSpellFound=yes], [HunSpellFound=no]) 469 save_cpp_flags=${CPPFLAGS} 470 CPPFLAGS="${CPPFLAGS} ${HUNSPELL_CFLAGS}" 471 AC_CHECK_HEADER([hunspell.h], [HunSpellFound=yes], HunSpellFound=no) 472 CPPFLAGS=$save_cpp_flags 473 if test "x${HunSpellFound}" = "xyes"; then 474 AC_DEFINE(HAVE_HUNSPELL, 1, [Define for compilation]) 475 AC_SUBST(HUNSPELL_LIBS) 476 AC_SUBST(HUNSPELL_CFLAGS) 477 478 # Now, look for the dictionaries. 479 HunSpellDictDir=$default_hunspell_dictdir 480 if test -n "$with_hunspell_dictdir"; then 481 HunSpellDictDir=$with_hunspell_dictdir 482 fi 483 484 if test "$native_win32" = yes; then 485 # Convert to native format with forward slashes 486 # (allow spaces in DIR when using --with-hunspell-dictdir="DIR"). 487 case $HunSpellDictDir in 488 *\ *) 489 file_format=dos 490 ;; 491 *) 492 file_format=windows 493 ;; 494 esac 495 HunSpellDictDir=`cygpath --$file_format --mixed "$HunSpellDictDir"` 496 fi 497 498 if ! test -d "$HunSpellDictDir" ; then 499 AC_MSG_WARN([HunSpell dictionary directory \"$HunSpellDictDir\" not found.]) 500 HunSpellDictDir_status=' (not found)' 501 fi 502 AC_DEFINE_UNQUOTED(HUNSPELL_DICT_DIR, "$HunSpellDictDir", [Defining the dictionary path]) 503 504 # If hunspell enabled and found, then do NOT do aspell 505 do_aspell=no 506 fi 507 508fi 509 510AM_CONDITIONAL(HAVE_HUNSPELL, test x${HunSpellFound} = xyes) 511 512ASpellFound=no 513if test "$do_aspell" = yes ; then 514 PKG_CHECK_MODULES([ASPELL], [aspell], [ASpellFound=yes], [ASpellFound=no]) 515 save_cpp_flags=${CPPFLAGS} 516 CPPFLAGS="${CPPFLAGS} ${ASPELL_CFLAGS}" 517 AC_CHECK_HEADER([aspell.h], [ASpellFound=yes], ASpellFound=no) 518 AC_CHECK_LIB(aspell, new_aspell_config, [], [ASpellFound=no]) 519 CPPFLAGS=$save_cpp_flags 520 if test "x${ASpellFound}" = "xyes"; then 521 AC_DEFINE(HAVE_ASPELL, 1, [Define for compilation]) 522 ASPELL_LIBS="${ASPELL_LIBS} -lpthread" 523 AC_SUBST(ASPELL_LIBS) 524 AC_SUBST(ASPELL_CFLAGS) 525 fi 526fi 527 528AM_CONDITIONAL(HAVE_ASPELL, test x${ASpellFound} = xyes) 529 530# ==================================================================== 531 532# Enable editline by default 533AC_ARG_ENABLE( editline, 534 [ --disable-editline disable use of editline], 535 [], 536 [enable_editline=yes]) 537 538edlin=no 539wedlin=no 540if test "x$enable_editline" = "xyes"; then 541 PKG_CHECK_MODULES([LIBEDIT], [libedit], [edlin=yes], [edlin=no]) 542 if test "x${edlin}" = "xyes"; then 543 AM_CONDITIONAL(HAVE_EDITLINE, true) 544 AC_DEFINE(HAVE_EDITLINE, 1, [Define for compilation]) 545 546 # Now test for widechar support 547 AC_CHECK_LIB(edit, history_winit, [wedlin=yes], [wedlin=no]) 548 549 if test "x${wedlin}" = "xyes"; then 550 AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, true) 551 AC_DEFINE(HAVE_WIDECHAR_EDITLINE, 1, [Define for compilation]) 552 else 553 AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, false) 554 fi 555 556 else 557 AM_CONDITIONAL(HAVE_EDITLINE, false) 558 AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, false) 559 fi 560else 561 AM_CONDITIONAL(HAVE_EDITLINE, false) 562 AM_CONDITIONAL(HAVE_WIDECHAR_EDITLINE, false) 563fi 564 565# ==================================================================== 566# Configure a regex library that supports UTF-8 and a POSIX interface. 567dnl AC_CHECK_HEADERS defines HAVE_FILENAME_H if found. 568 569AC_ARG_WITH([regexlib], 570 [AS_HELP_STRING([--with-regexlib=pcre2|tre|regex|c], 571 [Use the pecified regex library (default=first found)])], 572 [], with_regexlib=) 573 574lgregexlib=--with-regexlib="$with_regexlib" 575 576case $with_regexlib in 577 '') 578 break 579 ;; 580 pcre2) 581 AC_CHECK_HEADERS([pcre2.h], , 582 [AC_MSG_ERROR([$lgregexlib: pcre2.h not found])], 583 [#define PCRE2_CODE_UNIT_WIDTH 8]) 584 PKG_CHECK_MODULES([REGEX], [libpcre2-8]) 585 ;; 586 tre) 587 AC_CHECK_HEADERS([tre/regex.h], , 588 [AC_MSG_ERROR([$lgregexlib: tre/regex.h not found])]) 589 PKG_CHECK_MODULES([REGEX], [tre]) 590 ;; 591 regex) 592 AC_CHECK_HEADERS([regex.h], ,[AC_MSG_ERROR([No regex.h header found])]) 593 AC_CHECK_LIB([regex], [regexec], [REGEX_LIBS=-lregex], 594 [AC_MSG_ERROR([$lgregexlib: regexec() not found])]) 595 ;; 596 c) 597 AC_CHECK_HEADERS([regex.h], ,[AC_MSG_ERROR([No regex.h header found])]) 598 AC_CHECK_FUNCS(regexec, [REGEX_LIBS=-lc], 599 [AC_MSG_ERROR([$lgregexlib: regexec() not found])]) 600 ;; 601 *) 602 AC_MSG_ERROR([$lgregexlib: Library not configurable (see configure --help)]) 603 ;; 604esac 605 606if test -z "$REGEX_LIBS"; then 607 AC_MSG_NOTICE([Checking for REGEX implementation:]) 608fi 609dnl Find the first regex library according to this order: 610dnl libpcre2-8, libtre, libregex, libc. 611 612if test -z "$REGEX_LIBS"; then 613 AC_CHECK_HEADER([pcre2.h], 614 [PKG_CHECK_MODULES([REGEX], [libpcre2-8], 615 [AC_DEFINE([HAVE_PCRE2_H], 1)], 616 [AC_MSG_RESULT([... missing libpcre2-8, continuing])])] 617 , , [#define PCRE2_CODE_UNIT_WIDTH 8]) 618 619fi 620if test -z "$REGEX_LIBS"; then 621 AC_CHECK_HEADER([tre/regex.h], 622 [PKG_CHECK_MODULES([REGEX], [tre], 623 [AC_DEFINE([HAVE_TRE_REGEX_H], 1)], 624 [AC_MSG_RESULT([... missing libtre, continuing])])]) 625fi 626if test -z "$REGEX_LIBS"; then 627 AC_CHECK_HEADERS([regex.h], 628 [AC_CHECK_LIB([regex], [regex], [REGEX_LIBS=-lregex], 629 [AC_MSG_RESULT([... libregex not found, continuing])] 630 [AC_CHECK_FUNCS([regexec], [REGEX_LIBS=-lc])])], 631 [AC_MSG_ERROR([No regex.h header found])]) 632fi 633 634if test -n "$REGEX_LIBS"; then 635 AC_MSG_RESULT([... found REGEX implementation: $REGEX_LIBS]) 636 test "x$REGEX_LIBS" = x-lc && REGEX_LIBS= 637 test -n "$REGEX_CFLAGS" && CFLAGS="$CFLAGS $REGEX_CFLAGS" 638else 639 AC_MSG_ERROR([No REGEX implementation found]) 640fi 641 642AC_SUBST(REGEX_LIBS) 643AC_SUBST(REGEX_CFLAGS) 644 645# ===================================================================== 646# Find the location of the jni.h file. 647 648JNIfound=no 649 650if test "x$enable_java_bindings" = "xyes"; then 651 652 if test x${apple_osx} = xyes; then 653 # Java on Apple OSX requies a 64-bit build. However, even 654 # modern 64-bit Apple machines build 32-bit binaries by default. 655 # So force a 64-bit build if a 64-bit CPU is found. 656 CFLAGS="${CFLAGS} -arch x86_64" 657 fi 658 659 absolute_srcdir=`(cd "$srcdir"; pwd)` 660 JAVA_SRCDIR=$absolute_srcdir/bindings/java 661 if test "$native_win32" = yes; then 662 # javac needs a Windows path 663 JAVA_SRCDIR=`cygpath -w "$JAVA_SRCDIR"` 664 665 # The standard location of Windows Java is under "\Program Files". 666 # However, automake is unable to handle spaces in a filename even 667 # when quoted (e.g. "-I '$JAVA_HOME/include'"). As a workaround, 668 # convert $JAVA_HOME to a short DOS path. 669 test -n "${JAVA_HOME}" && JAVA_HOME=`cygpath --dos --mixed "$JAVA_HOME"` 670 671 # win32/jni_md.h:34:9: error: ‘__int64’ does not name a type 672 JAVA_CPPFLAGS=-D__int64=int64_t 673 fi 674 AC_SUBST(JAVA_SRCDIR) 675 676 pushdef([AC_MSG_ERROR]) 677 define([AC_MSG_ERROR], 678 [AC_MSG_NOTICE([$1])]) 679 680 AX_JNI_INCLUDE_DIR 681 682 popdef([AC_MSG_ERROR]) 683 684 if test -n "$JNI_INCLUDE_DIRS"; then 685 JNIfound=yes 686 fi 687 688 for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS 689 do 690 JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$JNI_INCLUDE_DIR" 691 done 692 AC_SUBST(JAVA_CPPFLAGS) 693 694 # This allows jni-client.c to be built 695 AM_CONDITIONAL(HAVE_JAVA, test x${JNIfound} = xyes) 696 697 # For now, we assume that if the ant tool is there, then the javac and 698 # jar compiler/packager are installed as well. These are needed to build 699 # the jar file and install it. 700 AC_CHECK_PROG(ANTfound, ant, yes, no) 701 AM_CONDITIONAL(HAVE_ANT, test x${ANTfound} = xyes) 702 703else 704 AM_CONDITIONAL(HAVE_JAVA, false) 705 AM_CONDITIONAL(HAVE_ANT, false) 706fi 707 708# =================================================================== 709 710PerlFound=no 711if test "x$enable_perl_bindings" = "xyes"; then 712 # Look for the perl bits and pieces... 713 # AX_PERL_EXT isn't working for me ... 714 # AX_PATH_EXT 715 AC_MSG_CHECKING([for Perl XS include directory]) 716 if test -z "$PERL_EXT_INC" ; then 717 PERL_EXT_INC=`perl -MConfig -e 'print $Config{archlib}'` 718 fi 719 test -z "$PERL_EXT_INC" && PERL_EXT_INC=no 720 AC_MSG_RESULT([$PERL_EXT_INC]) 721 PERL_CFLAGS="-I${PERL_EXT_INC} -I${PERL_EXT_INC}/CORE" 722 AC_SUBST(PERL_EXT_INC) 723 AC_SUBST(PERL_CFLAGS) 724 725 # PERL_EXT_LIB is where to install, typically /usr/local/lib/perl/5.14.2 726 # or similar. 727 AC_MSG_CHECKING([for Perl extensions destination directory]) 728 if test -z "$PERL_EXT_LIB" ; then 729 PERL_EXT_LIB=`perl -MConfig -e 'print $Config{sitearchexp}'` 730 fi 731 test -z "$PERL_EXT_LIB" && PERL_EXT_LIB=no 732 AC_MSG_RESULT([$PERL_EXT_LIB]) 733 AC_SUBST(PERL_EXT_LIB) 734 735 save_cpp_flags=${CPPFLAGS} 736 CPPFLAGS="${CPPFLAGS} ${PERL_CFLAGS}" 737 AC_CHECK_HEADER([EXTERN.h], [PerlFound=yes], [PerlFound=no]) 738 AM_CONDITIONAL(HAVE_PERL, test x${PerlFound} = xyes) 739 CPPFLAGS=$save_cpp_flags 740else 741 AM_CONDITIONAL(HAVE_PERL, false) 742fi 743 744# =================================================================== 745# Find python things. 746 747dnl AX_PYTHON_DEVEL uses AC_MSG_ERROR in case it doesn't find things. 748dnl Temporarily make AC_MSG_ERROR a soft error (to be restored by popdef()). 749pushdef([AC_MSG_ERROR]) 750define([AC_MSG_ERROR], 751 lg_python_unusable=yes 752 [AC_MSG_NOTICE([$1])]) 753 754PythonFound=no 755if test "x$enable_python_bindings" = xyes; then 756 AM_PATH_PYTHON(PYTHON3_REQUIRED, [PythonFound=yes]) 757 AX_PYTHON_DEVEL(>= 'PYTHON3_REQUIRED') 758 test -n "$lg_python_unusable" && PythonFound=no 759 if test x$PythonFound = xyes; then 760 PythonFound=$PYTHON_VERSION 761 lg_display_PYTHON=" ($PYTHON)" 762 PYTHON_CPPFLAGS=$PYTHON_CPPFLAGS 763 PYTHON_LIBS=$PYTHON_LIBS 764 PYTHON_LDFLAGS=$PYTHON_LDFLAGS 765 pythondir=$pythondir 766 AC_SUBST(PYTHON_CPPFLAGS) 767 AC_SUBST(PYTHON_LIBS) 768 AC_SUBST(PYTHON_LDFLAGS) 769 AC_SUBST(pythondir) 770 fi 771fi 772AM_CONDITIONAL(HAVE_PYTHON, test x$PythonFound != xno) 773 774AC_SUBST(PYTHON) 775AC_SUBST(pythondir) 776 777# Formerly both python2 and python3 bindings got generated. This caused a 778# redefinition of the preprocessor symbol HAVE_PYTHON and generates a lot 779# of compiler warnings, so it got discarded here. Now we generate only 780# python3 bindings, but since we don't use this definition, it is still 781# discarded here. 782# Note: The v command allows to differentiate between the two flavors of sed. 783edit_in_place=-i 784sed v </dev/null 2>/dev/null || edit_in_place="-i ''" 785sed $edit_in_place '/HAVE_PYTHON/d' confdefs.h 786 787popdef([AC_MSG_ERROR]) 788 789if test x$enable_python_bindings = xyes; then 790 if test x$PythonFound = xno; then 791 AC_MSG_NOTICE( 792 [Python binding is enabled, but an approprite Python version 793 could not be configured (minimum version: PYTHON3_REQUIRED).]) 794 fi 795fi 796 797# =================================================================== 798# swig is needed for compiling the Perl and Python bindings ... 799# ... well, actually, no, its not. 'make dist' is currently set up to 800# package all of the files generated by swig, so the user does not need 801# to actually install it. However, swig is needed to create the package, 802# and also needed to build from a GitHub pull. 803 804if ! test -s "$srcdir/bindings/python/lg_python_wrap.cc"; then 805 AM_COND_IF(HAVE_PYTHON, [swig_required="$swig_required Python"]) 806fi 807if ! test -s "$srcdir/bindings/perl/lg_perl_wrap.cc"; then 808 AM_COND_IF(HAVE_PERL, [swig_required="$swig_required Perl"]) 809fi 810 811if test -n "$swig_required"; then 812 AX_PKG_SWIG(2.0.0,, [AC_MSG_ERROR(['swig' is required to create bindings for: $swig_required])]) 813 AX_SWIG_ENABLE_CXX 814 SWIGfound="$SWIG" 815else 816 SWIGfound=no 817fi 818AM_CONDITIONAL(HAVE_SWIG, test -n "$SWIG") 819 820# ==================================================================== 821# check compiler flags 822 823AC_DEFUN([LINK_CC_TRY_FLAG], [ 824 AC_MSG_CHECKING([whether $CC supports $1]) 825 826 link_save_CFLAGS="$CFLAGS" 827 CFLAGS="$CFLAGS -Werror $1" 828 829 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ ]])], [link_cc_flag=yes], [link_cc_flag=no]) 830 CFLAGS="$link_save_CFLAGS" 831 832 if test "x$link_cc_flag" = "xyes"; then 833 ifelse([$2], , :, [$2]) 834 else 835 ifelse([$3], , :, [$3]) 836 fi 837 AC_MSG_RESULT([$link_cc_flag]) 838]) 839 840dnl Use lots of warning flags with with gcc and compatible compilers 841 842dnl Note: if you change the following variable, the cache is automatically 843dnl skipped and all flags rechecked. So there's no need to do anything 844dnl else. If for any reason you need to force a recheck, just change 845dnl MAYBE_WARN in an ignorable way (like adding whitespace) 846 847dnl MAYBE_WARN works for C++ and C, while MAYBE_WARN_C is for C only. 848MAYBE_WARN_CXX="-Wall -Wextra \ 849-Wsign-compare \ 850-Wpointer-arith -Wwrite-strings -Wmissing-declarations \ 851-Wpacked -Wswitch-enum -Wmissing-format-attribute \ 852-Wstrict-aliasing -Winit-self -Wshadow \ 853-Wno-missing-field-initializers -Wno-unused-parameter \ 854-Wno-attributes -Wno-long-long -Winline" 855 856MAYBE_WARN_C="-Wstrict-prototypes -Wmissing-prototypes -Wformat-signedness \ 857-Wnested-externs -Wold-style-definition -Werror-implicit-function-declaration" 858 859MAYBE_WARN="$MAYBE_WARN_CXX $MAYBE_WARN_C" 860 861# Invalidate cached value if MAYBE_WARN has changed 862if test "x$link_cv_warn_maybe" != "x$MAYBE_WARN"; then 863 unset link_cv_warn_cflags 864fi 865AC_CACHE_CHECK([for supported warning flags], link_cv_warn_cflags, [ 866 echo 867 WARN_CFLAGS="" 868 869 # Some warning options are not supported by all versions of 870 # gcc (or clang), so test all desired options against the 871 # current compiler. With only one issue: clang fails to return 872 # an error when it doesn't know the option. So this test fails. 873 # 874 # Note that there are some order dependencies 875 # here. Specifically, an option that disables a warning will 876 # have no net effect if a later option then enables that 877 # warnings, (perhaps implicitly). So we put some grouped 878 # options (-Wall and -Wextra) up front and the -Wno options 879 # last. 880 881 for W in $MAYBE_WARN_C; do 882 LINK_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"]) 883 done 884 885 for W in $MAYBE_WARN_CXX; do 886 LINK_CC_TRY_FLAG([$W], [WARN_CXXFLAGS="$WARN_CXXFLAGS $W"]) 887 done 888 889 link_cv_warn_cflags=$WARN_CFLAGS 890 link_cv_warn_cxxflags=$WARN_CXXFLAGS 891 892 AC_MSG_CHECKING([which warning flags were supported])]) 893 894WARN_CFLAGS="$link_cv_warn_cflags $link_cv_warn_cxxflags" 895WARN_CXXFLAGS="$link_cv_warn_cxxflags" 896 897AC_SUBST(WARN_CFLAGS) 898AC_SUBST(WARN_CXXFLAGS) 899 900LINK_CC_TRY_FLAG([-fno-strict-aliasing], 901 [LINK_CFLAGS="$LINK_CFLAGS -fno-strict-aliasing"]) 902 903AC_SUBST(LINK_CFLAGS) 904 905LINK_CC_TRY_FLAG([-Wmaybe-uninitialized -Werror], [AC_DEFINE(HAVE_MAYBE_UNINITIALIZED)]) 906 907# =================================================================== 908 909AC_FUNC_STRERROR_R 910 911AC_SUBST(CFLAGS) 912AC_SUBST(CPPFLAGS) 913AC_SUBST(CXXFLAGS) 914 915dnl Save the compilation definitions for an extended version printout 916AC_OUTPUT_MAKE_DEFS() 917LG_DEFS=`$ECHO "$DEFS" | $SED 's/\\\\//g'` 918AC_SUBST(LG_DEFS) 919 920AC_CONFIG_FILES([ 921Makefile 922link-grammar.pc 923link-grammar.spec 924link-grammar/Makefile 925link-grammar/minisat/Makefile 926link-grammar/sat-solver/Makefile 927link-grammar/link-features.h 928bindings/Makefile 929bindings/java-jni/Makefile 930bindings/java/Makefile 931bindings/java/build.xml 932bindings/ocaml/Makefile 933bindings/perl/Makefile 934bindings/python/Makefile 935bindings/python/__init__.py 936bindings/python-examples/Makefile 937morphology/Makefile 938link-parser/Makefile 939tests/Makefile 940data/Makefile 941data/ady/Makefile 942data/amy/Makefile 943data/any/Makefile 944data/ar/Makefile 945data/ar/words/Makefile 946data/de/Makefile 947data/en/Makefile 948data/en/words/Makefile 949data/fa/Makefile 950data/fa/words/Makefile 951data/he/Makefile 952data/id/Makefile 953data/kz/Makefile 954data/lt/Makefile 955data/ru/Makefile 956data/ru/words/Makefile 957data/tr/Makefile 958data/vn/Makefile 959data/demo-sql/Makefile 960man/Makefile 961]) 962AC_OUTPUT 963 964# ==================================================================== 965lglibs=`${ECHO} "$LIBEDIT_LIBS $HUNSPELL_LIBS $ASPELL_LIBS $REGEX_LIBS $MINISAT_LIBS $SQLITE3_LIBS $LIBS"|${SED} 's/ */ /g'` 966 967echo " 968$PACKAGE-$VERSION build configuration settings 969 970 prefix: ${prefix} 971 datadir: $(eval "echo ${datadir}") 972 C compiler: ${CC} ${CPPFLAGS} ${CFLAGS} 973 C++ compiler: ${CXX} ${CPPFLAGS} ${CXXFLAGS} 974 Regex library: ${REGEX_LIBS} 975 TLS: ${lg_tls} 976 Editline command-line history: ${edlin} 977 UTF8 editline support: ${wedlin} 978 Java libraries: ${JNIfound} 979 Java interfaces: ${ANTfound} 980 Swig interfaces generator: ${SWIGfound} 981 Perl interfaces: ${PerlFound} 982 Perl install location: ${PERL_EXT_LIB} 983 Python interfaces: ${PythonFound}${lg_display_PYTHON} 984 ASpell spell checker: ${ASpellFound} 985 HunSpell spell checker: ${HunSpellFound} 986 HunSpell dictionary location: ${HunSpellDictDir}${HunSpellDictDir_status} 987 Boolean SAT parser: ${enable_sat_solver}${use_minisat_bundled_library} 988 SQLite-backed dictionary: ${SQLiteFound} 989 RegEx tokenizer: ${enable_regex_tokenizer} 990 Definitions: ${DEFS} 991 Libraries: ${lglibs} 992" 993