configure.ac 40 KB

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