configure.ac 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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],[2.7.900a])
  6. m4_define([LIBARCHIVE_VERSION_N],[2007900])
  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. #
  11. # Now starts the "real" configure script.
  12. #
  13. AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[[email protected]])
  14. # Make sure the srcdir contains "libarchive" directory
  15. AC_CONFIG_SRCDIR([libarchive])
  16. # Use auxiliary subscripts from this subdirectory (cleans up root)
  17. AC_CONFIG_AUX_DIR([build/autoconf])
  18. # M4 scripts
  19. AC_CONFIG_MACRO_DIR([build/autoconf])
  20. # Must follow AC_CONFIG macros above...
  21. AM_INIT_AUTOMAKE()
  22. # Libtool versioning uses different conventions on different
  23. # platforms. At least on FreeBSD, libtool uses an overly complex
  24. # convention that attempts to solve problems that most people just
  25. # don't have and which just causes confusion for most end users.
  26. ARCHIVE_MAJOR=$(( LIBARCHIVE_VERSION_N() / 1000000 ))
  27. ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
  28. ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
  29. ARCHIVE_LIBTOOL_MAJOR=`echo $((${ARCHIVE_MAJOR} + ${ARCHIVE_MINOR}))`
  30. ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_LIBTOOL_MAJOR:$ARCHIVE_REVISION:$ARCHIVE_MINOR
  31. # Stick the version numbers into config.h
  32. AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
  33. [Version number of libarchive])
  34. AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
  35. [Version number of libarchive as a single integer])
  36. AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
  37. [Version number of bsdcpio])
  38. AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
  39. [Version number of bsdtar])
  40. # The shell variables here must be the same as the AC_SUBST() variables
  41. # below, but the shell variable names apparently cannot be the same as
  42. # the m4 macro names above. Why? Ask autoconf.
  43. BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
  44. BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
  45. LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
  46. LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
  47. # Substitute the above version numbers into the various files below.
  48. # Yes, I believe this is the fourth time we define what are essentially
  49. # the same symbols. Why? Ask autoconf.
  50. AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
  51. AC_SUBST(BSDCPIO_VERSION_STRING)
  52. AC_SUBST(BSDTAR_VERSION_STRING)
  53. AC_SUBST(LIBARCHIVE_VERSION_STRING)
  54. AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
  55. AC_CONFIG_HEADERS([config.h])
  56. AC_CONFIG_FILES([Makefile])
  57. # Check for host type
  58. AC_CANONICAL_HOST
  59. dnl Compilation on mingw and Cygwin needs special Makefile rules
  60. inc_windows_files=no
  61. inc_cygwin_files=no
  62. case "$host_os" in
  63. *mingw* ) inc_windows_files=yes ;;
  64. *cygwin*) inc_cygwin_files=yes ;;
  65. esac
  66. AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
  67. AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
  68. dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
  69. PLATFORMCPPFLAGS=
  70. case "$host_os" in
  71. *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
  72. esac
  73. AC_SUBST(PLATFORMCPPFLAGS)
  74. # Checks for programs.
  75. AC_PROG_CC
  76. AM_PROG_CC_C_O
  77. AC_LIBTOOL_WIN32_DLL
  78. AC_PROG_LIBTOOL
  79. AC_CHECK_TOOL([STRIP],[strip])
  80. #
  81. # Options for building bsdtar.
  82. #
  83. # Default is to build bsdtar, but allow people to override that.
  84. #
  85. AC_ARG_ENABLE([bsdtar],
  86. [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
  87. AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
  88. AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
  89. AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
  90. [], [enable_bsdtar=yes])
  91. case "$enable_bsdtar" in
  92. yes)
  93. if test "$enable_static" = "no"; then
  94. static_bsdtar=no
  95. else
  96. static_bsdtar=yes
  97. fi
  98. build_bsdtar=yes
  99. ;;
  100. dynamic|shared)
  101. if test "$enable_shared" = "no"; then
  102. AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
  103. fi
  104. build_bsdtar=yes
  105. static_bsdtar=no
  106. ;;
  107. static)
  108. build_bsdtar=yes
  109. static_bsdtar=yes
  110. ;;
  111. no)
  112. build_bsdtar=no
  113. static_bsdtar=no
  114. ;;
  115. *)
  116. AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
  117. ;;
  118. esac
  119. AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
  120. AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
  121. #
  122. # Options for building bsdcpio.
  123. #
  124. # Default is not to build bsdcpio, but that can be overridden.
  125. #
  126. AC_ARG_ENABLE([bsdcpio],
  127. [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
  128. AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
  129. AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
  130. AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
  131. [], [enable_bsdcpio=yes])
  132. case "$enable_bsdcpio" in
  133. yes)
  134. if test "$enable_static" = "no"; then
  135. static_bsdcpio=no
  136. else
  137. static_bsdcpio=yes
  138. fi
  139. build_bsdcpio=yes
  140. ;;
  141. dynamic|shared)
  142. if test "$enabled_shared" = "no"; then
  143. AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
  144. fi
  145. build_bsdcpio=yes
  146. ;;
  147. static)
  148. build_bsdcpio=yes
  149. static_bsdcpio=yes
  150. ;;
  151. no)
  152. build_bsdcpio=no
  153. static_bsdcpio=no
  154. ;;
  155. *)
  156. AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
  157. ;;
  158. esac
  159. AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
  160. AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
  161. # Set up defines needed before including any headers
  162. case $host in
  163. *mingw* | *cygwin* )
  164. AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
  165. AC_DEFINE([WINVER], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
  166. ;;
  167. esac
  168. # Checks for header files.
  169. AC_HEADER_STDC
  170. AC_HEADER_DIRENT
  171. AC_HEADER_SYS_WAIT
  172. AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h ctype.h errno.h])
  173. AC_CHECK_HEADERS([ext2fs/ext2_fs.h fcntl.h grp.h])
  174. AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h linux/fs.h])
  175. AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h signal.h stdarg.h])
  176. AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
  177. AC_CHECK_HEADERS([sys/acl.h sys/extattr.h sys/ioctl.h sys/mkdev.h])
  178. AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
  179. AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h windows.h])
  180. # Checks for libraries.
  181. AC_ARG_WITH([zlib],
  182. AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
  183. if test "x$with_zlib" != "xno"; then
  184. AC_CHECK_HEADERS([zlib.h])
  185. AC_CHECK_LIB(z,inflate)
  186. fi
  187. AC_ARG_WITH([bz2lib],
  188. AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
  189. if test "x$with_bz2lib" != "xno"; then
  190. AC_CHECK_HEADERS([bzlib.h])
  191. AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
  192. fi
  193. AC_ARG_WITH([lzmadec],
  194. AS_HELP_STRING([--without-lzmadec], [Don't build support for lzma through lzmadec]))
  195. if test "x$with_lzmadec" != "xno"; then
  196. AC_CHECK_HEADERS([lzmadec.h])
  197. AC_CHECK_LIB(lzmadec,lzmadec_decode)
  198. fi
  199. AC_ARG_WITH([lzma],
  200. AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
  201. if test "x$with_lzma" != "xno"; then
  202. AC_CHECK_HEADERS([lzma.h])
  203. AC_CHECK_LIB(lzma,lzma_stream_decoder)
  204. fi
  205. AC_ARG_WITH([openssl],
  206. AS_HELP_STRING([--without-openssl], [Don't build support for mtree hashes through openssl]))
  207. AC_CHECK_HEADERS([md5.h ripemd.h rmd160.h sha.h sha1.h sha2.h sha256.h])
  208. # Common names for libc implementation on NetBSD and OpenBSD
  209. AC_CHECK_FUNCS(MD5Init RMD160Init SHA1Init)
  210. # SHA2 on NetBSD and older OpenBSD
  211. AC_CHECK_FUNCS(SHA256_Init SHA384_Init SHA512_Init)
  212. # SHA2 on newer OpenBSD
  213. AC_CHECK_FUNCS(SHA256Init SHA384Init SHA512Init)
  214. if test "x$with_openssl" != "xno"; then
  215. if test "$ac_cv_func_MD5Init" != "yes"; then
  216. AC_CHECK_HEADERS([openssl/md5.h])
  217. AC_SEARCH_LIBS([MD5_Init], [crypto])
  218. fi
  219. if test "$ac_cv_func_RMD160Init" != "yes"; then
  220. AC_CHECK_HEADERS([openssl/ripemd.h])
  221. AC_SEARCH_LIBS([RIMEMD160_Init], [crypto])
  222. fi
  223. if test "$ac_cv_func_SHA1Init" != "yes"; then
  224. AC_CHECK_HEADERS([openssl/sha.h])
  225. AC_SEARCH_LIBS([SHA1_Init], [crypto])
  226. fi
  227. if test "$ac_cv_func_SHA256Init" != "yes" ||
  228. test "$ac_cv_func_SHA384Init" != "yes" ||
  229. test "$ac_cv_func_SHA512Init" != "yes"; then
  230. if test "$ac_cv_func_SHA256_Init" != "yes" ||
  231. test "$ac_cv_func_SHA384_Init" != "yes" ||
  232. test "$ac_cv_func_SHA512_Init" != "yes"; then
  233. AC_CHECK_HEADERS([openssl/sha.h])
  234. AC_SEARCH_LIBS([SHA256_Init SHA384_Init SHA512_Init], [crypto])
  235. fi
  236. fi
  237. fi
  238. # TODO: Give the user the option of using a pre-existing system
  239. # libarchive. This will define HAVE_LIBARCHIVE which will cause
  240. # bsdtar_platform.h to use #include <...> for the libarchive headers.
  241. # Need to include Makefile.am magic to link against system
  242. # -larchive in that case.
  243. #AC_CHECK_LIB(archive,archive_version)
  244. # Checks for typedefs, structures, and compiler characteristics.
  245. AC_C_CONST
  246. # AC_TYPE_UID_T defaults to "int", which is incorrect for MinGW
  247. # and MSVC. Use a customized version.
  248. la_TYPE_UID_T
  249. AC_TYPE_MODE_T
  250. # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
  251. # most systems... default to "long long" instead.
  252. AC_CHECK_TYPE(off_t, [long long])
  253. AC_TYPE_SIZE_T
  254. AC_CHECK_TYPE(id_t, [unsigned long])
  255. AC_CHECK_TYPE(uintptr_t, [unsigned int])
  256. # Check for birthtime in struct stat
  257. AC_CHECK_MEMBERS([struct stat.st_birthtime])
  258. # Check for high-resolution timestamps in struct stat
  259. AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
  260. AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
  261. AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
  262. AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
  263. AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
  264. AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
  265. # Check for block size support in struct stat
  266. AC_CHECK_MEMBERS([struct stat.st_blksize])
  267. # Check for st_flags in struct stat (BSD fflags)
  268. AC_CHECK_MEMBERS([struct stat.st_flags])
  269. # If you have uintmax_t, we assume printf supports %ju
  270. # If you have unsigned long long, we assume printf supports %llu
  271. # TODO: Check for %ju and %llu support directly.
  272. AC_CHECK_TYPES([uintmax_t, unsigned long long])
  273. # We need int64_t, uint64_t, intmax_t, and uintmax_t
  274. AC_TYPE_INTMAX_T
  275. AC_TYPE_INT64_T
  276. AC_TYPE_UINTMAX_T
  277. AC_TYPE_UINT64_T
  278. # TODO: If any of these are missing, define them right here.
  279. AC_CHECK_DECLS([SIZE_MAX, SSIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
  280. AC_CHECK_DECL([EFTYPE],
  281. [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
  282. [],
  283. [#include <errno.h>])
  284. AC_CHECK_DECL([EILSEQ],
  285. [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
  286. [],
  287. [#include <errno.h>])
  288. AC_CHECK_TYPE([wchar_t],
  289. [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
  290. AC_CHECK_SIZEOF([wchar_t])],
  291. [])
  292. AC_HEADER_TIME
  293. # Checks for library functions.
  294. AC_PROG_GCC_TRADITIONAL
  295. AC_HEADER_MAJOR
  296. AC_FUNC_FSEEKO
  297. AC_FUNC_MEMCMP
  298. AC_FUNC_LSTAT
  299. AC_FUNC_STAT
  300. AC_FUNC_STRERROR_R
  301. AC_FUNC_STRFTIME
  302. AC_FUNC_VPRINTF
  303. # check for:
  304. # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
  305. # To avoid necessity for including windows.h or special forward declaration
  306. # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
  307. AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
  308. AC_CHECK_FUNCS([chflags chown chroot])
  309. AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork])
  310. AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid])
  311. AC_CHECK_FUNCS([lchflags lchmod lchown link lstat])
  312. AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod])
  313. AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale])
  314. AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
  315. AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork])
  316. AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy])
  317. # detects cygwin-1.7, as opposed to older versions
  318. AC_CHECK_FUNCS([cygwin_conv_path])
  319. # FreeBSD's nl_langinfo supports an option to specify whether the
  320. # current locale uses month/day or day/month ordering. It makes the
  321. # output a little prettier...
  322. AC_CHECK_DECL([D_MD_ORDER],
  323. [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
  324. [],
  325. [#if HAVE_LANGINFO_H
  326. #include <langinfo.h>
  327. #endif
  328. ])
  329. # Check for dirent.d_namlen field explicitly
  330. # (This is a bit more straightforward than, if not quite as portable as,
  331. # the recipe given by the autoconf maintainers.)
  332. AC_CHECK_MEMBER(struct dirent.d_namlen,,,
  333. [#if HAVE_DIRENT_H
  334. #include <dirent.h>
  335. #endif
  336. ])
  337. # Check for Extended Attributes support
  338. AC_ARG_ENABLE([xattr],
  339. AS_HELP_STRING([--disable-xattr],
  340. [Enable Extended Attributes support (default: check)]))
  341. if test "x$enable_xattr" != "xno"; then
  342. AC_CHECK_HEADERS([attr/xattr.h])
  343. AC_CHECK_HEADERS([sys/xattr.h])
  344. AC_CHECK_LIB(attr,setxattr)
  345. AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
  346. AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
  347. AC_CHECK_FUNCS([fsetxattr getxattr])
  348. AC_CHECK_FUNCS([lgetxattr listxattr llistxattr lsetxattr])
  349. fi
  350. # Check for ACL support
  351. #
  352. # The ACL support in libarchive is written against the POSIX1e draft,
  353. # which was never officially approved and varies quite a bit across
  354. # platforms. Worse, some systems have completely non-POSIX acl functions,
  355. # which makes the following checks rather more complex than I would like.
  356. #
  357. AC_ARG_ENABLE([acl],
  358. AS_HELP_STRING([--disable-acl],
  359. [Enable ACL support (default: check)]))
  360. if test "x$enable_acl" != "xno"; then
  361. AC_CHECK_HEADERS([sys/acl.h])
  362. AC_CHECK_LIB([acl],[acl_get_file])
  363. AC_CHECK_FUNCS([acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file])
  364. AC_CHECK_TYPES(acl_permset_t,,,
  365. [#if HAVE_SYS_TYPES_H
  366. #include <sys/types.h>
  367. #endif
  368. #if HAVE_SYS_ACL_H
  369. #include <sys/acl.h>
  370. #endif
  371. ])
  372. # The "acl_get_perm()" function was omitted from the POSIX draft.
  373. # (It's a pretty obvious oversight; otherwise, there's no way to
  374. # test for specific permissions in a permset.) Linux uses the obvious
  375. # name, FreeBSD adds _np to mark it as "non-Posix extension."
  376. # Test for both as a double-check that we really have POSIX-style ACL support.
  377. AC_CHECK_FUNCS(acl_get_perm_np acl_get_perm acl_get_link acl_get_link_np,,,
  378. [#if HAVE_SYS_TYPES_H
  379. #include <sys/types.h>
  380. #endif
  381. #if HAVE_SYS_ACL_H
  382. #include <sys/acl.h>
  383. #endif
  384. ])
  385. # MacOS has an acl.h that isn't POSIX. It can be detected by
  386. # checking for ACL_USER
  387. AC_CHECK_DECL([ACL_USER],
  388. [AC_DEFINE(HAVE_ACL_USER, 1, [True for systems with POSIX ACL support])],
  389. [],
  390. [#include <sys/acl.h>])
  391. fi
  392. # Additional requirements
  393. AC_SYS_LARGEFILE
  394. AC_OUTPUT