]> git.ipfire.org Git - thirdparty/libarchive.git/blame - configure.ac
Add missing brackets to if clause
[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.
3da2fb7e
MM
7m4_define([LIBARCHIVE_VERSION_S],[3.6.3dev])
8m4_define([LIBARCHIVE_VERSION_N],[3006003])
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
013aef12 15AC_PREREQ([2.71])
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 28# Must follow AC_CONFIG macros above...
dc064872 29AM_INIT_AUTOMAKE([1.11 dist-xz dist-zip])
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
0d8b61ea
AR
50AC_DEFINE([__LIBARCHIVE_CONFIG_H_INCLUDED], [1],
51 [Internal macro for sanity checks])
b3cfa26b
TK
52AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
53 [Version number of libarchive])
54AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
55 [Version number of libarchive as a single integer])
56AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
57 [Version number of bsdcpio])
58AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
59 [Version number of bsdtar])
5d3f56d2
MK
60AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
61 [Version number of bsdcat])
b3cfa26b
TK
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.
66BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
67BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
5d3f56d2 68BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
b3cfa26b
TK
69LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
70LIBARCHIVE_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.
75AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
76AC_SUBST(BSDCPIO_VERSION_STRING)
77AC_SUBST(BSDTAR_VERSION_STRING)
5d3f56d2 78AC_SUBST(BSDCAT_VERSION_STRING)
b3cfa26b
TK
79AC_SUBST(LIBARCHIVE_VERSION_STRING)
80AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
81
82AC_CONFIG_HEADERS([config.h])
83AC_CONFIG_FILES([Makefile])
bafc3c6b 84AC_CONFIG_FILES([build/pkgconfig/libarchive.pc])
b3cfa26b 85
79cb8e5b
CW
86# Check for host type
87AC_CANONICAL_HOST
88
89dnl Compilation on mingw and Cygwin needs special Makefile rules
90inc_windows_files=no
91inc_cygwin_files=no
92case "$host_os" in
93 *mingw* ) inc_windows_files=yes ;;
1e2b6c98 94 *cygwin* | *msys*) inc_cygwin_files=yes ;;
79cb8e5b
CW
95esac
96AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
97AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
98
c31d1bc4
CW
99dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
100PLATFORMCPPFLAGS=
101case "$host_os" in
0348e24b 102 *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO -D__MINGW_USE_VC2005_COMPAT ;;
c31d1bc4
CW
103esac
104AC_SUBST(PLATFORMCPPFLAGS)
105
b3cfa26b
TK
106# Checks for programs.
107AC_PROG_CC
108AM_PROG_CC_C_O
b4c5bf51 109AC_PROG_CPP
6ca9835b 110AC_USE_SYSTEM_EXTENSIONS
01a4df54 111AC_LIBTOOL_WIN32_DLL
b3cfa26b
TK
112AC_PROG_LIBTOOL
113AC_CHECK_TOOL([STRIP],[strip])
1c6adda3 114AC_PROG_MKDIR_P
b3cfa26b
TK
115
116#
117# Options for building bsdtar.
118#
119# Default is to build bsdtar, but allow people to override that.
120#
121AC_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])
125AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
126 [], [enable_bsdtar=yes])
127
128case "$enable_bsdtar" in
129yes)
130 if test "$enable_static" = "no"; then
131 static_bsdtar=no
132 else
133 static_bsdtar=yes
134 fi
135 build_bsdtar=yes
136 ;;
137dynamic|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 ;;
144static)
145 build_bsdtar=yes
146 static_bsdtar=yes
147 ;;
148no)
149 build_bsdtar=no
150 static_bsdtar=no
151 ;;
152*)
153 AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
154 ;;
155esac
156
157AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
158AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
159
5d3f56d2
MK
160#
161# Options for building bsdcat.
162#
163# Default is to build bsdcat, but allow people to override that.
164#
165AC_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])
169AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
170 [], [enable_bsdcat=yes])
171
172case "$enable_bsdcat" in
173yes)
174 if test "$enable_static" = "no"; then
175 static_bsdcat=no
176 else
177 static_bsdcat=yes
178 fi
179 build_bsdcat=yes
180 ;;
181dynamic|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 ;;
188static)
189 build_bsdcat=yes
190 static_bsdcat=yes
191 ;;
192no)
193 build_bsdcat=no
194 static_bsdcat=no
195 ;;
196*)
197 AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
198 ;;
199esac
200
201AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
202AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
203
b3cfa26b
TK
204#
205# Options for building bsdcpio.
206#
207# Default is not to build bsdcpio, but that can be overridden.
208#
209AC_ARG_ENABLE([bsdcpio],
f9a97a03 210 [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
b3cfa26b
TK
211 AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
212 AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
f9a97a03
TK
213AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
214 [], [enable_bsdcpio=yes])
b3cfa26b
TK
215
216case "$enable_bsdcpio" in
217yes)
218 if test "$enable_static" = "no"; then
219 static_bsdcpio=no
220 else
221 static_bsdcpio=yes
222 fi
223 build_bsdcpio=yes
224 ;;
225dynamic|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 ;;
231static)
232 build_bsdcpio=yes
233 static_bsdcpio=yes
234 ;;
235no)
236 build_bsdcpio=no
237 static_bsdcpio=no
238 ;;
239*)
240 AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
241 ;;
242esac
243
244AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
245AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
246
197cc2d1
CW
247# Set up defines needed before including any headers
248case $host in
1e2b6c98 249 *mingw* | *cygwin* | *msys* )
1fd0c015
SL
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 ])
197cc2d1
CW
267 ;;
268esac
269
b3cfa26b 270# Checks for header files.
b3cfa26b
TK
271AC_HEADER_DIRENT
272AC_HEADER_SYS_WAIT
365a91de 273AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h])
b30c530a 274AC_CHECK_HEADERS([copyfile.h ctype.h])
c247a74f 275AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
95c74682
JS
276
277AC_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
285AS_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
d216d028 289AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
407f6e94 290AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
a9c5818b
MM
291
292AC_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
300AS_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
f57d129d 304AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h])
9769e6f7 305AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
8c1c0a7a 306AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
365a91de 307AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h])
fb67a295 308AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
bea9f9cf 309AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
4925fd0b 310AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h])
365a91de 311AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
996334f3 312AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
d7ae3cca
TK
313AC_CHECK_HEADERS([windows.h])
314# check windows.h first; the other headers require it.
315AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
316[[#ifdef HAVE_WINDOWS_H
317# include <windows.h>
318#endif
319]])
b3cfa26b
TK
320
321# Checks for libraries.
2186dc24
TK
322AC_ARG_WITH([zlib],
323 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
324
325if test "x$with_zlib" != "xno"; then
326 AC_CHECK_HEADERS([zlib.h])
327 AC_CHECK_LIB(z,inflate)
328fi
329
330AC_ARG_WITH([bz2lib],
331 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
332
333if test "x$with_bz2lib" != "xno"; then
334 AC_CHECK_HEADERS([bzlib.h])
1a0f8974 335 case "$host_os" in
1e2b6c98 336 *mingw* | *cygwin* | *msys*)
1a0f8974
AM
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
2186dc24
TK
358fi
359
c5013112
MM
360AC_ARG_WITH([libb2],
361 AS_HELP_STRING([--without-libb2], [Don't build support for BLAKE2 through libb2]))
362
363if test "x$with_libb2" != "xno"; then
364 AC_CHECK_HEADERS([blake2.h])
365 AC_CHECK_LIB(b2,blake2sp_init)
366fi
367
368AM_CONDITIONAL([INC_BLAKE2], [test "x$ac_cv_lib_b2_blake2sp_init" != "xyes"])
369
c91b3538
TK
370AC_ARG_WITH([iconv],
371 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
372
373if test "x$with_iconv" != "xno"; then
d975ebec 374 AM_ICONV
1354b7df 375 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
17fd872a 376 if test "x$am_cv_func_iconv" = "xyes"; then
89032bfd
MN
377 AC_CHECK_HEADERS([localcharset.h])
378 am_save_LIBS="$LIBS"
379 LIBS="${LIBS} ${LIBICONV}"
1f35c466
PP
380 if test -n "$LIBICONV"; then
381 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
382 fi
89032bfd
MN
383 AC_CHECK_FUNCS([locale_charset])
384 LIBS="${am_save_LIBS}"
385 if test "x$ac_cv_func_locale_charset" != "xyes"; then
057c8b91 386 # If locale_charset() is not in libiconv, we have to find libcharset.
89032bfd
MN
387 AC_CHECK_LIB(charset,locale_charset)
388 fi
389 fi
c91b3538
TK
390fi
391
724f3f91
MN
392AC_ARG_WITH([lz4],
393 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
394
395if test "x$with_lz4" != "xno"; then
396 AC_CHECK_HEADERS([lz4.h lz4hc.h])
397 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
398fi
399
26838cf5
SP
400AC_ARG_WITH([zstd],
401 AS_HELP_STRING([--without-zstd], [Don't build support for zstd through libzstd]))
402
403if test "x$with_zstd" != "xno"; then
404 AC_CHECK_HEADERS([zstd.h])
406165fc
PM
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.]))
26838cf5
SP
408fi
409
c25e0da2
MN
410AC_ARG_WITH([lzma],
411 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
412
413if test "x$with_lzma" != "xno"; then
414 AC_CHECK_HEADERS([lzma.h])
415 AC_CHECK_LIB(lzma,lzma_stream_decoder)
b05a2733
TK
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,
7c3148ec
JS
423 [AC_LINK_IFELSE([
424 AC_LANG_PROGRAM([[#include <lzma.h>]
425 [#if LZMA_VERSION < 50020000]
426 [#error unsupported]
427 [#endif]],
b05a2733
TK
428 [[lzma_stream_encoder_mt(0, 0);]])],
429 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
9690ea4f
JR
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
c25e0da2
MN
433fi
434
6b29a1cc 435AC_ARG_WITH([lzo2],
6a509898 436 AS_HELP_STRING([--with-lzo2], [Build with LZO support from liblzo2]))
6b29a1cc 437
525f55c9 438if test "x$with_lzo2" = "xyes"; then
6b29a1cc
MN
439 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
440 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
441fi
442
0869c13c
PM
443AC_ARG_WITH([cng],
444 AS_HELP_STRING([--without-cng], [Don't build support of CNG(Crypto Next Generation)]))
445
f96a7114
MM
446AC_ARG_WITH([mbedtls],
447 AS_HELP_STRING([--with-mbedtls], [Build with crypto support from mbed TLS]))
00ac9023 448AC_ARG_WITH([nettle],
f96a7114 449 AS_HELP_STRING([--with-nettle], [Build with crypto support from Nettle]))
eace4421 450AC_ARG_WITH([openssl],
d2c0930d 451 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
b0f3a5e1
TK
452case "$host_os" in
453 *darwin* ) with_openssl=no ;;
454esac
d2c0930d
MN
455
456AC_ARG_WITH([xml2],
457 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
458AC_ARG_WITH([expat],
459 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
460
461if test "x$with_xml2" != "xno"; then
f7b0a9f3
KM
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}"
5256aa1a 466 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
f7b0a9f3 467 ], [
5256aa1a 468 AC_CHECK_LIB(xml2,xmlInitParser)
f7b0a9f3 469 ])
b7115a7d 470 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
d2c0930d
MN
471fi
472if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
473 if test "x$with_expat" != "xno"; then
aa5b327f
MN
474 AC_CHECK_HEADERS([expat.h])
475 AC_CHECK_LIB(expat,XML_ParserCreate)
d2c0930d
MN
476 fi
477fi
eace4421 478
9fe06744
AM
479AC_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
488posix_regex_lib_found=
489if 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])
c9b68f41 491 if test "x$ac_cv_header_regex_h" != "xno"; then
9797fb4e
AM
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
c9b68f41
MN
501 fi
502fi
9fe06744
AM
503if 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])
9797fb4e 505 AC_CHECK_LIB(pcreposix,regcomp)
d16c4871
AM
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
91717f72 531 fi
d16c4871
AM
532 else
533 posix_regex_lib_found=1
9797fb4e 534 fi
9fe06744 535fi
c9b68f41 536
b3cfa26b
TK
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
9f6c6d5d
EVW
544# Checks for supported compiler flags
545AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
546
fc075823
EV
547# Place the functions and data into separate sections, allowing the linker
548# to garbage collect the unused ones.
549save_LDFLAGS=$LDFLAGS
550LDFLAGS="$LDFLAGS -Wl,--gc-sections"
551AC_MSG_CHECKING([whether ld supports --gc-sections])
552AC_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="";])
559LDFLAGS=$save_LDFLAGS
560
561AC_SUBST(GC_SECTIONS)
562
b3cfa26b
TK
563# Checks for typedefs, structures, and compiler characteristics.
564AC_C_CONST
a580c98e 565# la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
92165c97
CW
566# and MSVC. Use a customized version.
567la_TYPE_UID_T
b3cfa26b
TK
568AC_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.
571AC_CHECK_TYPE(off_t, [long long])
572AC_TYPE_SIZE_T
573AC_CHECK_TYPE(id_t, [unsigned long])
574AC_CHECK_TYPE(uintptr_t, [unsigned int])
8ac32d27 575
9d72ea76
MN
576# Check for tm_gmtoff in struct tm
577AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
578[
579#include <time.h>
580])
581
a3b61f44
MN
582# Check for f_namemax in struct statfs
583AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
584[
585#include <sys/param.h>
586#include <sys/mount.h>
587])
588
b8e4320b
CZ
589# Check for f_iosize in struct statfs
590AC_CHECK_MEMBERS([struct statfs.f_iosize],,,
591[
592#include <sys/param.h>
593#include <sys/mount.h>
594])
595
19c22e92
BK
596# Check for f_iosize in struct statvfs
597AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
598[
599#include <sys/statvfs.h>
600])
601
8ac32d27
TK
602# Check for birthtime in struct stat
603AC_CHECK_MEMBERS([struct stat.st_birthtime])
604
b3cfa26b 605# Check for high-resolution timestamps in struct stat
8ac32d27 606AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
b3cfa26b
TK
607AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
608AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
d831cc4b
BJ
609AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
610AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
a0b5f839 611AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
c15d8e24
TK
612# Check for block size support in struct stat
613AC_CHECK_MEMBERS([struct stat.st_blksize])
c5e9786e
TK
614# Check for st_flags in struct stat (BSD fflags)
615AC_CHECK_MEMBERS([struct stat.st_flags])
b3cfa26b
TK
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.
620AC_CHECK_TYPES([uintmax_t, unsigned long long])
621
566a6636
TK
622# We use C99-style integer types
623# Declare them if the local platform doesn't already do so.
b3cfa26b 624AC_TYPE_INTMAX_T
b3cfa26b 625AC_TYPE_UINTMAX_T
566a6636 626AC_TYPE_INT64_T
b3cfa26b 627AC_TYPE_UINT64_T
566a6636
TK
628AC_TYPE_INT32_T
629AC_TYPE_UINT32_T
630AC_TYPE_INT16_T
631AC_TYPE_UINT16_T
3de335e1 632AC_TYPE_UINT8_T
b3cfa26b 633
2f637b08
TK
634AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
635AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
b699d5c6 636AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
a1f91bd1
MN
637
638AC_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>])
b3cfa26b
TK
642
643AC_CHECK_DECL([EFTYPE],
644 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
645 [],
646 [#include <errno.h>])
647AC_CHECK_DECL([EILSEQ],
648 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
649 [],
650 [#include <errno.h>])
778a496c
CW
651AC_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
9a6a8e77 656AX_COMPILE_CHECK_SIZEOF(int)
657AX_COMPILE_CHECK_SIZEOF(long)
658
013aef12 659AC_CHECK_HEADERS_ONCE([sys/time.h])
b3cfa26b
TK
660
661# Checks for library functions.
662AC_PROG_GCC_TRADITIONAL
663AC_HEADER_MAJOR
664AC_FUNC_FSEEKO
665AC_FUNC_MEMCMP
666AC_FUNC_LSTAT
667AC_FUNC_STAT
668AC_FUNC_STRERROR_R
669AC_FUNC_STRFTIME
670AC_FUNC_VPRINTF
197cc2d1
CW
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 *'
675AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
d5ed4f85 676AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r])
ba463cc3 677AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
4f1939c9
MN
678AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
679AC_CHECK_FUNCS([futimens futimes futimesat])
a3b61f44 680AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
21467bd9 681AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
5e646b89 682AC_CHECK_FUNCS([lchflags lchmod lchown link linkat localtime_r lstat lutimes])
47a98250 683AC_CHECK_FUNCS([mbrtowc memmove memset])
496b1876 684AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
8c1c0a7a 685AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
9769e6f7 686AC_CHECK_FUNCS([readpassphrase])
4ba1f7d7 687AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
c581b317
MM
688AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
689AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
b6ba5603 690AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
0348e24b
RP
691AC_CHECK_FUNCS([_fseeki64 _get_timezone])
692AC_CHECK_DECL([cmtime_s],
693 [AC_DEFINE(HAVE_CMTIME_S, 1, [cmtime_s function])],
694 [],
695 [#include <time.h>])
696AC_CHECK_DECL([gmtime_s],
697 [AC_DEFINE(HAVE_GMTIME_S, 1, [gmtime_s function])],
698 [],
699 [#include <time.h>])
700AC_CHECK_TYPE([localtime_s],
701 [AC_DEFINE(HAVE_LOCALTIME_S, 1, [localtime_s function])],
702 [],
703 [#include <time.h>])
704AC_CHECK_DECL([_mkgmtime],
705 [AC_DEFINE(HAVE__MKGMTIME, 1, [_mkgmtime function])],
706 [],
707 [#include <time.h>])
708
ed585028
CW
709# detects cygwin-1.7, as opposed to older versions
710AC_CHECK_FUNCS([cygwin_conv_path])
b3cfa26b 711
e7642e12
JS
712# DragonFly uses vfsconf, FreeBSD xvfsconf.
713AC_CHECK_TYPES(struct vfsconf,,,
714 [#if HAVE_SYS_TYPES_H
715 #include <sys/types.h>
716 #endif
717 #include <sys/mount.h>
718 ])
719
a847b455
TK
720AC_CHECK_TYPES(struct xvfsconf,,,
721 [#if HAVE_SYS_TYPES_H
722 #include <sys/types.h>
723 #endif
724 #include <sys/mount.h>
725 ])
726
c4970dcd
CZ
727AC_CHECK_TYPES(struct statfs,,,
728 [#if HAVE_SYS_TYPES_H
729 #include <sys/types.h>
730 #endif
731 #include <sys/mount.h>
732 ])
733
09654df8
TK
734# There are several variants of readdir_r around; we only
735# accept the POSIX-compliant version.
3f8f054e 736AC_LINK_IFELSE(
09654df8
TK
737 [AC_LANG_PROGRAM([[#include <dirent.h>]],
738 [[DIR *dir; struct dirent e, *r;
c8f97841 739 return(readdir_r(dir, &e, &r));]])],
09654df8
TK
740 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
741)
d5ed4f85 742# dirfd can be either a function or a macro.
3f8f054e 743AC_LINK_IFELSE(
d5ed4f85
JS
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)
09654df8 749
b3cfa26b
TK
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...
753AC_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
b3cfa26b
TK
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.)
764AC_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
771AC_ARG_ENABLE([xattr],
772 AS_HELP_STRING([--disable-xattr],
b30c530a 773 [Disable Extended Attributes support (default: check)]))
b3cfa26b
TK
774
775if test "x$enable_xattr" != "xno"; then
37740e26 776 AC_SEARCH_LIBS([setxattr], [attr gnu])
365a91de 777 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
6d23f1c5
JS
778#include <sys/extattr.h>
779])
365a91de
MM
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
b3cfa26b
TK
878fi
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#
887AC_ARG_ENABLE([acl],
888 AS_HELP_STRING([--disable-acl],
b30c530a 889 [Disable ACL support (default: check)]))
b3cfa26b
TK
890
891if test "x$enable_acl" != "xno"; then
f57d129d
MM
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 ])
b3cfa26b 903
bea9f9cf
MM
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
f57d129d
MM
912 # Solaris and derivates ACLs
913 AC_CHECK_FUNCS(acl facl)
b3cfa26b 914
bea9f9cf
MM
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
f57d129d
MM
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 ])
992652f4
MM
976 ])
977
f57d129d 978 AC_CHECK_FUNCS(acl_get_perm)
9f43a7d6 979
f57d129d
MM
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])
bea9f9cf
MM
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
f57d129d 1055 AC_MSG_RESULT([libacl (POSIX.1e)])
bea9f9cf
MM
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])
f57d129d
MM
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
b3cfa26b
TK
1086fi
1087
f57d129d 1088
bea9f9cf
MM
1089AM_CONDITIONAL([INC_LINUX_ACL],
1090 [test "x$ac_cv_archive_acl_libacl" = "xyes" \
1091 -o "x$ac_cv_archive_acl_librichacl" = "xyes"])
f57d129d
MM
1092AM_CONDITIONAL([INC_SUNOS_ACL], [test "x$ac_cv_archive_acl_sunos" = "xyes"])
1093AM_CONDITIONAL([INC_DARWIN_ACL],
1094 [test "x$ac_cv_archive_acl_darwin" = "xyes"])
1095AM_CONDITIONAL([INC_FREEBSD_ACL],
1096 [test "x$ac_cv_archive_acl_freebsd" = "xyes"])
1097
b3cfa26b
TK
1098# Additional requirements
1099AC_SYS_LARGEFILE
1100
2d53ab9e
AM
1101dnl NOTE: Crypto checks must run last.
1102AC_DEFUN([CRYPTO_CHECK], [
1103 if test "$found_$1" != yes; then
2d53ab9e 1104 saved_CPPFLAGS="$CPPFLAGS"
38644a9a 1105 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
2d53ab9e
AM
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
c4c6533b 1113$(cat "$srcdir/libarchive/archive_digest.c")
2d53ab9e
AM
1114
1115int
1116main(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
177cf35b 1127 found_$2=yes
2d53ab9e
AM
1128 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
1129 ],
1130 [ AC_MSG_RESULT([no])])
2d53ab9e
AM
1131 CPPFLAGS="$saved_CPPFLAGS"
1132 rm "check_crypto_md.h"
1133 fi
1134])
1135
275000df
MN
1136AC_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([
275000df
MN
1140#define ARCHIVE_$1_COMPILE_TEST
1141#include <windows.h>
1142#include <wincrypt.h>
1143
1144int
1145main(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
177cf35b 1155 found_WIN=yes
275000df
MN
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
1162case "$host_os" in
1e2b6c98 1163 *mingw* | *cygwin* | *msys*)
275000df
MN
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 ;;
1184esac
2d53ab9e 1185
0869c13c
PM
1186if 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 ]])
1194fi
1195
f96a7114
MM
1196if 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
1209fi
1210
1211if test "x$with_nettle" = "xyes"; then
177cf35b 1212 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
48e40df7 1213 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
177cf35b 1214 saved_LIBS=$LIBS
48e40df7 1215 AC_CHECK_LIB(nettle,nettle_sha1_init)
177cf35b
AM
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
00ac9023 1225fi
48e40df7 1226
2d53ab9e 1227if test "x$with_openssl" != "xno"; then
177cf35b
AM
1228 AC_CHECK_HEADERS([openssl/evp.h])
1229 saved_LIBS=$LIBS
1f3c62eb 1230 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libcrypto"
9210f025 1231 AC_CHECK_LIB(crypto,OPENSSL_config)
fdd5acfe
AM
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)
b2b69d4f 1238 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
2d53ab9e 1239fi
f8709112 1240
a83f3d32
BN
1241AC_SUBST(LIBSREQUIRED)
1242
f8709112
TK
1243# Probe libmd AFTER OpenSSL/libcrypto.
1244# The two are incompatible and OpenSSL is more complete.
177cf35b
AM
1245AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
1246saved_LIBS=$LIBS
48e40df7 1247AC_CHECK_LIB(md,MD5Init)
fdd5acfe
AM
1248CRYPTO_CHECK(MD5, LIBMD, md5)
1249CRYPTO_CHECK(RMD160, LIBMD, rmd160)
1250CRYPTO_CHECK(SHA1, LIBMD, sha1)
1251CRYPTO_CHECK(SHA256, LIBMD, sha256)
1252CRYPTO_CHECK(SHA512, LIBMD, sha512)
177cf35b
AM
1253if test "x$found_LIBMD" != "xyes"; then
1254 LIBS=$saved_LIBS
1255fi
2d53ab9e 1256
c078ff5d 1257case "$host_os" in
1e2b6c98 1258 *mingw* | *cygwin* | *msys*)
c078ff5d
AM
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 ;;
1265esac
1266
5235554e
YG
1267dnl Visibility annotations...
1268saved_CFLAGS="$CFLAGS"
1269CFLAGS="$CFLAGS -fvisibility=hidden -Werror"
1270AC_MSG_CHECKING(whether compiler supports visibility annotations)
1271AC_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
af77429c
PB
1279# Ensure test directories are present if building out-of-tree
1280AC_CONFIG_COMMANDS([mkdirs],
41a759a7 1281 [mkdir -p libarchive/test tar/test cat/test cpio/test])
af77429c 1282
b3cfa26b 1283AC_OUTPUT