1 # Configure template for GNU tar. -*- autoconf -*-
3 # Copyright 1991, 1994-2010, 2013-2023 Free Software Foundation, Inc.
5 # This file is part of GNU tar.
7 # GNU tar is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # GNU tar is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 AC_INIT([GNU tar], [1.34.90], [bug-tar@gnu.org])
21 AC_CONFIG_SRCDIR([src/tar.c])
22 AC_CONFIG_AUX_DIR([build-aux])
23 AC_CONFIG_HEADERS([config.h])
25 AM_INIT_AUTOMAKE([1.15 gnits tar-ustar dist-bzip2 dist-xz std-options silent-rules])
27 # Enable silent rules by default:
28 AM_SILENT_RULES([yes])
35 AC_CHECK_TOOLS([AR], [ar])
39 AC_CHECK_HEADERS_ONCE(fcntl.h linux/fd.h memory.h net/errno.h \
41 sys/param.h sys/device.h sys/gentape.h \
42 sys/inet.h sys/io/trioctl.h \
43 sys/mtio.h sys/time.h sys/tprintf.h sys/tape.h \
46 AC_CHECK_HEADERS([sys/buf.h], [], [],
48 #include <sys/param.h>
53 AC_MSG_CHECKING([for st_fstype string in struct stat])
54 AC_CACHE_VAL(diff_cv_st_fstype_string,
57 [[#include <sys/types.h>
60 [[struct stat s; s.st_fstype[0] = 'x';]])],
61 [diff_cv_st_fstype_string=yes],
62 [diff_cv_st_fstype_string=no])])
63 AC_MSG_RESULT($diff_cv_st_fstype_string)
64 if test $diff_cv_st_fstype_string = yes; then
65 AC_DEFINE(HAVE_ST_FSTYPE_STRING, 1,
66 [Define if struct stat has a char st_fstype[] member.])
69 # even if we use gnulib's acl.h with integrated m4 file later on (used because
70 # of very useful file_has_acl() function) we need following checks that restrict
71 # tar to use POSIX.1e ACLs only.
72 AC_ARG_WITH([posix-acls],
73 AS_HELP_STRING([--without-posix-acls],
74 [do not use POSIX.1e access control lists]),
76 [with_posix_acls=yes])
77 if test "x$with_posix_acls" != "xno"; then
78 AC_CHECK_HEADERS(sys/acl.h,, [with_posix_acls=no])
79 for tar_acl_func in acl_get_file acl_get_fd acl_set_file acl_set_fd \
80 acl_to_text acl_from_text acl_delete_def_file \
82 test "x$with_posix_acls" = xno && break
83 AC_SEARCH_LIBS([$tar_acl_func], [acl pacl], [], [with_posix_acls=no])
85 if test "x$with_posix_acls" != xno; then
86 AC_DEFINE(HAVE_POSIX_ACLS,,[Define when we have working POSIX acls])
89 # disable acls in gnulib's checks
97 AC_CHECK_TYPE(major_t, , AC_DEFINE(major_t, int,
98 [Type of major device numbers.]))
99 AC_CHECK_TYPE(minor_t, , AC_DEFINE(minor_t, int,
100 [Type of minor device numbers.]))
101 AC_CHECK_TYPE(dev_t, unsigned)
102 AC_CHECK_TYPE(ino_t, unsigned)
109 AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
110 [Define if all programs in this package call functions of the Gnulib
111 'exclude' module only from a single thread.])
112 AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
113 [Define if all programs in this package call functions of the Gnulib
114 'mbtowc' module only from a single thread.])
115 AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
116 [Define if all programs in this package call functions of the Gnulib
117 'regex' module only from a single thread.])
118 AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
119 [Define if all programs in this package call locale-sensitive functions
120 like mbrtowc only after setting the locale, and never change the
123 if test $ac_cv_lib_error_at_line = no; then
124 # This means that the error() function is not present in libc, so
125 # the one from gnulib will be used instead. This function precedes
126 # error messages it prints with the program name as returned by getprogname()
127 # call, instead of using the name set by set_program_name.
128 # Install workaround.
129 AC_DEFINE([ENABLE_ERROR_PRINT_PROGNAME],[1],
130 [Enable the use of error_print_progname to print program name with error messages.
131 See comment to function tar_print_progname in src/tar.c])
137 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
138 # ------------------------------------------------
139 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
140 # Otherwise, run RUN-IF-NOT-FOUND.
141 AC_DEFUN([gl_GCC_VERSION_IFELSE],
145 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
148 # error "your version of gcc is older than $1.$2"
155 AC_ARG_ENABLE([gcc-warnings],
156 [AS_HELP_STRING([--enable-gcc-warnings],
157 [turn on many GCC warnings (for developers; best with GNU make)])],
160 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
162 gl_gcc_warnings=$enableval],
164 if test -d "$srcdir"/.git; then
165 gl_GCC_VERSION_IFELSE([11], [2], [gl_gcc_warnings=yes])
169 if test "$gl_gcc_warnings" = yes; then
170 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
171 AC_SUBST([WERROR_CFLAGS])
174 # This, $nw, is the list of warnings we disable.
175 nw="$nw -Wformat-nonliteral" # warnings in Fedora 17 stdio.h
176 nw="$nw -Wvla" # warnings in gettext.h
177 nw="$nw -Wswitch-default" # Too many warnings for now
178 nw="$nw -Wunsafe-loop-optimizations" # It's OK to omit unsafe optimizations.
179 nw="$nw -Winline" # It's OK to not inline.
180 nw="$nw -Wstrict-overflow" # It's OK to optimize strictly.
181 nw="$nw -Wsuggest-attribute=pure" # Too many warnings for now.
182 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
183 nw="$nw -Wstack-protector"
185 gl_MANYWARN_ALL_GCC([ws])
186 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
190 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
191 gl_WARN_ADD([-Wno-type-limits]) # It's OK to optimize based on types.
192 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
193 gl_WARN_ADD([-Wno-format-nonliteral])
195 gl_WARN_ADD([-fdiagnostics-show-option])
196 gl_WARN_ADD([-funit-at-a-time])
199 AC_SUBST([WARN_CFLAGS])
201 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
202 AH_VERBATIM([FORTIFY_SOURCE],
203 [/* Enable compile-time and run-time bounds-checking, and some warnings,
204 without upsetting glibc 2.15+. */
205 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
206 # define _FORTIFY_SOURCE 2
209 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
211 # Use a slightly smaller set of warning options for lib/.
212 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
214 nw="$nw -Wmissing-prototypes"
215 nw="$nw -Wunused-macros"
217 # These are for argp.
218 nw="$nw -Wmissing-field-initializers"
221 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
223 # This is also for argp.
224 gl_WARN_ADD([-Wno-missing-field-initializers], [GNULIB_WARN_CFLAGS])
226 AC_SUBST([GNULIB_WARN_CFLAGS])
228 # For gnulib-tests, the set is slightly smaller still.
230 # It's not worth being this picky about test programs.
231 nw="$nw -Wsuggest-attribute=const"
232 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
233 [$GNULIB_WARN_CFLAGS], [$nw])
234 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
237 TAR_HEADERS_ATTR_XATTR_H
239 AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
241 AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
242 AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
243 AC_CHECK_DECLS([time],,, [#include <time.h>])
245 AC_REPLACE_FUNCS(waitpid)
247 AC_ARG_VAR([RSH], [Configure absolute path to default remote shell binary])
248 AC_CACHE_CHECK(for remote shell, tar_cv_path_RSH,
249 [if test -n "$RSH"; then
253 for ac_file in /usr/ucb/rsh /usr/bin/remsh /usr/bin/rsh /usr/bsd/rsh \
254 /usr/bin/nsh /usr/bin/rcmd
256 # Prefer a non-symlink rsh to a symlink one, so that binaries built
257 # on AIX 4.1.4, where /usr/ucb/rsh is a symlink to /usr/bin/rsh
258 # will run on AIX 4.3.0, which has only /usr/bin/rsh.
259 if test -f $ac_file; then
260 if (test -h $ac_file) 2>/dev/null; then
261 test $tar_cv_path_RSH = no && tar_cv_path_RSH=$ac_file
263 tar_cv_path_RSH=$ac_file
269 if test $tar_cv_path_RSH = no; then
270 AC_CHECK_HEADERS(netdb.h)
272 AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$tar_cv_path_RSH",
273 [Define to the full path of your rsh, if any.])
276 TAR_COMPR_PROGRAM(compress)
277 TAR_COMPR_PROGRAM(gzip)
278 TAR_COMPR_PROGRAM(bzip2)
279 TAR_COMPR_PROGRAM(lzip)
280 TAR_COMPR_PROGRAM(lzma)
281 TAR_COMPR_PROGRAM(lzop)
282 TAR_COMPR_PROGRAM(xz)
283 TAR_COMPR_PROGRAM(zstd)
285 AC_MSG_CHECKING(for default archive format)
287 AC_ARG_VAR([DEFAULT_ARCHIVE_FORMAT],
288 [Set the default archive format. Allowed values are: V7, OLDGNU, USTAR, POSIX, GNU. Default is GNU])
290 if test -z "$DEFAULT_ARCHIVE_FORMAT"; then
291 DEFAULT_ARCHIVE_FORMAT="GNU"
293 case $DEFAULT_ARCHIVE_FORMAT in
294 V7|OLDGNU|USTAR|POSIX|GNU) ;;
295 *) AC_MSG_ERROR(Invalid format name);;
297 AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE_FORMAT, ${DEFAULT_ARCHIVE_FORMAT}_FORMAT,
298 [By default produce archives of this format])
299 AC_MSG_RESULT($DEFAULT_ARCHIVE_FORMAT)
301 AC_MSG_CHECKING(for default archive)
303 AC_ARG_VAR([DEFAULT_ARCHIVE],
304 [Set the name of the default archive (default: -)])
305 if test -z "$DEFAULT_ARCHIVE"; then
308 if test -z "`ls $DEFAULT_ARCHIVE 2>/dev/null`"; then
309 AC_MSG_WARN(DEFAULT_ARCHIVE '$DEFAULT_ARCHIVE' not found on this system)
311 # FIXME: Look for DEFTAPE in <sys/mtio.h>.
312 # FIXME: Let DEVICE_PREFIX be configured from the environment.
313 # FIXME: Rearrange, here.
314 case $DEFAULT_ARCHIVE in
316 AC_DEFINE(DENSITY_LETTER, 1,
317 [Define to 1 if density may be indicated by [lmh] at end of device.])
318 device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7][lmh]$//'`
321 device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7]$//'`
327 case "$device_prefix" in
329 AC_DEFINE_UNQUOTED(DEVICE_PREFIX, "$device_prefix",
330 [Define to a string giving the prefix of the default device, without the part specifying the unit and density.])
334 AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE, "$DEFAULT_ARCHIVE",
335 [Define to a string giving the full name of the default archive file.])
336 AC_MSG_RESULT($DEFAULT_ARCHIVE)
338 AC_ARG_VAR([DEFAULT_BLOCKING],
339 [Define default blocking factor (default: 20)])
340 AC_MSG_CHECKING(for default blocking)
341 DEFAULT_BLOCKING=${DEFAULT_BLOCKING-20}
342 AC_DEFINE_UNQUOTED(DEFAULT_BLOCKING, $DEFAULT_BLOCKING,
343 [Define to a number giving the default blocking size for archives.])
344 AC_MSG_RESULT($DEFAULT_BLOCKING)
346 AC_MSG_CHECKING(for default quoting style)
348 m4_define([QUOTING_STYLES],dnl
349 [literal|shell|shell-always|c|escape|locale|clocale])
350 DEFAULT_QUOTING_STYLE="escape"
351 AC_ARG_VAR([DEFAULT_QUOTING_STYLE],
352 [Set the default quoting style. Allowed values are: ] m4_bpatsubst(QUOTING_STYLES,[|], [[, ]]) [. Default is "escape".])
354 case $DEFAULT_QUOTING_STYLE in
356 *) AC_MSG_ERROR(Invalid quoting style);;
358 AC_MSG_RESULT($DEFAULT_QUOTING_STYLE)
359 DEFAULT_QUOTING_STYLE=`echo ${DEFAULT_QUOTING_STYLE}|sed 's/-/_/g'`_quoting_style
360 AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE,
361 [Define to a default quoting style (see lib/quoteargs.c for the list)])
365 AC_CHECK_HEADERS(iconv.h)
366 AC_CHECK_TYPE(iconv_t,:,
367 AC_DEFINE(iconv_t, int,
368 [Conversion descriptor type]),
376 AM_GNU_GETTEXT([external], [need-formatstring-macros])
377 AM_GNU_GETTEXT_VERSION([0.21])
379 # Initialize the test suite.
380 AC_CONFIG_TESTDIR(tests)
381 AC_CONFIG_FILES([tests/Makefile tests/atlocal]) # FIXME: tests/preset?
382 AM_MISSING_PROG([AUTOM4TE], [autom4te])
384 AC_SUBST(BACKUP_LIBEXEC_SCRIPTS)
385 AC_SUBST(BACKUP_SBIN_SCRIPTS)
386 AC_ARG_ENABLE(backup-scripts,
387 AS_HELP_STRING([--enable-backup-scripts],
388 [Create and install backup and restore scripts]),
390 yes) BACKUP_LIBEXEC_SCRIPTS='$(BACKUP_LIBEXEC_SCRIPTS_LIST)'
391 BACKUP_SBIN_SCRIPTS='$(BACKUP_SBIN_SCRIPTS_LIST)'
395 AC_SUBST(BACKUP_SED_COND)
396 if date +%Y-%m-%d 2>/dev/null >&2; then
397 BACKUP_SED_COND='/^\#ELSE_DATE_FORMAT_OK/,/^\#ENDIF_DATE_FORMAT_OK/d;/^\#IF_DATE_FORMAT_OK/d'
399 BACKUP_SED_COND='/^\#IF_DATE_FORMAT_OK/,/^\#ELSE_DATE_FORMAT_OK/d;/^\#ENDIF_DATE_FORMAT_OK/d'
402 AC_CONFIG_FILES([Makefile\