2 dnl autoconf input file for GNU grep
4 dnl Copyright (C) 1997-2006, 2009-2024 Free Software Foundation, Inc.
6 dnl This file is part of GNU grep.
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.
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.
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/>.
22 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
25 if test -n "$GREP" || test -n "$EGREP"; then
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.])
34 AC_CONFIG_AUX_DIR([build-aux])
35 AC_CONFIG_SRCDIR([src/grep.c])
36 AC_DEFINE([GREP], 1, [We are building grep])
38 AC_CONFIG_MACRO_DIRS([m4])
41 AM_INIT_AUTOMAKE([1.11 dist-xz color-tests parallel-tests
43 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
45 AC_CONFIG_HEADERS([config.h:config.hin])
47 dnl Checks for programs.
54 PKG_PROG_PKG_CONFIG([0.9.0])
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 gl_cv_func_mbrlen_empty_input='assume yes'
62 dnl Checks for typedefs, structures, and compiler characteristics.
65 # Ensure VLAs are not used.
66 # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
67 AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
69 # The test suite needs to know if we have a working perl.
70 AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
72 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
73 # ------------------------------------------------
74 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
75 # Otherwise, run RUN-IF-NOT-FOUND.
76 AC_DEFUN([gl_GCC_VERSION_IFELSE],
80 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
83 # error "your version of gcc is older than $1.$2"
90 AC_ARG_ENABLE([gcc-warnings],
91 [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
92 [control generation of GCC warnings. The TYPE 'no' disables
93 warnings (default for non-developer builds); 'yes' generates
94 cheap warnings if available (default for developer builds);
95 'expensive' in addition generates expensive-to-compute warnings
99 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
101 gl_gcc_warnings=$enableval],
103 # GCC provides fine-grained control over diagnostics which
104 # is used in gnulib for example to suppress warnings from
105 # certain sections of code. So if this is available and
106 # we're running from a git repo, then auto enable the warnings.
108 gl_GCC_VERSION_IFELSE([4], [6],
109 [test -d "$srcdir"/.git \
110 && ! test -f "$srcdir"/.tarball-version \
111 && gl_gcc_warnings=yes])]
114 if test $gl_gcc_warnings != no; then
115 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
116 AC_SUBST([WERROR_CFLAGS])
119 AS_IF([test $gl_gcc_warnings != expensive],
120 [# -fanalyzer and related options slow GCC considerably.
121 ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
122 ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
125 # This, $nw, is the list of warnings we disable.
126 nw="$nw -Wvla" # suppress a warning in regexec.h
127 nw="$nw -Winline" # suppress warnings from streq.h's streq5
128 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
129 nw="$nw -Wstack-protector" # generates false alarms for useful code
131 gl_MANYWARN_ALL_GCC([ws])
132 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
136 gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
137 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
138 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
139 gl_WARN_ADD([-Wno-cast-function-type]) # sig-handler.h's sa_handler_t cast
140 gl_WARN_ADD([-Wno-deprecated-declarations]) # clang complains about sprintf
142 # In spite of excluding -Wlogical-op above, it is enabled, as of
143 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
144 gl_WARN_ADD([-Wno-logical-op])
146 AC_SUBST([WARN_CFLAGS])
148 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
149 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
150 AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
151 [/* Enable compile-time and run-time bounds-checking, and some warnings,
152 without upsetting glibc 2.15+. */
153 #if (defined GNULIB_PORTCHECK && !defined _FORTIFY_SOURCE \
154 && defined __OPTIMIZE__ && __OPTIMIZE__)
155 # define _FORTIFY_SOURCE 2
159 # We use a slightly smaller set of warning options for lib/.
160 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
162 nw="$nw -Wunused-macros"
163 gl_WARN_ADD([-Wno-format-nonliteral])
164 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
165 AC_SUBST([GNULIB_WARN_CFLAGS])
167 # For gnulib-tests, the set is slightly smaller still.
168 # It's not worth being this picky about test programs.
170 nw="$nw -Wformat-truncation=2" # False alarm in strerror_r.c
171 nw="$nw -Wmissing-declarations"
172 nw="$nw -Wmissing-prototypes"
173 nw="$nw -Wmissing-variable-declarations"
174 nw="$nw -Wnull-dereference"
175 nw="$nw -Wold-style-definition"
176 nw="$nw -Wstrict-prototypes"
177 nw="$nw -Wsuggest-attribute=cold"
178 nw="$nw -Wsuggest-attribute=const"
179 nw="$nw -Wsuggest-attribute=format"
180 nw="$nw -Wsuggest-attribute=pure"
182 # Disable to avoid warnings in e.g., test-intprops.c and test-limits-h.c
183 # due to overlong expansions like this:
184 # test-intprops.c:147:5: error: string literal of length 9531 exceeds \
185 # maximum length 4095 that ISO C99 compilers are required to support
186 nw="$nw -Woverlength-strings"
188 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
189 [$GNULIB_WARN_CFLAGS], [$nw])
190 gl_WARN_ADD([-Wno-return-type], [GNULIB_TEST_WARN_CFLAGS])
191 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
194 # By default, argmatch should fail calling usage (EXIT_FAILURE).
195 AC_DEFINE([ARGMATCH_DIE], [usage (EXIT_FAILURE)],
196 [Define to the function xargmatch calls on failures.])
197 AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
198 [Define to the declaration of the xargmatch failure function.])
200 AC_CHECK_FUNCS_ONCE([setlocale])
203 AM_GNU_GETTEXT_VERSION([0.18.2])
204 AM_GNU_GETTEXT([external])
206 dnl Some installers want to be informed if we do not use our regex.
207 dnl For example, if the host platform uses dynamic linking and the installer
208 dnl knows that the grep may be invoked on other hosts with buggy libraries,
209 dnl then the installer should configure --with-included-regex.
210 AM_CONDITIONAL([USE_INCLUDED_REGEX], [test "$ac_use_included_regex" = yes])
211 if test "$ac_use_included_regex" = no; then
212 AC_MSG_WARN([Included lib/regex.c not used])
213 AC_DEFINE([USE_INCLUDED_REGEX], 1, [building with included regex code])
217 AM_CONDITIONAL([USE_PCRE], [test $use_pcre = yes])
220 mingw*) suffix=w32 ;;
223 COLORIZE_SOURCE=colorize-$suffix.c
224 AC_SUBST([COLORIZE_SOURCE])
233 gnulib-tests/Makefile