[3529] | 1 | dnl
|
---|
| 2 | dnl autoconf input file for GNU grep
|
---|
| 3 | dnl
|
---|
| 4 | dnl Copyright (C) 1997-2006, 2009-2021 Free Software Foundation, Inc.
|
---|
| 5 | dnl
|
---|
| 6 | dnl This file is part of GNU grep.
|
---|
| 7 | dnl
|
---|
| 8 | dnl This program is free software; you can redistribute it and/or modify
|
---|
| 9 | dnl it under the terms of the GNU General Public License as published by
|
---|
| 10 | dnl the Free Software Foundation; either version 3, or (at your option)
|
---|
| 11 | dnl any later version.
|
---|
| 12 | dnl
|
---|
| 13 | dnl This program is distributed in the hope that it will be useful,
|
---|
| 14 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 16 | dnl GNU General Public License for more details.
|
---|
| 17 | dnl
|
---|
| 18 | dnl You should have received a copy of the GNU General Public License
|
---|
| 19 | dnl along with this program. If not, see <https://www.gnu.org/licenses/>.
|
---|
| 20 |
|
---|
| 21 | AC_INIT([GNU grep],
|
---|
| 22 | m4_esyscmd([build-aux/git-version-gen .tarball-version]),
|
---|
| 23 | [bug-grep@gnu.org])
|
---|
| 24 |
|
---|
| 25 | if test -n "$GREP" || test -n "$EGREP"; then
|
---|
| 26 | AC_MSG_ERROR(
|
---|
| 27 | [no working 'grep' found
|
---|
| 28 | A working 'grep' command is needed to build GNU Grep.
|
---|
| 29 | This 'grep' should support -e and long lines.
|
---|
| 30 | On Solaris 10, install the package SUNWggrp or SUNWxcu4.
|
---|
| 31 | On Solaris 11, install the package text/gnu-grep or system/xopen/xcu4.])
|
---|
| 32 | fi
|
---|
| 33 |
|
---|
| 34 | AC_CONFIG_AUX_DIR([build-aux])
|
---|
| 35 | AC_CONFIG_SRCDIR([src/grep.c])
|
---|
| 36 | AC_DEFINE([GREP], 1, [We are building grep])
|
---|
| 37 | AC_PREREQ([2.64])
|
---|
| 38 | AC_CONFIG_MACRO_DIRS([m4])
|
---|
| 39 |
|
---|
| 40 | dnl Automake stuff.
|
---|
| 41 | AM_INIT_AUTOMAKE([1.11 dist-xz color-tests parallel-tests
|
---|
| 42 | subdir-objects])
|
---|
| 43 | AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
|
---|
| 44 |
|
---|
| 45 | AC_CONFIG_HEADERS([config.h:config.hin])
|
---|
| 46 |
|
---|
| 47 | dnl Checks for programs.
|
---|
| 48 | AC_CANONICAL_HOST
|
---|
| 49 | AC_PROG_AWK
|
---|
| 50 | AC_PROG_INSTALL
|
---|
| 51 | AC_PROG_CC
|
---|
| 52 | gl_EARLY
|
---|
| 53 | AC_PROG_RANLIB
|
---|
| 54 | PKG_PROG_PKG_CONFIG([0.9.0])
|
---|
| 55 |
|
---|
| 56 | # grep never invokes mbrtowc or mbrlen on empty input,
|
---|
| 57 | # so don't worry about this common bug,
|
---|
| 58 | # as working around it would merely slow grep down.
|
---|
| 59 | gl_cv_func_mbrtowc_empty_input='assume yes'
|
---|
| 60 |
|
---|
| 61 | dnl Checks for typedefs, structures, and compiler characteristics.
|
---|
| 62 | AC_TYPE_SIZE_T
|
---|
| 63 | AC_C_CONST
|
---|
| 64 | gl_INIT
|
---|
| 65 |
|
---|
| 66 | # Ensure VLAs are not used.
|
---|
| 67 | # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
|
---|
| 68 | AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
|
---|
| 69 |
|
---|
| 70 | # The test suite needs to know if we have a working perl.
|
---|
| 71 | # FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL
|
---|
| 72 | # with an ACTION-IF-NOT-FOUND argument ...
|
---|
| 73 | cu_have_perl=yes
|
---|
| 74 | case $PERL in *"/missing "*) cu_have_perl=no;; esac
|
---|
| 75 | AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
|
---|
| 76 |
|
---|
| 77 | AC_ARG_ENABLE([gcc-warnings],
|
---|
| 78 | [AS_HELP_STRING([--enable-gcc-warnings],
|
---|
| 79 | [turn on lots of GCC warnings (for developers)])],
|
---|
| 80 | [case $enableval in
|
---|
| 81 | yes|no) ;;
|
---|
| 82 | *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
|
---|
| 83 | esac
|
---|
| 84 | gl_gcc_warnings=$enableval],
|
---|
| 85 | [gl_gcc_warnings=no
|
---|
| 86 | if test "$GCC" = yes && test -d "$srcdir"/.git; then
|
---|
| 87 | AC_COMPILE_IFELSE(
|
---|
| 88 | [AC_LANG_PROGRAM([[
|
---|
| 89 | #if ! (6 < __GNUC__ + (2 <= __GNUC_MINOR__))
|
---|
| 90 | #error "--enable-gcc-warnings defaults to 'no' on older GCC"
|
---|
| 91 | #endif
|
---|
| 92 | ]])],
|
---|
| 93 | [gl_gcc_warnings=yes])
|
---|
| 94 | fi]
|
---|
| 95 | )
|
---|
| 96 |
|
---|
| 97 | if test "$gl_gcc_warnings" = yes; then
|
---|
| 98 | gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
---|
| 99 | AC_SUBST([WERROR_CFLAGS])
|
---|
| 100 |
|
---|
| 101 | nw=
|
---|
| 102 | # This, $nw, is the list of warnings we disable.
|
---|
| 103 | nw="$nw -Wdeclaration-after-statement" # too useful to forbid
|
---|
| 104 | nw="$nw -Waggregate-return" # anachronistic
|
---|
| 105 | nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
|
---|
| 106 | nw="$nw -Wc++-compat" # We don't care about C++ compilers
|
---|
| 107 | nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
|
---|
| 108 | nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
|
---|
| 109 | nw="$nw -Wpadded" # Our structs are not padded
|
---|
| 110 | nw="$nw -Wstack-protector" # generates false alarms for useful code
|
---|
| 111 | nw="$nw -Wswitch-default" # Too many warnings for now
|
---|
| 112 | nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
|
---|
| 113 | nw="$nw -Winline" # streq.h's streq4, streq6 and strcaseeq6
|
---|
| 114 | nw="$nw -Wstrict-overflow" # regexec.c
|
---|
| 115 |
|
---|
| 116 | gl_MANYWARN_ALL_GCC([ws])
|
---|
| 117 | gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
|
---|
| 118 | for w in $ws; do
|
---|
| 119 | gl_WARN_ADD([$w])
|
---|
| 120 | done
|
---|
| 121 | gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
|
---|
| 122 | gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
|
---|
| 123 | gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
---|
| 124 | gl_WARN_ADD([-Wno-cast-function-type]) # sig-handler.h's sa_handler_t cast
|
---|
| 125 |
|
---|
| 126 | # In spite of excluding -Wlogical-op above, it is enabled, as of
|
---|
| 127 | # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
|
---|
| 128 | gl_WARN_ADD([-Wno-logical-op])
|
---|
| 129 |
|
---|
| 130 | AC_SUBST([WARN_CFLAGS])
|
---|
| 131 |
|
---|
| 132 | AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
|
---|
| 133 | AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
|
---|
| 134 | AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
|
---|
| 135 | [/* Enable compile-time and run-time bounds-checking, and some warnings,
|
---|
| 136 | without upsetting glibc 2.15+. */
|
---|
| 137 | #if (defined GNULIB_PORTCHECK && !defined _FORTIFY_SOURCE \
|
---|
| 138 | && defined __OPTIMIZE__ && __OPTIMIZE__)
|
---|
| 139 | # define _FORTIFY_SOURCE 2
|
---|
| 140 | #endif
|
---|
| 141 | ])
|
---|
| 142 |
|
---|
| 143 | # We use a slightly smaller set of warning options for lib/.
|
---|
| 144 | # Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
---|
| 145 | nw=
|
---|
| 146 | nw="$nw -Wunused-macros"
|
---|
| 147 | gl_WARN_ADD([-Wno-format-nonliteral])
|
---|
| 148 | gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
---|
| 149 | AC_SUBST([GNULIB_WARN_CFLAGS])
|
---|
| 150 |
|
---|
| 151 | # For gnulib-tests, the set is slightly smaller still.
|
---|
| 152 | nw=
|
---|
| 153 | nw="$nw -Wstrict-prototypes"
|
---|
| 154 | # It's not worth being this picky about test programs.
|
---|
| 155 | nw="$nw -Wsuggest-attribute=const"
|
---|
| 156 | nw="$nw -Wsuggest-attribute=pure"
|
---|
| 157 | nw="$nw -Wsuggest-attribute=format"
|
---|
| 158 | nw="$nw -Wformat-truncation=2" # False alarm in strerror_r.c
|
---|
| 159 | nw="$nw -Wold-style-definition"
|
---|
| 160 |
|
---|
| 161 | # Disable to avoid warnings in e.g., test-intprops.c and test-limits-h.c
|
---|
| 162 | # due to overlong expansions like this:
|
---|
| 163 | # test-intprops.c:147:5: error: string literal of length 9531 exceeds \
|
---|
| 164 | # maximum length 4095 that ISO C99 compilers are required to support
|
---|
| 165 | nw="$nw -Woverlength-strings"
|
---|
| 166 |
|
---|
| 167 | gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
|
---|
| 168 | [$GNULIB_WARN_CFLAGS], [$nw])
|
---|
| 169 | gl_WARN_ADD([-Wno-return-type], [GNULIB_TEST_WARN_CFLAGS])
|
---|
| 170 | AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
|
---|
| 171 | fi
|
---|
| 172 |
|
---|
| 173 | # By default, argmatch should fail calling usage (EXIT_FAILURE).
|
---|
| 174 | AC_DEFINE([ARGMATCH_DIE], [usage (EXIT_FAILURE)],
|
---|
| 175 | [Define to the function xargmatch calls on failures.])
|
---|
| 176 | AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
|
---|
| 177 | [Define to the declaration of the xargmatch failure function.])
|
---|
| 178 |
|
---|
| 179 | dnl Checks for header files.
|
---|
| 180 | AC_HEADER_DIRENT
|
---|
| 181 |
|
---|
| 182 | dnl Checks for functions.
|
---|
| 183 | AC_FUNC_CLOSEDIR_VOID
|
---|
| 184 |
|
---|
| 185 | AC_CHECK_FUNCS_ONCE([isascii setlocale])
|
---|
| 186 |
|
---|
| 187 | dnl I18N feature
|
---|
| 188 | AM_GNU_GETTEXT_VERSION([0.18.2])
|
---|
| 189 | AM_GNU_GETTEXT([external])
|
---|
| 190 |
|
---|
| 191 | dnl Some installers want to be informed if we do not use our regex.
|
---|
| 192 | dnl For example, if the host platform uses dynamic linking and the installer
|
---|
| 193 | dnl knows that the grep may be invoked on other hosts with buggy libraries,
|
---|
| 194 | dnl then the installer should configure --with-included-regex.
|
---|
| 195 | AM_CONDITIONAL([USE_INCLUDED_REGEX], [test "$ac_use_included_regex" = yes])
|
---|
| 196 | if test "$ac_use_included_regex" = no; then
|
---|
| 197 | AC_MSG_WARN([Included lib/regex.c not used])
|
---|
| 198 | fi
|
---|
| 199 |
|
---|
| 200 | gl_FUNC_PCRE
|
---|
| 201 | AM_CONDITIONAL([USE_PCRE], [test $use_pcre = yes])
|
---|
| 202 |
|
---|
| 203 | case $host_os in
|
---|
| 204 | mingw*) suffix=w32 ;;
|
---|
| 205 | *) suffix=posix ;;
|
---|
| 206 | esac
|
---|
| 207 | COLORIZE_SOURCE=colorize-$suffix.c
|
---|
| 208 | AC_SUBST([COLORIZE_SOURCE])
|
---|
| 209 |
|
---|
| 210 | AC_CONFIG_FILES([
|
---|
| 211 | Makefile
|
---|
| 212 | lib/Makefile
|
---|
| 213 | src/Makefile
|
---|
| 214 | tests/Makefile
|
---|
| 215 | po/Makefile.in
|
---|
| 216 | doc/Makefile
|
---|
| 217 | gnulib-tests/Makefile
|
---|
| 218 | ])
|
---|
| 219 | AC_OUTPUT
|
---|