]> git.ipfire.org Git - thirdparty/libarchive.git/blob - configure.ac
Allow tests to pass after 2038 (#1838)
[thirdparty/libarchive.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl First, define all of the version numbers up front.
4 dnl In particular, this allows the version macro to be used in AC_INIT
5
6 dnl These first two version numbers are updated automatically on each release.
7 m4_define([LIBARCHIVE_VERSION_S],[3.6.3dev])
8 m4_define([LIBARCHIVE_VERSION_N],[3006003])
9
10 dnl bsdtar and bsdcpio versioning tracks libarchive
11 m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
12 m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())
13 m4_define([BSDCAT_VERSION_S],LIBARCHIVE_VERSION_S())
14
15 AC_PREREQ([2.71])
16
17 #
18 # Now starts the "real" configure script.
19 #
20
21 AC_INIT([libarchive],[LIBARCHIVE_VERSION_S()],[libarchive-discuss@googlegroups.com])
22 # Make sure the srcdir contains "libarchive" directory
23 AC_CONFIG_SRCDIR([libarchive])
24 # Use auxiliary subscripts from this subdirectory (cleans up root)
25 AC_CONFIG_AUX_DIR([build/autoconf])
26 # M4 scripts
27 AC_CONFIG_MACRO_DIR([build/autoconf])
28 # Must follow AC_CONFIG macros above...
29 AM_INIT_AUTOMAKE([1.11 dist-xz dist-zip])
30 AM_MAINTAINER_MODE([enable])
31 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
32
33 # Libtool's "interface version" can be computed from the libarchive version.
34
35 # Libtool interface version bumps on any API change, so increments
36 # whenever libarchive minor version does.
37 ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
38 # Libarchive 2.7 == libtool interface 9 = 2 + 7
39 # Libarchive 2.8 == libtool interface 10 = 2 + 8
40 # Libarchive 2.9 == libtool interface 11 = 2 + 8
41 # Libarchive 3.0 == libtool interface 12
42 # Libarchive 3.1 == libtool interface 13
43 ARCHIVE_INTERFACE=`echo $((13 + ${ARCHIVE_MINOR}))`
44 # Libarchive revision is bumped on any source change === libtool revision
45 ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
46 # Libarchive minor is bumped on any interface addition === libtool age
47 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_INTERFACE:$ARCHIVE_REVISION:$ARCHIVE_MINOR
48
49 # Stick the version numbers into config.h
50 AC_DEFINE([__LIBARCHIVE_CONFIG_H_INCLUDED], [1],
51 [Internal macro for sanity checks])
52 AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
53 [Version number of libarchive])
54 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
55 [Version number of libarchive as a single integer])
56 AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
57 [Version number of bsdcpio])
58 AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
59 [Version number of bsdtar])
60 AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
61 [Version number of bsdcat])
62
63 # The shell variables here must be the same as the AC_SUBST() variables
64 # below, but the shell variable names apparently cannot be the same as
65 # the m4 macro names above. Why? Ask autoconf.
66 BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
67 BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
68 BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
69 LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
70 LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
71
72 # Substitute the above version numbers into the various files below.
73 # Yes, I believe this is the fourth time we define what are essentially
74 # the same symbols. Why? Ask autoconf.
75 AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
76 AC_SUBST(BSDCPIO_VERSION_STRING)
77 AC_SUBST(BSDTAR_VERSION_STRING)
78 AC_SUBST(BSDCAT_VERSION_STRING)
79 AC_SUBST(LIBARCHIVE_VERSION_STRING)
80 AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
81
82 AC_CONFIG_HEADERS([config.h])
83 AC_CONFIG_FILES([Makefile])
84 AC_CONFIG_FILES([build/pkgconfig/libarchive.pc])
85
86 # Check for host type
87 AC_CANONICAL_HOST
88
89 dnl Compilation on mingw and Cygwin needs special Makefile rules
90 inc_windows_files=no
91 inc_cygwin_files=no
92 case "$host_os" in
93 *mingw* ) inc_windows_files=yes ;;
94 *cygwin* | *msys*) inc_cygwin_files=yes ;;
95 esac
96 AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
97 AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
98
99 dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
100 PLATFORMCPPFLAGS=
101 case "$host_os" in
102 *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO -D__MINGW_USE_VC2005_COMPAT ;;
103 esac
104 AC_SUBST(PLATFORMCPPFLAGS)
105
106 # Checks for programs.
107 AC_PROG_CC
108 AM_PROG_CC_C_O
109 AC_PROG_CPP
110 AC_USE_SYSTEM_EXTENSIONS
111 AC_LIBTOOL_WIN32_DLL
112 AC_PROG_LIBTOOL
113 AC_CHECK_TOOL([STRIP],[strip])
114 AC_PROG_MKDIR_P
115
116 #
117 # Options for building bsdtar.
118 #
119 # Default is to build bsdtar, but allow people to override that.
120 #
121 AC_ARG_ENABLE([bsdtar],
122 [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
123 AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
124 AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
125 AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
126 [], [enable_bsdtar=yes])
127
128 case "$enable_bsdtar" in
129 yes)
130 if test "$enable_static" = "no"; then
131 static_bsdtar=no
132 else
133 static_bsdtar=yes
134 fi
135 build_bsdtar=yes
136 ;;
137 dynamic|shared)
138 if test "$enable_shared" = "no"; then
139 AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
140 fi
141 build_bsdtar=yes
142 static_bsdtar=no
143 ;;
144 static)
145 build_bsdtar=yes
146 static_bsdtar=yes
147 ;;
148 no)
149 build_bsdtar=no
150 static_bsdtar=no
151 ;;
152 *)
153 AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
154 ;;
155 esac
156
157 AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
158 AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
159
160 #
161 # Options for building bsdcat.
162 #
163 # Default is to build bsdcat, but allow people to override that.
164 #
165 AC_ARG_ENABLE([bsdcat],
166 [AS_HELP_STRING([--enable-bsdcat], [enable build of bsdcat (default)])
167 AS_HELP_STRING([--enable-bsdcat=static], [force static build of bsdcat])
168 AS_HELP_STRING([--enable-bsdcat=shared], [force dynamic build of bsdcat])
169 AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
170 [], [enable_bsdcat=yes])
171
172 case "$enable_bsdcat" in
173 yes)
174 if test "$enable_static" = "no"; then
175 static_bsdcat=no
176 else
177 static_bsdcat=yes
178 fi
179 build_bsdcat=yes
180 ;;
181 dynamic|shared)
182 if test "$enable_shared" = "no"; then
183 AC_MSG_FAILURE([Shared linking of bsdcat requires shared libarchive])
184 fi
185 build_bsdcat=yes
186 static_bsdcat=no
187 ;;
188 static)
189 build_bsdcat=yes
190 static_bsdcat=yes
191 ;;
192 no)
193 build_bsdcat=no
194 static_bsdcat=no
195 ;;
196 *)
197 AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
198 ;;
199 esac
200
201 AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
202 AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
203
204 #
205 # Options for building bsdcpio.
206 #
207 # Default is not to build bsdcpio, but that can be overridden.
208 #
209 AC_ARG_ENABLE([bsdcpio],
210 [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
211 AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
212 AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
213 AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
214 [], [enable_bsdcpio=yes])
215
216 case "$enable_bsdcpio" in
217 yes)
218 if test "$enable_static" = "no"; then
219 static_bsdcpio=no
220 else
221 static_bsdcpio=yes
222 fi
223 build_bsdcpio=yes
224 ;;
225 dynamic|shared)
226 if test "$enabled_shared" = "no"; then
227 AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
228 fi
229 build_bsdcpio=yes
230 ;;
231 static)
232 build_bsdcpio=yes
233 static_bsdcpio=yes
234 ;;
235 no)
236 build_bsdcpio=no
237 static_bsdcpio=no
238 ;;
239 *)
240 AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
241 ;;
242 esac
243
244 AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
245 AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
246
247 # Set up defines needed before including any headers
248 case $host in
249 *mingw* | *cygwin* | *msys* )
250 AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
251 [[#ifdef _WIN32_WINNT
252 # error _WIN32_WINNT already defined
253 #endif
254 ]],[[;]])
255 ],[
256 AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
257 AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
258 ])
259 AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
260 [[#ifdef WINVER
261 # error WINVER already defined
262 #endif
263 ]],[[;]])
264 ],[
265 AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
266 ])
267 ;;
268 esac
269
270 # Checks for header files.
271 AC_HEADER_DIRENT
272 AC_HEADER_SYS_WAIT
273 AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h])
274 AC_CHECK_HEADERS([copyfile.h ctype.h])
275 AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
276
277 AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
278 [ac_cv_have_decl_EXT2_IOC_GETFLAGS],
279 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
280 @%:@include <ext2fs/ext2_fs.h>],
281 [int x = EXT2_IOC_GETFLAGS])],
282 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])],
283 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])])
284
285 AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
286 [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1],
287 [Define to 1 if you have a working EXT2_IOC_GETFLAGS])])
288
289 AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
290 AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
291
292 AC_CACHE_CHECK([whether FS_IOC_GETFLAGS is usable],
293 [ac_cv_have_decl_FS_IOC_GETFLAGS],
294 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
295 @%:@include <linux/fs.h>],
296 [int x = FS_IOC_GETFLAGS])],
297 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes])],
298 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [no])])])
299
300 AS_VAR_IF([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes],
301 [AC_DEFINE_UNQUOTED([HAVE_WORKING_FS_IOC_GETFLAGS], [1],
302 [Define to 1 if you have a working FS_IOC_GETFLAGS])])
303
304 AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h])
305 AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
306 AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
307 AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h])
308 AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
309 AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
310 AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h])
311 AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
312 AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
313 AC_CHECK_HEADERS([windows.h])
314 # check windows.h first; the other headers require it.
315 AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
316 [[#ifdef HAVE_WINDOWS_H
317 # include <windows.h>
318 #endif
319 ]])
320
321 # Checks for libraries.
322 AC_ARG_WITH([zlib],
323 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
324
325 if test "x$with_zlib" != "xno"; then
326 AC_CHECK_HEADERS([zlib.h])
327 AC_CHECK_LIB(z,inflate)
328 fi
329
330 AC_ARG_WITH([bz2lib],
331 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
332
333 if test "x$with_bz2lib" != "xno"; then
334 AC_CHECK_HEADERS([bzlib.h])
335 case "$host_os" in
336 *mingw* | *cygwin* | *msys*)
337 dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
338 dnl use AC_LINK_IFELSE.
339 AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
340 old_LIBS="$LIBS"
341 LIBS="-lbz2 $LIBS"
342 AC_LINK_IFELSE(
343 [AC_LANG_SOURCE(#include <bzlib.h>
344 int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
345 [ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
346 [ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
347 LIBS="$old_LIBS"
348 AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
349 if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
350 AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
351 LIBS="-lbz2 $LIBS"
352 fi
353 ;;
354 *)
355 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
356 ;;
357 esac
358 fi
359
360 AC_ARG_WITH([libb2],
361 AS_HELP_STRING([--without-libb2], [Don't build support for BLAKE2 through libb2]))
362
363 if test "x$with_libb2" != "xno"; then
364 AC_CHECK_HEADERS([blake2.h])
365 AC_CHECK_LIB(b2,blake2sp_init)
366 fi
367
368 AM_CONDITIONAL([INC_BLAKE2], [test "x$ac_cv_lib_b2_blake2sp_init" != "xyes"])
369
370 AC_ARG_WITH([iconv],
371 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
372
373 if test "x$with_iconv" != "xno"; then
374 AM_ICONV
375 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
376 if test "x$am_cv_func_iconv" = "xyes"; then
377 AC_CHECK_HEADERS([localcharset.h])
378 am_save_LIBS="$LIBS"
379 LIBS="${LIBS} ${LIBICONV}"
380 if test -n "$LIBICONV"; then
381 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
382 fi
383 AC_CHECK_FUNCS([locale_charset])
384 LIBS="${am_save_LIBS}"
385 if test "x$ac_cv_func_locale_charset" != "xyes"; then
386 # If locale_charset() is not in libiconv, we have to find libcharset.
387 AC_CHECK_LIB(charset,locale_charset)
388 fi
389 fi
390 fi
391
392 AC_ARG_WITH([lz4],
393 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
394
395 if test "x$with_lz4" != "xno"; then
396 AC_CHECK_HEADERS([lz4.h lz4hc.h])
397 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
398 fi
399
400 AC_ARG_WITH([zstd],
401 AS_HELP_STRING([--without-zstd], [Don't build support for zstd through libzstd]))
402
403 if test "x$with_zstd" != "xno"; then
404 AC_CHECK_HEADERS([zstd.h])
405 AC_CHECK_LIB(zstd,ZSTD_decompressStream)
406 AC_CHECK_LIB(zstd,ZSTD_compressStream,
407 AC_DEFINE([HAVE_LIBZSTD_COMPRESSOR], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.]))
408 fi
409
410 AC_ARG_WITH([lzma],
411 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
412
413 if test "x$with_lzma" != "xno"; then
414 AC_CHECK_HEADERS([lzma.h])
415 AC_CHECK_LIB(lzma,lzma_stream_decoder)
416 # Some pre-release (but widely distributed) versions of liblzma
417 # included a disabled version of lzma_stream_encoder_mt that
418 # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
419 # to do something more complex here:
420 AC_CACHE_CHECK(
421 [whether we have multithread support in lzma],
422 ac_cv_lzma_has_mt,
423 [AC_LINK_IFELSE([
424 AC_LANG_PROGRAM([[#include <lzma.h>]
425 [#if LZMA_VERSION < 50020000]
426 [#error unsupported]
427 [#endif]],
428 [[lzma_stream_encoder_mt(0, 0);]])],
429 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
430 if test "x$ac_cv_lzma_has_mt" != xno; then
431 AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
432 fi
433 fi
434
435 AC_ARG_WITH([lzo2],
436 AS_HELP_STRING([--with-lzo2], [Build with LZO support from liblzo2]))
437
438 if test "x$with_lzo2" = "xyes"; then
439 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
440 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
441 fi
442
443 AC_ARG_WITH([cng],
444 AS_HELP_STRING([--without-cng], [Don't build support of CNG(Crypto Next Generation)]))
445
446 AC_ARG_WITH([mbedtls],
447 AS_HELP_STRING([--with-mbedtls], [Build with crypto support from mbed TLS]))
448 AC_ARG_WITH([nettle],
449 AS_HELP_STRING([--with-nettle], [Build with crypto support from Nettle]))
450 AC_ARG_WITH([openssl],
451 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
452 case "$host_os" in
453 *darwin* ) with_openssl=no ;;
454 esac
455
456 AC_ARG_WITH([xml2],
457 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
458 AC_ARG_WITH([expat],
459 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
460
461 if test "x$with_xml2" != "xno"; then
462 PKG_PROG_PKG_CONFIG
463 PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
464 CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
465 LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
466 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
467 ], [
468 AC_CHECK_LIB(xml2,xmlInitParser)
469 ])
470 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
471 fi
472 if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
473 if test "x$with_expat" != "xno"; then
474 AC_CHECK_HEADERS([expat.h])
475 AC_CHECK_LIB(expat,XML_ParserCreate)
476 fi
477 fi
478
479 AC_ARG_ENABLE([posix-regex-lib],
480 [AS_HELP_STRING([--enable-posix-regex-lib],
481 [choose what library to use for POSIX regular expression support (default: auto)])
482 AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
483 AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
484 AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
485 AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
486 [], [enable_posix_regex_lib=auto])
487
488 posix_regex_lib_found=
489 if test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libc" || test "$enable_posix_regex_lib" = "libregex"; then
490 AC_CHECK_HEADERS([regex.h])
491 if test "x$ac_cv_header_regex_h" != "xno"; then
492 AC_CHECK_FUNC(regcomp)
493 if test "x$ac_cv_func_regcomp" = xyes; then
494 posix_regex_lib_found=1
495 else
496 AC_CHECK_LIB(regex,regcomp)
497 if test "x$ac_cv_lib_regex_regcomp" = xyes; then
498 posix_regex_lib_found=1
499 fi
500 fi
501 fi
502 fi
503 if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcreposix"); then
504 AC_CHECK_HEADERS([pcreposix.h])
505 AC_CHECK_LIB(pcreposix,regcomp)
506 if test "x$ac_cv_lib_pcreposix_regcomp" != xyes; then
507 AC_MSG_NOTICE(trying libpcreposix check again with libpcre)
508 unset ac_cv_lib_pcreposix_regcomp
509 AC_CHECK_LIB(pcre,pcre_exec)
510 AC_CHECK_LIB(pcreposix,regcomp)
511 if test "x$ac_cv_lib_pcre_pcre_exec" = xyes && test "x$ac_cv_lib_pcreposix_regcomp" = xyes; then
512 AC_MSG_CHECKING(if PCRE_STATIC needs to be defined)
513 AC_LINK_IFELSE(
514 [AC_LANG_SOURCE(#include <pcreposix.h>
515 int main() { return regcomp(NULL, NULL, 0); })],
516 [without_pcre_static=yes],
517 [without_pcre_static=no])
518 AC_LINK_IFELSE(
519 [AC_LANG_SOURCE(#define PCRE_STATIC
520 #include <pcreposix.h>
521 int main() { return regcomp(NULL, NULL, 0); })],
522 [with_pcre_static=yes],
523 [with_pcre_static=no])
524 if test "x$without_pcre_static" != xyes && test "x$with_pcre_static" = xyes; then
525 AC_MSG_RESULT(yes)
526 AC_DEFINE([PCRE_STATIC], [1], [Define to 1 if PCRE_STATIC needs to be defined.])
527 elif test "x$without_pcre_static" = xyes || test "x$with_pcre_static" = xyes; then
528 AC_MSG_RESULT(no)
529 fi
530 posix_regex_lib_found=1
531 fi
532 else
533 posix_regex_lib_found=1
534 fi
535 fi
536
537 # TODO: Give the user the option of using a pre-existing system
538 # libarchive. This will define HAVE_LIBARCHIVE which will cause
539 # bsdtar_platform.h to use #include <...> for the libarchive headers.
540 # Need to include Makefile.am magic to link against system
541 # -larchive in that case.
542 #AC_CHECK_LIB(archive,archive_version)
543
544 # Checks for supported compiler flags
545 AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
546
547 # Place the functions and data into separate sections, allowing the linker
548 # to garbage collect the unused ones.
549 save_LDFLAGS=$LDFLAGS
550 LDFLAGS="$LDFLAGS -Wl,--gc-sections"
551 AC_MSG_CHECKING([whether ld supports --gc-sections])
552 AC_LINK_IFELSE(
553 [AC_LANG_SOURCE([static char UnusedFunc() { return 5; } int main() { return 0;}])],
554 [AC_MSG_RESULT([yes])
555 GC_SECTIONS="-Wl,--gc-sections";
556 AX_APPEND_COMPILE_FLAGS([-ffunction-sections -fdata-sections])],
557 [AC_MSG_RESULT([no])
558 GC_SECTIONS="";])
559 LDFLAGS=$save_LDFLAGS
560
561 AC_SUBST(GC_SECTIONS)
562
563 # Checks for typedefs, structures, and compiler characteristics.
564 AC_C_CONST
565 # la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
566 # and MSVC. Use a customized version.
567 la_TYPE_UID_T
568 AC_TYPE_MODE_T
569 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
570 # most systems... default to "long long" instead.
571 AC_CHECK_TYPE(off_t, [long long])
572 AC_TYPE_SIZE_T
573 AC_CHECK_TYPE(id_t, [unsigned long])
574 AC_CHECK_TYPE(uintptr_t, [unsigned int])
575
576 # Check for tm_gmtoff in struct tm
577 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
578 [
579 #include <time.h>
580 ])
581
582 # Check for f_namemax in struct statfs
583 AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
584 [
585 #include <sys/param.h>
586 #include <sys/mount.h>
587 ])
588
589 # Check for f_iosize in struct statfs
590 AC_CHECK_MEMBERS([struct statfs.f_iosize],,,
591 [
592 #include <sys/param.h>
593 #include <sys/mount.h>
594 ])
595
596 # Check for f_iosize in struct statvfs
597 AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
598 [
599 #include <sys/statvfs.h>
600 ])
601
602 # Check for birthtime in struct stat
603 AC_CHECK_MEMBERS([struct stat.st_birthtime])
604
605 # Check for high-resolution timestamps in struct stat
606 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
607 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
608 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
609 AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
610 AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
611 AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
612 # Check for block size support in struct stat
613 AC_CHECK_MEMBERS([struct stat.st_blksize])
614 # Check for st_flags in struct stat (BSD fflags)
615 AC_CHECK_MEMBERS([struct stat.st_flags])
616
617 # If you have uintmax_t, we assume printf supports %ju
618 # If you have unsigned long long, we assume printf supports %llu
619 # TODO: Check for %ju and %llu support directly.
620 AC_CHECK_TYPES([uintmax_t, unsigned long long])
621
622 # We use C99-style integer types
623 # Declare them if the local platform doesn't already do so.
624 AC_TYPE_INTMAX_T
625 AC_TYPE_UINTMAX_T
626 AC_TYPE_INT64_T
627 AC_TYPE_UINT64_T
628 AC_TYPE_INT32_T
629 AC_TYPE_UINT32_T
630 AC_TYPE_INT16_T
631 AC_TYPE_UINT16_T
632 AC_TYPE_UINT8_T
633
634 AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
635 AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
636 AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
637
638 AC_CHECK_DECL([SSIZE_MAX],
639 [AC_DEFINE(HAVE_DECL_SSIZE_MAX, 1, [Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you don't.])],
640 [],
641 [#include <limits.h>])
642
643 AC_CHECK_DECL([EFTYPE],
644 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
645 [],
646 [#include <errno.h>])
647 AC_CHECK_DECL([EILSEQ],
648 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
649 [],
650 [#include <errno.h>])
651 AC_CHECK_TYPE([wchar_t],
652 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
653 AC_CHECK_SIZEOF([wchar_t])],
654 [])
655
656 AX_COMPILE_CHECK_SIZEOF(int)
657 AX_COMPILE_CHECK_SIZEOF(long)
658
659 AC_CHECK_HEADERS_ONCE([sys/time.h])
660
661 # Checks for library functions.
662 AC_PROG_GCC_TRADITIONAL
663 AC_HEADER_MAJOR
664 AC_FUNC_FSEEKO
665 AC_FUNC_MEMCMP
666 AC_FUNC_LSTAT
667 AC_FUNC_STAT
668 AC_FUNC_STRERROR_R
669 AC_FUNC_STRFTIME
670 AC_FUNC_VPRINTF
671 # check for:
672 # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
673 # To avoid necessity for including windows.h or special forward declaration
674 # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
675 AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
676 AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r])
677 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
678 AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
679 AC_CHECK_FUNCS([futimens futimes futimesat])
680 AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
681 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
682 AC_CHECK_FUNCS([lchflags lchmod lchown link linkat localtime_r lstat lutimes])
683 AC_CHECK_FUNCS([mbrtowc memmove memset])
684 AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
685 AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
686 AC_CHECK_FUNCS([readpassphrase])
687 AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
688 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
689 AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
690 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
691 AC_CHECK_FUNCS([_fseeki64 _get_timezone])
692 AC_CHECK_DECL([cmtime_s],
693 [AC_DEFINE(HAVE_CMTIME_S, 1, [cmtime_s function])],
694 [],
695 [#include <time.h>])
696 AC_CHECK_DECL([gmtime_s],
697 [AC_DEFINE(HAVE_GMTIME_S, 1, [gmtime_s function])],
698 [],
699 [#include <time.h>])
700 AC_CHECK_TYPE([localtime_s],
701 [AC_DEFINE(HAVE_LOCALTIME_S, 1, [localtime_s function])],
702 [],
703 [#include <time.h>])
704 AC_CHECK_DECL([_mkgmtime],
705 [AC_DEFINE(HAVE__MKGMTIME, 1, [_mkgmtime function])],
706 [],
707 [#include <time.h>])
708
709 # detects cygwin-1.7, as opposed to older versions
710 AC_CHECK_FUNCS([cygwin_conv_path])
711
712 # DragonFly uses vfsconf, FreeBSD xvfsconf.
713 AC_CHECK_TYPES(struct vfsconf,,,
714 [#if HAVE_SYS_TYPES_H
715 #include <sys/types.h>
716 #endif
717 #include <sys/mount.h>
718 ])
719
720 AC_CHECK_TYPES(struct xvfsconf,,,
721 [#if HAVE_SYS_TYPES_H
722 #include <sys/types.h>
723 #endif
724 #include <sys/mount.h>
725 ])
726
727 AC_CHECK_TYPES(struct statfs,,,
728 [#if HAVE_SYS_TYPES_H
729 #include <sys/types.h>
730 #endif
731 #include <sys/mount.h>
732 ])
733
734 # There are several variants of readdir_r around; we only
735 # accept the POSIX-compliant version.
736 AC_LINK_IFELSE(
737 [AC_LANG_PROGRAM([[#include <dirent.h>]],
738 [[DIR *dir; struct dirent e, *r;
739 return(readdir_r(dir, &e, &r));]])],
740 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
741 )
742 # dirfd can be either a function or a macro.
743 AC_LINK_IFELSE(
744 [AC_LANG_PROGRAM([[#include <dirent.h>
745 DIR *dir;]],
746 [[return(dirfd(dir));]])],
747 [AC_DEFINE(HAVE_DIRFD,1,[Define to 1 if you have a dirfd function or macro])]
748 )
749
750 # FreeBSD's nl_langinfo supports an option to specify whether the
751 # current locale uses month/day or day/month ordering. It makes the
752 # output a little prettier...
753 AC_CHECK_DECL([D_MD_ORDER],
754 [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
755 [],
756 [#if HAVE_LANGINFO_H
757 #include <langinfo.h>
758 #endif
759 ])
760
761 # Check for dirent.d_namlen field explicitly
762 # (This is a bit more straightforward than, if not quite as portable as,
763 # the recipe given by the autoconf maintainers.)
764 AC_CHECK_MEMBER(struct dirent.d_namlen,,,
765 [#if HAVE_DIRENT_H
766 #include <dirent.h>
767 #endif
768 ])
769
770 # Check for Extended Attributes support
771 AC_ARG_ENABLE([xattr],
772 AS_HELP_STRING([--disable-xattr],
773 [Disable Extended Attributes support (default: check)]))
774
775 if test "x$enable_xattr" != "xno"; then
776 AC_SEARCH_LIBS([setxattr], [attr gnu])
777 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
778 #include <sys/extattr.h>
779 ])
780 AC_CHECK_DECLS([XATTR_NOFOLLOW], [], [], [#include <sys/xattr.h>
781 ])
782 if test "x$ac_cv_header_sys_xattr_h" = "xyes" \
783 -a "x$ac_cv_have_decl_XATTR_NOFOLLOW" = "xyes"; then
784 # Darwin extended attributes support
785 AC_CACHE_VAL([ac_cv_archive_xattr_darwin],
786 [AC_CHECK_FUNCS(fgetxattr \
787 flistxattr \
788 fsetxattr \
789 getxattr \
790 listxattr \
791 setxattr,
792 [ac_cv_archive_xattr_darwin=yes],
793 [ac_cv_archive_xattr_darwin=no],
794 [#include <sys/xattr.h>
795 ])
796 ]
797 )
798 elif test "x$ac_cv_header_sys_extattr_h" = "xyes" \
799 -a "x$ac_cv_have_decl_EXTATTR_NAMESPACE_USER" = "xyes"; then
800 # FreeBSD extended attributes support
801 AC_CACHE_VAL([ac_cv_archive_xattr_freebsd],
802 [AC_CHECK_FUNCS(extattr_get_fd \
803 extattr_get_file \
804 extattr_get_link \
805 extattr_list_fd \
806 extattr_list_file \
807 extattr_list_link \
808 extattr_set_fd \
809 extattr_set_link,
810 [ac_cv_archive_xattr_freebsd=yes],
811 [ac_cv_archive_xattr_freebsd=no],
812 [#include <sys/types.h>
813 #include <sys/extattr.h>
814 ])
815 ]
816 )
817 elif test "x$ac_cv_header_sys_xattr_h" = "xyes" \
818 -o "x$ac_cv_header_attr_xattr_h" = "xyes"; then
819 # Linux extended attributes support
820 AC_CACHE_VAL([ac_cv_archive_xattr_linux],
821 [AC_CHECK_FUNCS(fgetxattr \
822 flistxattr \
823 fsetxattr \
824 getxattr \
825 lgetxattr \
826 listxattr \
827 llistxattr \
828 lsetxattr,
829 [ac_cv_archive_xattr_linux=yes],
830 [ac_cv_archive_xattr_linux=no],
831 [#if HAVE_SYS_TYPES_H
832 #include <sys/types.h>
833 #endif
834 #if HAVE_SYS_XATTR_H
835 #include <sys/xattr.h>
836 #endif
837 #if HAVE_ATTR_XATTR_H
838 #include <attr/xatr.h>
839 #endif
840 ])
841 ]
842 )
843 elif test "x$ac_cv_header_sys_ea_h" = "xyes"; then
844 # AIX extended attributes support
845 AC_CACHE_VAL([ac_cv_archive_xattr_aix],
846 [AC_CHECK_FUNCS(fgetea \
847 flistea \
848 fsetea \
849 getea \
850 lgetea \
851 listea \
852 llistea \
853 lsetea,
854 [ac_cv_archive_xattr_aix=yes],
855 [ac_cv_archive_xattr_aix=no],
856 [#include <sys/ea.h>
857 ])
858 ]
859 )
860 fi
861
862 AC_MSG_CHECKING([for extended attributes support])
863 if test "x$ac_cv_archive_xattr_linux" = "xyes"; then
864 AC_DEFINE([ARCHIVE_XATTR_LINUX], [1], [Linux xattr support])
865 AC_MSG_RESULT([Linux])
866 elif test "x$ac_cv_archive_xattr_darwin" = "xyes"; then
867 AC_DEFINE([ARCHIVE_XATTR_DARWIN], [1], [Darwin xattr support])
868 AC_MSG_RESULT([Darwin])
869 elif test "x$ac_cv_archive_xattr_freebsd" = "xyes"; then
870 AC_DEFINE([ARCHIVE_XATTR_FREEBSD], [1], [FreeBSD xattr support])
871 AC_MSG_RESULT([FreeBSD])
872 elif test "x$ac_cv_archive_xattr_aix" = "xyes"; then
873 AC_DEFINE([ARCHIVE_XATTR_AIX], [1], [AIX xattr support])
874 AC_MSG_RESULT([AIX])
875 else
876 AC_MSG_RESULT([none])
877 fi
878 fi
879
880 # Check for ACL support
881 #
882 # The ACL support in libarchive is written against the POSIX1e draft,
883 # which was never officially approved and varies quite a bit across
884 # platforms. Worse, some systems have completely non-POSIX acl functions,
885 # which makes the following checks rather more complex than I would like.
886 #
887 AC_ARG_ENABLE([acl],
888 AS_HELP_STRING([--disable-acl],
889 [Disable ACL support (default: check)]))
890
891 if test "x$enable_acl" != "xno"; then
892 # Libacl
893 AC_CHECK_LIB([acl], [acl_get_file])
894
895 AC_CHECK_TYPES([acl_t, acl_entry_t, acl_permset_t, acl_tag_t], [], [], [
896 #if HAVE_SYS_TYPES_H
897 #include <sys/types.h>
898 #endif
899 #if HAVE_SYS_ACL_H
900 #include <sys/acl.h>
901 #endif
902 ])
903
904 AC_CHECK_LIB([richacl], [richacl_get_file])
905
906 AC_CHECK_TYPES([[struct richace], [struct richacl]], [], [], [
907 #if HAVE_SYS_RICHACL_H
908 #include <sys/richacl.h>
909 #endif
910 ])
911
912 # Solaris and derivates ACLs
913 AC_CHECK_FUNCS(acl facl)
914
915 if test "x$ac_cv_lib_richacl_richacl_get_file" = "xyes" \
916 -a "x$ac_cv_type_struct_richace" = "xyes" \
917 -a "x$ac_cv_type_struct_richacl" = "xyes"; then
918 AC_CACHE_VAL([ac_cv_archive_acl_librichacl],
919 [AC_CHECK_FUNCS(richacl_alloc \
920 richacl_equiv_mode \
921 richacl_free \
922 richacl_get_fd \
923 richacl_get_file \
924 richacl_set_fd \
925 richacl_set_file,
926 [ac_cv_archive_acl_librichacl=yes], [ac_cv_archive_acl_librichacl=no], [#include <sys/richacl.h>])])
927 fi
928
929 if test "x$ac_cv_func_acl" = "xyes" \
930 -a "x$ac_cv_func_facl" = "xyes"; then
931 AC_CHECK_TYPES([aclent_t], [], [], [[#include <sys/acl.h>]])
932 if test "x$ac_cv_type_aclent_t" = "xyes"; then
933 AC_CACHE_VAL([ac_cv_archive_acl_sunos],
934 [AC_CHECK_DECLS([GETACL, SETACL, GETACLCNT],
935 [ac_cv_archive_acl_sunos=yes], [ac_cv_archive_acl_sunos=no],
936 [#include <sys/acl.h>])])
937 AC_CHECK_TYPES([ace_t], [], [], [[#include <sys/acl.h>]])
938 if test "x$ac_cv_type_ace_t" = "xyes"; then
939 AC_CACHE_VAL([ac_cv_archive_acl_sunos_nfs4],
940 [AC_CHECK_DECLS([ACE_GETACL, ACE_SETACL, ACE_GETACLCNT],
941 [ac_cv_archive_acl_sunos_nfs4=yes],
942 [ac_cv_archive_acl_sonos_nfs4=no],
943 [#include <sys/acl.h>])])
944 fi
945 fi
946 elif test "x$ac_cv_type_acl_t" = "xyes" \
947 -a "x$ac_cv_type_acl_entry_t" = "xyes" \
948 -a "x$ac_cv_type_acl_permset_t" = "xyes" \
949 -a "x$ac_cv_type_acl_tag_t" = "xyes"; then
950 # POSIX.1e ACL functions
951 AC_CACHE_VAL([ac_cv_posix_acl_funcs],
952 [AC_CHECK_FUNCS(acl_add_perm \
953 acl_clear_perms \
954 acl_create_entry \
955 acl_delete_def_file \
956 acl_free \
957 acl_get_entry \
958 acl_get_fd \
959 acl_get_file \
960 acl_get_permset \
961 acl_get_qualifier \
962 acl_get_tag_type \
963 acl_init \
964 acl_set_fd \
965 acl_set_file \
966 acl_set_qualifier \
967 acl_set_tag_type,
968 [ac_cv_posix_acl_funcs=yes], [ac_cv_posix_acl_funcs=no],
969 [#if HAVE_SYS_TYPES_H
970 #include <sys/types.h>
971 #endif
972 #if HAVE_SYS_ACL_H
973 #include <sys/acl.h>
974 #endif
975 ])
976 ])
977
978 AC_CHECK_FUNCS(acl_get_perm)
979
980 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
981 -a "x$ac_cv_header_acl_libacl_h" = "xyes" \
982 -a "x$ac_cv_lib_acl_acl_get_file" = "xyes" \
983 -a "x$ac_cv_func_acl_get_perm"; then
984 AC_CACHE_VAL([ac_cv_archive_acl_libacl],
985 [ac_cv_archive_acl_libacl=yes])
986 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
987 [POSIX.1e ACL support via libacl])
988 else
989 # FreeBSD/Darwin
990 AC_CHECK_FUNCS(acl_add_flag_np \
991 acl_clear_flags_np \
992 acl_get_brand_np \
993 acl_get_entry_type_np \
994 acl_get_flag_np \
995 acl_get_flagset_np \
996 acl_get_fd_np \
997 acl_get_link_np \
998 acl_get_perm_np \
999 acl_is_trivial_np \
1000 acl_set_entry_type_np \
1001 acl_set_fd_np \
1002 acl_set_link_np,,,
1003 [#include <sys/types.h>
1004 #include <sys/acl.h>])
1005
1006 AC_CHECK_FUNCS(mbr_uid_to_uuid \
1007 mbr_uuid_to_id \
1008 mbr_gid_to_uuid,,,
1009 [#include <membership.h>])
1010
1011 AC_CHECK_DECLS([ACL_TYPE_EXTENDED, ACL_TYPE_NFS4, ACL_USER,
1012 ACL_SYNCHRONIZE], [], [],
1013 [#include <sys/types.h>
1014 #include <sys/acl.h>])
1015 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
1016 -a "x$ac_cv_func_acl_get_fd_np" = "xyes" \
1017 -a "x$ac_cv_func_acl_get_perm" != "xyes" \
1018 -a "x$ac_cv_func_acl_get_perm_np" = "xyes" \
1019 -a "x$ac_cv_func_acl_set_fd_np" = "xyes"; then
1020 if test "x$ac_cv_have_decl_ACL_USER" = "xyes"; then
1021 AC_CACHE_VAL([ac_cv_archive_acl_freebsd],
1022 [ac_cv_archive_acl_freebsd=yes])
1023 if test "x$ac_cv_have_decl_ACL_TYPE_NFS4" = "xyes" \
1024 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
1025 -a "x$ac_cv_func_acl_get_brand_np" = "xyes" \
1026 -a "x$ac_cv_func_acl_get_entry_type_np" = "xyes" \
1027 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
1028 -a "x$ac_cv_func_acl_set_entry_type_np" = "xyes"; then
1029 AC_CACHE_VAL([ac_cv_archive_acl_freebsd_nfs4],
1030 [ac_cv_archive_acl_freebsd_nfs4=yes])
1031 fi
1032 elif test "x$ac_cv_have_decl_ACL_TYPE_EXTENDED" = "xyes" \
1033 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
1034 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
1035 -a "x$ac_cv_func_acl_get_link_np" = "xyes" \
1036 -a "x$ac_cv_func_acl_set_link_np" = "xyes" \
1037 -a "x$ac_cv_func_mbr_uid_to_uuid" = "xyes" \
1038 -a "x$ac_cv_func_mbr_uuid_to_id" = "xyes" \
1039 -a "x$ac_cv_func_mbr_gid_to_uuid" = "xyes"; then
1040 AC_CACHE_VAL([ac_cv_archive_acl_darwin],
1041 [ac_cv_archive_acl_darwin=yes])
1042 fi
1043 fi
1044 fi
1045 fi
1046 AC_MSG_CHECKING([for ACL support])
1047 if test "x$ac_cv_archive_acl_libacl" = "xyes" \
1048 -a "x$ac_cv_archive_acl_librichacl" = "xyes"; then
1049 AC_MSG_RESULT([libacl (POSIX.1e) + librichacl (NFSv4)])
1050 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1051 [Linux POSIX.1e ACL support via libacl])
1052 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
1053 [Linux NFSv4 ACL support via librichacl])
1054 elif test "x$ac_cv_archive_acl_libacl" = "xyes"; then
1055 AC_MSG_RESULT([libacl (POSIX.1e)])
1056 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1057 [Linux POSIX.1e ACL support via libacl])
1058 elif test "x$ac_cv_archive_acl_librichacl" = "xyes"; then
1059 AC_MSG_RESULT([librichacl (NFSv4)])
1060 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
1061 [Linux NFSv4 ACL support via librichacl])
1062 elif test "x$ac_cv_archive_acl_darwin" = "xyes"; then
1063 AC_DEFINE([ARCHIVE_ACL_DARWIN], [1], [Darwin ACL support])
1064 AC_MSG_RESULT([Darwin (limited NFSv4)])
1065 elif test "x$ac_cv_archive_acl_sunos" = "xyes"; then
1066 AC_DEFINE([ARCHIVE_ACL_SUNOS], [1], [Solaris ACL support])
1067 if test "x$ac_cv_archive_acl_sunos_nfs4" = "xyes"; then
1068 AC_DEFINE([ARCHIVE_ACL_SUNOS_NFS4], [1],
1069 [Solaris NFSv4 ACL support])
1070 AC_MSG_RESULT([Solaris (POSIX.1e and NFSv4)])
1071 else
1072 AC_MSG_RESULT([Solaris (POSIX.1e)])
1073 fi
1074 elif test "x$ac_cv_archive_acl_freebsd" = "xyes"; then
1075 AC_DEFINE([ARCHIVE_ACL_FREEBSD], [1], [FreeBSD ACL support])
1076 if test "x$ac_cv_archive_acl_freebsd_nfs4" = "xyes"; then
1077 AC_DEFINE([ARCHIVE_ACL_FREEBSD_NFS4], [1],
1078 [FreeBSD NFSv4 ACL support])
1079 AC_MSG_RESULT([FreeBSD (POSIX.1e and NFSv4)])
1080 else
1081 AC_MSG_RESULT([FreeBSD (POSIX.1e)])
1082 fi
1083 else
1084 AC_MSG_RESULT([none])
1085 fi
1086 fi
1087
1088
1089 AM_CONDITIONAL([INC_LINUX_ACL],
1090 [test "x$ac_cv_archive_acl_libacl" = "xyes" \
1091 -o "x$ac_cv_archive_acl_librichacl" = "xyes"])
1092 AM_CONDITIONAL([INC_SUNOS_ACL], [test "x$ac_cv_archive_acl_sunos" = "xyes"])
1093 AM_CONDITIONAL([INC_DARWIN_ACL],
1094 [test "x$ac_cv_archive_acl_darwin" = "xyes"])
1095 AM_CONDITIONAL([INC_FREEBSD_ACL],
1096 [test "x$ac_cv_archive_acl_freebsd" = "xyes"])
1097
1098 # Additional requirements
1099 AC_SYS_LARGEFILE
1100
1101 dnl NOTE: Crypto checks must run last.
1102 AC_DEFUN([CRYPTO_CHECK], [
1103 if test "$found_$1" != yes; then
1104 saved_CPPFLAGS="$CPPFLAGS"
1105 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
1106 touch "check_crypto_md.h"
1107 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_$2])
1108 AC_LINK_IFELSE([AC_LANG_SOURCE([
1109 #define ARCHIVE_$1_COMPILE_TEST
1110 #define ARCHIVE_CRYPTO_$1_$2
1111 #define PLATFORM_CONFIG_H "check_crypto_md.h"
1112
1113 $(cat "$srcdir/libarchive/archive_digest.c")
1114
1115 int
1116 main(int argc, char **argv)
1117 {
1118 archive_$3_ctx ctx;
1119 archive_$3_init(&ctx);
1120 archive_$3_update(&ctx, *argv, argc);
1121 archive_$3_final(&ctx, NULL);
1122 return 0;
1123 }
1124 ])],
1125 [ AC_MSG_RESULT([yes])
1126 found_$1=yes
1127 found_$2=yes
1128 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
1129 ],
1130 [ AC_MSG_RESULT([no])])
1131 CPPFLAGS="$saved_CPPFLAGS"
1132 rm "check_crypto_md.h"
1133 fi
1134 ])
1135
1136 AC_DEFUN([CRYPTO_CHECK_WIN], [
1137 if test "$found_$1" != yes; then
1138 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_WIN])
1139 AC_LINK_IFELSE([AC_LANG_SOURCE([
1140 #define ARCHIVE_$1_COMPILE_TEST
1141 #include <windows.h>
1142 #include <wincrypt.h>
1143
1144 int
1145 main(int argc, char **argv)
1146 {
1147 (void)argc;
1148 (void)argv;
1149
1150 return ($2);
1151 }
1152 ])],
1153 [ AC_MSG_RESULT([yes])
1154 found_$1=yes
1155 found_WIN=yes
1156 AC_DEFINE(ARCHIVE_CRYPTO_$1_WIN, 1, [ $1 via ARCHIVE_CRYPTO_$1_WIN supported.])
1157 ],
1158 [ AC_MSG_RESULT([no])])
1159 fi
1160 ])
1161
1162 case "$host_os" in
1163 *mingw* | *cygwin* | *msys*)
1164 ;;
1165 *)
1166 CRYPTO_CHECK(MD5, LIBC, md5)
1167 CRYPTO_CHECK(MD5, LIBSYSTEM, md5)
1168 CRYPTO_CHECK(RMD160, LIBC, rmd160)
1169 CRYPTO_CHECK(SHA1, LIBC, sha1)
1170 CRYPTO_CHECK(SHA1, LIBSYSTEM, sha1)
1171 CRYPTO_CHECK(SHA256, LIBC, sha256)
1172 CRYPTO_CHECK(SHA256, LIBC2, sha256)
1173 CRYPTO_CHECK(SHA256, LIBC3, sha256)
1174 CRYPTO_CHECK(SHA256, LIBSYSTEM, sha256)
1175 CRYPTO_CHECK(SHA384, LIBC, sha384)
1176 CRYPTO_CHECK(SHA384, LIBC2, sha384)
1177 CRYPTO_CHECK(SHA384, LIBC3, sha384)
1178 CRYPTO_CHECK(SHA384, LIBSYSTEM, sha384)
1179 CRYPTO_CHECK(SHA512, LIBC, sha512)
1180 CRYPTO_CHECK(SHA512, LIBC2, sha512)
1181 CRYPTO_CHECK(SHA512, LIBC3, sha512)
1182 CRYPTO_CHECK(SHA512, LIBSYSTEM, sha512)
1183 ;;
1184 esac
1185
1186 if test "x$with_cng" != "xno"; then
1187 AC_CHECK_HEADERS([bcrypt.h],[
1188 LIBS="$LIBS -lbcrypt"
1189 ],[],
1190 [[#ifdef HAVE_WINDOWS_H
1191 # include <windows.h>
1192 #endif
1193 ]])
1194 fi
1195
1196 if test "x$with_mbedtls" = "xyes"; then
1197 AC_CHECK_HEADERS([mbedtls/aes.h mbedtls/md.h mbedtls/pkcs5.h])
1198 saved_LIBS=$LIBS
1199 AC_CHECK_LIB(mbedcrypto,mbedtls_sha1_init)
1200 CRYPTO_CHECK(MD5, MBEDTLS, md5)
1201 CRYPTO_CHECK(RMD160, MBEDTLS, rmd160)
1202 CRYPTO_CHECK(SHA1, MBEDTLS, sha1)
1203 CRYPTO_CHECK(SHA256, MBEDTLS, sha256)
1204 CRYPTO_CHECK(SHA384, MBEDTLS, sha384)
1205 CRYPTO_CHECK(SHA512, MBEDTLS, sha512)
1206 if test "x$found_MBEDTLS" != "xyes"; then
1207 LIBS=$saved_LIBS
1208 fi
1209 fi
1210
1211 if test "x$with_nettle" = "xyes"; then
1212 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
1213 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
1214 saved_LIBS=$LIBS
1215 AC_CHECK_LIB(nettle,nettle_sha1_init)
1216 CRYPTO_CHECK(MD5, NETTLE, md5)
1217 CRYPTO_CHECK(RMD160, NETTLE, rmd160)
1218 CRYPTO_CHECK(SHA1, NETTLE, sha1)
1219 CRYPTO_CHECK(SHA256, NETTLE, sha256)
1220 CRYPTO_CHECK(SHA384, NETTLE, sha384)
1221 CRYPTO_CHECK(SHA512, NETTLE, sha512)
1222 if test "x$found_NETTLE" != "xyes"; then
1223 LIBS=$saved_LIBS
1224 fi
1225 fi
1226
1227 if test "x$with_openssl" != "xno"; then
1228 AC_CHECK_HEADERS([openssl/evp.h])
1229 saved_LIBS=$LIBS
1230 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libssl libcrypto"
1231 AC_CHECK_LIB(crypto,OPENSSL_config)
1232 CRYPTO_CHECK(MD5, OPENSSL, md5)
1233 CRYPTO_CHECK(RMD160, OPENSSL, rmd160)
1234 CRYPTO_CHECK(SHA1, OPENSSL, sha1)
1235 CRYPTO_CHECK(SHA256, OPENSSL, sha256)
1236 CRYPTO_CHECK(SHA384, OPENSSL, sha384)
1237 CRYPTO_CHECK(SHA512, OPENSSL, sha512)
1238 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
1239 fi
1240
1241 AC_SUBST(LIBSREQUIRED)
1242
1243 # Probe libmd AFTER OpenSSL/libcrypto.
1244 # The two are incompatible and OpenSSL is more complete.
1245 AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
1246 saved_LIBS=$LIBS
1247 AC_CHECK_LIB(md,MD5Init)
1248 CRYPTO_CHECK(MD5, LIBMD, md5)
1249 CRYPTO_CHECK(RMD160, LIBMD, rmd160)
1250 CRYPTO_CHECK(SHA1, LIBMD, sha1)
1251 CRYPTO_CHECK(SHA256, LIBMD, sha256)
1252 CRYPTO_CHECK(SHA512, LIBMD, sha512)
1253 if test "x$found_LIBMD" != "xyes"; then
1254 LIBS=$saved_LIBS
1255 fi
1256
1257 case "$host_os" in
1258 *mingw* | *cygwin* | *msys*)
1259 CRYPTO_CHECK_WIN(MD5, CALG_MD5)
1260 CRYPTO_CHECK_WIN(SHA1, CALG_SHA1)
1261 CRYPTO_CHECK_WIN(SHA256, CALG_SHA_256)
1262 CRYPTO_CHECK_WIN(SHA384, CALG_SHA_384)
1263 CRYPTO_CHECK_WIN(SHA512, CALG_SHA_512)
1264 ;;
1265 esac
1266
1267 dnl Visibility annotations...
1268 saved_CFLAGS="$CFLAGS"
1269 CFLAGS="$CFLAGS -fvisibility=hidden -Werror"
1270 AC_MSG_CHECKING(whether compiler supports visibility annotations)
1271 AC_LINK_IFELSE([AC_LANG_PROGRAM([
1272 int foo( void ) __attribute__((visibility("default")));
1273 ])],
1274 [CFLAGS="$saved_CFLAGS -fvisibility=hidden -D__LIBARCHIVE_ENABLE_VISIBILITY";
1275 AC_MSG_RESULT(yes)],
1276 [CFLAGS="$saved_CFLAGS"
1277 AC_MSG_RESULT(no)])
1278
1279 # Ensure test directories are present if building out-of-tree
1280 AC_CONFIG_COMMANDS([mkdirs],
1281 [mkdir -p libarchive/test tar/test cat/test cpio/test])
1282
1283 AC_OUTPUT