]> git.ipfire.org Git - thirdparty/tar.git/blob - configure.ac
Update to current Autoconf & Gettext
[thirdparty/tar.git] / configure.ac
1 # Configure template for GNU tar. -*- autoconf -*-
2
3 # Copyright 1991, 1994-2010, 2013-2022 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.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])
24 AC_PREREQ([2.71])
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
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_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM(
57 [[#include <sys/types.h>
58 #include <sys/stat.h>
59 ]],
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.])
67 fi
68
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]),
75 [],
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 \
81 acl_free; do \
82 test "x$with_posix_acls" = xno && break
83 AC_SEARCH_LIBS([$tar_acl_func], [acl pacl], [], [with_posix_acls=no])
84 done
85 if test "x$with_posix_acls" != xno; then
86 AC_DEFINE(HAVE_POSIX_ACLS,,[Define when we have working POSIX acls])
87 fi
88 else
89 # disable acls in gnulib's checks
90 export enable_acl=no
91 fi
92
93 AC_TYPE_MODE_T
94 AC_TYPE_PID_T
95 AC_TYPE_OFF_T
96 AC_TYPE_UID_T
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)
103
104 gt_TYPE_SSIZE_T
105
106 # gnulib modules
107 gl_INIT
108
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
121 locale once set.])
122
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])
132 fi
133
134 # paxutils modules
135 tar_PAXUTILS
136
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],
142 [AC_PREPROC_IFELSE(
143 [AC_LANG_PROGRAM(
144 [[
145 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
146 /* ok */
147 #else
148 # error "your version of gcc is older than $1.$2"
149 #endif
150 ]]),
151 ], [$3], [$4])
152 ]
153 )
154
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)])],
158 [case $enableval in
159 yes|no) ;;
160 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
161 esac
162 gl_gcc_warnings=$enableval],
163 [gl_gcc_warnings=no
164 if test -d "$srcdir"/.git; then
165 gl_GCC_VERSION_IFELSE([11], [2], [gl_gcc_warnings=yes])
166 fi]
167 )
168
169 if test "$gl_gcc_warnings" = yes; then
170 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
171 AC_SUBST([WERROR_CFLAGS])
172
173 nw=
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"
184
185 gl_MANYWARN_ALL_GCC([ws])
186 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
187 for w in $ws; do
188 gl_WARN_ADD([$w])
189 done
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])
194
195 gl_WARN_ADD([-fdiagnostics-show-option])
196 gl_WARN_ADD([-funit-at-a-time])
197
198
199 AC_SUBST([WARN_CFLAGS])
200
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
207 #endif
208 ])
209 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
210
211 # Use a slightly smaller set of warning options for lib/.
212 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
213 nw=
214 nw="$nw -Wmissing-prototypes"
215 nw="$nw -Wunused-macros"
216 #
217 # These are for argp.
218 nw="$nw -Wmissing-field-initializers"
219 nw="$nw -Wshadow"
220 #
221 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
222
223 # This is also for argp.
224 gl_WARN_ADD([-Wno-missing-field-initializers], [GNULIB_WARN_CFLAGS])
225
226 AC_SUBST([GNULIB_WARN_CFLAGS])
227
228 # For gnulib-tests, the set is slightly smaller still.
229 nw=
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])
235 fi
236
237 TAR_HEADERS_ATTR_XATTR_H
238
239 AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
240
241 AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
242 AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
243 AC_CHECK_DECLS([time],,, [#include <time.h>])
244
245 AC_REPLACE_FUNCS(waitpid)
246
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
250 tar_cv_path_RSH=$RSH
251 else
252 tar_cv_path_RSH=no
253 for ac_file in /usr/ucb/rsh /usr/bin/remsh /usr/bin/rsh /usr/bsd/rsh \
254 /usr/bin/nsh /usr/bin/rcmd
255 do
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
262 else
263 tar_cv_path_RSH=$ac_file
264 break
265 fi
266 fi
267 done
268 fi])
269 if test $tar_cv_path_RSH = no; then
270 AC_CHECK_HEADERS(netdb.h)
271 else
272 AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$tar_cv_path_RSH",
273 [Define to the full path of your rsh, if any.])
274 fi
275
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)
284
285 AC_MSG_CHECKING(for default archive format)
286
287 AC_ARG_VAR([DEFAULT_ARCHIVE_FORMAT],
288 [Set the default archive format. Allowed values are: V7, OLDGNU, USTAR, POSIX, GNU. Default is GNU])
289
290 if test -z "$DEFAULT_ARCHIVE_FORMAT"; then
291 DEFAULT_ARCHIVE_FORMAT="GNU"
292 fi
293 case $DEFAULT_ARCHIVE_FORMAT in
294 V7|OLDGNU|USTAR|POSIX|GNU) ;;
295 *) AC_MSG_ERROR(Invalid format name);;
296 esac
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)
300
301 AC_MSG_CHECKING(for default archive)
302
303 AC_ARG_VAR([DEFAULT_ARCHIVE],
304 [Set the name of the default archive (default: -)])
305 if test -z "$DEFAULT_ARCHIVE"; then
306 DEFAULT_ARCHIVE=-
307 else
308 if test -z "`ls $DEFAULT_ARCHIVE 2>/dev/null`"; then
309 AC_MSG_WARN(DEFAULT_ARCHIVE '$DEFAULT_ARCHIVE' not found on this system)
310 fi
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
315 *[[0-7][lmh]])
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]$//'`
319 ;;
320 *[[0-7]])
321 device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7]$//'`
322 ;;
323 *)
324 device_prefix=
325 ;;
326 esac
327 case "$device_prefix" in
328 ?*)
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.])
331 ;;
332 esac
333 fi
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)
337
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)
345
346 AC_MSG_CHECKING(for default quoting style)
347
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".])
353
354 case $DEFAULT_QUOTING_STYLE in
355 QUOTING_STYLES) ;;
356 *) AC_MSG_ERROR(Invalid quoting style);;
357 esac
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)])
362
363 # Iconv
364 AM_ICONV
365 AC_CHECK_HEADERS(iconv.h)
366 AC_CHECK_TYPE(iconv_t,:,
367 AC_DEFINE(iconv_t, int,
368 [Conversion descriptor type]),
369 [
370 #ifdef HAVE_ICONV_H
371 # include <iconv.h>
372 #endif
373 ])
374
375 # Gettext.
376 AM_GNU_GETTEXT([external], [need-formatstring-macros])
377 AM_GNU_GETTEXT_VERSION([0.21])
378
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])
383
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]),
389 [case $enableval in
390 yes) BACKUP_LIBEXEC_SCRIPTS='$(BACKUP_LIBEXEC_SCRIPTS_LIST)'
391 BACKUP_SBIN_SCRIPTS='$(BACKUP_SBIN_SCRIPTS_LIST)'
392 ;;
393 esac])
394
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'
398 else
399 BACKUP_SED_COND='/^\#IF_DATE_FORMAT_OK/,/^\#ELSE_DATE_FORMAT_OK/d;/^\#ENDIF_DATE_FORMAT_OK/d'
400 fi
401
402 AC_CONFIG_FILES([Makefile\
403 doc/Makefile\
404 gnu/Makefile\
405 lib/Makefile\
406 po/Makefile.in\
407 scripts/Makefile\
408 rmt/Makefile\
409 src/Makefile])
410 AC_OUTPUT