1 # Configure template for GNU Diffutils.
3 # Copyright (C) 1994-1995, 1998, 2001-2002, 2004, 2006, 2009-2013, 2015-2025
4 # Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 AC_INIT([GNU diffutils],
22 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
23 [bug-diffutils@gnu.org],
25 [https://www.gnu.org/software/diffutils/])
27 AC_CONFIG_SRCDIR([src/diff.c])
28 AC_CONFIG_AUX_DIR([build-aux])
29 AC_CONFIG_MACRO_DIR([m4])
31 AM_INIT_AUTOMAKE([1.11 dist-xz subdir-objects color-tests parallel-tests])
32 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
34 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
38 AM_MISSING_PROG([HELP2MAN], [help2man])
41 gl_USE_SYSTEM_EXTENSIONS
44 # Ensure VLAs are not used.
45 # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
46 AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
48 # diffutils is single-threaded; optimize for this.
49 AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
50 ['exclude' code is called only from 1 thread.])
51 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
52 ['mbrtowc', 'mbrtoc32', 'regex' code is called only from 1 thread.])
53 AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
54 ['regex' code is called only from 1 thread.])
55 AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
56 [Locale-sensitive functions are called only after locale is set.])
58 AC_DEFINE([GNULIB_MBRTOC32_REGULAR], [1],
59 [Do not worry about rare encodings like CP864, EBCDIC, Johab, and Shift JIS
60 that glibc does not support.])
64 AC_CHECK_MEMBERS([struct stat.st_rdev])
69 AC_CHECK_FUNCS_ONCE([sigaction sigprocmask])
70 if test $ac_cv_func_sigprocmask = no; then
71 AC_CHECK_FUNCS([sigblock])
75 dnl O_PATH exists since Linux 2.6.39, but is supported with fstat() only since
76 dnl Linux 3.6. Use a configure test rather than testing `uname -sr`.
77 AC_CACHE_CHECK([whether O_PATH supports fstat],
81 #include <sys/types.h>
86 int fd = openat (AT_FDCWD, "conftest.c", O_RDONLY|O_PATH);
87 return !(fd >= 0 && fstat (fd, &statbuf) == 0);
90 [du_cv_O_PATH_fstat=yes],
91 [du_cv_O_PATH_fstat=no],
92 [du_cv_O_PATH_fstat="guessing no"])
94 case "$du_cv_O_PATH_fstat" in
96 AC_DEFINE([O_PATH_SUPPORTS_FSTAT], [1],
97 [Define to 1 if <fcntl.h> defines O_PATH and file descriptors
98 created with this flag are supported by fstat().])
102 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
103 # ------------------------------------------------
104 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
105 # Otherwise, run RUN-IF-NOT-FOUND.
106 AC_DEFUN([gl_GCC_VERSION_IFELSE],
110 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
113 # error "your version of gcc is older than $1.$2"
120 AC_ARG_ENABLE([gcc-warnings],
121 [AS_HELP_STRING([[--enable-gcc-warnings[=TYPE]]],
122 [control generation of GCC warnings. The TYPE 'no' disables
123 warnings (default for non-developer builds); 'yes' generates
124 cheap warnings if available (default for developer builds);
125 'expensive' in addition generates expensive-to-compute warnings
129 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
131 gl_gcc_warnings=$enableval],
133 # GCC provides fine-grained control over diagnostics which
134 # is used in gnulib for example to suppress warnings from
135 # certain sections of code. So if this is available and
136 # we're running from a git repo, then auto enable the warnings.
138 gl_GCC_VERSION_IFELSE([4], [6],
139 [test -d "$srcdir"/.git \
140 && ! test -f "$srcdir"/.tarball-version \
141 && gl_gcc_warnings=yes])]
144 if test $gl_gcc_warnings != no; then
145 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
146 AC_SUBST([WERROR_CFLAGS])
149 AS_IF([test $gl_gcc_warnings != expensive],
150 [# -fanalyzer and related options slow GCC considerably.
151 ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
153 # This, $nw, is the list of warnings we disable.
155 nw="$nw -Winline" # not a correctness warning
156 nw="$nw -Wstack-protector" # not a correctness warning
158 gl_MANYWARN_ALL_GCC([ws])
159 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
163 gl_WARN_ADD([-Wno-sign-compare]) # Too many false positives
164 gl_WARN_ADD([-Wno-format-nonliteral])
166 AC_SUBST([WARN_CFLAGS])
168 AH_VERBATIM([FORTIFY_SOURCE],
169 [/* Enable compile-time and run-time bounds-checking, and some warnings,
170 without upsetting glibc 2.15+. */
171 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ \
172 && !defined __MINGW32__
173 # define _FORTIFY_SOURCE 2
176 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
179 AC_DEFINE([DEFAULT_EDITOR_PROGRAM], ["ed"],
180 [Name of editor program, unless overridden.])
182 AC_PATH_PROG([PR_PROGRAM], [pr], [""])
183 AC_DEFINE_UNQUOTED([PR_PROGRAM], ["$PR_PROGRAM"], [Name of "pr" program.])
185 # When .tarball-version exists, we're building from a tarball
186 # and must not make man/*.1 files depend on the generated src/version.c,
187 # because that would induce a requirement to run the help2man perl script.
188 # We are not yet prepared to make perl a build-from-tarball requirement.
189 # Hence, here we detect .tarball-version existence. When not present,
190 # we define a variable to be used in man/Makefile.am to induce the
191 # proper dependency (so that man/*.1 will be rebuilt upon any version change),
192 # but not when built from a tarball.
193 AC_SUBST([SRC_VERSION_C])
194 test -f $srcdir/.tarball-version \
196 || SRC_VERSION_C=../src/version.c
198 AM_GNU_GETTEXT([external], [need-ngettext])
199 AM_GNU_GETTEXT_VERSION([0.19.2])
200 XGETTEXT="AWK='$AWK' \$(SHELL) \$(top_srcdir)/exgettext $XGETTEXT"
203 Makefile doc/Makefile
207 gnulib-tests/Makefile