]> git.ipfire.org Git - thirdparty/libarchive.git/blob - configure.ac
configure.ac: check acl/libacl.h and sys/acl.h based on requirement
[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.2.0])
8 m4_define([LIBARCHIVE_VERSION_N],[3002000])
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()
30 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
31
32 # Libtool's "interface version" can be computed from the libarchive version.
33
34 # Libtool interface version bumps on any API change, so increments
35 # whenever libarchive minor version does.
36 ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
37 # Libarchive 2.7 == libtool interface 9 = 2 + 7
38 # Libarchive 2.8 == libtool interface 10 = 2 + 8
39 # Libarchive 2.9 == libtool interface 11 = 2 + 8
40 # Libarchive 3.0 == libtool interface 12
41 # Libarchive 3.1 == libtool interface 13
42 ARCHIVE_INTERFACE=`echo $((13 + ${ARCHIVE_MINOR}))`
43 # Libarchive revision is bumped on any source change === libtool revision
44 ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
45 # Libarchive minor is bumped on any interface addition === libtool age
46 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_INTERFACE:$ARCHIVE_REVISION:$ARCHIVE_MINOR
47
48 # Stick the version numbers into config.h
49 AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
50 [Version number of libarchive])
51 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
52 [Version number of libarchive as a single integer])
53 AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
54 [Version number of bsdcpio])
55 AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
56 [Version number of bsdtar])
57 AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
58 [Version number of bsdcat])
59
60 # The shell variables here must be the same as the AC_SUBST() variables
61 # below, but the shell variable names apparently cannot be the same as
62 # the m4 macro names above. Why? Ask autoconf.
63 BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
64 BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
65 BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
66 LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
67 LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
68
69 # Substitute the above version numbers into the various files below.
70 # Yes, I believe this is the fourth time we define what are essentially
71 # the same symbols. Why? Ask autoconf.
72 AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
73 AC_SUBST(BSDCPIO_VERSION_STRING)
74 AC_SUBST(BSDTAR_VERSION_STRING)
75 AC_SUBST(BSDCAT_VERSION_STRING)
76 AC_SUBST(LIBARCHIVE_VERSION_STRING)
77 AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
78
79 AC_CONFIG_HEADERS([config.h])
80 AC_CONFIG_FILES([Makefile])
81 AC_CONFIG_FILES([build/pkgconfig/libarchive.pc])
82
83 # Check for host type
84 AC_CANONICAL_HOST
85
86 dnl Compilation on mingw and Cygwin needs special Makefile rules
87 inc_windows_files=no
88 inc_cygwin_files=no
89 case "$host_os" in
90 *mingw* ) inc_windows_files=yes ;;
91 *cygwin*) inc_cygwin_files=yes ;;
92 esac
93 AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
94 AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
95
96 dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
97 PLATFORMCPPFLAGS=
98 case "$host_os" in
99 *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
100 esac
101 AC_SUBST(PLATFORMCPPFLAGS)
102
103 # Checks for programs.
104 AC_PROG_CC
105 AM_PROG_CC_C_O
106 AC_USE_SYSTEM_EXTENSIONS
107 AC_LIBTOOL_WIN32_DLL
108 AC_PROG_LIBTOOL
109 AC_CHECK_TOOL([STRIP],[strip])
110 AC_PROG_MKDIR_P
111
112 #
113 # Options for building bsdtar.
114 #
115 # Default is to build bsdtar, but allow people to override that.
116 #
117 AC_ARG_ENABLE([bsdtar],
118 [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
119 AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
120 AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
121 AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
122 [], [enable_bsdtar=yes])
123
124 case "$enable_bsdtar" in
125 yes)
126 if test "$enable_static" = "no"; then
127 static_bsdtar=no
128 else
129 static_bsdtar=yes
130 fi
131 build_bsdtar=yes
132 ;;
133 dynamic|shared)
134 if test "$enable_shared" = "no"; then
135 AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
136 fi
137 build_bsdtar=yes
138 static_bsdtar=no
139 ;;
140 static)
141 build_bsdtar=yes
142 static_bsdtar=yes
143 ;;
144 no)
145 build_bsdtar=no
146 static_bsdtar=no
147 ;;
148 *)
149 AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
150 ;;
151 esac
152
153 AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
154 AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
155
156 #
157 # Options for building bsdcat.
158 #
159 # Default is to build bsdcat, but allow people to override that.
160 #
161 AC_ARG_ENABLE([bsdcat],
162 [AS_HELP_STRING([--enable-bsdcat], [enable build of bsdcat (default)])
163 AS_HELP_STRING([--enable-bsdcat=static], [force static build of bsdcat])
164 AS_HELP_STRING([--enable-bsdcat=shared], [force dynamic build of bsdcat])
165 AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
166 [], [enable_bsdcat=yes])
167
168 case "$enable_bsdcat" in
169 yes)
170 if test "$enable_static" = "no"; then
171 static_bsdcat=no
172 else
173 static_bsdcat=yes
174 fi
175 build_bsdcat=yes
176 ;;
177 dynamic|shared)
178 if test "$enable_shared" = "no"; then
179 AC_MSG_FAILURE([Shared linking of bsdcat requires shared libarchive])
180 fi
181 build_bsdcat=yes
182 static_bsdcat=no
183 ;;
184 static)
185 build_bsdcat=yes
186 static_bsdcat=yes
187 ;;
188 no)
189 build_bsdcat=no
190 static_bsdcat=no
191 ;;
192 *)
193 AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
194 ;;
195 esac
196
197 AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
198 AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
199
200 #
201 # Options for building bsdcpio.
202 #
203 # Default is not to build bsdcpio, but that can be overridden.
204 #
205 AC_ARG_ENABLE([bsdcpio],
206 [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
207 AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
208 AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
209 AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
210 [], [enable_bsdcpio=yes])
211
212 case "$enable_bsdcpio" in
213 yes)
214 if test "$enable_static" = "no"; then
215 static_bsdcpio=no
216 else
217 static_bsdcpio=yes
218 fi
219 build_bsdcpio=yes
220 ;;
221 dynamic|shared)
222 if test "$enabled_shared" = "no"; then
223 AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
224 fi
225 build_bsdcpio=yes
226 ;;
227 static)
228 build_bsdcpio=yes
229 static_bsdcpio=yes
230 ;;
231 no)
232 build_bsdcpio=no
233 static_bsdcpio=no
234 ;;
235 *)
236 AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
237 ;;
238 esac
239
240 AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
241 AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
242
243 # Set up defines needed before including any headers
244 case $host in
245 *mingw* | *cygwin* )
246 AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
247 AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
248 AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
249 ;;
250 esac
251
252 # Checks for header files.
253 AC_HEADER_DIRENT
254 AC_HEADER_SYS_WAIT
255 AC_CHECK_HEADERS([copyfile.h ctype.h])
256 AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
257
258 AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
259 [ac_cv_have_decl_EXT2_IOC_GETFLAGS],
260 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
261 @%:@include <ext2fs/ext2_fs.h>],
262 [int x = EXT2_IOC_GETFLAGS])],
263 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])],
264 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])])
265
266 AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
267 [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1],
268 [Define to 1 if you have a working EXT2_IOC_GETFLAGS])])
269
270 AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
271 AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
272 AC_CHECK_HEADERS([locale.h paths.h poll.h pthread.h pwd.h])
273 AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
274 AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
275 AC_CHECK_HEADERS([sys/cdefs.h sys/extattr.h])
276 AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
277 AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/statfs.h sys/statvfs.h])
278 AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h])
279 AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
280 AC_CHECK_HEADERS([windows.h])
281 AC_CHECK_HEADERS([Bcrypt.h])
282 # check windows.h first; the other headers require it.
283 AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
284 [[#ifdef HAVE_WINDOWS_H
285 # include <windows.h>
286 #endif
287 ]])
288
289 # Checks for libraries.
290 AC_ARG_WITH([zlib],
291 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
292
293 if test "x$with_zlib" != "xno"; then
294 AC_CHECK_HEADERS([zlib.h])
295 AC_CHECK_LIB(z,inflate)
296 fi
297
298 AC_ARG_WITH([bz2lib],
299 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
300
301 if test "x$with_bz2lib" != "xno"; then
302 AC_CHECK_HEADERS([bzlib.h])
303 case "$host_os" in
304 *mingw* | *cygwin*)
305 dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
306 dnl use AC_LINK_IFELSE.
307 AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
308 old_LIBS="$LIBS"
309 LIBS="-lbz2 $LIBS"
310 AC_LINK_IFELSE(
311 [AC_LANG_SOURCE(#include <bzlib.h>
312 int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
313 [ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
314 [ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
315 LIBS="$old_LIBS"
316 AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
317 if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
318 AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
319 LIBS="-lbz2 $LIBS"
320 fi
321 ;;
322 *)
323 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
324 ;;
325 esac
326 fi
327
328 AC_ARG_WITH([lzmadec],
329 AS_HELP_STRING([--without-lzmadec], [Don't build support for lzma through lzmadec]))
330
331 if test "x$with_lzmadec" != "xno"; then
332 AC_CHECK_HEADERS([lzmadec.h])
333 AC_CHECK_LIB(lzmadec,lzmadec_decode)
334 fi
335
336 AC_ARG_WITH([iconv],
337 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
338
339 if test "x$with_iconv" != "xno"; then
340 AM_ICONV
341 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
342 if test "x$am_cv_func_iconv" = "xyes"; then
343 AC_CHECK_HEADERS([localcharset.h])
344 am_save_LIBS="$LIBS"
345 LIBS="${LIBS} ${LIBICONV}"
346 AC_CHECK_FUNCS([locale_charset])
347 LIBS="${am_save_LIBS}"
348 if test "x$ac_cv_func_locale_charset" != "xyes"; then
349 # If locale_charset() is not in libiconv, we have to find libcharset.
350 AC_CHECK_LIB(charset,locale_charset)
351 fi
352 fi
353 fi
354
355 AC_ARG_WITH([lz4],
356 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
357
358 if test "x$with_lz4" != "xno"; then
359 AC_CHECK_HEADERS([lz4.h lz4hc.h])
360 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
361 fi
362
363 AC_ARG_WITH([lzma],
364 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
365
366 if test "x$with_lzma" != "xno"; then
367 AC_CHECK_HEADERS([lzma.h])
368 AC_CHECK_LIB(lzma,lzma_stream_decoder)
369 # Some pre-release (but widely distributed) versions of liblzma
370 # included a disabled version of lzma_stream_encoder_mt that
371 # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
372 # to do something more complex here:
373 AC_CACHE_CHECK(
374 [whether we have multithread support in lzma],
375 ac_cv_lzma_has_mt,
376 [AC_COMPILE_IFELSE([
377 AC_LANG_PROGRAM([[#include <lzma.h>]],
378 [[lzma_stream_encoder_mt(0, 0);]])],
379 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
380 if test "x$ac_cv_lzma_has_mt" != xno; then
381 AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
382 fi
383 fi
384
385 AC_ARG_WITH([lzo2],
386 AS_HELP_STRING([--without-lzo2], [Don't build support for lzop through liblzo2]))
387
388 if test "x$with_lzo2" != "xno"; then
389 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
390 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
391 fi
392
393 AC_ARG_WITH([nettle],
394 AS_HELP_STRING([--without-nettle], [Don't build with crypto support from Nettle]))
395 AC_ARG_WITH([openssl],
396 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
397 case "$host_os" in
398 *darwin* ) with_openssl=no ;;
399 esac
400
401 AC_ARG_WITH([xml2],
402 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
403 AC_ARG_WITH([expat],
404 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
405
406 if test "x$with_xml2" != "xno"; then
407 PKG_PROG_PKG_CONFIG
408 PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
409 CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
410 LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
411 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
412 ], [
413 AC_CHECK_LIB(xml2,xmlInitParser)
414 ])
415 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
416 fi
417 if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
418 if test "x$with_expat" != "xno"; then
419 AC_CHECK_HEADERS([expat.h])
420 AC_CHECK_LIB(expat,XML_ParserCreate)
421 fi
422 fi
423
424 AC_ARG_ENABLE([posix-regex-lib],
425 [AS_HELP_STRING([--enable-posix-regex-lib],
426 [choose what library to use for POSIX regular expression support (default: auto)])
427 AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
428 AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
429 AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
430 AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
431 [], [enable_posix_regex_lib=auto])
432
433 posix_regex_lib_found=
434 if test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libc" || test "$enable_posix_regex_lib" = "libregex"; then
435 AC_CHECK_HEADERS([regex.h])
436 if test "x$ac_cv_header_regex_h" != "xno"; then
437 AC_CHECK_FUNC(regcomp)
438 if test "x$ac_cv_func_regcomp" = xyes; then
439 posix_regex_lib_found=1
440 else
441 AC_CHECK_LIB(regex,regcomp)
442 if test "x$ac_cv_lib_regex_regcomp" = xyes; then
443 posix_regex_lib_found=1
444 fi
445 fi
446 fi
447 fi
448 if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcreposix"); then
449 AC_CHECK_HEADERS([pcreposix.h])
450 AC_CHECK_LIB(pcreposix,regcomp)
451 if test "x$ac_cv_lib_pcreposix_regcomp" != xyes; then
452 AC_MSG_NOTICE(trying libpcreposix check again with libpcre)
453 unset ac_cv_lib_pcreposix_regcomp
454 AC_CHECK_LIB(pcre,pcre_exec)
455 AC_CHECK_LIB(pcreposix,regcomp)
456 if test "x$ac_cv_lib_pcre_pcre_exec" = xyes && test "x$ac_cv_lib_pcreposix_regcomp" = xyes; then
457 AC_MSG_CHECKING(if PCRE_STATIC needs to be defined)
458 AC_LINK_IFELSE(
459 [AC_LANG_SOURCE(#include <pcreposix.h>
460 int main() { return regcomp(NULL, NULL, 0); })],
461 [without_pcre_static=yes],
462 [without_pcre_static=no])
463 AC_LINK_IFELSE(
464 [AC_LANG_SOURCE(#define PCRE_STATIC
465 #include <pcreposix.h>
466 int main() { return regcomp(NULL, NULL, 0); })],
467 [with_pcre_static=yes],
468 [with_pcre_static=no])
469 if test "x$without_pcre_static" != xyes && test "x$with_pcre_static" = xyes; then
470 AC_MSG_RESULT(yes)
471 AC_DEFINE([PCRE_STATIC], [1], [Define to 1 if PCRE_STATIC needs to be defined.])
472 elif test "x$without_pcre_static" = xyes || test "x$with_pcre_static" = xyes; then
473 AC_MSG_RESULT(no)
474 fi
475 posix_regex_lib_found=1
476 fi
477 else
478 posix_regex_lib_found=1
479 fi
480 fi
481
482 # TODO: Give the user the option of using a pre-existing system
483 # libarchive. This will define HAVE_LIBARCHIVE which will cause
484 # bsdtar_platform.h to use #include <...> for the libarchive headers.
485 # Need to include Makefile.am magic to link against system
486 # -larchive in that case.
487 #AC_CHECK_LIB(archive,archive_version)
488
489 # Checks for supported compiler flags
490 AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
491
492 # Checks for typedefs, structures, and compiler characteristics.
493 AC_C_CONST
494 # la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
495 # and MSVC. Use a customized version.
496 la_TYPE_UID_T
497 AC_TYPE_MODE_T
498 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
499 # most systems... default to "long long" instead.
500 AC_CHECK_TYPE(off_t, [long long])
501 AC_TYPE_SIZE_T
502 AC_CHECK_TYPE(id_t, [unsigned long])
503 AC_CHECK_TYPE(uintptr_t, [unsigned int])
504
505 # Check for tm_gmtoff in struct tm
506 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
507 [
508 #include <time.h>
509 ])
510
511 # Check for f_namemax in struct statfs
512 AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
513 [
514 #include <sys/param.h>
515 #include <sys/mount.h>
516 ])
517
518 # Check for f_iosize in struct statvfs
519 AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
520 [
521 #include <sys/statvfs.h>
522 ])
523
524 # Check for birthtime in struct stat
525 AC_CHECK_MEMBERS([struct stat.st_birthtime])
526
527 # Check for high-resolution timestamps in struct stat
528 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
529 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
530 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
531 AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
532 AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
533 AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
534 # Check for block size support in struct stat
535 AC_CHECK_MEMBERS([struct stat.st_blksize])
536 # Check for st_flags in struct stat (BSD fflags)
537 AC_CHECK_MEMBERS([struct stat.st_flags])
538
539 # If you have uintmax_t, we assume printf supports %ju
540 # If you have unsigned long long, we assume printf supports %llu
541 # TODO: Check for %ju and %llu support directly.
542 AC_CHECK_TYPES([uintmax_t, unsigned long long])
543
544 # We use C99-style integer types
545 # Declare them if the local platform doesn't already do so.
546 AC_TYPE_INTMAX_T
547 AC_TYPE_UINTMAX_T
548 AC_TYPE_INT64_T
549 AC_TYPE_UINT64_T
550 AC_TYPE_INT32_T
551 AC_TYPE_UINT32_T
552 AC_TYPE_INT16_T
553 AC_TYPE_UINT16_T
554 AC_TYPE_UINT8_T
555
556 AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
557 AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
558 AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
559
560 AC_CHECK_DECL([SSIZE_MAX],
561 [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.])],
562 [],
563 [#include <limits.h>])
564
565 AC_CHECK_DECL([EFTYPE],
566 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
567 [],
568 [#include <errno.h>])
569 AC_CHECK_DECL([EILSEQ],
570 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
571 [],
572 [#include <errno.h>])
573 AC_CHECK_TYPE([wchar_t],
574 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
575 AC_CHECK_SIZEOF([wchar_t])],
576 [])
577
578 AC_HEADER_TIME
579
580 # Checks for library functions.
581 AC_PROG_GCC_TRADITIONAL
582 AC_HEADER_MAJOR
583 AC_FUNC_FSEEKO
584 AC_FUNC_MEMCMP
585 AC_FUNC_LSTAT
586 AC_FUNC_STAT
587 AC_FUNC_STRERROR_R
588 AC_FUNC_STRFTIME
589 AC_FUNC_VPRINTF
590 # check for:
591 # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
592 # To avoid necessity for including windows.h or special forward declaration
593 # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
594 AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
595 AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r dirfd])
596 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
597 AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
598 AC_CHECK_FUNCS([futimens futimes futimesat])
599 AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
600 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
601 AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat lutimes])
602 AC_CHECK_FUNCS([mbrtowc memmove memset])
603 AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
604 AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
605 AC_CHECK_FUNCS([readpassphrase])
606 AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
607 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
608 AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
609 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
610 AC_CHECK_FUNCS([_ctime64_s _fseeki64])
611 AC_CHECK_FUNCS([_get_timezone _localtime64_s _mkgmtime64])
612 # detects cygwin-1.7, as opposed to older versions
613 AC_CHECK_FUNCS([cygwin_conv_path])
614
615 # There are several variants of readdir_r around; we only
616 # accept the POSIX-compliant version.
617 AC_COMPILE_IFELSE(
618 [AC_LANG_PROGRAM([[#include <dirent.h>]],
619 [[DIR *dir; struct dirent e, *r;
620 return(readdir_r(dir, &e, &r));]])],
621 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
622 )
623
624 # FreeBSD's nl_langinfo supports an option to specify whether the
625 # current locale uses month/day or day/month ordering. It makes the
626 # output a little prettier...
627 AC_CHECK_DECL([D_MD_ORDER],
628 [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
629 [],
630 [#if HAVE_LANGINFO_H
631 #include <langinfo.h>
632 #endif
633 ])
634
635 # Check for dirent.d_namlen field explicitly
636 # (This is a bit more straightforward than, if not quite as portable as,
637 # the recipe given by the autoconf maintainers.)
638 AC_CHECK_MEMBER(struct dirent.d_namlen,,,
639 [#if HAVE_DIRENT_H
640 #include <dirent.h>
641 #endif
642 ])
643
644 # Check for Extended Attributes support
645 AC_ARG_ENABLE([xattr],
646 AS_HELP_STRING([--disable-xattr],
647 [Disable Extended Attributes support (default: check)]))
648
649 if test "x$enable_xattr" != "xno"; then
650 AC_CHECK_HEADERS([attr/xattr.h])
651 AC_CHECK_HEADERS([sys/xattr.h sys/ea.h])
652 AC_SEARCH_LIBS([setxattr], [attr])
653 AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
654 AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
655 AC_CHECK_FUNCS([fgetxattr flistxattr fsetxattr getxattr])
656 AC_CHECK_FUNCS([lgetxattr listxattr llistxattr lsetxattr])
657 AC_CHECK_FUNCS([fgetea flistea fsetea getea])
658 AC_CHECK_FUNCS([lgetea listea llistea lsetea])
659 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
660 #include <sys/extattr.h>
661 ])
662 fi
663
664 # Check for ACL support
665 #
666 # The ACL support in libarchive is written against the POSIX1e draft,
667 # which was never officially approved and varies quite a bit across
668 # platforms. Worse, some systems have completely non-POSIX acl functions,
669 # which makes the following checks rather more complex than I would like.
670 #
671 AC_ARG_ENABLE([acl],
672 AS_HELP_STRING([--disable-acl],
673 [Disable ACL support (default: check)]))
674
675 if test "x$enable_acl" != "xno"; then
676 AC_CHECK_HEADERS([acl/libacl.h])
677 AC_CHECK_HEADERS([sys/acl.h])
678 AC_CHECK_LIB([acl],[acl_get_file])
679 AC_CHECK_FUNCS([acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file])
680
681 AC_CHECK_TYPES(acl_permset_t,,,
682 [#if HAVE_SYS_TYPES_H
683 #include <sys/types.h>
684 #endif
685 #if HAVE_SYS_ACL_H
686 #include <sys/acl.h>
687 #endif
688 ])
689
690 # The "acl_get_perm()" function was omitted from the POSIX draft.
691 # (It's a pretty obvious oversight; otherwise, there's no way to
692 # test for specific permissions in a permset.) Linux uses the obvious
693 # name, FreeBSD adds _np to mark it as "non-Posix extension."
694 # Test for both as a double-check that we really have POSIX-style ACL support.
695 AC_CHECK_FUNCS(acl_get_perm_np acl_get_perm acl_get_link acl_get_link_np,,,
696 [#if HAVE_SYS_TYPES_H
697 #include <sys/types.h>
698 #endif
699 #if HAVE_SYS_ACL_H
700 #include <sys/acl.h>
701 #endif
702 ])
703
704 # MacOS has an acl.h that isn't POSIX. It can be detected by
705 # checking for ACL_USER
706 AC_CHECK_DECL([ACL_USER],
707 [AC_DEFINE(HAVE_ACL_USER, 1, [True for systems with POSIX ACL support])],
708 [],
709 [#include <sys/acl.h>])
710 fi
711
712 # Additional requirements
713 AC_SYS_LARGEFILE
714
715 dnl NOTE: Crypto checks must run last.
716 AC_DEFUN([CRYPTO_CHECK], [
717 if test "$found_$1" != yes; then
718 saved_CPPFLAGS="$CPPFLAGS"
719 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
720 touch "check_crypto_md.h"
721 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_$2])
722 AC_LINK_IFELSE([AC_LANG_SOURCE([
723 #define ARCHIVE_$1_COMPILE_TEST
724 #define ARCHIVE_CRYPTO_$1_$2
725 #define PLATFORM_CONFIG_H "check_crypto_md.h"
726
727 $(cat "$srcdir/libarchive/archive_digest.c")
728
729 int
730 main(int argc, char **argv)
731 {
732 archive_$3_ctx ctx;
733 archive_$3_init(&ctx);
734 archive_$3_update(&ctx, *argv, argc);
735 archive_$3_final(&ctx, NULL);
736 return 0;
737 }
738 ])],
739 [ AC_MSG_RESULT([yes])
740 found_$1=yes
741 found_$2=yes
742 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
743 ],
744 [ AC_MSG_RESULT([no])])
745 CPPFLAGS="$saved_CPPFLAGS"
746 rm "check_crypto_md.h"
747 fi
748 ])
749
750 AC_DEFUN([CRYPTO_CHECK_WIN], [
751 if test "$found_$1" != yes; then
752 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_WIN])
753 AC_LINK_IFELSE([AC_LANG_SOURCE([
754 #define ARCHIVE_$1_COMPILE_TEST
755 #include <windows.h>
756 #include <wincrypt.h>
757
758 int
759 main(int argc, char **argv)
760 {
761 (void)argc;
762 (void)argv;
763
764 return ($2);
765 }
766 ])],
767 [ AC_MSG_RESULT([yes])
768 found_$1=yes
769 found_WIN=yes
770 AC_DEFINE(ARCHIVE_CRYPTO_$1_WIN, 1, [ $1 via ARCHIVE_CRYPTO_$1_WIN supported.])
771 ],
772 [ AC_MSG_RESULT([no])])
773 fi
774 ])
775
776 case "$host_os" in
777 *mingw* | *cygwin*)
778 ;;
779 *)
780 CRYPTO_CHECK(MD5, LIBC, md5)
781 CRYPTO_CHECK(MD5, LIBSYSTEM, md5)
782 CRYPTO_CHECK(RMD160, LIBC, rmd160)
783 CRYPTO_CHECK(SHA1, LIBC, sha1)
784 CRYPTO_CHECK(SHA1, LIBSYSTEM, sha1)
785 CRYPTO_CHECK(SHA256, LIBC, sha256)
786 CRYPTO_CHECK(SHA256, LIBC2, sha256)
787 CRYPTO_CHECK(SHA256, LIBC3, sha256)
788 CRYPTO_CHECK(SHA256, LIBSYSTEM, sha256)
789 CRYPTO_CHECK(SHA384, LIBC, sha384)
790 CRYPTO_CHECK(SHA384, LIBC2, sha384)
791 CRYPTO_CHECK(SHA384, LIBC3, sha384)
792 CRYPTO_CHECK(SHA384, LIBSYSTEM, sha384)
793 CRYPTO_CHECK(SHA512, LIBC, sha512)
794 CRYPTO_CHECK(SHA512, LIBC2, sha512)
795 CRYPTO_CHECK(SHA512, LIBC3, sha512)
796 CRYPTO_CHECK(SHA512, LIBSYSTEM, sha512)
797 ;;
798 esac
799
800 if test "x$with_nettle" != "xno"; then
801 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
802 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
803 saved_LIBS=$LIBS
804 AC_CHECK_LIB(nettle,nettle_sha1_init)
805 CRYPTO_CHECK(MD5, NETTLE, md5)
806 CRYPTO_CHECK(RMD160, NETTLE, rmd160)
807 CRYPTO_CHECK(SHA1, NETTLE, sha1)
808 CRYPTO_CHECK(SHA256, NETTLE, sha256)
809 CRYPTO_CHECK(SHA384, NETTLE, sha384)
810 CRYPTO_CHECK(SHA512, NETTLE, sha512)
811 if test "x$found_NETTLE" != "xyes"; then
812 LIBS=$saved_LIBS
813 fi
814 fi
815
816 if test "x$with_openssl" != "xno"; then
817 AC_CHECK_HEADERS([openssl/evp.h])
818 saved_LIBS=$LIBS
819 case "$host_os" in
820 *mingw* | *cygwin*)
821 case "$host_cpu" in
822 x86_64)
823 AC_CHECK_LIB(eay64,OPENSSL_config)
824 if test "x$ac_cv_lib_eay64_main" != "xyes"; then
825 AC_CHECK_LIB(eay32,OPENSSL_config)
826 fi
827 ;;
828 *)
829 AC_CHECK_LIB(eay32,OPENSSL_config)
830 ;;
831 esac
832 ;;
833 *)
834 AC_CHECK_LIB(crypto,OPENSSL_config)
835 ;;
836 esac
837 CRYPTO_CHECK(MD5, OPENSSL, md5)
838 CRYPTO_CHECK(RMD160, OPENSSL, rmd160)
839 CRYPTO_CHECK(SHA1, OPENSSL, sha1)
840 CRYPTO_CHECK(SHA256, OPENSSL, sha256)
841 CRYPTO_CHECK(SHA384, OPENSSL, sha384)
842 CRYPTO_CHECK(SHA512, OPENSSL, sha512)
843 if test "x$found_OPENSSL" != "xyes"; then
844 LIBS=$saved_LIBS
845 else
846 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
847 fi
848 fi
849
850 # Probe libmd AFTER OpenSSL/libcrypto.
851 # The two are incompatible and OpenSSL is more complete.
852 AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
853 saved_LIBS=$LIBS
854 AC_CHECK_LIB(md,MD5Init)
855 CRYPTO_CHECK(MD5, LIBMD, md5)
856 CRYPTO_CHECK(RMD160, LIBMD, rmd160)
857 CRYPTO_CHECK(SHA1, LIBMD, sha1)
858 CRYPTO_CHECK(SHA256, LIBMD, sha256)
859 CRYPTO_CHECK(SHA512, LIBMD, sha512)
860 if test "x$found_LIBMD" != "xyes"; then
861 LIBS=$saved_LIBS
862 fi
863
864 case "$host_os" in
865 *mingw* | *cygwin*)
866 CRYPTO_CHECK_WIN(MD5, CALG_MD5)
867 CRYPTO_CHECK_WIN(SHA1, CALG_SHA1)
868 CRYPTO_CHECK_WIN(SHA256, CALG_SHA_256)
869 CRYPTO_CHECK_WIN(SHA384, CALG_SHA_384)
870 CRYPTO_CHECK_WIN(SHA512, CALG_SHA_512)
871 ;;
872 esac
873
874 # Ensure test directories are present if building out-of-tree
875 AC_CONFIG_COMMANDS([mkdirs],
876 [mkdir -p libarchive/test tar/test cat/test cpio/test])
877
878 AC_OUTPUT