1# -*- autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4# Copyright (C) 1996-2021 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 <https://www.gnu.org/licenses/>.
18
19dnl Written by James Youngman.
20
21dnl Process this file with autoconf to produce a configure script.
22# Make inter-release version strings look like, e.g., v4.6-131-gda920ee, which
23# indicates that it is built from the 131st delta (in _some_ repository)
24# following the v4.6 tag, and that da920ee is a prefix of the commit SHA1.
25AC_INIT([GNU findutils],
26        m4_esyscmd([build-aux/git-version-gen .tarball-version]),
27        [bug-findutils@gnu.org])
28
29dnl Set the bug-report URL
30dnl
31dnl The call to AC_INIT causes AC_PACKAGE_BUGREPORT to be defined
32dnl and we've used an email address.  However, we would also like to
33dnl specify an URL at which to report bugs (and in fact we prefer
34dnl people to use that).  Se we define that here, too.
35bugreport_url='https://savannah.gnu.org/bugs/?group=findutils'
36dnl Ensure that PACKAGE_BUGREPORT_URL shows up in config.h so that
37dnl it can be picked up by bugreport.c.
38AC_DEFINE_UNQUOTED([PACKAGE_BUGREPORT_URL], ["$bugreport_url"],
39                   [URL at which bugs should be reported])
40dnl Also ensure that it is substituted in output files so that it
41dnl turns up in locate/Makefile so that we can generate the correct
42dnl content in the updatedb script.
43AC_SUBST([PACKAGE_BUGREPORT_URL],[$bugreport_url])
44
45AC_CONFIG_AUX_DIR(build-aux)
46AM_INIT_AUTOMAKE([no-dist-gzip dist-xz color-tests])
47AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
48
49AC_CONFIG_SRCDIR([find/pred.c])
50AC_CONFIG_HEADERS([config.h])
51AC_CANONICAL_HOST
52AC_CONFIG_MACRO_DIR(gl/m4)
53
54AC_SUBST(AUXDIR,$ac_aux_dir)
55
56AC_ARG_ENABLE(leaf-optimisation,
57	AS_HELP_STRING(--enable-leaf-optimisation,Enable an optimisation which saves lstat calls to identify subdirectories on filesystems having traditional Unix semantics),
58	[ac_cv_leaf_optimisation=$enableval],[ac_cv_leaf_optimisation=yes])
59
60AC_ARG_ENABLE(d_type-optimization,
61	AS_HELP_STRING(--enable-d_type-optimization,Make use of the file type data returned in struct dirent.d_type by readdir()),
62	[ac_cv_d_type=$enableval],[ac_cv_d_type=yes])
63
64dnl This one has no default, because otherwise we would have to say
65dnl both --enable-d_type-optimisation=no and --enable-d_type-optimization=no
66dnl to turn it off.
67AC_ARG_ENABLE(d_type-optimisation,
68	AS_HELP_STRING(--enable-d_type-optimisation,Synonym for --enable-d_type-optimization),
69	[ac_cv_d_type=$enableval],[])
70
71
72AC_MSG_CHECKING([for leaf optimisation])
73if test x$ac_cv_leaf_optimisation = xno; then
74   AC_MSG_RESULT([no])
75else
76   AC_MSG_RESULT([yes])
77   AC_DEFINE([LEAF_OPTIMISATION], 1, [Define if you want to use the leaf optimisation (this can still be turned off with -noleaf)])
78fi
79
80AC_ARG_VAR([DEFAULT_ARG_SIZE], [Default size of arguments to child processes
81of find and xargs, 128k if unspecified])
82if test -n "$DEFAULT_ARG_SIZE"; then
83   AC_DEFINE_UNQUOTED([DEFAULT_ARG_SIZE], [$DEFAULT_ARG_SIZE],
84     [If defined, the default argument size used in child processes])
85fi
86
87
88
89dnl Checks for programs.
90AC_PROG_CC
91AC_PROG_CPP
92
93dnl for gnulib
94gl_EARLY
95AC_PROG_LN_S
96AC_PROG_INSTALL
97AC_CHECK_TOOLS([AR], [ar])
98AC_CHECK_TOOLS([RANLIB], [ranlib], [:])
99dnl AC_PROG_LIBTOOL
100AC_PROG_MAKE_SET
101AC_SYS_LARGEFILE
102
103
104gl_INIT
105
106AC_ARG_ENABLE(compiler-warnings,
107  AS_HELP_STRING(--enable-compiler-warnings,Enable many compiler warnings),
108  [
109  dnl Enable various GCC warnings.
110  gl_MANYWARN_ALL_GCC([warnings])
111
112  # Ensure VLAs are not used.
113  # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
114  AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
115
116  # Set up the list of the pointless, undesired warnings.
117  findutils_nw=
118  findutils_nw="$findutils_nw -Wsystem-headers"	 # Don't let system headers trigger warnings
119  findutils_nw="$findutils_nw -Wundef"           # All compiler preprocessors support #if UNDEF
120  findutils_nw="$findutils_nw -Wtraditional"     # All compilers nowadays support ANSI C
121  findutils_nw="$findutils_nw -Wconversion"      # These warnings usually don't point to mistakes.
122  findutils_nw="$findutils_nw -Wsign-conversion" # Likewise.
123  findutils_nw="$findutils_nw -Wc++-compat"      # malloc returns void* and a cast would be ugly.
124  findutils_nw="$findutils_nw -Wswitch-default"  # A switch on an enum value needs no default.
125
126  # Warnings we might enable in the future, but not yet (because they generate a
127  # lot of noise).
128  findutils_marginal=""
129  findutils_marginal="$findutils_marginal -Wtraditional-conversion"
130  findutils_marginal="$findutils_marginal -Wpadded"
131  findutils_marginal="$findutils_marginal -Wformat-nonliteral"
132  findutils_marginal="$findutils_marginal -Wunreachable-code"
133  # -Wdouble-promotion generates many warnings when printing values with fprintf.
134  findutils_marginal="$findutils_marginal -Wdouble-promotion"
135  findutils_marginal="$findutils_marginal -Woverlength-strings"
136  # Also disable some other warnings that we do in principle want, but currently lack
137  # a way to portably avoid.
138  findutils_tmp_nowarning=
139  findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=const"
140  findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=pure"
141  findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=format"
142  # And some other warnings that we should fix but haven't, yet.
143  findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=const"
144
145  # Enable all GCC warnings not in our list of excluded warnings.
146  gl_MANYWARN_COMPLEMENT(
147	[warnings], [$warnings],
148	[$findutils_nw $findutils_marginal $findutils_tmp_nowarning])
149  for w in $warnings
150  do
151    gl_WARN_ADD([$w])
152  done
153  # -Wextra implies -Wsign-compare, so removing -Wsign-compare from $warnings does not
154  # actually eliminate this warning, as manywarnings will have included -Wextra.
155  # We should actually eliminate the uses that cause this warning, but some of them are
156  # tricky as they're comparisons between a type we choose and a type the implementation
157  # chooses without stating whether or not it is signed (e.g. time_t).
158  WARN_CFLAGS="$WARN_CFLAGS  -Wno-sign-compare"
159  # Likewise for -Wunused-parameter: it is implied by -Wunused and -Wextra.
160  gl_WARN_ADD([-Wno-unused-parameter])
161  # Likewise for -Wformat-nonliteral: it is implied by -Wformat.
162  gl_WARN_ADD([-Wno-format-nonliteral])
163  ])
164
165dnl For --enable-compiler-warnings-are-errors, any GCC compiler
166dnl warning is actually an error which results in a non-zero result
167dnl from the compiler (that is, the code will fail to compile).  We do
168dnl this late in the configure script so that it doesn't interfere
169dnl with the compilation tests run by other parts of the configure
170dnl script.
171AC_ARG_ENABLE(compiler-warnings-are-errors,
172  AS_HELP_STRING(--enable-compiler-warnings-are-errors,Compiler warnings are errors),
173  [
174    AC_MSG_CHECKING([whether it is safe to use -Werror])
175    if test -n "$GCC"; then
176      CFLAGS="$CFLAGS -Werror"
177      AC_MSG_RESULT([yes])
178    else
179      AC_MSG_RESULT([no, because $CC is not GCC])
180    fi
181  ])
182
183dnl Older versions of gl/m4/nls.m4 provide AM_MKINSTALLDIRS.
184dnl The current version of gnulib does not, but the version of
185dnl po/Makefile.in.in that comes with gettext-0.14.6 expects
186dnl that @MKINSTALLDIRS@ will be expanded.
187AM_MKINSTALLDIRS
188
189dnl lib/regexprops needs to be a native program, because we need to
190dnl run it in order to generate the documentation about the properties
191dnl of regular expressions.  See lib/Makefile.am.
192AM_CONDITIONAL(CROSS_COMPILING, [[test "x$cross_compiling" = xyes]])
193
194dnl Try to get a POSIX.1 environment.
195
196dnl Checks for libraries.  If getpwnam() isn't present in the
197dnl C library, try -lsun.
198AC_CHECK_FUNC(getpwnam, [],
199[AC_CHECK_LIB(sun, getpwnam)])
200
201AC_CHECK_LIB([m],[modf],[FINDLIBS="-lm $FINDLIBS"]
202  AC_DEFINE_UNQUOTED([HAVE_MODF_IN_LIBM],1,[modf is defined in -lm]))
203AC_CHECK_LIB([m],[fabs],[FINDLIBS="-lm $FINDLIBS"]
204  AC_DEFINE_UNQUOTED([HAVE_FABS_IN_LIBM],1,[fabs is defined in -lm]))
205AC_SUBST([FINDLIBS])
206
207dnl Checks for header files.
208AC_HEADER_STDC
209AC_CHECK_HEADERS(sys/param.h mntent.h sys/mnttab.h sys/mntio.h sys/mkdev.h)
210dnl fdleak.c needs sys/resource.h because it calls getrlimit(2).
211AC_CHECK_FUNCS(getrlimit)
212AC_HEADER_MAJOR
213dnl TODO: it's possible gnulib eliminates the need for AC_HEADER_DIRENT.
214AC_HEADER_DIRENT
215AC_HEADER_STAT
216AC_HEADER_SYS_WAIT
217
218
219dnl Checks for typedefs, structures, and compiler characteristics.
220
221AC_TYPE_UID_T
222AC_TYPE_SIZE_T
223AC_CHECK_TYPE(ssize_t, int)
224AC_TYPE_PID_T
225AC_CHECK_TYPE(ino_t, unsigned long)
226AC_CHECK_TYPE(dev_t, unsigned long)
227AC_TYPE_MODE_T
228AC_STRUCT_ST_BLOCKS
229AC_CHECK_MEMBERS([struct stat.st_rdev])
230
231dnl fdleak.c uses PROMOTED_MODE_T, which is defined by gnulib.
232gl_PROMOTED_TYPE_MODE_T
233
234
235AC_STRUCT_TM
236AC_STRUCT_TIMEZONE
237
238dnl Checks for library functions that are provided by gnulib.
239AC_FUNC_STRFTIME
240AC_REPLACE_FUNCS(memcmp memset stpcpy strdup strstr strtol strtoul)
241AC_CHECK_FUNCS(fchdir getcwd strerror endgrent endpwent setlocale)
242AC_CHECK_FUNCS(getrusage)
243AC_FUNC_VPRINTF
244AC_FUNC_ALLOCA
245AC_FUNC_CLOSEDIR_VOID
246
247dnl We don't just use AC_FUNC_GETMNTENT directly because it
248dnl will try to use -lsun on platforms which have getmntent() in the
249dnl C library, for example UNICOS.
250AC_CHECK_FUNC(getmntent, [], [AC_FUNC_GETMNTENT])
251AC_CHECK_FUNCS(getmntent)
252AC_CHECK_FUNCS(setmntent endmntent)
253
254
255# Check for common but not-POSIX functions.
256AC_CHECK_FUNCS(setgroups)
257
258
259dnl gl_XALLOC
260gl_FUNC_ALLOCA
261
262dnl Use gl_INCLUDED_REGEX so that findutils will build on systems like
263dnl Solaris, which lacks those functions in libc (see GNU Savannah bug
264dnl #11710) (Sun Sep  4 20:15:11 2005: gl_INCLUDED_REGEX no longer seems
265dnl to be available in gnulib CVS)
266gl_REGEX
267
268AC_PREREQ([2.69])
269
270jy_SORTZ
271
272
273AC_CHECK_MEMBER(struct dirent.d_type,,,[
274#include <sys/types.h>
275#include <dirent.h>])
276
277jy_AC_ATTRIBUTE_NORETURN
278
279dnl internationalization macros
280AM_GNU_GETTEXT([external])
281AM_GNU_GETTEXT_VERSION([0.19.3])
282
283dnl regextype.c and regexprops.c are designed to be usable outside findutils,
284dnl but findutils doesn't want to support all the regex types in gnulib,
285dnl and wants to support an additional one (RE_SYNTAX_EMACS|RE_DOT_NEWLINE).
286dnl Hence they need to know if they are being compiled into findutils or not.
287AC_DEFINE([FINDUTILS], 1, [Define if we are compiling GNU findutils])
288AC_DEFINE([ALREADY_INCLUDED_CONFIG_H], 1, [Define so that source code can verify that config.h was already included])
289
290dnl Test support.
291AM_PATH_PYTHON(,, [:])
292AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
293AC_CHECK_PROGS([FAKETIME],[faketime],[:])
294AM_CONDITIONAL([HAVE_FAKETIME], [test "$FAKETIME" != :])
295
296# This is necessary so that .o files in LIBOBJS are also built via
297# the ANSI2KNR-filtering rules.
298#LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
299
300# Note that in the list below, po/Makefile.in should appear before
301# po/Makefile, so that po/Makefile can be created even if po/Makefile.in
302# starts off missing.
303AC_CONFIG_FILES([
304Makefile
305build-aux/Makefile
306doc/Makefile
307find/Makefile
308find/testsuite/Makefile
309gl/Makefile
310gl/lib/Makefile
311lib/Makefile
312locate/Makefile
313locate/testsuite/Makefile
314m4/Makefile
315po/Makefile.in
316po/Makefile
317gnulib-tests/Makefile
318xargs/Makefile
319xargs/testsuite/Makefile
320])
321AC_OUTPUT
322dnl intl/Makefile
323