Debian Codegraph @

configure.ac

raw
1 # Configure template for GNU tar. -*- autoconf -*-
2
3 # Copyright 1991, 1994-2010, 2013-2023 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.35], [[email protected]])
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-format-nonliteral])
193
194 gl_WARN_ADD([-fdiagnostics-show-option])
195 gl_WARN_ADD([-funit-at-a-time])
196
197
198 AC_SUBST([WARN_CFLAGS])
199
200 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
201 AH_VERBATIM([FORTIFY_SOURCE],
202 [/* Enable compile-time and run-time bounds-checking, and some warnings,
203 without upsetting glibc 2.15+. */
204 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
205 # define _FORTIFY_SOURCE 2
206 #endif
207 ])
208 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
209
210 # Use a slightly smaller set of warning options for lib/.
211 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
212 nw=
213 nw="$nw -Wmissing-prototypes"
214 nw="$nw -Wunused-macros"
215 #
216 # These are for argp.
217 nw="$nw -Wmissing-field-initializers"
218 nw="$nw -Wshadow"
219 #
220 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
221
222 # This is also for argp.
223 gl_WARN_ADD([-Wno-missing-field-initializers], [GNULIB_WARN_CFLAGS])
224
225 AC_SUBST([GNULIB_WARN_CFLAGS])
226
227 # For gnulib-tests, the set is slightly smaller still.
228 nw=
229 # It's not worth being this picky about test programs.
230 nw="$nw -Wsuggest-attribute=const"
231 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
232 [$GNULIB_WARN_CFLAGS], [$nw])
233 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
234 fi
235
236 TAR_HEADERS_ATTR_XATTR_H
237
238 AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
239
240 AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
241 AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
242 AC_CHECK_DECLS([time],,, [#include <time.h>])
243
244 AC_REPLACE_FUNCS(waitpid)
245
246 AC_ARG_VAR([RSH], [Configure absolute path to default remote shell binary])
247 AC_CACHE_CHECK(for remote shell, tar_cv_path_RSH,
248 [if test -n "$RSH"; then
249 tar_cv_path_RSH=$RSH
250 else
251 tar_cv_path_RSH=no
252 for ac_file in /usr/ucb/rsh /usr/bin/remsh /usr/bin/rsh /usr/bsd/rsh \
253 /usr/bin/nsh /usr/bin/rcmd
254 do
255 # Prefer a non-symlink rsh to a symlink one, so that binaries built
256 # on AIX 4.1.4, where /usr/ucb/rsh is a symlink to /usr/bin/rsh
257 # will run on AIX 4.3.0, which has only /usr/bin/rsh.
258 if test -f $ac_file; then
259 if (test -h $ac_file) 2>/dev/null; then
260 test $tar_cv_path_RSH = no && tar_cv_path_RSH=$ac_file
261 else
262 tar_cv_path_RSH=$ac_file
263 break
264 fi
265 fi
266 done
267 fi])
268 if test $tar_cv_path_RSH = no; then
269 AC_CHECK_HEADERS(netdb.h)
270 else
271 AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$tar_cv_path_RSH",
272 [Define to the full path of your rsh, if any.])
273 fi
274
275 TAR_COMPR_PROGRAM(compress)
276 TAR_COMPR_PROGRAM(gzip)
277 TAR_COMPR_PROGRAM(bzip2)
278 TAR_COMPR_PROGRAM(lzip)
279 TAR_COMPR_PROGRAM(lzma)
280 TAR_COMPR_PROGRAM(lzop)
281 TAR_COMPR_PROGRAM(xz)
282 TAR_COMPR_PROGRAM(zstd)
283
284 AC_MSG_CHECKING(for default archive format)
285
286 AC_ARG_VAR([DEFAULT_ARCHIVE_FORMAT],
287 [Set the default archive format. Allowed values are: V7, OLDGNU, USTAR, POSIX, GNU. Default is GNU])
288
289 if test -z "$DEFAULT_ARCHIVE_FORMAT"; then
290 DEFAULT_ARCHIVE_FORMAT="GNU"
291 fi
292 case $DEFAULT_ARCHIVE_FORMAT in
293 V7|OLDGNU|USTAR|POSIX|GNU) ;;
294 *) AC_MSG_ERROR(Invalid format name);;
295 esac
296 AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE_FORMAT, ${DEFAULT_ARCHIVE_FORMAT}_FORMAT,
297 [By default produce archives of this format])
298 AC_MSG_RESULT($DEFAULT_ARCHIVE_FORMAT)
299
300 AC_MSG_CHECKING(for default archive)
301
302 AC_ARG_VAR([DEFAULT_ARCHIVE],
303 [Set the name of the default archive (default: -)])
304 if test -z "$DEFAULT_ARCHIVE"; then
305 DEFAULT_ARCHIVE=-
306 else
307 if test -z "`ls $DEFAULT_ARCHIVE 2>/dev/null`"; then
308 AC_MSG_WARN(DEFAULT_ARCHIVE '$DEFAULT_ARCHIVE' not found on this system)
309 fi
310 # FIXME: Look for DEFTAPE in <sys/mtio.h>.
311 # FIXME: Let DEVICE_PREFIX be configured from the environment.
312 # FIXME: Rearrange, here.
313 case $DEFAULT_ARCHIVE in
314 *[[0-7][lmh]])
315 AC_DEFINE(DENSITY_LETTER, 1,
316 [Define to 1 if density may be indicated by [lmh] at end of device.])
317 device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7][lmh]$//'`
318 ;;
319 *[[0-7]])
320 device_prefix=`echo $DEFAULT_ARCHIVE | sed 's/[0-7]$//'`
321 ;;
322 *)
323 device_prefix=
324 ;;
325 esac
326 case "$device_prefix" in
327 ?*)
328 AC_DEFINE_UNQUOTED(DEVICE_PREFIX, "$device_prefix",
329 [Define to a string giving the prefix of the default device, without the part specifying the unit and density.])
330 ;;
331 esac
332 fi
333 AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE, "$DEFAULT_ARCHIVE",
334 [Define to a string giving the full name of the default archive file.])
335 AC_MSG_RESULT($DEFAULT_ARCHIVE)
336
337 AC_ARG_VAR([DEFAULT_BLOCKING],
338 [Define default blocking factor (default: 20)])
339 AC_MSG_CHECKING(for default blocking)
340 DEFAULT_BLOCKING=${DEFAULT_BLOCKING-20}
341 AC_DEFINE_UNQUOTED(DEFAULT_BLOCKING, $DEFAULT_BLOCKING,
342 [Define to a number giving the default blocking size for archives.])
343 AC_MSG_RESULT($DEFAULT_BLOCKING)
344
345 AC_MSG_CHECKING(for default quoting style)
346
347 m4_define([QUOTING_STYLES],dnl
348 [literal|shell|shell-always|c|escape|locale|clocale])
349 DEFAULT_QUOTING_STYLE="escape"
350 AC_ARG_VAR([DEFAULT_QUOTING_STYLE],
351 [Set the default quoting style. Allowed values are: ] m4_bpatsubst(QUOTING_STYLES,[|], [[, ]]) [. Default is "escape".])
352
353 case $DEFAULT_QUOTING_STYLE in
354 QUOTING_STYLES) ;;
355 *) AC_MSG_ERROR(Invalid quoting style);;
356 esac
357 AC_MSG_RESULT($DEFAULT_QUOTING_STYLE)
358 DEFAULT_QUOTING_STYLE=`echo ${DEFAULT_QUOTING_STYLE}|sed 's/-/_/g'`_quoting_style
359 AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE,
360 [Define to a default quoting style (see lib/quoteargs.c for the list)])
361
362 # Iconv
363 AM_ICONV
364 AC_CHECK_HEADERS(iconv.h)
365 AC_CHECK_TYPE(iconv_t,:,
366 AC_DEFINE(iconv_t, int,
367 [Conversion descriptor type]),
368 [
369 #ifdef HAVE_ICONV_H
370 # include <iconv.h>
371 #endif
372 ])
373
374 # Gettext.
375 AM_GNU_GETTEXT([external], [need-formatstring-macros])
376 AM_GNU_GETTEXT_VERSION([0.21])
377
378 # Initialize the test suite.
379 AC_CONFIG_TESTDIR(tests)
380 AC_CONFIG_FILES([tests/Makefile tests/atlocal]) # FIXME: tests/preset?
381 AM_MISSING_PROG([AUTOM4TE], [autom4te])
382
383 AC_SUBST(BACKUP_LIBEXEC_SCRIPTS)
384 AC_SUBST(BACKUP_SBIN_SCRIPTS)
385 AC_ARG_ENABLE(backup-scripts,
386 AS_HELP_STRING([--enable-backup-scripts],
387 [Create and install backup and restore scripts]),
388 [case $enableval in
389 yes) BACKUP_LIBEXEC_SCRIPTS='$(BACKUP_LIBEXEC_SCRIPTS_LIST)'
390 BACKUP_SBIN_SCRIPTS='$(BACKUP_SBIN_SCRIPTS_LIST)'
391 ;;
392 esac])
393
394 AC_SUBST(BACKUP_SED_COND)
395 if date +%Y-%m-%d 2>/dev/null >&2; then
396 BACKUP_SED_COND='/^\#ELSE_DATE_FORMAT_OK/,/^\#ENDIF_DATE_FORMAT_OK/d;/^\#IF_DATE_FORMAT_OK/d'
397 else
398 BACKUP_SED_COND='/^\#IF_DATE_FORMAT_OK/,/^\#ELSE_DATE_FORMAT_OK/d;/^\#ENDIF_DATE_FORMAT_OK/d'
399 fi
400
401 AC_CONFIG_FILES([Makefile\
402 doc/Makefile\
403 gnu/Makefile\
404 lib/Makefile\
405 po/Makefile.in\
406 scripts/Makefile\
407 rmt/Makefile\
408 src/Makefile])
409 AC_OUTPUT