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