]> git.ipfire.org Git - thirdparty/libarchive.git/blame - configure.ac
bsdunzip_test: fix link against ACL libs in cmake
[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
c157e4ce
AV
270#
271# Options for building bsdunzip.
272#
273# Default is to build bsdunzip, but allow people to override that.
386412e2 274# Bsdunzip has not yet been ported for Windows
c157e4ce 275#
386412e2
MM
276case "$host_os" in
277 *mingw* | *msys*)
278 enable_bsdunzip=no
279 ;;
280 *)
281 AC_ARG_ENABLE([bsdunzip],
282 [AS_HELP_STRING([--enable-bsdunzip], [enable build of bsdunzip (default)])
283 AS_HELP_STRING([--enable-bsdunzip=static], [force static build of bsdunzip])
284 AS_HELP_STRING([--enable-bsdunzip=shared], [force dynamic build of bsdunzip])
285 AS_HELP_STRING([--disable-bsdunzip], [disable build of bsdunzip])],
286 [], [enable_bsdunzip=yes])
287 ;;
288esac
c157e4ce
AV
289
290case "$enable_bsdunzip" in
291yes)
292 if test "$enable_static" = "no"; then
293 static_bsdunzip=no
294 else
295 static_bsdunzip=yes
296 fi
297 build_bsdunzip=yes
298 ;;
299dynamic|shared)
300 if test "$enable_shared" = "no"; then
301 AC_MSG_FAILURE([Shared linking of bsdunzip requires shared libarchive])
302 fi
303 build_bsdunzip=yes
304 static_bsdunzip=no
305 ;;
306static)
307 build_bsdunzip=yes
308 static_bsdunzip=yes
309 ;;
310no)
311 build_bsdunzip=no
312 static_bsdunzip=no
313 ;;
314*)
315 AC_MSG_FAILURE([Unsupported value for --enable-bsdunzip])
316 ;;
317esac
318
319AM_CONDITIONAL([BUILD_BSDUNZIP], [ test "$build_bsdunzip" = yes ])
320AM_CONDITIONAL([STATIC_BSDUNZIP], [ test "$static_bsdunzip" = yes ])
321
b3cfa26b 322# Checks for header files.
b3cfa26b
TK
323AC_HEADER_DIRENT
324AC_HEADER_SYS_WAIT
365a91de 325AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h])
b30c530a 326AC_CHECK_HEADERS([copyfile.h ctype.h])
386412e2 327AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h fnmatch.h grp.h])
95c74682
JS
328
329AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
330 [ac_cv_have_decl_EXT2_IOC_GETFLAGS],
331 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
332@%:@include <ext2fs/ext2_fs.h>],
333 [int x = EXT2_IOC_GETFLAGS])],
334 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])],
335 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])])
336
337AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
338 [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1],
339 [Define to 1 if you have a working EXT2_IOC_GETFLAGS])])
340
d216d028 341AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
407f6e94 342AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
a9c5818b
MM
343
344AC_CACHE_CHECK([whether FS_IOC_GETFLAGS is usable],
345 [ac_cv_have_decl_FS_IOC_GETFLAGS],
346 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
347@%:@include <linux/fs.h>],
348 [int x = FS_IOC_GETFLAGS])],
349 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes])],
350 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [no])])])
351
352AS_VAR_IF([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes],
353 [AC_DEFINE_UNQUOTED([HAVE_WORKING_FS_IOC_GETFLAGS], [1],
354 [Define to 1 if you have a working FS_IOC_GETFLAGS])])
355
f57d129d 356AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h])
9769e6f7 357AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
8c1c0a7a 358AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
365a91de 359AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h])
386412e2 360AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h sys/queue.h])
bea9f9cf 361AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
4925fd0b 362AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h])
365a91de 363AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
996334f3 364AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
d7ae3cca
TK
365AC_CHECK_HEADERS([windows.h])
366# check windows.h first; the other headers require it.
367AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
368[[#ifdef HAVE_WINDOWS_H
369# include <windows.h>
370#endif
371]])
b3cfa26b
TK
372
373# Checks for libraries.
2186dc24
TK
374AC_ARG_WITH([zlib],
375 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
376
377if test "x$with_zlib" != "xno"; then
378 AC_CHECK_HEADERS([zlib.h])
379 AC_CHECK_LIB(z,inflate)
380fi
381
382AC_ARG_WITH([bz2lib],
383 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
384
385if test "x$with_bz2lib" != "xno"; then
386 AC_CHECK_HEADERS([bzlib.h])
1a0f8974 387 case "$host_os" in
1e2b6c98 388 *mingw* | *cygwin* | *msys*)
1a0f8974
AM
389 dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
390 dnl use AC_LINK_IFELSE.
391 AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
392 old_LIBS="$LIBS"
393 LIBS="-lbz2 $LIBS"
394 AC_LINK_IFELSE(
395 [AC_LANG_SOURCE(#include <bzlib.h>
396 int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
397 [ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
398 [ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
399 LIBS="$old_LIBS"
400 AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
401 if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
402 AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
403 LIBS="-lbz2 $LIBS"
404 fi
405 ;;
406 *)
407 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
408 ;;
409 esac
2186dc24
TK
410fi
411
c5013112
MM
412AC_ARG_WITH([libb2],
413 AS_HELP_STRING([--without-libb2], [Don't build support for BLAKE2 through libb2]))
414
415if test "x$with_libb2" != "xno"; then
416 AC_CHECK_HEADERS([blake2.h])
417 AC_CHECK_LIB(b2,blake2sp_init)
418fi
419
420AM_CONDITIONAL([INC_BLAKE2], [test "x$ac_cv_lib_b2_blake2sp_init" != "xyes"])
421
c91b3538
TK
422AC_ARG_WITH([iconv],
423 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
424
425if test "x$with_iconv" != "xno"; then
d975ebec 426 AM_ICONV
1354b7df 427 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
17fd872a 428 if test "x$am_cv_func_iconv" = "xyes"; then
89032bfd
MN
429 AC_CHECK_HEADERS([localcharset.h])
430 am_save_LIBS="$LIBS"
431 LIBS="${LIBS} ${LIBICONV}"
1f35c466
PP
432 if test -n "$LIBICONV"; then
433 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
434 fi
89032bfd
MN
435 AC_CHECK_FUNCS([locale_charset])
436 LIBS="${am_save_LIBS}"
437 if test "x$ac_cv_func_locale_charset" != "xyes"; then
057c8b91 438 # If locale_charset() is not in libiconv, we have to find libcharset.
89032bfd
MN
439 AC_CHECK_LIB(charset,locale_charset)
440 fi
441 fi
c91b3538
TK
442fi
443
724f3f91
MN
444AC_ARG_WITH([lz4],
445 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
446
447if test "x$with_lz4" != "xno"; then
448 AC_CHECK_HEADERS([lz4.h lz4hc.h])
449 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
450fi
451
26838cf5
SP
452AC_ARG_WITH([zstd],
453 AS_HELP_STRING([--without-zstd], [Don't build support for zstd through libzstd]))
454
455if test "x$with_zstd" != "xno"; then
456 AC_CHECK_HEADERS([zstd.h])
406165fc
PM
457 AC_CHECK_LIB(zstd,ZSTD_decompressStream)
458 AC_CHECK_LIB(zstd,ZSTD_compressStream,
459 AC_DEFINE([HAVE_LIBZSTD_COMPRESSOR], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.]))
26838cf5
SP
460fi
461
c25e0da2
MN
462AC_ARG_WITH([lzma],
463 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
464
465if test "x$with_lzma" != "xno"; then
466 AC_CHECK_HEADERS([lzma.h])
467 AC_CHECK_LIB(lzma,lzma_stream_decoder)
b05a2733
TK
468 # Some pre-release (but widely distributed) versions of liblzma
469 # included a disabled version of lzma_stream_encoder_mt that
470 # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
471 # to do something more complex here:
472 AC_CACHE_CHECK(
473 [whether we have multithread support in lzma],
474 ac_cv_lzma_has_mt,
7c3148ec
JS
475 [AC_LINK_IFELSE([
476 AC_LANG_PROGRAM([[#include <lzma.h>]
477 [#if LZMA_VERSION < 50020000]
478 [#error unsupported]
479 [#endif]],
b05a2733
TK
480 [[lzma_stream_encoder_mt(0, 0);]])],
481 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
9690ea4f
JR
482 if test "x$ac_cv_lzma_has_mt" != xno; then
483 AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
484 fi
c25e0da2
MN
485fi
486
6b29a1cc 487AC_ARG_WITH([lzo2],
6a509898 488 AS_HELP_STRING([--with-lzo2], [Build with LZO support from liblzo2]))
6b29a1cc 489
525f55c9 490if test "x$with_lzo2" = "xyes"; then
6b29a1cc
MN
491 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
492 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
493fi
494
0869c13c
PM
495AC_ARG_WITH([cng],
496 AS_HELP_STRING([--without-cng], [Don't build support of CNG(Crypto Next Generation)]))
497
f96a7114
MM
498AC_ARG_WITH([mbedtls],
499 AS_HELP_STRING([--with-mbedtls], [Build with crypto support from mbed TLS]))
00ac9023 500AC_ARG_WITH([nettle],
f96a7114 501 AS_HELP_STRING([--with-nettle], [Build with crypto support from Nettle]))
eace4421 502AC_ARG_WITH([openssl],
d2c0930d 503 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
b0f3a5e1
TK
504case "$host_os" in
505 *darwin* ) with_openssl=no ;;
506esac
d2c0930d
MN
507
508AC_ARG_WITH([xml2],
509 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
510AC_ARG_WITH([expat],
511 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
512
513if test "x$with_xml2" != "xno"; then
f7b0a9f3
KM
514 PKG_PROG_PKG_CONFIG
515 PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
516 CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
517 LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
5256aa1a 518 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
f7b0a9f3 519 ], [
5256aa1a 520 AC_CHECK_LIB(xml2,xmlInitParser)
f7b0a9f3 521 ])
b7115a7d 522 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
d2c0930d
MN
523fi
524if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
525 if test "x$with_expat" != "xno"; then
aa5b327f
MN
526 AC_CHECK_HEADERS([expat.h])
527 AC_CHECK_LIB(expat,XML_ParserCreate)
d2c0930d
MN
528 fi
529fi
eace4421 530
9fe06744
AM
531AC_ARG_ENABLE([posix-regex-lib],
532 [AS_HELP_STRING([--enable-posix-regex-lib],
533 [choose what library to use for POSIX regular expression support (default: auto)])
534 AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
535 AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
536 AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
537 AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
538 [], [enable_posix_regex_lib=auto])
539
540posix_regex_lib_found=
541if test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libc" || test "$enable_posix_regex_lib" = "libregex"; then
542 AC_CHECK_HEADERS([regex.h])
c9b68f41 543 if test "x$ac_cv_header_regex_h" != "xno"; then
9797fb4e
AM
544 AC_CHECK_FUNC(regcomp)
545 if test "x$ac_cv_func_regcomp" = xyes; then
546 posix_regex_lib_found=1
547 else
548 AC_CHECK_LIB(regex,regcomp)
549 if test "x$ac_cv_lib_regex_regcomp" = xyes; then
550 posix_regex_lib_found=1
551 fi
552 fi
c9b68f41
MN
553 fi
554fi
9fe06744
AM
555if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcreposix"); then
556 AC_CHECK_HEADERS([pcreposix.h])
9797fb4e 557 AC_CHECK_LIB(pcreposix,regcomp)
d16c4871
AM
558 if test "x$ac_cv_lib_pcreposix_regcomp" != xyes; then
559 AC_MSG_NOTICE(trying libpcreposix check again with libpcre)
560 unset ac_cv_lib_pcreposix_regcomp
561 AC_CHECK_LIB(pcre,pcre_exec)
562 AC_CHECK_LIB(pcreposix,regcomp)
563 if test "x$ac_cv_lib_pcre_pcre_exec" = xyes && test "x$ac_cv_lib_pcreposix_regcomp" = xyes; then
564 AC_MSG_CHECKING(if PCRE_STATIC needs to be defined)
565 AC_LINK_IFELSE(
566 [AC_LANG_SOURCE(#include <pcreposix.h>
567 int main() { return regcomp(NULL, NULL, 0); })],
568 [without_pcre_static=yes],
569 [without_pcre_static=no])
570 AC_LINK_IFELSE(
571 [AC_LANG_SOURCE(#define PCRE_STATIC
572 #include <pcreposix.h>
573 int main() { return regcomp(NULL, NULL, 0); })],
574 [with_pcre_static=yes],
575 [with_pcre_static=no])
576 if test "x$without_pcre_static" != xyes && test "x$with_pcre_static" = xyes; then
577 AC_MSG_RESULT(yes)
578 AC_DEFINE([PCRE_STATIC], [1], [Define to 1 if PCRE_STATIC needs to be defined.])
579 elif test "x$without_pcre_static" = xyes || test "x$with_pcre_static" = xyes; then
580 AC_MSG_RESULT(no)
581 fi
582 posix_regex_lib_found=1
91717f72 583 fi
d16c4871
AM
584 else
585 posix_regex_lib_found=1
9797fb4e 586 fi
9fe06744 587fi
c9b68f41 588
b3cfa26b
TK
589# TODO: Give the user the option of using a pre-existing system
590# libarchive. This will define HAVE_LIBARCHIVE which will cause
591# bsdtar_platform.h to use #include <...> for the libarchive headers.
592# Need to include Makefile.am magic to link against system
593# -larchive in that case.
594#AC_CHECK_LIB(archive,archive_version)
595
9f6c6d5d
EVW
596# Checks for supported compiler flags
597AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
598
fc075823
EV
599# Place the functions and data into separate sections, allowing the linker
600# to garbage collect the unused ones.
601save_LDFLAGS=$LDFLAGS
602LDFLAGS="$LDFLAGS -Wl,--gc-sections"
603AC_MSG_CHECKING([whether ld supports --gc-sections])
604AC_LINK_IFELSE(
605 [AC_LANG_SOURCE([static char UnusedFunc() { return 5; } int main() { return 0;}])],
606 [AC_MSG_RESULT([yes])
607 GC_SECTIONS="-Wl,--gc-sections";
608 AX_APPEND_COMPILE_FLAGS([-ffunction-sections -fdata-sections])],
609 [AC_MSG_RESULT([no])
610 GC_SECTIONS="";])
611LDFLAGS=$save_LDFLAGS
612
613AC_SUBST(GC_SECTIONS)
614
b3cfa26b
TK
615# Checks for typedefs, structures, and compiler characteristics.
616AC_C_CONST
a580c98e 617# la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
92165c97
CW
618# and MSVC. Use a customized version.
619la_TYPE_UID_T
b3cfa26b
TK
620AC_TYPE_MODE_T
621# AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
622# most systems... default to "long long" instead.
623AC_CHECK_TYPE(off_t, [long long])
624AC_TYPE_SIZE_T
625AC_CHECK_TYPE(id_t, [unsigned long])
626AC_CHECK_TYPE(uintptr_t, [unsigned int])
8ac32d27 627
9d72ea76
MN
628# Check for tm_gmtoff in struct tm
629AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
630[
631#include <time.h>
632])
633
a3b61f44
MN
634# Check for f_namemax in struct statfs
635AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
636[
637#include <sys/param.h>
638#include <sys/mount.h>
639])
640
b8e4320b
CZ
641# Check for f_iosize in struct statfs
642AC_CHECK_MEMBERS([struct statfs.f_iosize],,,
643[
644#include <sys/param.h>
645#include <sys/mount.h>
646])
647
19c22e92
BK
648# Check for f_iosize in struct statvfs
649AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
650[
651#include <sys/statvfs.h>
652])
653
8ac32d27
TK
654# Check for birthtime in struct stat
655AC_CHECK_MEMBERS([struct stat.st_birthtime])
656
b3cfa26b 657# Check for high-resolution timestamps in struct stat
8ac32d27 658AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
b3cfa26b
TK
659AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
660AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
d831cc4b
BJ
661AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
662AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
a0b5f839 663AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
c15d8e24
TK
664# Check for block size support in struct stat
665AC_CHECK_MEMBERS([struct stat.st_blksize])
c5e9786e
TK
666# Check for st_flags in struct stat (BSD fflags)
667AC_CHECK_MEMBERS([struct stat.st_flags])
b3cfa26b
TK
668
669# If you have uintmax_t, we assume printf supports %ju
670# If you have unsigned long long, we assume printf supports %llu
671# TODO: Check for %ju and %llu support directly.
672AC_CHECK_TYPES([uintmax_t, unsigned long long])
673
566a6636
TK
674# We use C99-style integer types
675# Declare them if the local platform doesn't already do so.
b3cfa26b 676AC_TYPE_INTMAX_T
b3cfa26b 677AC_TYPE_UINTMAX_T
566a6636 678AC_TYPE_INT64_T
b3cfa26b 679AC_TYPE_UINT64_T
566a6636
TK
680AC_TYPE_INT32_T
681AC_TYPE_UINT32_T
682AC_TYPE_INT16_T
683AC_TYPE_UINT16_T
3de335e1 684AC_TYPE_UINT8_T
b3cfa26b 685
2f637b08
TK
686AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
687AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
b699d5c6 688AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
a1f91bd1
MN
689
690AC_CHECK_DECL([SSIZE_MAX],
691 [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.])],
692 [],
693 [#include <limits.h>])
b3cfa26b
TK
694
695AC_CHECK_DECL([EFTYPE],
696 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
697 [],
698 [#include <errno.h>])
699AC_CHECK_DECL([EILSEQ],
700 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
701 [],
702 [#include <errno.h>])
778a496c
CW
703AC_CHECK_TYPE([wchar_t],
704 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
705 AC_CHECK_SIZEOF([wchar_t])],
706 [])
707
9a6a8e77 708AX_COMPILE_CHECK_SIZEOF(int)
709AX_COMPILE_CHECK_SIZEOF(long)
710
013aef12 711AC_CHECK_HEADERS_ONCE([sys/time.h])
b3cfa26b
TK
712
713# Checks for library functions.
714AC_PROG_GCC_TRADITIONAL
715AC_HEADER_MAJOR
716AC_FUNC_FSEEKO
717AC_FUNC_MEMCMP
718AC_FUNC_LSTAT
719AC_FUNC_STAT
720AC_FUNC_STRERROR_R
721AC_FUNC_STRFTIME
722AC_FUNC_VPRINTF
197cc2d1
CW
723# check for:
724# CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
725# To avoid necessity for including windows.h or special forward declaration
726# workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
727AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
d5ed4f85 728AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r])
386412e2 729AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fnmatch fork])
4f1939c9
MN
730AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
731AC_CHECK_FUNCS([futimens futimes futimesat])
a3b61f44 732AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
21467bd9 733AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
5e646b89 734AC_CHECK_FUNCS([lchflags lchmod lchown link linkat localtime_r lstat lutimes])
47a98250 735AC_CHECK_FUNCS([mbrtowc memmove memset])
496b1876 736AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
8c1c0a7a 737AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
9769e6f7 738AC_CHECK_FUNCS([readpassphrase])
4ba1f7d7 739AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
c581b317
MM
740AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
741AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
b6ba5603 742AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
0348e24b
RP
743AC_CHECK_FUNCS([_fseeki64 _get_timezone])
744AC_CHECK_DECL([cmtime_s],
745 [AC_DEFINE(HAVE_CMTIME_S, 1, [cmtime_s function])],
746 [],
747 [#include <time.h>])
748AC_CHECK_DECL([gmtime_s],
749 [AC_DEFINE(HAVE_GMTIME_S, 1, [gmtime_s function])],
750 [],
751 [#include <time.h>])
752AC_CHECK_TYPE([localtime_s],
753 [AC_DEFINE(HAVE_LOCALTIME_S, 1, [localtime_s function])],
754 [],
755 [#include <time.h>])
756AC_CHECK_DECL([_mkgmtime],
757 [AC_DEFINE(HAVE__MKGMTIME, 1, [_mkgmtime function])],
758 [],
759 [#include <time.h>])
760
ed585028
CW
761# detects cygwin-1.7, as opposed to older versions
762AC_CHECK_FUNCS([cygwin_conv_path])
b3cfa26b 763
e7642e12
JS
764# DragonFly uses vfsconf, FreeBSD xvfsconf.
765AC_CHECK_TYPES(struct vfsconf,,,
766 [#if HAVE_SYS_TYPES_H
767 #include <sys/types.h>
768 #endif
769 #include <sys/mount.h>
770 ])
771
a847b455
TK
772AC_CHECK_TYPES(struct xvfsconf,,,
773 [#if HAVE_SYS_TYPES_H
774 #include <sys/types.h>
775 #endif
776 #include <sys/mount.h>
777 ])
778
c4970dcd
CZ
779AC_CHECK_TYPES(struct statfs,,,
780 [#if HAVE_SYS_TYPES_H
781 #include <sys/types.h>
782 #endif
783 #include <sys/mount.h>
784 ])
785
09654df8
TK
786# There are several variants of readdir_r around; we only
787# accept the POSIX-compliant version.
3f8f054e 788AC_LINK_IFELSE(
09654df8
TK
789 [AC_LANG_PROGRAM([[#include <dirent.h>]],
790 [[DIR *dir; struct dirent e, *r;
c8f97841 791 return(readdir_r(dir, &e, &r));]])],
09654df8
TK
792 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
793)
d5ed4f85 794# dirfd can be either a function or a macro.
3f8f054e 795AC_LINK_IFELSE(
d5ed4f85
JS
796 [AC_LANG_PROGRAM([[#include <dirent.h>
797 DIR *dir;]],
798 [[return(dirfd(dir));]])],
799 [AC_DEFINE(HAVE_DIRFD,1,[Define to 1 if you have a dirfd function or macro])]
800)
09654df8 801
b3cfa26b
TK
802# FreeBSD's nl_langinfo supports an option to specify whether the
803# current locale uses month/day or day/month ordering. It makes the
804# output a little prettier...
805AC_CHECK_DECL([D_MD_ORDER],
806[AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
807[],
808[#if HAVE_LANGINFO_H
809#include <langinfo.h>
810#endif
811])
812
b3cfa26b
TK
813# Check for dirent.d_namlen field explicitly
814# (This is a bit more straightforward than, if not quite as portable as,
815# the recipe given by the autoconf maintainers.)
816AC_CHECK_MEMBER(struct dirent.d_namlen,,,
817[#if HAVE_DIRENT_H
818#include <dirent.h>
819#endif
820])
821
c157e4ce
AV
822AC_CHECK_DECL([optreset],
823 [AC_DEFINE(HAVE_GETOPT_OPTRESET, 1, [Platform uses optreset to reset getopt])],
824 [],
825 [#include <getopt.h>])
826
b3cfa26b
TK
827# Check for Extended Attributes support
828AC_ARG_ENABLE([xattr],
829 AS_HELP_STRING([--disable-xattr],
b30c530a 830 [Disable Extended Attributes support (default: check)]))
b3cfa26b
TK
831
832if test "x$enable_xattr" != "xno"; then
37740e26 833 AC_SEARCH_LIBS([setxattr], [attr gnu])
365a91de 834 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
6d23f1c5
JS
835#include <sys/extattr.h>
836])
365a91de
MM
837 AC_CHECK_DECLS([XATTR_NOFOLLOW], [], [], [#include <sys/xattr.h>
838])
839 if test "x$ac_cv_header_sys_xattr_h" = "xyes" \
840 -a "x$ac_cv_have_decl_XATTR_NOFOLLOW" = "xyes"; then
841 # Darwin extended attributes support
842 AC_CACHE_VAL([ac_cv_archive_xattr_darwin],
843 [AC_CHECK_FUNCS(fgetxattr \
844 flistxattr \
845 fsetxattr \
846 getxattr \
847 listxattr \
848 setxattr,
849 [ac_cv_archive_xattr_darwin=yes],
850 [ac_cv_archive_xattr_darwin=no],
851 [#include <sys/xattr.h>
852])
853 ]
854 )
855 elif test "x$ac_cv_header_sys_extattr_h" = "xyes" \
856 -a "x$ac_cv_have_decl_EXTATTR_NAMESPACE_USER" = "xyes"; then
857 # FreeBSD extended attributes support
858 AC_CACHE_VAL([ac_cv_archive_xattr_freebsd],
859 [AC_CHECK_FUNCS(extattr_get_fd \
860 extattr_get_file \
861 extattr_get_link \
862 extattr_list_fd \
863 extattr_list_file \
864 extattr_list_link \
865 extattr_set_fd \
866 extattr_set_link,
867 [ac_cv_archive_xattr_freebsd=yes],
868 [ac_cv_archive_xattr_freebsd=no],
869 [#include <sys/types.h>
870#include <sys/extattr.h>
871])
872 ]
873 )
874 elif test "x$ac_cv_header_sys_xattr_h" = "xyes" \
875 -o "x$ac_cv_header_attr_xattr_h" = "xyes"; then
876 # Linux extended attributes support
877 AC_CACHE_VAL([ac_cv_archive_xattr_linux],
878 [AC_CHECK_FUNCS(fgetxattr \
879 flistxattr \
880 fsetxattr \
881 getxattr \
882 lgetxattr \
883 listxattr \
884 llistxattr \
885 lsetxattr,
886 [ac_cv_archive_xattr_linux=yes],
887 [ac_cv_archive_xattr_linux=no],
888 [#if HAVE_SYS_TYPES_H
889#include <sys/types.h>
890#endif
891#if HAVE_SYS_XATTR_H
892#include <sys/xattr.h>
893#endif
894#if HAVE_ATTR_XATTR_H
895#include <attr/xatr.h>
896#endif
897])
898 ]
899 )
900 elif test "x$ac_cv_header_sys_ea_h" = "xyes"; then
901 # AIX extended attributes support
902 AC_CACHE_VAL([ac_cv_archive_xattr_aix],
903 [AC_CHECK_FUNCS(fgetea \
904 flistea \
905 fsetea \
906 getea \
907 lgetea \
908 listea \
909 llistea \
910 lsetea,
911 [ac_cv_archive_xattr_aix=yes],
912 [ac_cv_archive_xattr_aix=no],
913 [#include <sys/ea.h>
914])
915 ]
916 )
917 fi
918
919 AC_MSG_CHECKING([for extended attributes support])
920 if test "x$ac_cv_archive_xattr_linux" = "xyes"; then
921 AC_DEFINE([ARCHIVE_XATTR_LINUX], [1], [Linux xattr support])
922 AC_MSG_RESULT([Linux])
923 elif test "x$ac_cv_archive_xattr_darwin" = "xyes"; then
924 AC_DEFINE([ARCHIVE_XATTR_DARWIN], [1], [Darwin xattr support])
925 AC_MSG_RESULT([Darwin])
926 elif test "x$ac_cv_archive_xattr_freebsd" = "xyes"; then
927 AC_DEFINE([ARCHIVE_XATTR_FREEBSD], [1], [FreeBSD xattr support])
928 AC_MSG_RESULT([FreeBSD])
929 elif test "x$ac_cv_archive_xattr_aix" = "xyes"; then
930 AC_DEFINE([ARCHIVE_XATTR_AIX], [1], [AIX xattr support])
931 AC_MSG_RESULT([AIX])
932 else
933 AC_MSG_RESULT([none])
934 fi
b3cfa26b
TK
935fi
936
937# Check for ACL support
938#
939# The ACL support in libarchive is written against the POSIX1e draft,
940# which was never officially approved and varies quite a bit across
941# platforms. Worse, some systems have completely non-POSIX acl functions,
942# which makes the following checks rather more complex than I would like.
943#
944AC_ARG_ENABLE([acl],
945 AS_HELP_STRING([--disable-acl],
b30c530a 946 [Disable ACL support (default: check)]))
b3cfa26b
TK
947
948if test "x$enable_acl" != "xno"; then
f57d129d
MM
949 # Libacl
950 AC_CHECK_LIB([acl], [acl_get_file])
951
952 AC_CHECK_TYPES([acl_t, acl_entry_t, acl_permset_t, acl_tag_t], [], [], [
953 #if HAVE_SYS_TYPES_H
954 #include <sys/types.h>
955 #endif
956 #if HAVE_SYS_ACL_H
957 #include <sys/acl.h>
958 #endif
959 ])
b3cfa26b 960
bea9f9cf
MM
961 AC_CHECK_LIB([richacl], [richacl_get_file])
962
963 AC_CHECK_TYPES([[struct richace], [struct richacl]], [], [], [
964 #if HAVE_SYS_RICHACL_H
965 #include <sys/richacl.h>
966 #endif
967 ])
968
f57d129d
MM
969 # Solaris and derivates ACLs
970 AC_CHECK_FUNCS(acl facl)
b3cfa26b 971
bea9f9cf
MM
972 if test "x$ac_cv_lib_richacl_richacl_get_file" = "xyes" \
973 -a "x$ac_cv_type_struct_richace" = "xyes" \
974 -a "x$ac_cv_type_struct_richacl" = "xyes"; then
975 AC_CACHE_VAL([ac_cv_archive_acl_librichacl],
976 [AC_CHECK_FUNCS(richacl_alloc \
977 richacl_equiv_mode \
978 richacl_free \
979 richacl_get_fd \
980 richacl_get_file \
981 richacl_set_fd \
982 richacl_set_file,
983 [ac_cv_archive_acl_librichacl=yes], [ac_cv_archive_acl_librichacl=no], [#include <sys/richacl.h>])])
984 fi
985
f57d129d
MM
986 if test "x$ac_cv_func_acl" = "xyes" \
987 -a "x$ac_cv_func_facl" = "xyes"; then
988 AC_CHECK_TYPES([aclent_t], [], [], [[#include <sys/acl.h>]])
989 if test "x$ac_cv_type_aclent_t" = "xyes"; then
990 AC_CACHE_VAL([ac_cv_archive_acl_sunos],
991 [AC_CHECK_DECLS([GETACL, SETACL, GETACLCNT],
992 [ac_cv_archive_acl_sunos=yes], [ac_cv_archive_acl_sunos=no],
993 [#include <sys/acl.h>])])
994 AC_CHECK_TYPES([ace_t], [], [], [[#include <sys/acl.h>]])
995 if test "x$ac_cv_type_ace_t" = "xyes"; then
996 AC_CACHE_VAL([ac_cv_archive_acl_sunos_nfs4],
997 [AC_CHECK_DECLS([ACE_GETACL, ACE_SETACL, ACE_GETACLCNT],
998 [ac_cv_archive_acl_sunos_nfs4=yes],
999 [ac_cv_archive_acl_sonos_nfs4=no],
1000 [#include <sys/acl.h>])])
1001 fi
1002 fi
1003 elif test "x$ac_cv_type_acl_t" = "xyes" \
1004 -a "x$ac_cv_type_acl_entry_t" = "xyes" \
1005 -a "x$ac_cv_type_acl_permset_t" = "xyes" \
1006 -a "x$ac_cv_type_acl_tag_t" = "xyes"; then
1007 # POSIX.1e ACL functions
1008 AC_CACHE_VAL([ac_cv_posix_acl_funcs],
1009 [AC_CHECK_FUNCS(acl_add_perm \
1010 acl_clear_perms \
1011 acl_create_entry \
1012 acl_delete_def_file \
1013 acl_free \
1014 acl_get_entry \
1015 acl_get_fd \
1016 acl_get_file \
1017 acl_get_permset \
1018 acl_get_qualifier \
1019 acl_get_tag_type \
1020 acl_init \
1021 acl_set_fd \
1022 acl_set_file \
1023 acl_set_qualifier \
1024 acl_set_tag_type,
1025 [ac_cv_posix_acl_funcs=yes], [ac_cv_posix_acl_funcs=no],
1026 [#if HAVE_SYS_TYPES_H
1027 #include <sys/types.h>
1028 #endif
1029 #if HAVE_SYS_ACL_H
1030 #include <sys/acl.h>
1031 #endif
1032 ])
992652f4
MM
1033 ])
1034
f57d129d 1035 AC_CHECK_FUNCS(acl_get_perm)
9f43a7d6 1036
f57d129d
MM
1037 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
1038 -a "x$ac_cv_header_acl_libacl_h" = "xyes" \
1039 -a "x$ac_cv_lib_acl_acl_get_file" = "xyes" \
1040 -a "x$ac_cv_func_acl_get_perm"; then
1041 AC_CACHE_VAL([ac_cv_archive_acl_libacl],
1042 [ac_cv_archive_acl_libacl=yes])
1043 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1044 [POSIX.1e ACL support via libacl])
1045 else
1046 # FreeBSD/Darwin
1047 AC_CHECK_FUNCS(acl_add_flag_np \
1048 acl_clear_flags_np \
1049 acl_get_brand_np \
1050 acl_get_entry_type_np \
1051 acl_get_flag_np \
1052 acl_get_flagset_np \
1053 acl_get_fd_np \
1054 acl_get_link_np \
1055 acl_get_perm_np \
1056 acl_is_trivial_np \
1057 acl_set_entry_type_np \
1058 acl_set_fd_np \
1059 acl_set_link_np,,,
1060 [#include <sys/types.h>
1061 #include <sys/acl.h>])
1062
1063 AC_CHECK_FUNCS(mbr_uid_to_uuid \
1064 mbr_uuid_to_id \
1065 mbr_gid_to_uuid,,,
1066 [#include <membership.h>])
1067
1068 AC_CHECK_DECLS([ACL_TYPE_EXTENDED, ACL_TYPE_NFS4, ACL_USER,
1069 ACL_SYNCHRONIZE], [], [],
1070 [#include <sys/types.h>
1071 #include <sys/acl.h>])
1072 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
1073 -a "x$ac_cv_func_acl_get_fd_np" = "xyes" \
1074 -a "x$ac_cv_func_acl_get_perm" != "xyes" \
1075 -a "x$ac_cv_func_acl_get_perm_np" = "xyes" \
1076 -a "x$ac_cv_func_acl_set_fd_np" = "xyes"; then
1077 if test "x$ac_cv_have_decl_ACL_USER" = "xyes"; then
1078 AC_CACHE_VAL([ac_cv_archive_acl_freebsd],
1079 [ac_cv_archive_acl_freebsd=yes])
1080 if test "x$ac_cv_have_decl_ACL_TYPE_NFS4" = "xyes" \
1081 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
1082 -a "x$ac_cv_func_acl_get_brand_np" = "xyes" \
1083 -a "x$ac_cv_func_acl_get_entry_type_np" = "xyes" \
1084 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
1085 -a "x$ac_cv_func_acl_set_entry_type_np" = "xyes"; then
1086 AC_CACHE_VAL([ac_cv_archive_acl_freebsd_nfs4],
1087 [ac_cv_archive_acl_freebsd_nfs4=yes])
1088 fi
1089 elif test "x$ac_cv_have_decl_ACL_TYPE_EXTENDED" = "xyes" \
1090 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
1091 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
1092 -a "x$ac_cv_func_acl_get_link_np" = "xyes" \
1093 -a "x$ac_cv_func_acl_set_link_np" = "xyes" \
1094 -a "x$ac_cv_func_mbr_uid_to_uuid" = "xyes" \
1095 -a "x$ac_cv_func_mbr_uuid_to_id" = "xyes" \
1096 -a "x$ac_cv_func_mbr_gid_to_uuid" = "xyes"; then
1097 AC_CACHE_VAL([ac_cv_archive_acl_darwin],
1098 [ac_cv_archive_acl_darwin=yes])
1099 fi
1100 fi
1101 fi
1102 fi
1103 AC_MSG_CHECKING([for ACL support])
bea9f9cf
MM
1104 if test "x$ac_cv_archive_acl_libacl" = "xyes" \
1105 -a "x$ac_cv_archive_acl_librichacl" = "xyes"; then
1106 AC_MSG_RESULT([libacl (POSIX.1e) + librichacl (NFSv4)])
1107 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1108 [Linux POSIX.1e ACL support via libacl])
1109 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
1110 [Linux NFSv4 ACL support via librichacl])
1111 elif test "x$ac_cv_archive_acl_libacl" = "xyes"; then
f57d129d 1112 AC_MSG_RESULT([libacl (POSIX.1e)])
bea9f9cf
MM
1113 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1114 [Linux POSIX.1e ACL support via libacl])
1115 elif test "x$ac_cv_archive_acl_librichacl" = "xyes"; then
1116 AC_MSG_RESULT([librichacl (NFSv4)])
1117 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
1118 [Linux NFSv4 ACL support via librichacl])
f57d129d
MM
1119 elif test "x$ac_cv_archive_acl_darwin" = "xyes"; then
1120 AC_DEFINE([ARCHIVE_ACL_DARWIN], [1], [Darwin ACL support])
1121 AC_MSG_RESULT([Darwin (limited NFSv4)])
1122 elif test "x$ac_cv_archive_acl_sunos" = "xyes"; then
1123 AC_DEFINE([ARCHIVE_ACL_SUNOS], [1], [Solaris ACL support])
1124 if test "x$ac_cv_archive_acl_sunos_nfs4" = "xyes"; then
1125 AC_DEFINE([ARCHIVE_ACL_SUNOS_NFS4], [1],
1126 [Solaris NFSv4 ACL support])
1127 AC_MSG_RESULT([Solaris (POSIX.1e and NFSv4)])
1128 else
1129 AC_MSG_RESULT([Solaris (POSIX.1e)])
1130 fi
1131 elif test "x$ac_cv_archive_acl_freebsd" = "xyes"; then
1132 AC_DEFINE([ARCHIVE_ACL_FREEBSD], [1], [FreeBSD ACL support])
1133 if test "x$ac_cv_archive_acl_freebsd_nfs4" = "xyes"; then
1134 AC_DEFINE([ARCHIVE_ACL_FREEBSD_NFS4], [1],
1135 [FreeBSD NFSv4 ACL support])
1136 AC_MSG_RESULT([FreeBSD (POSIX.1e and NFSv4)])
1137 else
1138 AC_MSG_RESULT([FreeBSD (POSIX.1e)])
1139 fi
1140 else
1141 AC_MSG_RESULT([none])
1142 fi
b3cfa26b
TK
1143fi
1144
f57d129d 1145
bea9f9cf
MM
1146AM_CONDITIONAL([INC_LINUX_ACL],
1147 [test "x$ac_cv_archive_acl_libacl" = "xyes" \
1148 -o "x$ac_cv_archive_acl_librichacl" = "xyes"])
f57d129d
MM
1149AM_CONDITIONAL([INC_SUNOS_ACL], [test "x$ac_cv_archive_acl_sunos" = "xyes"])
1150AM_CONDITIONAL([INC_DARWIN_ACL],
1151 [test "x$ac_cv_archive_acl_darwin" = "xyes"])
1152AM_CONDITIONAL([INC_FREEBSD_ACL],
1153 [test "x$ac_cv_archive_acl_freebsd" = "xyes"])
1154
b3cfa26b
TK
1155# Additional requirements
1156AC_SYS_LARGEFILE
1157
2d53ab9e
AM
1158dnl NOTE: Crypto checks must run last.
1159AC_DEFUN([CRYPTO_CHECK], [
1160 if test "$found_$1" != yes; then
2d53ab9e 1161 saved_CPPFLAGS="$CPPFLAGS"
38644a9a 1162 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
2d53ab9e
AM
1163 touch "check_crypto_md.h"
1164 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_$2])
1165 AC_LINK_IFELSE([AC_LANG_SOURCE([
1166#define ARCHIVE_$1_COMPILE_TEST
1167#define ARCHIVE_CRYPTO_$1_$2
1168#define PLATFORM_CONFIG_H "check_crypto_md.h"
1169
c4c6533b 1170$(cat "$srcdir/libarchive/archive_digest.c")
2d53ab9e
AM
1171
1172int
1173main(int argc, char **argv)
1174{
1175 archive_$3_ctx ctx;
1176 archive_$3_init(&ctx);
1177 archive_$3_update(&ctx, *argv, argc);
1178 archive_$3_final(&ctx, NULL);
1179 return 0;
1180}
1181])],
1182 [ AC_MSG_RESULT([yes])
1183 found_$1=yes
177cf35b 1184 found_$2=yes
2d53ab9e
AM
1185 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
1186 ],
1187 [ AC_MSG_RESULT([no])])
2d53ab9e
AM
1188 CPPFLAGS="$saved_CPPFLAGS"
1189 rm "check_crypto_md.h"
1190 fi
1191])
1192
275000df
MN
1193AC_DEFUN([CRYPTO_CHECK_WIN], [
1194 if test "$found_$1" != yes; then
1195 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_WIN])
1196 AC_LINK_IFELSE([AC_LANG_SOURCE([
275000df
MN
1197#define ARCHIVE_$1_COMPILE_TEST
1198#include <windows.h>
1199#include <wincrypt.h>
1200
1201int
1202main(int argc, char **argv)
1203{
1204 (void)argc;
1205 (void)argv;
1206
1207 return ($2);
1208}
1209])],
1210 [ AC_MSG_RESULT([yes])
1211 found_$1=yes
177cf35b 1212 found_WIN=yes
275000df
MN
1213 AC_DEFINE(ARCHIVE_CRYPTO_$1_WIN, 1, [ $1 via ARCHIVE_CRYPTO_$1_WIN supported.])
1214 ],
1215 [ AC_MSG_RESULT([no])])
1216 fi
1217])
1218
1219case "$host_os" in
1e2b6c98 1220 *mingw* | *cygwin* | *msys*)
275000df
MN
1221 ;;
1222 *)
1223 CRYPTO_CHECK(MD5, LIBC, md5)
1224 CRYPTO_CHECK(MD5, LIBSYSTEM, md5)
1225 CRYPTO_CHECK(RMD160, LIBC, rmd160)
1226 CRYPTO_CHECK(SHA1, LIBC, sha1)
1227 CRYPTO_CHECK(SHA1, LIBSYSTEM, sha1)
1228 CRYPTO_CHECK(SHA256, LIBC, sha256)
1229 CRYPTO_CHECK(SHA256, LIBC2, sha256)
1230 CRYPTO_CHECK(SHA256, LIBC3, sha256)
1231 CRYPTO_CHECK(SHA256, LIBSYSTEM, sha256)
1232 CRYPTO_CHECK(SHA384, LIBC, sha384)
1233 CRYPTO_CHECK(SHA384, LIBC2, sha384)
1234 CRYPTO_CHECK(SHA384, LIBC3, sha384)
1235 CRYPTO_CHECK(SHA384, LIBSYSTEM, sha384)
1236 CRYPTO_CHECK(SHA512, LIBC, sha512)
1237 CRYPTO_CHECK(SHA512, LIBC2, sha512)
1238 CRYPTO_CHECK(SHA512, LIBC3, sha512)
1239 CRYPTO_CHECK(SHA512, LIBSYSTEM, sha512)
1240 ;;
1241esac
2d53ab9e 1242
0869c13c
PM
1243if test "x$with_cng" != "xno"; then
1244 AC_CHECK_HEADERS([bcrypt.h],[
1245 LIBS="$LIBS -lbcrypt"
1246 ],[],
1247 [[#ifdef HAVE_WINDOWS_H
1248 # include <windows.h>
1249 #endif
1250 ]])
1251fi
1252
f96a7114
MM
1253if test "x$with_mbedtls" = "xyes"; then
1254 AC_CHECK_HEADERS([mbedtls/aes.h mbedtls/md.h mbedtls/pkcs5.h])
1255 saved_LIBS=$LIBS
1256 AC_CHECK_LIB(mbedcrypto,mbedtls_sha1_init)
1257 CRYPTO_CHECK(MD5, MBEDTLS, md5)
1258 CRYPTO_CHECK(RMD160, MBEDTLS, rmd160)
1259 CRYPTO_CHECK(SHA1, MBEDTLS, sha1)
1260 CRYPTO_CHECK(SHA256, MBEDTLS, sha256)
1261 CRYPTO_CHECK(SHA384, MBEDTLS, sha384)
1262 CRYPTO_CHECK(SHA512, MBEDTLS, sha512)
1263 if test "x$found_MBEDTLS" != "xyes"; then
1264 LIBS=$saved_LIBS
1265 fi
1266fi
1267
1268if test "x$with_nettle" = "xyes"; then
177cf35b 1269 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
48e40df7 1270 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
177cf35b 1271 saved_LIBS=$LIBS
48e40df7 1272 AC_CHECK_LIB(nettle,nettle_sha1_init)
177cf35b
AM
1273 CRYPTO_CHECK(MD5, NETTLE, md5)
1274 CRYPTO_CHECK(RMD160, NETTLE, rmd160)
1275 CRYPTO_CHECK(SHA1, NETTLE, sha1)
1276 CRYPTO_CHECK(SHA256, NETTLE, sha256)
1277 CRYPTO_CHECK(SHA384, NETTLE, sha384)
1278 CRYPTO_CHECK(SHA512, NETTLE, sha512)
1279 if test "x$found_NETTLE" != "xyes"; then
1280 LIBS=$saved_LIBS
1281 fi
00ac9023 1282fi
48e40df7 1283
2d53ab9e 1284if test "x$with_openssl" != "xno"; then
177cf35b
AM
1285 AC_CHECK_HEADERS([openssl/evp.h])
1286 saved_LIBS=$LIBS
1f3c62eb 1287 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libcrypto"
9210f025 1288 AC_CHECK_LIB(crypto,OPENSSL_config)
fdd5acfe
AM
1289 CRYPTO_CHECK(MD5, OPENSSL, md5)
1290 CRYPTO_CHECK(RMD160, OPENSSL, rmd160)
1291 CRYPTO_CHECK(SHA1, OPENSSL, sha1)
1292 CRYPTO_CHECK(SHA256, OPENSSL, sha256)
1293 CRYPTO_CHECK(SHA384, OPENSSL, sha384)
1294 CRYPTO_CHECK(SHA512, OPENSSL, sha512)
b2b69d4f 1295 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
2d53ab9e 1296fi
f8709112 1297
a83f3d32
BN
1298AC_SUBST(LIBSREQUIRED)
1299
f8709112
TK
1300# Probe libmd AFTER OpenSSL/libcrypto.
1301# The two are incompatible and OpenSSL is more complete.
177cf35b
AM
1302AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
1303saved_LIBS=$LIBS
48e40df7 1304AC_CHECK_LIB(md,MD5Init)
fdd5acfe
AM
1305CRYPTO_CHECK(MD5, LIBMD, md5)
1306CRYPTO_CHECK(RMD160, LIBMD, rmd160)
1307CRYPTO_CHECK(SHA1, LIBMD, sha1)
1308CRYPTO_CHECK(SHA256, LIBMD, sha256)
1309CRYPTO_CHECK(SHA512, LIBMD, sha512)
177cf35b
AM
1310if test "x$found_LIBMD" != "xyes"; then
1311 LIBS=$saved_LIBS
1312fi
2d53ab9e 1313
c078ff5d 1314case "$host_os" in
1e2b6c98 1315 *mingw* | *cygwin* | *msys*)
c078ff5d
AM
1316 CRYPTO_CHECK_WIN(MD5, CALG_MD5)
1317 CRYPTO_CHECK_WIN(SHA1, CALG_SHA1)
1318 CRYPTO_CHECK_WIN(SHA256, CALG_SHA_256)
1319 CRYPTO_CHECK_WIN(SHA384, CALG_SHA_384)
1320 CRYPTO_CHECK_WIN(SHA512, CALG_SHA_512)
1321 ;;
1322esac
1323
5235554e
YG
1324dnl Visibility annotations...
1325saved_CFLAGS="$CFLAGS"
1326CFLAGS="$CFLAGS -fvisibility=hidden -Werror"
1327AC_MSG_CHECKING(whether compiler supports visibility annotations)
1328AC_LINK_IFELSE([AC_LANG_PROGRAM([
1329 int foo( void ) __attribute__((visibility("default")));
1330 ])],
1331 [CFLAGS="$saved_CFLAGS -fvisibility=hidden -D__LIBARCHIVE_ENABLE_VISIBILITY";
1332 AC_MSG_RESULT(yes)],
1333 [CFLAGS="$saved_CFLAGS"
1334 AC_MSG_RESULT(no)])
1335
af77429c
PB
1336# Ensure test directories are present if building out-of-tree
1337AC_CONFIG_COMMANDS([mkdirs],
41a759a7 1338 [mkdir -p libarchive/test tar/test cat/test cpio/test])
af77429c 1339
b3cfa26b 1340AC_OUTPUT