Imported Upstream version 1.5
[debian/gzip] / configure.ac
1 # Configure template for gzip.
2
3 # Copyright (C) 1999-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
4
5 # Copyright (C) 1992-1993 Jean-loup Gailly
6
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)
10 # any later version.
11
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.
16
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
20 # 02111-1307, USA.
21
22 AC_PREREQ([2.60])
23 AC_INIT([gzip],
24         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
25         [bug-gzip@gnu.org])
26
27 AC_CONFIG_SRCDIR(gzip.c)
28 AC_CONFIG_AUX_DIR(build-aux)
29 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
30 AM_INIT_AUTOMAKE([1.11 dist-xz color-tests parallel-tests])
31 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
32
33 AC_PROG_CC_STDC
34 AM_PROG_CC_C_O
35 AC_PROG_CPP
36 AC_CHECK_TOOL([NM], [nm], [nm])
37 AC_PROG_LN_S
38 AC_PROG_RANLIB
39 AC_PROG_SHELL
40
41 gl_EARLY
42
43 gl_INIT
44
45 AC_ARG_ENABLE([gcc-warnings],
46   [AS_HELP_STRING([--enable-gcc-warnings],
47                   [turn on lots of GCC warnings (for developers)])],
48   [case $enableval in
49      yes|no) ;;
50      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
51    esac
52    gl_gcc_warnings=$enableval],
53   [gl_gcc_warnings=no]
54 )
55
56 if test "$gl_gcc_warnings" = yes; then
57   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
58   AC_SUBST([WERROR_CFLAGS])
59
60   nw=
61   # This, $nw, is the list of warnings we disable.
62   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
63   nw="$nw -Waggregate-return"       # anachronistic
64   nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
65   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
66   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
67   nw="$nw -Wtraditional"            # Warns on #elif which we use often
68   nw="$nw -Wcast-qual"              # Too many warnings for now
69   nw="$nw -Wconversion"             # Too many warnings for now
70   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
71   nw="$nw -Wsign-conversion"        # Too many warnings for now
72   nw="$nw -Wtraditional-conversion" # Too many warnings for now
73   nw="$nw -Wunreachable-code"       # Too many warnings for now
74   nw="$nw -Wpadded"                 # Our structs are not padded
75   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
76   nw="$nw -Wlogical-op"             # any use of fwrite provokes this
77   nw="$nw -Wformat-nonliteral"      # who.c and pinky.c strftime uses
78   nw="$nw -Wvla"                    # warnings in gettext.h
79   nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
80   nw="$nw -Wswitch-enum"            # Too many warnings for now
81   nw="$nw -Wswitch-default"         # Too many warnings for now
82   nw="$nw -Wstack-protector"        # not worth working around
83   # things I might fix soon:
84   nw="$nw -Wfloat-equal"            # sort.c, seq.c
85   nw="$nw -Wmissing-format-attribute" # copy.c
86   nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
87   nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
88   nw="$nw -Wstrict-overflow"        # expr.c, pr.c, tr.c, factor.c
89   # initial problems in gzip
90   nw="$nw -Wold-style-definition"
91   nw="$nw -Wshadow"
92   nw="$nw -Wunused-macros"
93   # ?? -Wstrict-overflow
94
95   gl_MANYWARN_ALL_GCC([ws])
96   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
97   for w in $ws; do
98     gl_WARN_ADD([$w])
99   done
100   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
101   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
102   gl_WARN_ADD([-Wno-pointer-sign])     # Too many warnings for now
103   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
104   gl_WARN_ADD([-Wno-overflow])         # util.c
105   gl_WARN_ADD([-Wno-type-limits])      # util.c
106   gl_WARN_ADD([-Wno-format-nonliteral])
107   gl_WARN_ADD([-Wno-unsuffixed-float-constants])
108
109   # In spite of excluding -Wlogical-op above, it is enabled, as of
110   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
111   gl_WARN_ADD([-Wno-logical-op])
112
113   gl_WARN_ADD([-fdiagnostics-show-option])
114   gl_WARN_ADD([-funit-at-a-time])
115
116   AC_SUBST([WARN_CFLAGS])
117
118   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
119   AC_DEFINE([_FORTIFY_SOURCE], [2],
120     [enable compile-time and run-time bounds-checking, and some warnings])
121   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
122
123   # We use a slightly smaller set of warning options for lib/.
124   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
125   nw=
126   nw="$nw -Wuninitialized"
127   nw="$nw -Wmissing-prototypes"
128   nw="$nw -Wold-style-definition"
129   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
130   AC_SUBST([GNULIB_WARN_CFLAGS])
131 fi
132
133 # cc -E produces incorrect asm files on SVR4, so postprocess it.
134 ASCPPPOST="sed '/^ *\\#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
135 AC_SUBST([ASCPPPOST])
136
137 AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
138   [gzip_cv_underline=yes
139    AC_TRY_COMPILE([int foo() {return 0;}], [],
140      [$NM conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
141         gzip_cv_underline=no])])
142 ASCPPFLAGS=
143 if test $gzip_cv_underline = no; then
144   ASCPPFLAGS='-DNO_UNDERLINE'
145 fi
146 AC_SUBST([ASCPPFLAGS])
147 AC_OBJEXT
148
149 # Try to assemble match.S.
150 # "gcc -E match.s" ignores -E, so we must use _match.S.
151 AC_CACHE_CHECK([for an assembler syntax supported by this package],
152   [gzip_cv_assembler],
153   [gzip_cv_assembler=no
154    case " $DEFS " in
155    *' NO_ASM '*) ;;
156    *)
157      if cp $srcdir/lib/match.c _match.S &&
158         eval "$CPP $CPPFLAGS $ASCPPFLAGS _match.S > _match.i" &&
159         eval "$ASCPPPOST < _match.i > match_.s"; then
160        if test ! -s match_.s || grep error < match_.s > /dev/null; then
161          :
162        elif eval "$CC $CPPFLAGS $CFLAGS -c match_.s >/dev/null" &&
163             test -f match_.$OBJEXT; then
164          rm -f match_.$OBJEXT
165          gzip_cv_assembler=yes
166          if echo 'void foo (void) {}' > conftest.c &&
167             eval "$CC $CPPFLAGS $CFLAGS -S conftest.c >/dev/null" &&
168             grep '\.note\.GNU-stack' conftest.s >/dev/null &&
169             eval "$CC $CPPFLAGS $CFLAGS -c -Wa,--noexecstack match_.s >/dev/null" &&
170             test -f match_.$OBJEXT; then
171            gzip_cv_assembler='yes, with -Wa,--noexecstack'
172          fi
173        fi
174      fi
175      rm -f conftest* _match.i _match.S match_.s match_.$OBJEXT;;
176    esac])
177 if test "$gzip_cv_assembler" != no; then
178   AC_DEFINE(ASMV, ,
179     [Define if an assembler version of longest_match is available.])
180   AC_LIBOBJ(match)
181 fi
182 if test "$gzip_cv_assembler" = 'yes, with -Wa,--noexecstack'; then
183   ASFLAGS_config='-Wa,--noexecstack'
184 else
185   ASFLAGS_config=
186 fi
187 AC_SUBST([ASFLAGS_config])
188
189 AC_ISC_POSIX
190 AC_C_CONST
191 AC_HEADER_STDC
192 AC_CHECK_HEADERS_ONCE(fcntl.h limits.h memory.h time.h)
193 AC_CHECK_FUNCS_ONCE([chown fchmod fchown lstat siginterrupt])
194 AC_HEADER_DIRENT
195 AC_TYPE_SIGNAL
196 AC_TYPE_SIZE_T
197 AC_TYPE_OFF_T
198
199 AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile tests/Makefile])
200 AC_OUTPUT