configure.ac 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. # Configure template for GNU tar. -*- autoconf -*-
  2. # Copyright 1991, 1994-2010, 2013-2022 Free Software Foundation, Inc.
  3. # This file is part of GNU tar.
  4. # GNU tar 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. # GNU tar 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 <http://www.gnu.org/licenses/>.
  14. AC_INIT([GNU tar], [1.34.90], [[email protected]])
  15. AC_CONFIG_SRCDIR([src/tar.c])
  16. AC_CONFIG_AUX_DIR([build-aux])
  17. AC_CONFIG_HEADERS([config.h])
  18. AC_PREREQ([2.71])
  19. AM_INIT_AUTOMAKE([1.15 gnits tar-ustar dist-bzip2 dist-xz std-options silent-rules])
  20. # Enable silent rules by default:
  21. AM_SILENT_RULES([yes])
  22. AC_PROG_CC
  23. AC_EXEEXT
  24. AC_PROG_RANLIB
  25. AC_PROG_YACC
  26. gl_EARLY
  27. AC_CHECK_TOOLS([AR], [ar])
  28. AC_SYS_LARGEFILE
  29. AC_CHECK_HEADERS_ONCE(fcntl.h linux/fd.h memory.h net/errno.h \
  30. sgtty.h string.h \
  31. sys/param.h sys/device.h sys/gentape.h \
  32. sys/inet.h sys/io/trioctl.h \
  33. sys/mtio.h sys/time.h sys/tprintf.h sys/tape.h \
  34. unistd.h locale.h)
  35. AC_CHECK_HEADERS([sys/buf.h], [], [],
  36. [#if HAVE_SYS_PARAM_H
  37. #include <sys/param.h>
  38. #endif])
  39. AC_HEADER_MAJOR
  40. AC_MSG_CHECKING([for st_fstype string in struct stat])
  41. AC_CACHE_VAL(diff_cv_st_fstype_string,
  42. [AC_COMPILE_IFELSE(
  43. [AC_LANG_PROGRAM(
  44. [[#include <sys/types.h>
  45. #include <sys/stat.h>
  46. ]],
  47. [[struct stat s; s.st_fstype[0] = 'x';]])],
  48. [diff_cv_st_fstype_string=yes],
  49. [diff_cv_st_fstype_string=no])])
  50. AC_MSG_RESULT($diff_cv_st_fstype_string)
  51. if test $diff_cv_st_fstype_string = yes; then
  52. AC_DEFINE(HAVE_ST_FSTYPE_STRING, 1,
  53. [Define if struct stat has a char st_fstype[] member.])
  54. fi
  55. # even if we use gnulib's acl.h with integrated m4 file later on (used because
  56. # of very useful file_has_acl() function) we need following checks that restrict
  57. # tar to use POSIX.1e ACLs only.
  58. AC_ARG_WITH([posix-acls],
  59. AS_HELP_STRING([--without-posix-acls],
  60. [do not use POSIX.1e access control lists]),
  61. [],
  62. [with_posix_acls=yes])
  63. if test "x$with_posix_acls" != "xno"; then
  64. AC_CHECK_HEADERS(sys/acl.h,, [with_posix_acls=no])
  65. for tar_acl_func in acl_get_file acl_get_fd acl_set_file acl_set_fd \
  66. acl_to_text acl_from_text acl_delete_def_file \
  67. acl_free; do \
  68. test "x$with_posix_acls" = xno && break
  69. AC_SEARCH_LIBS([$tar_acl_func], [acl pacl], [], [with_posix_acls=no])
  70. done
  71. if test "x$with_posix_acls" != xno; then
  72. AC_DEFINE(HAVE_POSIX_ACLS,,[Define when we have working POSIX acls])
  73. fi
  74. else
  75. # disable acls in gnulib's checks
  76. export enable_acl=no
  77. fi
  78. AC_TYPE_MODE_T
  79. AC_TYPE_PID_T
  80. AC_TYPE_OFF_T
  81. AC_TYPE_UID_T
  82. AC_CHECK_TYPE(major_t, , AC_DEFINE(major_t, int,
  83. [Type of major device numbers.]))
  84. AC_CHECK_TYPE(minor_t, , AC_DEFINE(minor_t, int,
  85. [Type of minor device numbers.]))
  86. AC_CHECK_TYPE(dev_t, unsigned)
  87. AC_CHECK_TYPE(ino_t, unsigned)
  88. gt_TYPE_SSIZE_T
  89. # gnulib modules
  90. gl_INIT
  91. AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
  92. [Define if all programs in this package call functions of the Gnulib
  93. 'exclude' module only from a single thread.])
  94. AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
  95. [Define if all programs in this package call functions of the Gnulib
  96. 'mbtowc' module only from a single thread.])
  97. AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
  98. [Define if all programs in this package call functions of the Gnulib
  99. 'regex' module only from a single thread.])
  100. AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
  101. [Define if all programs in this package call locale-sensitive functions
  102. like mbrtowc only after setting the locale, and never change the
  103. locale once set.])
  104. if test $ac_cv_lib_error_at_line = no; then
  105. # This means that the error() function is not present in libc, so
  106. # the one from gnulib will be used instead. This function precedes
  107. # error messages it prints with the program name as returned by getprogname()
  108. # call, instead of using the name set by set_program_name.
  109. # Install workaround.
  110. AC_DEFINE([ENABLE_ERROR_PRINT_PROGNAME],[1],
  111. [Enable the use of error_print_progname to print program name with error messages.
  112. See comment to function tar_print_progname in src/tar.c])
  113. fi
  114. # paxutils modules
  115. tar_PAXUTILS
  116. # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
  117. # ------------------------------------------------
  118. # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
  119. # Otherwise, run RUN-IF-NOT-FOUND.
  120. AC_DEFUN([gl_GCC_VERSION_IFELSE],
  121. [AC_PREPROC_IFELSE(
  122. [AC_LANG_PROGRAM(
  123. [[
  124. #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
  125. /* ok */
  126. #else
  127. # error "your version of gcc is older than $1.$2"
  128. #endif
  129. ]]),
  130. ], [$3], [$4])
  131. ]
  132. )
  133. AC_ARG_ENABLE([gcc-warnings],
  134. [AS_HELP_STRING([--enable-gcc-warnings],
  135. [turn on many GCC warnings (for developers; best with GNU make)])],
  136. [case $enableval in
  137. yes|no) ;;
  138. *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
  139. esac
  140. gl_gcc_warnings=$enableval],
  141. [gl_gcc_warnings=no
  142. if test -d "$srcdir"/.git; then
  143. gl_GCC_VERSION_IFELSE([11], [2], [gl_gcc_warnings=yes])
  144. fi]
  145. )
  146. if test "$gl_gcc_warnings" = yes; then
  147. gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
  148. AC_SUBST([WERROR_CFLAGS])
  149. nw=
  150. # This, $nw, is the list of warnings we disable.
  151. nw="$nw -Wformat-nonliteral" # warnings in Fedora 17 stdio.h
  152. nw="$nw -Wvla" # warnings in gettext.h
  153. nw="$nw -Wswitch-default" # Too many warnings for now
  154. nw="$nw -Wunsafe-loop-optimizations" # It's OK to omit unsafe optimizations.
  155. nw="$nw -Winline" # It's OK to not inline.
  156. nw="$nw -Wstrict-overflow" # It's OK to optimize strictly.
  157. nw="$nw -Wsuggest-attribute=pure" # Too many warnings for now.
  158. nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
  159. nw="$nw -Wstack-protector"
  160. gl_MANYWARN_ALL_GCC([ws])
  161. gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
  162. for w in $ws; do
  163. gl_WARN_ADD([$w])
  164. done
  165. gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
  166. gl_WARN_ADD([-Wno-type-limits]) # It's OK to optimize based on types.
  167. gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
  168. gl_WARN_ADD([-Wno-format-nonliteral])
  169. gl_WARN_ADD([-fdiagnostics-show-option])
  170. gl_WARN_ADD([-funit-at-a-time])
  171. AC_SUBST([WARN_CFLAGS])
  172. AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
  173. AH_VERBATIM([FORTIFY_SOURCE],
  174. [/* Enable compile-time and run-time bounds-checking, and some warnings,
  175. without upsetting glibc 2.15+. */
  176. #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
  177. # define _FORTIFY_SOURCE 2
  178. #endif
  179. ])
  180. AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
  181. # Use a slightly smaller set of warning options for lib/.
  182. # Remove the following and save the result in GNULIB_WARN_CFLAGS.
  183. nw=
  184. nw="$nw -Wmissing-prototypes"
  185. nw="$nw -Wunused-macros"
  186. #
  187. # These are for argp.
  188. nw="$nw -Wmissing-field-initializers"
  189. nw="$nw -Wshadow"
  190. #
  191. gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
  192. # This is also for argp.
  193. gl_WARN_ADD([-Wno-missing-field-initializers], [GNULIB_WARN_CFLAGS])
  194. AC_SUBST([GNULIB_WARN_CFLAGS])
  195. # For gnulib-tests, the set is slightly smaller still.
  196. nw=
  197. # It's not worth being this picky about test programs.
  198. nw="$nw -Wsuggest-attribute=const"
  199. gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
  200. [$GNULIB_WARN_CFLAGS], [$nw])
  201. AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
  202. fi
  203. TAR_HEADERS_ATTR_XATTR_H
  204. AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
  205. AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
  206. AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
  207. AC_CHECK_DECLS([time],,, [#include <time.h>])
  208. AC_REPLACE_FUNCS(waitpid)
  209. AC_ARG_VAR([RSH], [Configure absolute path to default remote shell binary])
  210. AC_CACHE_CHECK(for remote shell, tar_cv_path_RSH,
  211. [if test -n "$RSH"; then
  212. tar_cv_path_RSH=$RSH
  213. else
  214. tar_cv_path_RSH=no
  215. for ac_file in /usr/ucb/rsh /usr/bin/remsh /usr/bin/rsh /usr/bsd/rsh \
  216. /usr/bin/nsh /usr/bin/rcmd
  217. do
  218. # Prefer a non-symlink rsh to a symlink one, so that binaries built
  219. # on AIX 4.1.4, where /usr/ucb/rsh is a symlink to /usr/bin/rsh
  220. # will run on AIX 4.3.0, which has only /usr/bin/rsh.
  221. if test -f $ac_file; then
  222. if (test -h $ac_file) 2>/dev/null; then
  223. test $tar_cv_path_RSH = no && tar_cv_path_RSH=$ac_file
  224. else
  225. tar_cv_path_RSH=$ac_file
  226. break
  227. fi
  228. fi
  229. done
  230. fi])
  231. if test $tar_cv_path_RSH = no; then
  232. AC_CHECK_HEADERS(netdb.h)
  233. else
  234. AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$tar_cv_path_RSH",
  235. [Define to the full path of your rsh, if any.])
  236. fi
  237. TAR_COMPR_PROGRAM(compress)
  238. TAR_COMPR_PROGRAM(gzip)
  239. TAR_COMPR_PROGRAM(bzip2)
  240. TAR_COMPR_PROGRAM(lzip)
  241. TAR_COMPR_PROGRAM(lzma)
  242. TAR_COMPR_PROGRAM(lzop)
  243. TAR_COMPR_PROGRAM(xz)
  244. TAR_COMPR_PROGRAM(zstd)
  245. AC_MSG_CHECKING(for default archive format)
  246. AC_ARG_VAR([DEFAULT_ARCHIVE_FORMAT],
  247. [Set the default archive format. Allowed values are: V7, OLDGNU, USTAR, POSIX, GNU. Default is GNU])
  248. if test -z "$DEFAULT_ARCHIVE_FORMAT"; then
  249. DEFAULT_ARCHIVE_FORMAT="GNU"
  250. fi
  251. case $DEFAULT_ARCHIVE_FORMAT in
  252. V7|OLDGNU|USTAR|POSIX|GNU) ;;
  253. *) AC_MSG_ERROR(Invalid format name);;
  254. esac
  255. AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE_FORMAT, ${DEFAULT_ARCHIVE_FORMAT}_FORMAT,
  256. [By default produce archives of this format])
  257. AC_MSG_RESULT($DEFAULT_ARCHIVE_FORMAT)
  258. AC_MSG_CHECKING(for default archive)
  259. AC_ARG_VAR([DEFAULT_ARCHIVE],
  260. [Set the name of the default archive (default: -)])
  261. if test -z "$DEFAULT_ARCHIVE"; then
  262. DEFAULT_ARCHIVE=-
  263. else
  264. if test -z "`ls $DEFAULT_ARCHIVE 2>/dev/null`"; then
  265. AC_MSG_WARN(DEFAULT_ARCHIVE '$DEFAULT_ARCHIVE' not found on this system)
  266. fi
  267. # FIXME: Look for DEFTAPE in <sys/mtio.h>.
  268. # FIXME: Let DEVICE_PREFIX be configured from the environment.
  269. # FIXME: Rearrange, here.
  270. case $DEFAULT_ARCHIVE in
  271. *[[0-7][lmh]])
  272. AC_DEFINE(DENSITY_LETTER, 1,
  273. [Define to 1 if density may be indicated by [lmh] at end of device.])
  274. device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7][lmh]$//'`
  275. ;;
  276. *[[0-7]])
  277. device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7]$//'`
  278. ;;
  279. *)
  280. device_prefix=
  281. ;;
  282. esac
  283. case "$device_prefix" in
  284. ?*)
  285. AC_DEFINE_UNQUOTED(DEVICE_PREFIX, "$device_prefix",
  286. [Define to a string giving the prefix of the default device, without the part specifying the unit and density.])
  287. ;;
  288. esac
  289. fi
  290. AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE, "$DEFAULT_ARCHIVE",
  291. [Define to a string giving the full name of the default archive file.])
  292. AC_MSG_RESULT($DEFAULT_ARCHIVE)
  293. AC_ARG_VAR([DEFAULT_BLOCKING],
  294. [Define default blocking factor (default: 20)])
  295. AC_MSG_CHECKING(for default blocking)
  296. DEFAULT_BLOCKING=${DEFAULT_BLOCKING-20}
  297. AC_DEFINE_UNQUOTED(DEFAULT_BLOCKING, $DEFAULT_BLOCKING,
  298. [Define to a number giving the default blocking size for archives.])
  299. AC_MSG_RESULT($DEFAULT_BLOCKING)
  300. AC_MSG_CHECKING(for default quoting style)
  301. m4_define([QUOTING_STYLES],dnl
  302. [literal|shell|shell-always|c|escape|locale|clocale])
  303. DEFAULT_QUOTING_STYLE="escape"
  304. AC_ARG_VAR([DEFAULT_QUOTING_STYLE],
  305. [Set the default quoting style. Allowed values are: ] m4_bpatsubst(QUOTING_STYLES,[|], [[, ]]) [. Default is "escape".])
  306. case $DEFAULT_QUOTING_STYLE in
  307. QUOTING_STYLES) ;;
  308. *) AC_MSG_ERROR(Invalid quoting style);;
  309. esac
  310. AC_MSG_RESULT($DEFAULT_QUOTING_STYLE)
  311. DEFAULT_QUOTING_STYLE=`echo ${DEFAULT_QUOTING_STYLE}|sed 's/-/_/g'`_quoting_style
  312. AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE,
  313. [Define to a default quoting style (see lib/quoteargs.c for the list)])
  314. # Iconv
  315. AM_ICONV
  316. AC_CHECK_HEADERS(iconv.h)
  317. AC_CHECK_TYPE(iconv_t,:,
  318. AC_DEFINE(iconv_t, int,
  319. [Conversion descriptor type]),
  320. [
  321. #ifdef HAVE_ICONV_H
  322. # include <iconv.h>
  323. #endif
  324. ])
  325. # Gettext.
  326. AM_GNU_GETTEXT([external], [need-formatstring-macros])
  327. AM_GNU_GETTEXT_VERSION([0.21])
  328. # Initialize the test suite.
  329. AC_CONFIG_TESTDIR(tests)
  330. AC_CONFIG_FILES([tests/Makefile tests/atlocal]) # FIXME: tests/preset?
  331. AM_MISSING_PROG([AUTOM4TE], [autom4te])
  332. AC_SUBST(BACKUP_LIBEXEC_SCRIPTS)
  333. AC_SUBST(BACKUP_SBIN_SCRIPTS)
  334. AC_ARG_ENABLE(backup-scripts,
  335. AS_HELP_STRING([--enable-backup-scripts],
  336. [Create and install backup and restore scripts]),
  337. [case $enableval in
  338. yes) BACKUP_LIBEXEC_SCRIPTS='$(BACKUP_LIBEXEC_SCRIPTS_LIST)'
  339. BACKUP_SBIN_SCRIPTS='$(BACKUP_SBIN_SCRIPTS_LIST)'
  340. ;;
  341. esac])
  342. AC_SUBST(BACKUP_SED_COND)
  343. if date +%Y-%m-%d 2>/dev/null >&2; then
  344. BACKUP_SED_COND='/^\#ELSE_DATE_FORMAT_OK/,/^\#ENDIF_DATE_FORMAT_OK/d;/^\#IF_DATE_FORMAT_OK/d'
  345. else
  346. BACKUP_SED_COND='/^\#IF_DATE_FORMAT_OK/,/^\#ELSE_DATE_FORMAT_OK/d;/^\#ENDIF_DATE_FORMAT_OK/d'
  347. fi
  348. AC_CONFIG_FILES([Makefile\
  349. doc/Makefile\
  350. gnu/Makefile\
  351. lib/Makefile\
  352. po/Makefile.in\
  353. scripts/Makefile\
  354. rmt/Makefile\
  355. src/Makefile])
  356. AC_OUTPUT