configure.ac 42 KB

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