5 kx # -*- autoconf -*-
5 kx # Process this file with autoconf to produce a configure script.
5 kx
5 kx # Copyright (C) 1996-2021 Free Software Foundation, Inc.
5 kx
5 kx # This program is free software: you can redistribute it and/or modify
5 kx # it under the terms of the GNU General Public License as published by
5 kx # the Free Software Foundation, either version 3 of the License, or
5 kx # (at your option) any later version.
5 kx
5 kx # This program is distributed in the hope that it will be useful,
5 kx # but WITHOUT ANY WARRANTY; without even the implied warranty of
5 kx # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 kx # GNU General Public License for more details.
5 kx
5 kx # You should have received a copy of the GNU General Public License
5 kx # along with this program. If not, see <https://www.gnu.org/licenses/>.
5 kx
5 kx dnl Written by James Youngman.
5 kx
5 kx dnl Process this file with autoconf to produce a configure script.
5 kx # Make inter-release version strings look like, e.g., v4.6-131-gda920ee, which
5 kx # indicates that it is built from the 131st delta (in _some_ repository)
5 kx # following the v4.6 tag, and that da920ee is a prefix of the commit SHA1.
5 kx AC_INIT([GNU findutils],
5 kx m4_esyscmd([build-aux/git-version-gen .tarball-version]),
5 kx [bug-findutils@gnu.org])
5 kx
5 kx dnl Set the bug-report URL
5 kx dnl
5 kx dnl The call to AC_INIT causes AC_PACKAGE_BUGREPORT to be defined
5 kx dnl and we've used an email address. However, we would also like to
5 kx dnl specify an URL at which to report bugs (and in fact we prefer
5 kx dnl people to use that). Se we define that here, too.
5 kx bugreport_url='https://savannah.gnu.org/bugs/?group=findutils'
5 kx dnl Ensure that PACKAGE_BUGREPORT_URL shows up in config.h so that
5 kx dnl it can be picked up by bugreport.c.
5 kx AC_DEFINE_UNQUOTED([PACKAGE_BUGREPORT_URL], ["$bugreport_url"],
5 kx [URL at which bugs should be reported])
5 kx dnl Also ensure that it is substituted in output files so that it
5 kx dnl turns up in locate/Makefile so that we can generate the correct
5 kx dnl content in the updatedb script.
5 kx AC_SUBST([PACKAGE_BUGREPORT_URL],[$bugreport_url])
5 kx
5 kx AC_CONFIG_AUX_DIR(build-aux)
5 kx AM_INIT_AUTOMAKE([no-dist-gzip dist-xz color-tests])
5 kx AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
5 kx
5 kx AC_CONFIG_SRCDIR([find/pred.c])
5 kx AC_CONFIG_HEADERS([config.h])
5 kx AC_CANONICAL_HOST
5 kx AC_CONFIG_MACRO_DIR(gl/m4)
5 kx
5 kx AC_SUBST(AUXDIR,$ac_aux_dir)
5 kx
5 kx AC_ARG_ENABLE(leaf-optimisation,
5 kx AS_HELP_STRING(--enable-leaf-optimisation,Enable an optimisation which saves lstat calls to identify subdirectories on filesystems having traditional Unix semantics),
5 kx [ac_cv_leaf_optimisation=$enableval],[ac_cv_leaf_optimisation=yes])
5 kx
5 kx AC_ARG_ENABLE(d_type-optimization,
5 kx AS_HELP_STRING(--enable-d_type-optimization,Make use of the file type data returned in struct dirent.d_type by readdir()),
5 kx [ac_cv_d_type=$enableval],[ac_cv_d_type=yes])
5 kx
5 kx dnl This one has no default, because otherwise we would have to say
5 kx dnl both --enable-d_type-optimisation=no and --enable-d_type-optimization=no
5 kx dnl to turn it off.
5 kx AC_ARG_ENABLE(d_type-optimisation,
5 kx AS_HELP_STRING(--enable-d_type-optimisation,Synonym for --enable-d_type-optimization),
5 kx [ac_cv_d_type=$enableval],[])
5 kx
5 kx
5 kx AC_MSG_CHECKING([for leaf optimisation])
5 kx if test x$ac_cv_leaf_optimisation = xno; then
5 kx AC_MSG_RESULT([no])
5 kx else
5 kx AC_MSG_RESULT([yes])
5 kx AC_DEFINE([LEAF_OPTIMISATION], 1, [Define if you want to use the leaf optimisation (this can still be turned off with -noleaf)])
5 kx fi
5 kx
5 kx AC_ARG_VAR([DEFAULT_ARG_SIZE], [Default size of arguments to child processes
5 kx of find and xargs, 128k if unspecified])
5 kx if test -n "$DEFAULT_ARG_SIZE"; then
5 kx AC_DEFINE_UNQUOTED([DEFAULT_ARG_SIZE], [$DEFAULT_ARG_SIZE],
5 kx [If defined, the default argument size used in child processes])
5 kx fi
5 kx
5 kx
5 kx
5 kx dnl Checks for programs.
5 kx AC_PROG_CC
5 kx AC_PROG_CPP
5 kx
5 kx dnl for gnulib
5 kx gl_EARLY
5 kx AC_PROG_INSTALL
5 kx AC_CHECK_TOOLS([AR], [ar])
5 kx AC_CHECK_TOOLS([RANLIB], [ranlib], [:])
5 kx dnl AC_PROG_LIBTOOL
5 kx AC_PROG_MAKE_SET
5 kx AC_SYS_LARGEFILE
5 kx
5 kx
5 kx gl_INIT
5 kx
5 kx AC_ARG_ENABLE(compiler-warnings,
5 kx AS_HELP_STRING(--enable-compiler-warnings,Enable many compiler warnings),
5 kx [
5 kx dnl Enable various GCC warnings.
5 kx gl_MANYWARN_ALL_GCC([warnings])
5 kx
5 kx # Ensure VLAs are not used.
5 kx # Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
5 kx AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
5 kx
5 kx # Set up the list of the pointless, undesired warnings.
5 kx findutils_nw=
5 kx findutils_nw="$findutils_nw -Wsystem-headers" # Don't let system headers trigger warnings
5 kx findutils_nw="$findutils_nw -Wundef" # All compiler preprocessors support #if UNDEF
5 kx findutils_nw="$findutils_nw -Wtraditional" # All compilers nowadays support ANSI C
5 kx findutils_nw="$findutils_nw -Wconversion" # These warnings usually don't point to mistakes.
5 kx findutils_nw="$findutils_nw -Wsign-conversion" # Likewise.
5 kx findutils_nw="$findutils_nw -Wc++-compat" # malloc returns void* and a cast would be ugly.
5 kx findutils_nw="$findutils_nw -Wswitch-default" # A switch on an enum value needs no default.
5 kx
5 kx # Warnings we might enable in the future, but not yet (because they generate a
5 kx # lot of noise).
5 kx findutils_marginal=""
5 kx findutils_marginal="$findutils_marginal -Wtraditional-conversion"
5 kx findutils_marginal="$findutils_marginal -Wpadded"
5 kx findutils_marginal="$findutils_marginal -Wformat-nonliteral"
5 kx findutils_marginal="$findutils_marginal -Wunreachable-code"
5 kx # -Wdouble-promotion generates many warnings when printing values with fprintf.
5 kx findutils_marginal="$findutils_marginal -Wdouble-promotion"
5 kx findutils_marginal="$findutils_marginal -Woverlength-strings"
5 kx # Also disable some other warnings that we do in principle want, but currently lack
5 kx # a way to portably avoid.
5 kx findutils_tmp_nowarning=
5 kx findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=const"
5 kx findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=pure"
5 kx findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=format"
5 kx # And some other warnings that we should fix but haven't, yet.
5 kx findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=const"
5 kx
5 kx # Enable all GCC warnings not in our list of excluded warnings.
5 kx gl_MANYWARN_COMPLEMENT(
5 kx [warnings], [$warnings],
5 kx [$findutils_nw $findutils_marginal $findutils_tmp_nowarning])
5 kx for w in $warnings
5 kx do
5 kx gl_WARN_ADD([$w])
5 kx done
5 kx # -Wextra implies -Wsign-compare, so removing -Wsign-compare from $warnings does not
5 kx # actually eliminate this warning, as manywarnings will have included -Wextra.
5 kx # We should actually eliminate the uses that cause this warning, but some of them are
5 kx # tricky as they're comparisons between a type we choose and a type the implementation
5 kx # chooses without stating whether or not it is signed (e.g. time_t).
5 kx WARN_CFLAGS="$WARN_CFLAGS -Wno-sign-compare"
5 kx # Likewise for -Wunused-parameter: it is implied by -Wunused and -Wextra.
5 kx gl_WARN_ADD([-Wno-unused-parameter])
5 kx # Likewise for -Wformat-nonliteral: it is implied by -Wformat.
5 kx gl_WARN_ADD([-Wno-format-nonliteral])
5 kx ])
5 kx
5 kx dnl For --enable-compiler-warnings-are-errors, any GCC compiler
5 kx dnl warning is actually an error which results in a non-zero result
5 kx dnl from the compiler (that is, the code will fail to compile). We do
5 kx dnl this late in the configure script so that it doesn't interfere
5 kx dnl with the compilation tests run by other parts of the configure
5 kx dnl script.
5 kx AC_ARG_ENABLE(compiler-warnings-are-errors,
5 kx AS_HELP_STRING(--enable-compiler-warnings-are-errors,Compiler warnings are errors),
5 kx [
5 kx AC_MSG_CHECKING([whether it is safe to use -Werror])
5 kx if test -n "$GCC"; then
5 kx CFLAGS="$CFLAGS -Werror"
5 kx AC_MSG_RESULT([yes])
5 kx else
5 kx AC_MSG_RESULT([no, because $CC is not GCC])
5 kx fi
5 kx ])
5 kx
5 kx dnl Older versions of gl/m4/nls.m4 provide AM_MKINSTALLDIRS.
5 kx dnl The current version of gnulib does not, but the version of
5 kx dnl po/Makefile.in.in that comes with gettext-0.14.6 expects
5 kx dnl that @MKINSTALLDIRS@ will be expanded.
5 kx AM_MKINSTALLDIRS
5 kx
5 kx dnl lib/regexprops needs to be a native program, because we need to
5 kx dnl run it in order to generate the documentation about the properties
5 kx dnl of regular expressions. See lib/Makefile.am.
5 kx AM_CONDITIONAL(CROSS_COMPILING, [[test "x$cross_compiling" = xyes]])
5 kx
5 kx dnl Try to get a POSIX.1 environment.
5 kx
5 kx dnl Checks for libraries. If getpwnam() isn't present in the
5 kx dnl C library, try -lsun.
5 kx AC_CHECK_FUNC(getpwnam, [],
5 kx [AC_CHECK_LIB(sun, getpwnam)])
5 kx
5 kx AC_CHECK_LIB([m],[modf],[FINDLIBS="-lm $FINDLIBS"]
5 kx AC_DEFINE_UNQUOTED([HAVE_MODF_IN_LIBM],1,[modf is defined in -lm]))
5 kx AC_CHECK_LIB([m],[fabs],[FINDLIBS="-lm $FINDLIBS"]
5 kx AC_DEFINE_UNQUOTED([HAVE_FABS_IN_LIBM],1,[fabs is defined in -lm]))
5 kx AC_SUBST([FINDLIBS])
5 kx
5 kx dnl Checks for header files.
5 kx AC_HEADER_STDC
5 kx AC_CHECK_HEADERS(sys/param.h mntent.h sys/mnttab.h sys/mntio.h sys/mkdev.h)
5 kx dnl fdleak.c needs sys/resource.h because it calls getrlimit(2).
5 kx AC_CHECK_FUNCS(getrlimit)
5 kx AC_HEADER_MAJOR
5 kx dnl TODO: it's possible gnulib eliminates the need for AC_HEADER_DIRENT.
5 kx AC_HEADER_DIRENT
5 kx AC_HEADER_STAT
5 kx AC_HEADER_SYS_WAIT
5 kx
5 kx
5 kx dnl Checks for typedefs, structures, and compiler characteristics.
5 kx
5 kx AC_TYPE_UID_T
5 kx AC_TYPE_SIZE_T
5 kx AC_CHECK_TYPE(ssize_t, int)
5 kx AC_TYPE_PID_T
5 kx AC_CHECK_TYPE(ino_t, unsigned long)
5 kx AC_CHECK_TYPE(dev_t, unsigned long)
5 kx AC_TYPE_MODE_T
5 kx AC_STRUCT_ST_BLOCKS
5 kx AC_CHECK_MEMBERS([struct stat.st_rdev])
5 kx
5 kx dnl fdleak.c uses PROMOTED_MODE_T, which is defined by gnulib.
5 kx gl_PROMOTED_TYPE_MODE_T
5 kx
5 kx
5 kx AC_STRUCT_TM
5 kx AC_STRUCT_TIMEZONE
5 kx
5 kx dnl Checks for library functions that are provided by gnulib.
5 kx AC_FUNC_STRFTIME
5 kx AC_REPLACE_FUNCS(memcmp memset stpcpy strdup strstr strtol strtoul)
5 kx AC_CHECK_FUNCS(fchdir getcwd strerror endgrent endpwent setlocale)
5 kx AC_CHECK_FUNCS(getrusage)
5 kx AC_FUNC_VPRINTF
5 kx AC_FUNC_ALLOCA
5 kx AC_FUNC_CLOSEDIR_VOID
5 kx
5 kx dnl We don't just use AC_FUNC_GETMNTENT directly because it
5 kx dnl will try to use -lsun on platforms which have getmntent() in the
5 kx dnl C library, for example UNICOS.
5 kx AC_CHECK_FUNC(getmntent, [], [AC_FUNC_GETMNTENT])
5 kx AC_CHECK_FUNCS(getmntent)
5 kx AC_CHECK_FUNCS(setmntent endmntent)
5 kx
5 kx
5 kx # Check for common but not-POSIX functions.
5 kx AC_CHECK_FUNCS(setgroups)
5 kx
5 kx
5 kx dnl gl_XALLOC
5 kx gl_FUNC_ALLOCA
5 kx
5 kx dnl Use gl_INCLUDED_REGEX so that findutils will build on systems like
5 kx dnl Solaris, which lacks those functions in libc (see GNU Savannah bug
5 kx dnl #11710) (Sun Sep 4 20:15:11 2005: gl_INCLUDED_REGEX no longer seems
5 kx dnl to be available in gnulib CVS)
5 kx gl_REGEX
5 kx
5 kx AC_PREREQ([2.69])
5 kx
5 kx jy_SORTZ
5 kx
5 kx
5 kx AC_CHECK_MEMBER(struct dirent.d_type,,,[
5 kx #include <sys/types.h>
5 kx #include <dirent.h>])
5 kx
5 kx jy_AC_ATTRIBUTE_NORETURN
5 kx
5 kx dnl internationalization macros
5 kx AM_GNU_GETTEXT([external])
5 kx AM_GNU_GETTEXT_VERSION([0.19.3])
5 kx
5 kx dnl regextype.c and regexprops.c are designed to be usable outside findutils,
5 kx dnl but findutils doesn't want to support all the regex types in gnulib,
5 kx dnl and wants to support an additional one (RE_SYNTAX_EMACS|RE_DOT_NEWLINE).
5 kx dnl Hence they need to know if they are being compiled into findutils or not.
5 kx AC_DEFINE([FINDUTILS], 1, [Define if we are compiling GNU findutils])
5 kx AC_DEFINE([ALREADY_INCLUDED_CONFIG_H], 1, [Define so that source code can verify that config.h was already included])
5 kx
5 kx dnl Test support.
5 kx AM_PATH_PYTHON(,, [:])
5 kx AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
5 kx AC_CHECK_PROGS([FAKETIME],[faketime],[:])
5 kx AM_CONDITIONAL([HAVE_FAKETIME], [test "$FAKETIME" != :])
5 kx
5 kx # This is necessary so that .o files in LIBOBJS are also built via
5 kx # the ANSI2KNR-filtering rules.
5 kx #LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
5 kx
5 kx # Note that in the list below, po/Makefile.in should appear before
5 kx # po/Makefile, so that po/Makefile can be created even if po/Makefile.in
5 kx # starts off missing.
5 kx AC_CONFIG_FILES([
5 kx Makefile
5 kx build-aux/Makefile
5 kx doc/Makefile
5 kx find/Makefile
5 kx find/testsuite/Makefile
5 kx gl/Makefile
5 kx gl/lib/Makefile
5 kx lib/Makefile
5 kx m4/Makefile
5 kx po/Makefile.in
5 kx po/Makefile
5 kx gnulib-tests/Makefile
5 kx xargs/Makefile
5 kx xargs/testsuite/Makefile
5 kx ])
5 kx AC_OUTPUT
5 kx dnl intl/Makefile