| 1 | dnl
|
|---|
| 2 | dnl autoconf input file for ``GNU grep''
|
|---|
| 3 | dnl
|
|---|
| 4 | dnl Copyright (C) 1997-2006, 2009-2012 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 <http://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 | # Set the GREP and EGREP variables to a dummy replacement for the 'grep'
|
|---|
| 26 | # command, so that AC_PROG_GREP and AC_PROG_EGREP don't fail when no good
|
|---|
| 27 | # 'grep' program is found. This makes it possible to build GNU grep on a
|
|---|
| 28 | # Solaris machine that has only /usr/bin/grep and no /usr/xpg4/bin/grep.
|
|---|
| 29 | # This function supports only restricted arguments:
|
|---|
| 30 | # - No file names as arguments, process only standard input.
|
|---|
| 31 | # - Only literal strings without backslashes, no regular expressions.
|
|---|
| 32 | # - The only options are -e and -E (and -Ee).
|
|---|
| 33 | # This function also does not support long lines beyond what the shell
|
|---|
| 34 | # supports), and backslash-processes the input.
|
|---|
| 35 | fn_grep () {
|
|---|
| 36 | test "$1" = -E && shift
|
|---|
| 37 | case $@%:@:$1 in
|
|---|
| 38 | 0:*) AC_MSG_ERROR([fn_grep: expected pattern]) ;;
|
|---|
| 39 | 1:-*) AC_MSG_ERROR([fn_grep: invalid command line]) ;;
|
|---|
| 40 | 1:*) pattern=$1 ;;
|
|---|
| 41 | 2:--|2:-e|2:-Ee) pattern=$2 ;;
|
|---|
| 42 | *) AC_MSG_ERROR([fn_grep: invalid command line]) ;;
|
|---|
| 43 | esac
|
|---|
| 44 |
|
|---|
| 45 | case $pattern in
|
|---|
| 46 | [*[].^$\\*[]*]) dnl The outer brackets are for M4.
|
|---|
| 47 | AC_MSG_ERROR([fn_grep: regular expressions not supported]) ;;
|
|---|
| 48 | esac
|
|---|
| 49 |
|
|---|
| 50 | rc=1
|
|---|
| 51 | while read line; do
|
|---|
| 52 | case $line in
|
|---|
| 53 | *$pattern*)
|
|---|
| 54 | rc=0
|
|---|
| 55 | AS_ECHO([$line]) ;;
|
|---|
| 56 | esac
|
|---|
| 57 | done
|
|---|
| 58 | return $rc
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | test -n "$GREP" || GREP=fn_grep
|
|---|
| 62 | test -n "$EGREP" || EGREP=fn_grep
|
|---|
| 63 | ac_cv_path_EGREP=$EGREP
|
|---|
| 64 |
|
|---|
| 65 | AC_CONFIG_AUX_DIR(build-aux)
|
|---|
| 66 | AC_CONFIG_SRCDIR(src/grep.c)
|
|---|
| 67 | AC_DEFINE([GREP], 1, [We are building grep])
|
|---|
| 68 | AC_PREREQ(2.59)
|
|---|
| 69 |
|
|---|
| 70 | dnl Automake stuff.
|
|---|
| 71 | AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz color-tests parallel-tests])
|
|---|
| 72 | AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
|
|---|
| 73 |
|
|---|
| 74 | AC_CONFIG_HEADERS([config.h:config.hin])
|
|---|
| 75 |
|
|---|
| 76 | dnl Checks for programs.
|
|---|
| 77 | AC_CANONICAL_HOST
|
|---|
| 78 | AC_PROG_AWK
|
|---|
| 79 | AC_PROG_INSTALL
|
|---|
| 80 | AC_PROG_CC
|
|---|
| 81 | gl_EARLY
|
|---|
| 82 | AC_PROG_RANLIB
|
|---|
| 83 |
|
|---|
| 84 | dnl Checks for typedefs, structures, and compiler characteristics.
|
|---|
| 85 | AC_TYPE_SIZE_T
|
|---|
| 86 | AC_C_CONST
|
|---|
| 87 | gl_INIT
|
|---|
| 88 |
|
|---|
| 89 | AC_ARG_ENABLE([gcc-warnings],
|
|---|
| 90 | [AS_HELP_STRING([--enable-gcc-warnings],
|
|---|
| 91 | [turn on lots of GCC warnings (for developers)])],
|
|---|
| 92 | [case $enableval in
|
|---|
| 93 | yes|no) ;;
|
|---|
| 94 | *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
|
|---|
| 95 | esac
|
|---|
| 96 | gl_gcc_warnings=$enableval],
|
|---|
| 97 | [gl_gcc_warnings=no]
|
|---|
| 98 | )
|
|---|
| 99 |
|
|---|
| 100 | if test "$gl_gcc_warnings" = yes; then
|
|---|
| 101 | gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
|---|
| 102 | AC_SUBST([WERROR_CFLAGS])
|
|---|
| 103 |
|
|---|
| 104 | nw=
|
|---|
| 105 | # This, $nw, is the list of warnings we disable.
|
|---|
| 106 | nw="$nw -Wdeclaration-after-statement" # too useful to forbid
|
|---|
| 107 | nw="$nw -Waggregate-return" # anachronistic
|
|---|
| 108 | nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
|
|---|
| 109 | nw="$nw -Wc++-compat" # We don't care about C++ compilers
|
|---|
| 110 | nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
|
|---|
| 111 | nw="$nw -Wtraditional" # Warns on #elif which we use often
|
|---|
| 112 | nw="$nw -Wcast-qual" # Too many warnings for now
|
|---|
| 113 | nw="$nw -Wconversion" # Too many warnings for now
|
|---|
| 114 | nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
|
|---|
| 115 | nw="$nw -Wsign-conversion" # Too many warnings for now
|
|---|
| 116 | nw="$nw -Wtraditional-conversion" # Too many warnings for now
|
|---|
| 117 | nw="$nw -Wunreachable-code" # Too many warnings for now
|
|---|
| 118 | nw="$nw -Wpadded" # Our structs are not padded
|
|---|
| 119 | nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
|
|---|
| 120 | nw="$nw -Wlogical-op" # any use of fwrite provokes this
|
|---|
| 121 | nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
|
|---|
| 122 | nw="$nw -Wvla" # warnings in gettext.h
|
|---|
| 123 | nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
|
|---|
| 124 | nw="$nw -Wswitch-enum" # Too many warnings for now
|
|---|
| 125 | nw="$nw -Wswitch-default" # Too many warnings for now
|
|---|
| 126 | nw="$nw -Wstack-protector" # not worth working around
|
|---|
| 127 | # things I might fix soon:
|
|---|
| 128 | nw="$nw -Wfloat-equal" # sort.c, seq.c
|
|---|
| 129 | nw="$nw -Wmissing-format-attribute" # copy.c
|
|---|
| 130 | nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
|
|---|
| 131 | nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
|
|---|
| 132 | nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
|
|---|
| 133 | # ?? -Wstrict-overflow
|
|---|
| 134 |
|
|---|
| 135 | gl_MANYWARN_ALL_GCC([ws])
|
|---|
| 136 | gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
|
|---|
| 137 | for w in $ws; do
|
|---|
| 138 | gl_WARN_ADD([$w])
|
|---|
| 139 | done
|
|---|
| 140 | gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
|
|---|
| 141 | gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
|
|---|
| 142 | gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
|
|---|
| 143 | gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
|---|
| 144 |
|
|---|
| 145 | # In spite of excluding -Wlogical-op above, it is enabled, as of
|
|---|
| 146 | # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
|
|---|
| 147 | gl_WARN_ADD([-Wno-logical-op])
|
|---|
| 148 |
|
|---|
| 149 | gl_WARN_ADD([-fdiagnostics-show-option])
|
|---|
| 150 | gl_WARN_ADD([-funit-at-a-time])
|
|---|
| 151 |
|
|---|
| 152 | AC_SUBST([WARN_CFLAGS])
|
|---|
| 153 |
|
|---|
| 154 | AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
|
|---|
| 155 | AC_DEFINE([_FORTIFY_SOURCE], [2],
|
|---|
| 156 | [enable compile-time and run-time bounds-checking, and some warnings])
|
|---|
| 157 | AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
|
|---|
| 158 |
|
|---|
| 159 | # We use a slightly smaller set of warning options for lib/.
|
|---|
| 160 | # Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
|---|
| 161 | nw=
|
|---|
| 162 | #nw="$nw -Wuninitialized"
|
|---|
| 163 | nw="$nw -Wunused-macros"
|
|---|
| 164 | #nw="$nw -Wmissing-prototypes"
|
|---|
| 165 | nw="$nw -Wold-style-definition"
|
|---|
| 166 | nw="$nw -Wcast-align"
|
|---|
| 167 | nw="$nw -Wunsuffixed-float-constants"
|
|---|
| 168 | gl_WARN_ADD([-Wno-format-nonliteral])
|
|---|
| 169 | gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
|---|
| 170 | AC_SUBST([GNULIB_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_STDC
|
|---|
| 181 | AC_HEADER_DIRENT
|
|---|
| 182 |
|
|---|
| 183 | dnl Checks for functions.
|
|---|
| 184 | AC_FUNC_CLOSEDIR_VOID
|
|---|
| 185 |
|
|---|
| 186 | AC_CHECK_FUNCS_ONCE(isascii setlocale)
|
|---|
| 187 |
|
|---|
| 188 | dnl I18N feature
|
|---|
| 189 | AM_GNU_GETTEXT_VERSION([0.18])
|
|---|
| 190 | AM_GNU_GETTEXT([external])
|
|---|
| 191 |
|
|---|
| 192 | dnl Some installers want to be informed if we do not use our regex.
|
|---|
| 193 | dnl For example, if the host platform uses dynamic linking and the installer
|
|---|
| 194 | dnl knows that the grep may be invoked on other hosts with buggy libraries,
|
|---|
| 195 | dnl then the installer should configure --with-included-regex.
|
|---|
| 196 | AM_CONDITIONAL([USE_INCLUDED_REGEX], [test "$ac_use_included_regex" = yes])
|
|---|
| 197 | if test "$ac_use_included_regex" = no; then
|
|---|
| 198 | AC_MSG_WARN([Included lib/regex.c not used])
|
|---|
| 199 | fi
|
|---|
| 200 |
|
|---|
| 201 | gl_FUNC_PCRE
|
|---|
| 202 |
|
|---|
| 203 | case $host_os in
|
|---|
| 204 | mingw*) suffix=w32 ;;
|
|---|
| 205 | *) suffix=posix ;;
|
|---|
| 206 | esac
|
|---|
| 207 | AC_CONFIG_LINKS([lib/colorize.c:lib/colorize-$suffix.c])
|
|---|
| 208 |
|
|---|
| 209 | AC_CONFIG_FILES([
|
|---|
| 210 | Makefile
|
|---|
| 211 | lib/Makefile
|
|---|
| 212 | src/Makefile
|
|---|
| 213 | tests/Makefile
|
|---|
| 214 | po/Makefile.in
|
|---|
| 215 | doc/Makefile
|
|---|
| 216 | gnulib-tests/Makefile
|
|---|
| 217 | ])
|
|---|
| 218 | GREP="$ac_abs_top_builddir/src/grep"
|
|---|
| 219 | EGREP="$ac_abs_top_builddir/src/grep -E"
|
|---|
| 220 | AC_OUTPUT
|
|---|