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