1 # Configure template for gzip.
3 # Copyright (C) 1999-2002, 2006-2007, 2009-2017 Free Software Foundation, Inc.
5 # Copyright (C) 1992-1993 Jean-loup Gailly
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
27 AC_CONFIG_SRCDIR([gzip.c])
28 AC_CONFIG_AUX_DIR([build-aux])
29 AC_CONFIG_MACRO_DIR([m4])
30 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
31 AM_INIT_AUTOMAKE([1.11 subdir-objects dist-xz dist-zip
32 color-tests parallel-tests])
33 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
35 dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
36 dnl (more than 10% execution time) to ./configure, with no benefit for
37 dnl most users. Using it to look for bugs requires:
38 dnl GNULIB_POSIXCHECK=1 autoreconf -f
42 dnl make CFLAGS=-DGNULIB_POSIXCHECK=1
43 dnl FIXME: Once we figure out how to avoid false positives, we should
44 dnl have 'make my-distcheck' in dist-check.mk exercise this.
45 m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
46 m4_if(m4_sysval, [0], [], [dnl
47 gl_ASSERT_NO_GNULIB_POSIXCHECK])
53 AC_CHECK_TOOL([NM], [nm], [nm])
62 AC_ARG_ENABLE([gcc-warnings],
63 [AS_HELP_STRING([--enable-gcc-warnings],
64 [turn on many GCC warnings (for developers; best with GNU make)])],
67 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
69 gl_gcc_warnings=$enableval],
70 [if test -d "$srcdir"/.git; then
77 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
78 # ------------------------------------------------
79 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
80 # Otherwise, run RUN-IF-NOT-FOUND.
81 AC_DEFUN([gl_GCC_VERSION_IFELSE],
85 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
88 # error "your version of gcc is older than $1.$2"
95 if test "$gl_gcc_warnings" = yes; then
96 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
97 AC_SUBST([WERROR_CFLAGS])
100 # This, $nw, is the list of warnings we disable.
101 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
102 nw="$nw -Waggregate-return" # anachronistic
103 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
104 nw="$nw -Wc++-compat" # We don't care about C++ compilers
105 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
106 nw="$nw -Wtraditional" # Warns on #elif which we use often
107 nw="$nw -Wcast-qual" # Too many warnings for now
108 nw="$nw -Wconversion" # Too many warnings for now
109 nw="$nw -Wduplicated-branches" # Too many false alarms
110 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
111 nw="$nw -Wsign-conversion" # Too many warnings for now
112 nw="$nw -Wtraditional-conversion" # Too many warnings for now
113 nw="$nw -Wunreachable-code" # Too many warnings for now
114 nw="$nw -Wpadded" # Our structs are not padded
115 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
116 nw="$nw -Wlogical-op" # any use of fwrite provokes this
117 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
118 nw="$nw -Wvla" # warnings in gettext.h
119 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
120 nw="$nw -Wswitch-enum" # Too many warnings for now
121 nw="$nw -Wswitch-default" # Too many warnings for now
122 nw="$nw -Wstack-protector" # not worth working around
123 # things I might fix soon:
124 nw="$nw -Wfloat-equal" # sort.c, seq.c
125 nw="$nw -Wmissing-format-attribute" # copy.c
126 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
127 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
129 # Warnings that gzip runs afoul of but coreutils does not.
130 nw="$nw -Wold-style-definition"
132 nw="$nw -Wstrict-overflow"
134 # Using -Wstrict-overflow is a pain, but the alternative is worse.
135 # For an example, see the code that provoked this report:
136 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
137 # Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
139 gl_MANYWARN_ALL_GCC([ws])
140 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
144 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
145 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
146 gl_WARN_ADD([-Wsuggest-attribute=const])
147 gl_WARN_ADD([-Wsuggest-attribute=noreturn])
148 gl_WARN_ADD([-Wno-format-nonliteral])
150 # Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
151 # it suggests test.c's advance function may be pure, even though it
152 # increments a global variable. Oops.
153 # Normally we'd write code to test for the precise failure, but that
154 # requires a relatively large input to make gcc exhibit the failure.
155 gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
157 # In spite of excluding -Wlogical-op above, it is enabled, as of
158 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
159 gl_WARN_ADD([-Wno-logical-op])
161 gl_WARN_ADD([-fdiagnostics-show-option])
162 gl_WARN_ADD([-funit-at-a-time])
164 AC_SUBST([WARN_CFLAGS])
166 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
167 AH_VERBATIM([FORTIFY_SOURCE],
168 [/* Enable compile-time and run-time bounds-checking, and some warnings,
169 without upsetting glibc 2.15+. */
170 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
171 # define _FORTIFY_SOURCE 2
174 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
176 # We use a slightly smaller set of warning options for lib/.
177 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
179 nw="$nw -Wstrict-overflow"
180 nw="$nw -Wuninitialized"
181 nw="$nw -Wunused-macros"
182 nw="$nw -Wmissing-prototypes"
183 nw="$nw -Wold-style-definition"
184 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
185 AC_SUBST([GNULIB_WARN_CFLAGS])
188 # cc -E produces incorrect asm files on SVR4, so postprocess it.
189 ASCPPPOST="sed '/^ *\\#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
190 AC_SUBST([ASCPPPOST])
192 AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
193 [gzip_cv_underline=yes
194 AC_TRY_COMPILE([int foo() {return 0;}], [],
195 [$NM conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
196 gzip_cv_underline=no])])
198 if test $gzip_cv_underline = no; then
199 ASCPPFLAGS='-DNO_UNDERLINE'
201 AC_SUBST([ASCPPFLAGS])
204 # Try to assemble match.S.
205 # "gcc -E match.s" ignores -E, so we must use _match.S.
206 AC_CACHE_CHECK([for an assembler syntax supported by this package],
208 [gzip_cv_assembler=no
212 if cp $srcdir/lib/match.c _match.S &&
213 eval "$CPP $CPPFLAGS $ASCPPFLAGS _match.S > _match.i" &&
214 eval "$ASCPPPOST < _match.i > match_.s"; then
215 if test ! -s match_.s || grep error < match_.s > /dev/null; then
217 elif eval "$CC $CPPFLAGS $CFLAGS -c match_.s >/dev/null" &&
218 test -f match_.$OBJEXT; then
220 gzip_cv_assembler=yes
221 if echo 'void foo (void) {}' > conftest.c &&
222 eval "$CC $CPPFLAGS $CFLAGS -S conftest.c >/dev/null" &&
223 grep '\.note\.GNU-stack' conftest.s >/dev/null &&
224 eval "$CC $CPPFLAGS $CFLAGS -c -Wa,--noexecstack match_.s >/dev/null" &&
225 test -f match_.$OBJEXT; then
226 gzip_cv_assembler='yes, with -Wa,--noexecstack'
230 rm -f conftest* _match.i _match.S match_.s match_.$OBJEXT;;
232 if test "$gzip_cv_assembler" != no; then
234 [Define if an assembler version of longest_match is available.])
237 if test "$gzip_cv_assembler" = 'yes, with -Wa,--noexecstack'; then
238 ASFLAGS_config='-Wa,--noexecstack'
242 AC_SUBST([ASFLAGS_config])
247 AC_CHECK_HEADERS_ONCE(fcntl.h limits.h memory.h time.h)
248 AC_CHECK_FUNCS_ONCE([chown fchmod fchown lstat siginterrupt])
254 AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile tests/Makefile])