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