Imported Upstream version 3.8
[platform/upstream/diffutils.git] / configure.ac
1 # Configure template for GNU Diffutils.
2
3 # Copyright (C) 1994-1995, 1998, 2001-2002, 2004, 2006, 2009-2013, 2015-2021
4 # Free Software Foundation, Inc.
5
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.
10
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.
15
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/>.
18
19 AC_PREREQ([2.64])
20
21 AC_INIT([GNU diffutils],
22         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
23         [bug-diffutils@gnu.org])
24
25 AC_CONFIG_SRCDIR([src/diff.c])
26 AC_CONFIG_AUX_DIR([build-aux])
27 AC_CONFIG_MACRO_DIR([m4])
28
29 AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip subdir-objects
30                        color-tests parallel-tests])
31 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
32
33 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
34
35 AC_PROG_AWK
36 AC_PROG_CC
37 AM_PROG_CC_C_O
38 AM_MISSING_PROG([HELP2MAN], [help2man])
39 AC_PROG_RANLIB
40 gl_EARLY
41 gl_USE_SYSTEM_EXTENSIONS
42 gl_INIT
43
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])
47
48 AC_ARG_ENABLE([gcc-warnings],
49   [AS_HELP_STRING([--enable-gcc-warnings],
50                   [turn on lots of GCC warnings (for developers)])],
51   [case $enableval in
52      yes|no) ;;
53      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
54    esac
55    gl_gcc_warnings=$enableval],
56   [if test -d "$srcdir"/.git; then
57      gl_gcc_warnings=yes
58    else
59      gl_gcc_warnings=no
60    fi]
61 )
62
63 if test "$gl_gcc_warnings" = yes; then
64   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
65   AC_SUBST([WERROR_CFLAGS])
66
67   nw=
68   # This, $nw, is the list of warnings we disable.
69   nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
70   nw="$nw -Wstack-protector"        # not worth working around
71
72   gl_MANYWARN_ALL_GCC([ws])
73   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
74   for w in $ws; do
75     gl_WARN_ADD([$w])
76   done
77   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
78   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
79   gl_WARN_ADD([-Wno-format-nonliteral])
80
81   gl_WARN_ADD([-fdiagnostics-show-option])
82   gl_WARN_ADD([-funit-at-a-time])
83   gl_WARN_ADD([-fno-common])
84
85   AC_SUBST([WARN_CFLAGS])
86
87   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
88   AC_DEFINE([_FORTIFY_SOURCE], [2],
89     [enable compile-time and run-time bounds-checking, and some warnings])
90   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
91
92   # We use a slightly smaller set of warning options for lib/.
93   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
94   nw=
95   nw="$nw -Wunused-macros"
96   nw="$nw -Wsuggest-attribute=pure"
97   nw="$nw -Wduplicated-branches"    # Too many false alarms
98
99   # Avoid false alarm in lib/vasnprintf.c.
100   # https://lists.gnu.org/r/bug-gnulib/2021-01/msg00031.html
101   gl_WARN_ADD([-Wno-analyzer-null-argument])
102
103   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
104   AC_SUBST([GNULIB_WARN_CFLAGS])
105 fi
106
107 AC_C_INLINE
108
109 AC_DEFINE([DEFAULT_EDITOR_PROGRAM], ["ed"],
110   [Name of editor program, unless overridden.])
111
112 AC_PATH_PROG([PR_PROGRAM], [pr], [""])
113 AC_DEFINE_UNQUOTED([PR_PROGRAM], ["$PR_PROGRAM"], [Name of "pr" program.])
114
115 AC_CHECK_MEMBERS([struct stat.st_blksize])
116 AC_CHECK_MEMBERS([struct stat.st_rdev])
117 AC_HEADER_DIRENT
118 AC_HEADER_SYS_WAIT
119 AC_TYPE_PID_T
120
121 AC_CHECK_FUNCS_ONCE([sigaction sigprocmask strcasecoll stricoll])
122 if test $ac_cv_func_sigprocmask = no; then
123   AC_CHECK_FUNCS([sigblock])
124 fi
125 AC_FUNC_CLOSEDIR_VOID
126 AC_FUNC_FORK
127
128 # When .tarball-version exists, we're building from a tarball
129 # and must not make man/*.1 files depend on the generated src/version.c,
130 # because that would induce a requirement to run the help2man perl script.
131 # We are not yet prepared to make perl a build-from-tarball requirement.
132 # Hence, here we detect .tarball-version existence.  When not present,
133 # we define a variable to be used in man/Makefile.am to induce the
134 # proper dependency (so that man/*.1 will be rebuilt upon any version change),
135 # but not when built from a tarball.
136 AC_SUBST([SRC_VERSION_C])
137 test -f $srcdir/.tarball-version \
138   && SRC_VERSION_C= \
139   || SRC_VERSION_C=../src/version.c
140
141 AM_GNU_GETTEXT([external], [need-ngettext])
142 AM_GNU_GETTEXT_VERSION([0.19.2])
143 XGETTEXT="AWK='$AWK' \$(SHELL) \$(top_srcdir)/exgettext $XGETTEXT"
144
145 AC_CONFIG_FILES([
146   Makefile doc/Makefile
147   lib/Makefile
148   src/Makefile
149   tests/Makefile
150   gnulib-tests/Makefile
151   man/Makefile
152   po/Makefile.in
153 ])
154 AC_OUTPUT