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