1# Copyright (c) 2009, Darren Hiebert 2# 3# This source code is released for free distribution under the terms 4# of the GNU General Public License version 2 or (at your option) any 5# later version. 6 7# Process this file with autoconf to produce a configure script. 8 9AC_PREREQ([2.64]) 10AC_INIT([universal-ctags],[5.9.0]) 11 12if ! test -e "${srcdir}/config.h.in"; then 13 echo "---" 14 echo "--- ${srcdir}/config.h.in WAS NOT FOUND." 1>&2 15 echo "--- YOU MIGHT HAVE RUN autoconf ONLY" 1>&2 16 echo "--- BUT YOU MAY HAVE TO RUN autogen.sh." 1>&2 17 echo "---" 18 exit 1 19fi 20 21# Report system info 22# ------------------ 23program_name=[`grep 'PROGRAM_NAME *"' $srcdir/main/ctags.h | sed -e 's/.*"\([^"]*\)".*/\1/'`] 24program_version=[`grep 'PROGRAM_VERSION *"' $srcdir/main/ctags.h | sed -e 's/.*"\([^"]*\)".*/\1/'`] 25echo "$program_name, version $program_version" 26uname -mrsv 2>/dev/null 27 28AM_INIT_AUTOMAKE([foreign subdir-objects tar-ustar]) 29AM_SILENT_RULES([yes]) 30AC_CONFIG_HEADERS([config.h]) 31 32m4_ifndef([PKG_CHECK_EXISTS], [m4_fatal([must install pkg-config 0.18 or later before running ./autogen.sh])]) 33 34AC_CANONICAL_BUILD 35AC_CANONICAL_HOST 36 37case $host in 38 *darwin*) 39 if test "${enable_static}" = "yes"; then 40 printf "\n%s\n" "macOS not support --enable-static." >&5 41 printf "\n%s\n" "macOS not support --enable-static." >&6 42 exit 1 43 fi 44 ;; 45 *freebsd*|*openbsd*) 46 # https://github.com/universal-ctags/ctags/issues/3338 47 export LDFLAGS="$LDFLAGS -L/usr/local/lib" 48 ;; 49esac 50 51AH_TEMPLATE([PACKAGE], [Package name.]) 52AH_TEMPLATE([VERSION], [Package version.]) 53AH_TEMPLATE([clock_t], 54 [Define to the appropriate type if <time.h> does not define this.]) 55AH_TEMPLATE([fpos_t], 56 [Define to long if <stdio.h> does not define this.]) 57AH_TEMPLATE([L_tmpnam], 58 [Define to the appropriate size for tmpnam() if <stdio.h> does not define 59 this.]) 60AH_TEMPLATE([HAVE_STAT_ST_INO], 61 [Define this macro if the field "st_ino" exists in struct stat in 62 <sys/stat.h>.]) 63AH_TEMPLATE([HAVE_STATEMENT_EXPRESSION_EXT], 64 [Define this macro if compiler supports statement expression non-standard 65 C feature.]) 66AH_TEMPLATE([remove], 67 [Define remove to unlink if you have unlink(), but not remove().]) 68AH_TEMPLATE([INT_MAX], 69 [Define as the maximum integer on your system if not defined <limits.h>.]) 70AH_TEMPLATE([CUSTOM_CONFIGURATION_FILE], 71 [You can define this label to be a string containing the name of a 72 site-specific configuration file containing site-wide default options. The 73 files /etc/ctags.conf and /usr/local/etc/ctags.conf are already checked, 74 so only define one here if you need a file somewhere else.]) 75AH_TEMPLATE([ETAGS], 76 [Define the string to check (in executable name) for etags mode]) 77AH_TEMPLATE([MACROS_USE_PATTERNS], 78 [Define this label if you want macro tags (defined lables) to use patterns 79 in the EX command by default (original ctags behavior is to use line 80 numbers).]) 81AH_VERBATIM([DEFAULT_FILE_FORMAT], [ 82/* Define this as desired. 83 * 1: Original ctags format 84 * 2: Extended ctags format with extension flags in EX-style comment. 85 */ 86#define DEFAULT_FILE_FORMAT 2 87]) 88AH_TEMPLATE([CASE_INSENSITIVE_FILENAMES], 89 [Define this label if your system uses case-insensitive file names]) 90AH_VERBATIM([EXTERNAL_SORT], [ 91/* Define this label to use the system sort utility (which is probably more 92* efficient) over the internal sorting algorithm. 93*/ 94#ifndef INTERNAL_SORT 95# undef EXTERNAL_SORT 96#endif 97]) 98AH_TEMPLATE([HAVE_ICONV], 99 [Define this value if support multibyte character encoding.]) 100AH_TEMPLATE([ICONV_USE_LIB_PREFIX], 101 [Define this value if the platform uses "lib" as prefix for iconv functions.]) 102AH_TEMPLATE([TMPDIR], 103 [If you wish to change the directory in which temporary files are stored, 104 define this label to the directory desired.]) 105AH_TEMPLATE([NON_CONST_PUTENV_PROTOTYPE], 106 [Define this is you have a prototype for putenv() in <stdlib.h>, but 107 doesn't declare its argument as "const char *".]) 108AH_TEMPLATE([MSDOS_STYLE_PATH], 109 [Define to 1 if your system uses MS-DOS style path.]) 110AH_TEMPLATE([MANUAL_GLOBBING], 111 [Define to 1 if your system doesn't expand wildcards.]) 112AH_TEMPLATE([HAVE__FINDFIRST], 113 [Define to 1 if your system have _findfirst().]) 114AH_TEMPLATE([ENABLE_GCOV], 115 [Define to 1 if gcov is instrumented.]) 116AH_TEMPLATE([USE_GNULIB_FNMATCH], 117 [Define to 1 when using fnmatch implementation in bundled gnulib.]) 118 119# Define convenience macros 120# ------------------------- 121# CHECK_HEADER_DEFINE(LABEL, HEADER [,ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ] ]) 122AC_DEFUN([CHECK_HEADER_DEFINE], [ 123 AC_MSG_CHECKING([if $1 is defined in $2]) 124 AC_EGREP_CPP([$2:$1], 125[ 126#include <$2> 127#ifdef $1 128const char *result_yes = "$2:$1"; 129#endif 130], [ 131 AC_MSG_RESULT(yes) 132 [$3] 133], [ 134 AC_MSG_RESULT(no) 135 [$4] 136]) ]) 137 138# CHECK_PROTO(FUNCTION, HEADER-FILE) 139AC_DEFUN([CHECK_PROTO], [ 140 AC_EGREP_HEADER([[^A-Za-z0-9_]$1([ ]+[A-Za-z0-9_]*)?[ ]*\(], 141 [$2], 142 [], 143 [ 144 AC_MSG_NOTICE([adding prototype for $1]) 145 AH_TEMPLATE(AS_TR_CPP([NEED_PROTO_$1]), 146 [If you receive error or warning messages indicating that you are missing a prototype for, or a type mismatch using, the following function, define this label and remake.]) 147 AC_DEFINE(AS_TR_CPP([NEED_PROTO_$1])) 148 ]) 149]) 150 151# PRETTY_ARG_VAR(VARIABLE, DESCRIPTION, DEFAULT) 152# ---------------------------------------------- 153# Call AC_ARG_VAR with DEFAULT value. 154AC_DEFUN([PRETTY_ARG_VAR], [ 155 AC_ARG_VAR([$1], [$2 [$3]]) 156 157 if test "${ac_env_$1_set}" = "set"; then 158 $1="${ac_env_$1_value}" 159 else 160 $1="$3" 161 fi 162]) 163 164# Checks for configuration options 165# -------------------------------- 166 167AC_ARG_WITH([sparse-cgcc], 168 [AS_HELP_STRING([--with-sparse-cgcc], 169 [use Sparse 'compiler wrapper' cgcc as C compiler [no]])]) 170 171AC_ARG_ENABLE([coverage-gcov], 172 [AS_HELP_STRING([--enable-coverage-gcov], 173 [enable 'gcov' coverage testing tool [no]])]) 174 175AC_ARG_ENABLE(readcmd, 176 [AS_HELP_STRING([--disable-readcmd], 177 [do not include readtags command during install])], 178 [], [enable_readcmd=yes]) 179 180# AC_ARG_WITH(perl-regex, 181# [AS_HELP_STRING([--with-perl-regex], 182# [use Perl pcre interface, if available])]) 183 184AC_ARG_ENABLE(etags, 185 [AS_HELP_STRING([--enable-etags], 186 [enable the installation of links for etags])]) 187 188AC_ARG_ENABLE(extended-format, 189 [AS_HELP_STRING([--disable-extended-format], 190 [disable extension flags; use original ctags file format only])], 191 AC_DEFINE(DEFAULT_FILE_FORMAT, 1), AC_DEFINE(DEFAULT_FILE_FORMAT, 2)) 192 193AC_ARG_ENABLE(external-sort, 194 [AS_HELP_STRING([--disable-external-sort], 195 [use internal sort algorithm instead of sort program])]) 196 197AC_ARG_ENABLE(iconv, 198 [AS_HELP_STRING([--disable-iconv], 199 [disable multibyte character encoding support])]) 200 201AC_ARG_ENABLE(custom-config, 202 [AS_HELP_STRING([--enable-custom-config=FILE], 203 [enable custom config file for site-wide defaults])]) 204 205AC_ARG_ENABLE(macro-patterns, 206 [AS_HELP_STRING([--enable-macro-patterns], 207 [use patterns as default method to locate macros instead of line numbers])]) 208 209AC_ARG_ENABLE(tmpdir, 210 [AS_HELP_STRING([--enable-tmpdir=DIR], 211 [default directory for temporary files [ARG=/tmp]])], 212 tmpdir_specified=yes) 213 214AC_ARG_ENABLE([debugging], 215 [AS_HELP_STRING([--enable-debugging], 216 [enable debugging features])]) 217 218AC_ARG_ENABLE([static], 219 [AS_HELP_STRING([--enable-static], 220 [enable static linking (mainly for MinGW)])]) 221 222AC_ARG_PROGRAM 223 224# Process configuration options 225# ----------------------------- 226 227AM_CONDITIONAL(INSTALL_ETAGS, [test "x$enable_etags" = "xyes"]) 228AM_CONDITIONAL(USE_READCMD, [test "x$enable_readcmd" = "xyes"]) 229 230dnl AC_MSG_NOTICE(Change with $program_transform_name) 231CTAGS_NAME_EXECUTABLE=`echo ctags | sed "$program_transform_name"` 232AC_SUBST(CTAGS_NAME_EXECUTABLE) 233ETAGS_NAME_EXECUTABLE=`echo etags | sed "$program_transform_name"` 234AC_SUBST(ETAGS_NAME_EXECUTABLE) 235 236AC_DEFINE_UNQUOTED(ETAGS, "$ETAGS_NAME_EXECUTABLE") 237 238if test "$enable_custom_config" = no -o "$enable_custom_config" = yes ; then 239 AC_MSG_NOTICE(no name supplied for custom configuration file) 240elif test -n "$enable_custom_config" ; then 241 AC_DEFINE_UNQUOTED(CUSTOM_CONFIGURATION_FILE, "$enable_custom_config") 242 AC_MSG_NOTICE($enable_custom_config will be used as custom configuration file) 243fi 244 245if test "$enable_macro_patterns" = yes ; then 246 AC_DEFINE(MACROS_USE_PATTERNS) 247 AC_MSG_NOTICE(tag file will use patterns for macros by default) 248fi 249 250AM_CONDITIONAL(ENABLE_DEBUGGING, [test "x$enable_debugging" = "xyes"]) 251 252 253# Checks for programs 254# ------------------- 255 256AC_PROG_CC 257AC_PROG_CC_C99 258# For gnulib. 259# Typically, this is immediately after AC_PROG_CC, ... 260gl_EARLY 261 262AC_PROG_RANLIB 263AC_C_BIGENDIAN 264 265if test "$cross_compiling" = "yes"; then 266 # We need to compile and run a program on the build machine. 267 AC_MSG_CHECKING(for cc for build) 268 if test "x${CC_FOR_BUILD}" = "x" ; then 269 CC_FOR_BUILD=cc 270 fi 271 AC_MSG_RESULT($CC_FOR_BUILD) 272 273 AC_MSG_CHECKING(if $CC_FOR_BUILD works) 274 275 unset TEMP_DIR_FOR_CHECKING 276 TEMP_DIR_FOR_CHECKING=$(mktemp -d) 277 278 unset CC_FOR_BUILD_WORKS 279 CC_FOR_BUILD_WORKS=no 280 281 ( 282 cd "$TEMP_DIR_FOR_CHECKING" || return 1 283 284 printf 'int main() { return 0;}' > test.c 285 286 $CC_FOR_BUILD $CPPFLAGS_FOR_BUILD $CFLAGS_FOR_BUILD $LDFLAGS_FOR_BUILD -o test test.c 287 ) && CC_FOR_BUILD_WORKS=yes 288 289 AC_MSG_RESULT($CC_FOR_BUILD_WORKS) 290 291 unset BUILD_EXEEXT 292 unset BUILD_OBJEXT 293 294 BUILD_OBJEXT='o' 295 296 if [ -f "$TEMP_DIR_FOR_CHECKING/test.exe" ] ; then 297 BUILD_EXEEXT='.exe' 298 fi 299else 300 CC_FOR_BUILD="$CC" 301 CFLAGS_FOR_BUILD="$CFLAGS" 302 CPPFLAGS_FOR_BUILD="$CPPFLAGS" 303 LDFLAGS_FOR_BUILD="$LDFLAGS" 304 305 BUILD_OBJEXT="$OBJEXT" 306 BUILD_EXEEXT="$EXEEXT" 307fi 308 309AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) 310AC_ARG_VAR(CFLAGS_FOR_BUILD,[CFLAGS for build system C compiler]) 311AC_ARG_VAR(CPPFLAGS_FOR_BUILD,[CPPFLAGS for build system C compiler]) 312AC_ARG_VAR(LDFLAGS_FOR_BUILD,[LDFLAGS for build system C compiler]) 313 314AC_SUBST([CC_FOR_BUILD]) 315AC_SUBST([CFLAGS_FOR_BUILD]) 316AC_SUBST([CPPFLAGS_FOR_BUILD]) 317AC_SUBST([LDFLAGS_FOR_BUILD]) 318 319AC_SUBST([BUILD_OBJEXT]) 320AC_SUBST([BUILD_EXEEXT]) 321 322AC_ARG_VAR(AR,[ar command or path]) 323AC_ARG_VAR(RANLIB,[ranlib command or path]) 324AC_ARG_VAR(WINDRES,[windres command or path, used with mingw-w64]) 325AC_SUBST([WINDRES]) 326 327if test "x${AR}" = "x" ; then 328 AR=ar 329fi 330 331if test "x${WINDRES}" = "x" ; then 332 WINDRES=windres 333fi 334 335if test "${with_sparse_cgcc}" = "yes"; then 336 REAL_CC="${CC}" 337 CC="cgcc" 338 AC_SUBST([REAL_CC]) 339 340 PRETTY_ARG_VAR([CGCC_CFLAGS], [cgcc specific flags], 341 [-Wsparse-all]) 342else 343 CGCC_CFLAGS="" 344fi 345 346if test "${enable_coverage_gcov}" = "yes"; then 347 COVERAGE_CFLAGS="--coverage" 348 COVERAGE_LDFLAGS="--coverage" 349 AC_DEFINE(ENABLE_GCOV) 350fi 351AC_SUBST([COVERAGE_CFLAGS]) 352AC_SUBST([COVERAGE_LDFLAGS]) 353 354AC_PROG_LN_S 355AC_CHECK_PROG(STRIP, strip, strip, :) 356AC_SYS_LARGEFILE 357 358AC_CHECK_PROG([perl_found], [perl], [yes], [no]) 359AM_CONDITIONAL([RUN_OPTLIB2C], [test "${perl_found}" = "yes"]) 360AM_CONDITIONAL([RUN_TXT2CSTR], [test "${perl_found}" = "yes"]) 361 362# rst2man and rst2html are part of python-docutils, and if not found 363# can be installed using pip ("pip install docutils"). On some 364# systems, rst2man and rst2html are actually installed as rst2man.py 365# and rst2html.py - create a symlink of that's the case. 366AC_PATH_PROGS(RST2MAN, [rst2man rst2man.py rst2man-3 rst2man-3.6 rst2man-3.7 rst2man-3.8 rst2man-3.9], [no]) 367AM_CONDITIONAL([HAVE_RST2MAN], [test "x$RST2MAN" != "xno"]) 368AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py rst2html-3 rst2html-3.6 rst2html-3.7 rst2html-3.8 rst2html-3.9], [no]) 369AM_CONDITIONAL([HAVE_RST2HTML], [test "x$RST2HTML" != "xno"]) 370 371# rst2pdf is a separate tool and can also be installed via pip (e.g., 372# "pip install rst2pdf") 373AC_PATH_PROGS(RST2PDF, [rst2pdf], [no]) 374AM_CONDITIONAL([HAVE_RST2PDF], [test "x$RST2PDF" != "xno"]) 375 376# rst2man had a bug about code-block:: handling. 377# https://sourceforge.net/p/docutils/patches/141 378RST2MAN_OPTIONS= 379if ! test "x$RST2MAN" = "xno"; then 380 RST2MAN_SUPPORTING_SYNTAX_HIGHLIGHT_OPTION=no 381 AC_MSG_CHECKING(whether rst2mn has --syntax-highlight option) 382 if $RST2MAN --help | grep -q -e --syntax-highlight; then 383 RST2MAN_SUPPORTING_SYNTAX_HIGHLIGHT_OPTION=yes 384 dnl See man/Makefile about the option 385 RST2MAN_OPTIONS=--syntax-highlight=none 386 fi 387 AC_MSG_RESULT($RST2MAN_SUPPORTING_SYNTAX_HIGHLIGHT_OPTION) 388fi 389AC_SUBST(RST2MAN_OPTIONS) 390AM_CONDITIONAL([HAS_GNU_SED], [sed --version 2>/dev/null | grep -q GNU]) 391 392# Checks for operating environment 393# -------------------------------- 394in_git_repo=no 395AC_MSG_CHECKING(building in a git repository) 396if test -f "${srcdir}/.git/HEAD" || test -f "${srcdir}/.git"; then 397 in_git_repo=yes 398fi 399AC_MSG_RESULT(${in_git_repo}) 400 401AC_CHECK_PROGS([GIT], [git]) 402if ! test "${GIT:+set}" = "set"; then 403 in_git_repo=no 404fi 405AM_CONDITIONAL([BUILD_IN_GIT_REPO], [test "x${in_git_repo}" = "xyes"]) 406 407have_timeout=no 408AC_CHECK_PROGS([TESTING_TIMEOUT], [timeout]) 409if test "${TESTING_TIMEOUT:+set}" = "set"; then 410 have_timeout=yes 411fi 412AM_CONDITIONAL([HAVE_TIMEOUT], [test "x${have_timeout}" = "xyes"]) 413 414AC_CHECK_PROGS([PYTHON], 415 [python3 python3.8 python3.7 python3.6 python3.5 python], []) 416 417 418# Check for temporary directory 419AC_MSG_CHECKING(directory to use for temporary files) 420if test -n "$enable_tmpdir"; then 421 tmpdir="$enable_tmpdir" 422elif test -n "$TMPDIR"; then 423 tmpdir="$TMPDIR" 424elif test -n "$TMP"; then 425 tmpdir="$TMP" 426elif test -n "$TEMP"; then 427 tmpdir="$TEMP" 428elif test -d "c:/"; then 429 tmpdir="c:/" 430else 431 tmpdir="/tmp" 432fi 433if test -d $tmpdir ; then 434 AC_MSG_RESULT($tmpdir) 435 AC_DEFINE_UNQUOTED(TMPDIR, "$tmpdir") 436else 437 AC_MSG_ERROR($tmpdir does not exist) 438fi 439 440# Test for case-insensitive filenames 441AC_MSG_CHECKING(for case-insensitive filenames) 442touch conftest.cif 443if test -f CONFTEST.CIF; then 444 AC_MSG_RESULT(yes) 445 AC_DEFINE(CASE_INSENSITIVE_FILENAMES) 446else 447 AC_MSG_RESULT(no) 448fi 449rm -f conftest.cif 450 451AC_MSG_CHECKING(selected sort method) 452if test no = "$enable_external_sort"; then 453 AC_MSG_RESULT(simple internal algorithm) 454else 455 AC_MSG_RESULT(external sort utility) 456 enable_external_sort=no 457 AC_CHECK_PROG(sort_found, sort, yes, no) 458 if test "$sort_found" = yes ; then 459 AC_MSG_CHECKING(if sort accepts our command line) 460 touch ${tmpdir}/sort.test 461 sort -u -f -o ${tmpdir}/sort.test ${tmpdir}/sort.test 1>/dev/null 2>&1 462 if test $? -ne 0 ; then 463 AC_MSG_RESULT(no) 464 else 465 AC_MSG_RESULT(yes) 466 AC_DEFINE(EXTERNAL_SORT) 467 enable_external_sort=yes 468 fi 469 rm -f ${tmpdir}/sort.test 470 fi 471fi 472if test "$enable_external_sort" != yes ; then 473 AC_MSG_NOTICE(using internal sort algorithm as fallback) 474fi 475 476 477# Checks for header files 478# ----------------------- 479 480AC_CHECK_HEADERS([direct.h dirent.h fcntl.h io.h stat.h types.h unistd.h]) 481AC_CHECK_HEADERS([sys/dir.h sys/stat.h sys/types.h sys/wait.h]) 482 483# Checks for header file macros 484# ----------------------------- 485 486CHECK_HEADER_DEFINE(L_tmpnam, [stdio.h],, AC_DEFINE(L_tmpnam, 20)) 487 488 489# Checks for typedefs and types 490# ----------------------------- 491 492AC_TYPE_OFF_T 493 494AC_CHECK_HEADERS([stdbool.h]) 495 496# Checks for compiler characteristics 497# ----------------------------------- 498 499AC_C_CONST 500AC_OBJEXT 501AC_EXEEXT 502AC_C_TYPEOF 503 504if test "${enable_static}" = "yes"; then 505 LDFLAGS="$LDFLAGS -static" 506fi 507 508# Check for host type 509case "$host" in 510 i?86-*-mingw* | x86_64-*-mingw*) 511 host_mingw=yes 512 # See https://github.com/universal-ctags/ctags/pull/3069 513 gl_cv_have_weak=no 514 AC_DEFINE(MSDOS_STYLE_PATH) 515 AC_DEFINE(MANUAL_GLOBBING) 516 AC_DEFINE(HAVE__FINDFIRST) 517 ;; 518 *-cygwin | *-msys) 519 gl_cv_have_weak=no 520 ;; 521esac 522AM_CONDITIONAL([HOST_MINGW], [test "x${host_mingw}" = "xyes"]) 523 524AC_MSG_CHECKING(if compiler supports statement expressions) 525AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ 526int main(int argc, char **argv) {return ({ int x = 1; x + argc;});} 527])],[have_statement_expression_ext=yes],[have_statement_expression_ext=no]) 528AC_MSG_RESULT($have_statement_expression_ext) 529if test yes = "$have_statement_expression_ext"; then 530 AC_DEFINE(HAVE_STATEMENT_EXPRESSION_EXT) 531fi 532 533 534# Check if struct stat contains st_ino. 535# MinGW has st_ino, but it doesn't work. 536if test yes != "$host_mingw"; then 537 AC_MSG_CHECKING(if struct stat contains st_ino) 538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 539 #include <sys/stat.h> 540 #include <stdlib.h> 541 ], [ 542 struct stat st; 543 stat(".", &st); 544 if (st.st_ino > 0) 545 exit(0); 546 ])],[have_st_ino=yes],[have_st_ino=no]) 547 AC_MSG_RESULT($have_st_ino) 548 if test yes = "$have_st_ino"; then 549 AC_DEFINE(HAVE_STAT_ST_INO) 550 fi 551fi 552 553PRETTY_ARG_VAR([EXTRA_CPPFLAGS], [extra (Objective) C/C++ preprocessor flags], 554 [-D_GNU_SOURCE -D__USE_GNU]) 555PRETTY_ARG_VAR([DEBUG_CPPFLAGS], [(Objective) C/C++ preprocessor debug flags], 556 [-DDEBUG]) 557 558PRETTY_ARG_VAR([EXTRA_CFLAGS], [extra C compiler flags], 559 [-std=gnu99]) 560PRETTY_ARG_VAR([WARNING_CFLAGS], [C compiler warning flags], 561 [-Wall]) 562 563# For gnulib. 564# Place it further down in the file, typically where you normally check for 565# header files or functions. 566gl_INIT 567 568if test "$REPLACE_FNMATCH" != 0; then 569 AC_DEFINE([USE_GNULIB_FNMATCH]) 570fi 571 572AC_CHECK_FUNCS(asprintf) 573AC_CHECK_FUNCS(strstr) 574AC_CHECK_FUNCS(strcasecmp stricmp, break) 575AC_CHECK_FUNCS(strncasecmp strnicmp, break) 576 577AC_CHECK_FUNCS(mkstemp, have_mkstemp=yes) 578if test "$have_mkstemp" != yes ; then 579 AC_CHECK_FUNCS(tempnam, have_tempnam=yes) 580fi 581if test "$have_mkstemp" != yes -a "$have_tempnam" != yes; then 582 AC_CHECK_FUNCS(chmod) 583 if test "$tmpdir_specified" = yes ; then 584 AC_MSG_NOTICE(use of tmpnam overrides temporary directory selection) 585 fi 586fi 587 588AC_CHECK_FUNCS(opendir findfirst _findfirst, break) 589AC_CHECK_FUNCS(strerror) 590 591AC_CHECK_FUNCS(truncate, have_truncate=yes) 592# === Cannot nest AC_CHECK_FUNCS() calls 593if test "$have_truncate" != yes ; then 594 AC_CHECK_FUNCS(ftruncate, have_ftruncate=yes) 595 if test "$have_ftruncate" != yes ; then 596 AC_CHECK_FUNCS(chsize) 597 fi 598fi 599 600AC_CHECK_FUNCS(setenv, have_setenv=yes) 601# === Cannot nest AC_CHECK_FUNCS() calls 602if test "$have_setenv" != yes ; then 603 AC_CHECK_FUNCS(putenv, have_putenv=yes) 604 if test "$have_putenv" = yes ; then 605 AC_EGREP_HEADER(putenv, stdlib.h, have_putenv_prototype=yes) 606 if test "$have_putenv_prototype" = yes ; then 607 AC_MSG_CHECKING(putenv prototype) 608 AC_EGREP_HEADER([[^A-Za-zo-9_]putenv[ ]*\(.*const.*\)[ ]*;], 609 stdlib.h, AC_MSG_RESULT(correct), 610 [ 611 AC_MSG_RESULT(no const) 612 AC_DEFINE(NON_CONST_PUTENV_PROTOTYPE) 613 ]) 614 fi 615 fi 616fi 617 618have_scandir=no 619AC_CHECK_FUNCS(scandir,have_scandir=yes) 620 621have_dirent_h=no 622AC_CHECK_HEADERS(dirent.h,have_dirent_h=yes) 623 624dnl Dummy check for setting $PKG_CONFIG. 625PKG_CHECK_EXISTS([dummy]) 626if test "${enable_static}" = "yes"; then 627 PKG_CONFIG="$PKG_CONFIG --static" 628fi 629 630AC_ARG_ENABLE([xml], 631 [AS_HELP_STRING([--disable-xml], 632 [disable xml support])]) 633 634AH_TEMPLATE([HAVE_LIBXML], 635 [Define this value if libxml is available.]) 636dnl About the condition of version 637dnl see https://mail.gnome.org/archives/xml/2010-February/msg00008.html 638AS_IF([test "x$enable_xml" != "xno"], [ 639 PKG_CHECK_MODULES(LIBXML, [libxml-2.0 >= 2.7.7], 640 [have_libxml=yes 641 AC_DEFINE(HAVE_LIBXML)], 642 [AS_IF([test "x$enable_xml" = "xyes"], [ 643 AC_MSG_ERROR([libxml2 not found])])]) 644]) 645AM_CONDITIONAL(HAVE_LIBXML, test "x$have_libxml" = xyes) 646 647if test "${enable_static}" = "yes"; then 648 if test "${have_libxml}" = "yes"; then 649 if test "${host_mingw}" = "yes"; then 650 dnl -DLIBXML_STATIC needs to be added manually. 651 LIBXML_CFLAGS="$LIBXML_CFLAGS -DLIBXML_STATIC" 652 fi 653 fi 654fi 655 656AC_ARG_ENABLE([json], 657 [AS_HELP_STRING([--disable-json], 658 [disable json support])]) 659 660AH_TEMPLATE([HAVE_JANSSON], 661 [Define this value if jansson is available.]) 662dnl This enforces explicit feature usage regardless of the libraries 663dnl available on the build system. This avoids automagic dependencies which 664dnl can cause issues for source-based distros [1]. 665dnl [1]: https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Automagic_dependencies 666AS_IF([test "x$enable_json" != "xno"], [ 667 PKG_CHECK_MODULES(JANSSON, jansson, 668 [have_jansson=yes 669 AC_DEFINE(HAVE_JANSSON)], 670 [AS_IF([test "x$enable_json" = "xyes"], [ 671 AC_MSG_ERROR([jansson not found])])]) 672]) 673AM_CONDITIONAL(HAVE_JANSSON, test "x$have_jansson" = xyes) 674 675AH_TEMPLATE([HAVE_SECCOMP], 676 [Define this value if libseccomp is available.]) 677AC_ARG_ENABLE([seccomp], 678 [AS_HELP_STRING([--disable-seccomp], 679 [disable seccomp support])]) 680AS_IF([test "x$enable_seccomp" != "xno"], [ 681 PKG_CHECK_MODULES(SECCOMP, libseccomp, 682 [have_seccomp=yes 683 AC_DEFINE(HAVE_SECCOMP)], 684 [AS_IF([test "x$enable_seccomp" = "xyes"], [ 685 AC_MSG_ERROR([libseccomp not found])])]) 686]) 687 688AC_ARG_ENABLE([yaml], 689 [AS_HELP_STRING([--disable-yaml], 690 [disable yaml support])]) 691 692AH_TEMPLATE([HAVE_LIBYAML], 693 [Define this value if libyaml is available.]) 694AS_IF([test "x$enable_yaml" != "xno"], [ 695 PKG_CHECK_MODULES(LIBYAML, yaml-0.1, 696 [have_libyaml=yes 697 AC_DEFINE(HAVE_LIBYAML)], 698 [AS_IF([test "x$enable_yaml" = "xyes"], [ 699 AC_MSG_ERROR([libyaml not found])])]) 700]) 701AM_CONDITIONAL(HAVE_LIBYAML, test "x$have_libyaml" = xyes) 702 703AC_ARG_ENABLE([pcre2], 704 [AS_HELP_STRING([--disable-pcre2], 705 [disable pcre2 support])]) 706 707AH_TEMPLATE([HAVE_PCRE2], 708 [Define this value if pcre2 is available.]) 709AS_IF([test "x$enable_pcre2" != "xno"], [ 710 PKG_CHECK_MODULES(PCRE2, libpcre2-8, 711 [have_libpcre2_8=yes 712 AC_DEFINE(HAVE_PCRE2)], 713 [AS_IF([test "x$enable_pcre2" = "xyes"], [ 714 AC_MSG_ERROR([libpcre2-8 not found])])]) 715]) 716AM_CONDITIONAL(HAVE_PCRE2, test "x$have_libpcre2_8" = xyes) 717 718if test "${enable_static}" = "yes"; then 719 if test "${have_libpcre2_8}" = "yes"; then 720 if test "${host_mingw}" = "yes"; then 721 dnl -DPCRE2_STATIC needs to be added manually. 722 PCRE2_CFLAGS="$PCRE2_CFLAGS -DPCRE2_STATIC" 723 fi 724 fi 725fi 726 727 728# Checks for missing prototypes 729# ----------------------------- 730AC_MSG_NOTICE(checking for new missing prototypes) 731 732CHECK_PROTO(stat, sys/stat.h) 733CHECK_PROTO(lstat, sys/stat.h) 734if test "$have_truncate" = yes ; then 735 CHECK_PROTO(truncate, unistd.h) 736fi 737if test "$have_ftruncate" = yes ; then 738 CHECK_PROTO(ftruncate, unistd.h) 739fi 740 741# Process library configuration options 742# ------------------------------------- 743 744ICONV_LIBS= 745if test "$enable_iconv" != no ; then 746 save_LIBS="$LIBS" 747 # 748 # Working around for issue #1620 749 # 750 LIBS="$LIBS $LIBXML_LIBS" 751 LIBS="$LIBS $JANSSON_LIBS" 752 LIBS="$LIBS $SECCOMP_LIBS" 753 LIBS="$LIBS $LIBYAML_LIBS" 754 LIBS="$LIBS $ASPELL_LIBS" 755 LIBS="$LIBS -liconv" 756 # 757 AC_MSG_CHECKING(for iconv_open or libiconv_open with -liconv) 758 AC_LINK_IFELSE([AC_LANG_PROGRAM([ 759 #include <iconv.h> 760 ], [iconv_open("fr", "to")])], [ 761 # 762 # iconv_open is available in libiconv. 763 # 764 LIBS="$save_LIBS" 765 ICONV_LIBS=-liconv 766 AC_MSG_RESULT([yes(iconv)]) 767 AC_DEFINE(HAVE_ICONV) 768 ], [AC_LINK_IFELSE([AC_LANG_PROGRAM([ 769 #include <iconv.h> 770 ], [libiconv_open("fr", "to")])],[ 771 # 772 # libiconv_open is available in libiconv 773 # 774 LIBS="$save_LIBS" 775 ICONV_LIBS=-liconv 776 AC_MSG_RESULT([yes(libiconv_open)]) 777 AC_DEFINE(HAVE_ICONV) 778 AC_DEFINE(ICONV_USE_LIB_PREFIX) 779 ],[LIBS="$save_LIBS" 780 AC_MSG_RESULT(no) 781 AC_CHECK_FUNC(iconv_open, [ 782 # 783 # iconv_open is available in libc. 784 # No extra -l flag is needed. 785 # 786 AC_DEFINE(HAVE_ICONV) 787 ], [ 788 AC_MSG_ERROR([Could not find libiconv. Please install libiconv and libiconv-devel.])])]) 789 ]) 790 AC_SUBST([ICONV_LIBS]) 791fi 792 793# Checks for declaration 794# ---------------------- 795AC_CHECK_DECLS([__environ], [], [], [ 796[#include <unistd.h>] 797]) 798AC_CHECK_DECLS([_NSGetEnviron],[],[],[ 799[#include <crt_externs.h>] 800]) 801AC_CHECK_DECLS([strnlen],[have_strnlen=yes],[],[ 802[#include <string.h>] 803]) 804AM_CONDITIONAL(HAVE_STRNLEN, test "x$have_strnlen" = xyes) 805 806if test "$cross_compiling" = "yes"; then 807 AC_MSG_CHECKING(whether strnlen is declared for build) 808 TEMP_DIR_FOR_CHECKING=$(mktemp -d || exit 1) 809 cat > "$TEMP_DIR_FOR_CHECKING/test.c" <<EOF 810#include<string.h> 811int main() { strnlen("abcd",1); return 0;} 812EOF 813 814 if $CC_FOR_BUILD $CPPFLAGS_FOR_BUILD $CFLAGS_FOR_BUILD -o "$TEMP_DIR_FOR_CHECKING/test.o" "$TEMP_DIR_FOR_CHECKING/test.c" > /dev/null 2>&1 ; then 815 have_strnlen_for_build=yes 816 else 817 have_strnlen_for_build=no 818 fi 819 AC_MSG_RESULT($have_strnlen_for_build) 820 AM_CONDITIONAL(HAVE_STRNLEN_FOR_BUILD, test "x$have_strnlen_for_build" = xyes) 821else 822 AM_CONDITIONAL(HAVE_STRNLEN_FOR_BUILD, test "x$have_strnlen" = xyes) 823fi 824 825if test "$CTAGS_NAME_EXECUTABLE" != ctags ; then 826 AC_MSG_NOTICE(Changing name of 'ctags' for $CTAGS_NAME_EXECUTABLE) 827fi 828 829if test "$ETAGS_NAME_EXECUTABLE" != etags ; then 830 AC_MSG_NOTICE(Changing name of 'etags' for $ETAGS_NAME_EXECUTABLE) 831fi 832 833# Output files 834# ------------ 835 836AC_CHECK_FUNCS(mblen) 837 838AC_CONFIG_FILES([Makefile gnulib/Makefile man/GNUmakefile]) 839 840AC_OUTPUT 841 842AC_MSG_RESULT([ 843########################################################################## 844Now you can run make or gmake, when you run as make, besure it is GNU make. 845########################################################################## 846]) 847 848# vim:ts=4:sw=4: 849