configure.ac 12 KB

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