1 # Configure template for gzip.
3 # Copyright (C) 1999-2002, 2006-2007, 2009-2024 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_PROG([LESS], [less], [less])
54 AM_CONDITIONAL([LESS], [test "$LESS"])
55 AC_CHECK_TOOL([NM], [nm], [nm])
64 # Ensure VLAs are not used.
65 # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
66 AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
68 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
69 # ------------------------------------------------
70 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
71 # Otherwise, run RUN-IF-NOT-FOUND.
72 AC_DEFUN([gl_GCC_VERSION_IFELSE],
76 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
79 # error "your version of gcc is older than $1.$2"
86 AC_ARG_ENABLE([gcc-warnings],
87 [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
88 [control generation of GCC warnings. The TYPE 'no' disables
89 warnings (default for non-developer builds); 'yes' generates
90 cheap warnings if available (default for developer builds);
91 'expensive' in addition generates expensive-to-compute warnings
95 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
97 gl_gcc_warnings=$enableval],
99 # GCC provides fine-grained control over diagnostics which
100 # is used in gnulib for example to suppress warnings from
101 # certain sections of code. So if this is available and
102 # we're running from a git repo, then auto enable the warnings.
104 gl_GCC_VERSION_IFELSE([4], [6],
105 [test -d "$srcdir"/.git \
106 && ! test -f "$srcdir"/.tarball-version \
107 && gl_gcc_warnings=yes])]
110 AC_ARG_ENABLE([dfltcc],
111 [AS_HELP_STRING([--enable-dfltcc],
112 [use DEFLATE COMPRESSION CALL instruction on IBM Z])],
114 yes|no) gl_dfltcc=$enableval ;;
115 *) AC_MSG_ERROR([bad value $enableval for dfltcc option]) ;;
120 if test "$gl_gcc_warnings" = yes; then
121 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
122 AC_SUBST([WERROR_CFLAGS])
125 AS_IF([test $gl_gcc_warnings != expensive],
126 [# -fanalyzer and related options slow GCC considerably.
127 ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
128 ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
130 # This, $nw, is the list of warnings we disable.
132 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
133 nw="$nw -Waggregate-return" # anachronistic
134 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
135 nw="$nw -Wc++-compat" # We don't care about C++ compilers
136 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
137 nw="$nw -Wtraditional" # Warns on #elif which we use often
138 nw="$nw -Wcast-qual" # Too many warnings for now
139 nw="$nw -Wconversion" # Too many warnings for now
140 nw="$nw -Wduplicated-branches" # Too many false alarms
141 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
142 nw="$nw -Wsign-conversion" # Too many warnings for now
143 nw="$nw -Wtraditional-conversion" # Too many warnings for now
144 nw="$nw -Wpadded" # Our structs are not padded
145 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
146 nw="$nw -Wlogical-op" # any use of fwrite provokes this
147 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
148 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
149 nw="$nw -Wswitch-enum" # Too many warnings for now
150 nw="$nw -Wswitch-default" # Too many warnings for now
151 nw="$nw -Wstack-protector" # not worth working around
152 # things I might fix soon:
153 nw="$nw -Wfloat-equal" # sort.c, seq.c
154 nw="$nw -Wmissing-format-attribute" # copy.c
155 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
156 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
158 # Warnings that gzip runs afoul of but coreutils does not.
159 nw="$nw -Wold-style-definition"
161 nw="$nw -Wstrict-overflow"
163 # Using -Wstrict-overflow is a pain, but the alternative is worse.
164 # For an example, see the code that provoked this report:
165 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
166 # Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
168 gl_MANYWARN_ALL_GCC([ws])
169 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
173 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
174 gl_WARN_ADD([-Wno-type-limits]) # false alarms if 32-bit long, 64-bit time_t
175 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
176 gl_WARN_ADD([-Wsuggest-attribute=const])
177 gl_WARN_ADD([-Wsuggest-attribute=noreturn])
178 gl_WARN_ADD([-Wno-format-nonliteral])
180 # Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
181 # it suggests test.c's advance function may be pure, even though it
182 # increments a global variable. Oops.
183 # Normally we'd write code to test for the precise failure, but that
184 # requires a relatively large input to make gcc exhibit the failure.
185 gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
187 # In spite of excluding -Wlogical-op above, it is enabled, as of
188 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
189 gl_WARN_ADD([-Wno-logical-op])
191 gl_WARN_ADD([-fdiagnostics-show-option])
192 gl_WARN_ADD([-funit-at-a-time])
194 AC_SUBST([WARN_CFLAGS])
196 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
197 AH_VERBATIM([FORTIFY_SOURCE],
198 [/* Enable compile-time and run-time bounds-checking, and some warnings,
199 without upsetting glibc 2.15+. */
200 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
201 # define _FORTIFY_SOURCE 2
204 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
206 # We use a slightly smaller set of warning options for lib/.
207 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
209 nw="$nw -Wstrict-overflow"
210 nw="$nw -Wformat-truncation=2"
211 nw="$nw -Wuninitialized"
212 nw="$nw -Wunused-macros"
213 nw="$nw -Wmissing-prototypes"
214 nw="$nw -Wold-style-definition"
215 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
216 AC_SUBST([GNULIB_WARN_CFLAGS])
219 if test "$gl_dfltcc" = yes; then
220 AC_DEFINE([IBM_Z_DFLTCC], ,
221 [Use DEFLATE COMPRESSION CALL instruction on IBM Z machines.])
223 AM_CONDITIONAL([IBM_Z_DFLTCC], [test "$gl_dfltcc" = yes])
225 # cc -E produces incorrect asm files on SVR4, so postprocess it.
226 ASCPPPOST="sed '/^ *\\#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
227 AC_SUBST([ASCPPPOST])
229 AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
230 [gzip_cv_underline=yes
232 [AC_LANG_PROGRAM([[int foo() {return 0;}]], [[]])],
233 [$NM conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
234 gzip_cv_underline=no])])
236 if test $gzip_cv_underline = no; then
237 ASCPPFLAGS='-DNO_UNDERLINE'
239 AC_SUBST([ASCPPFLAGS])
242 # Try to assemble match.S.
243 # "gcc -E match.s" ignores -E, so we must use _match.S.
244 AC_CACHE_CHECK([for an assembler syntax supported by this package],
246 [gzip_cv_assembler=no
250 if cp $srcdir/lib/match.c _match.S &&
251 eval "$CPP $CPPFLAGS $ASCPPFLAGS _match.S > _match.i" &&
252 eval "$ASCPPPOST < _match.i > match_.s"; then
253 if test ! -s match_.s || grep error < match_.s > /dev/null; then
255 elif eval "$CC $CPPFLAGS $CFLAGS -c match_.s >/dev/null" &&
256 test -f match_.$OBJEXT; then
258 gzip_cv_assembler=yes
259 if echo 'void foo (void) {}' > conftest.c &&
260 eval "$CC $CPPFLAGS $CFLAGS -S conftest.c >/dev/null" &&
261 grep '\.note\.GNU-stack' conftest.s >/dev/null &&
262 eval "$CC $CPPFLAGS $CFLAGS -c -Wa,--noexecstack match_.s >/dev/null" &&
263 test -f match_.$OBJEXT; then
264 gzip_cv_assembler='yes, with -Wa,--noexecstack'
268 rm -f conftest* _match.i _match.S match_.s match_.$OBJEXT;;
270 if test "$gzip_cv_assembler" != no; then
272 [Define if an assembler version of longest_match is available.])
275 if test "$gzip_cv_assembler" = 'yes, with -Wa,--noexecstack'; then
276 ASFLAGS_config='-Wa,--noexecstack'
280 AC_SUBST([ASFLAGS_config])
282 GZIP_TRANSFORMED=` echo gzip | sed "$program_transform_name"`
283 ZDIFF_TRANSFORMED=`echo zdiff | sed "$program_transform_name"`
284 ZGREP_TRANSFORMED=`echo zgrep | sed "$program_transform_name"`
285 AC_SUBST([GZIP_TRANSFORMED])
286 AC_SUBST([ZDIFF_TRANSFORMED])
287 AC_SUBST([ZGREP_TRANSFORMED])
288 AM_CONDITIONAL([GZIP_IS_TRANSFORMED], [test "$GZIP_TRANSFORMED" != gzip])
289 AM_CONDITIONAL([ZDIFF_IS_TRANSFORMED], [test "$ZDIFF_TRANSFORMED" != zdiff])
290 AM_CONDITIONAL([ZGREP_IS_TRANSFORMED], [test "$ZGREP_TRANSFORMED" != zgrep])
293 AC_CHECK_HEADERS_ONCE(fcntl.h limits.h memory.h time.h sys/sdt.h)
294 AC_CHECK_FUNCS_ONCE([chown fchmod fchown lstat siginterrupt])
299 AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile tests/Makefile])