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