configure.ac 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT([file],[5.44],[christos@astron.com])
  3. AM_INIT_AUTOMAKE([subdir-objects foreign])
  4. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  5. AC_CONFIG_HEADERS([config.h])
  6. AC_CONFIG_MACRO_DIR([m4])
  7. AC_MSG_CHECKING(for builtin ELF support)
  8. AC_ARG_ENABLE(elf,
  9. [ --disable-elf disable builtin ELF support],
  10. [if test "${enableval}" = yes; then
  11. AC_MSG_RESULT(yes)
  12. AC_DEFINE([BUILTIN_ELF], 1, [Define if built-in ELF support is used])
  13. else
  14. AC_MSG_RESULT(no)
  15. fi], [
  16. # enable by default
  17. AC_MSG_RESULT(yes)
  18. AC_DEFINE([BUILTIN_ELF], 1, [Define in built-in ELF support is used])
  19. ])
  20. AC_MSG_CHECKING(for ELF core file support)
  21. AC_ARG_ENABLE(elf-core,
  22. [ --disable-elf-core disable ELF core file support],
  23. [if test "${enableval}" = yes; then
  24. AC_MSG_RESULT(yes)
  25. AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
  26. else
  27. AC_MSG_RESULT(no)
  28. fi], [
  29. # enable by default
  30. AC_MSG_RESULT(yes)
  31. AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
  32. ])
  33. AC_MSG_CHECKING(for zlib support)
  34. AC_ARG_ENABLE([zlib],
  35. [AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])])
  36. AC_MSG_RESULT($enable_zlib)
  37. AC_MSG_CHECKING(for bzlib support)
  38. AC_ARG_ENABLE([bzlib],
  39. [AS_HELP_STRING([--disable-bzlib], [disable bz2lib compression support @<:@default=auto@:>@])])
  40. AC_MSG_RESULT($enable_bzlib)
  41. AC_MSG_CHECKING(for xzlib support)
  42. AC_ARG_ENABLE([xzlib],
  43. [AS_HELP_STRING([--disable-xzlib], [disable liblzma/xz compression support @<:@default=auto@:>@])])
  44. AC_MSG_RESULT($enable_xzlib)
  45. AC_MSG_CHECKING(for zstdlib support)
  46. AC_ARG_ENABLE([zstdlib],
  47. [AS_HELP_STRING([--disable-zstdlib], [disable zstdlib compression support @<:@default=auto@:>@])])
  48. AC_MSG_RESULT($enable_zstdlib)
  49. AC_MSG_CHECKING(for lzlib support)
  50. AC_ARG_ENABLE([lzlib],
  51. [AS_HELP_STRING([--disable-lzlib], [disable liblz (lzip) compression support @<:@default=auto@:>@])])
  52. AC_MSG_RESULT($enable_lzlib)
  53. AC_MSG_CHECKING(for libseccomp support)
  54. AC_ARG_ENABLE([libseccomp],
  55. [AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
  56. AC_MSG_RESULT($enable_libseccomp)
  57. AC_MSG_CHECKING(for file formats in man section 5)
  58. AC_ARG_ENABLE(fsect-man5,
  59. [ --enable-fsect-man5 enable file formats in man section 5],
  60. [if test "${enableval}" = yes; then
  61. AC_MSG_RESULT(yes)
  62. fsect=5
  63. else
  64. AC_MSG_RESULT(no)
  65. fsect=4
  66. fi], [
  67. # disable by default
  68. AC_MSG_RESULT(no)
  69. fsect=4
  70. ])
  71. AC_CANONICAL_HOST
  72. case "$host_os" in
  73. mingw32*)
  74. MINGW=1
  75. ;;
  76. *)
  77. MINGW=0
  78. ;;
  79. esac
  80. AC_SUBST(MINGW)
  81. AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
  82. AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
  83. AC_SUBST(fsect)
  84. AM_CONDITIONAL(FSECT5, test x$fsect = x5)
  85. AC_SUBST(WARNINGS)
  86. dnl Checks for programs.
  87. AC_PROG_CC
  88. AC_USE_SYSTEM_EXTENSIONS
  89. AM_PROG_CC_C_O
  90. AC_C_BIGENDIAN
  91. AC_PROG_INSTALL
  92. AC_PROG_LN_S
  93. LT_INIT([disable-static pic-only])
  94. gl_VISIBILITY
  95. dnl Checks for headers
  96. AC_HEADER_MAJOR
  97. AC_HEADER_SYS_WAIT
  98. AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h byteswap.h)
  99. AC_CHECK_HEADERS(spawn.h utime.h wchar.h wctype.h)
  100. AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
  101. AC_CHECK_HEADERS(sys/bswap.h sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h sys/ioctl.h)
  102. if test "$enable_zlib" != "no"; then
  103. AC_CHECK_HEADERS(zlib.h)
  104. fi
  105. if test "$enable_bzlib" != "no"; then
  106. AC_CHECK_HEADERS(bzlib.h)
  107. fi
  108. if test "$enable_xzlib" != "no"; then
  109. AC_CHECK_HEADERS(lzma.h)
  110. fi
  111. if test "$enable_zstdlib" != "no"; then
  112. AC_CHECK_HEADERS(zstd.h zstd_errors.h)
  113. fi
  114. if test "$enable_lzlib" != "no"; then
  115. AC_CHECK_HEADERS(lzlib.h)
  116. fi
  117. AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
  118. dnl Checks for typedefs, structures, and compiler characteristics.
  119. AC_TYPE_OFF_T
  120. AC_TYPE_SIZE_T
  121. AC_CHECK_MEMBERS([struct stat.st_rdev])
  122. AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
  123. AC_STRUCT_TIMEZONE
  124. AC_STRUCT_TIMEZONE_DAYLIGHT
  125. AC_SYS_LARGEFILE
  126. AC_FUNC_FSEEKO
  127. AC_TYPE_MBSTATE_T
  128. AC_STRUCT_OPTION_GETOPT_H
  129. AC_TYPE_PID_T
  130. AC_TYPE_UINT8_T
  131. AC_TYPE_UINT16_T
  132. AC_TYPE_UINT32_T
  133. AC_TYPE_INT32_T
  134. AC_TYPE_UINT64_T
  135. AC_TYPE_INT64_T
  136. AC_TYPE_INTPTR_T
  137. AC_TYPE_UINTPTR_T
  138. AC_FUNC_MMAP
  139. AC_FUNC_FORK
  140. AC_FUNC_MBRTOWC
  141. AC_MSG_CHECKING(for gcc compiler warnings)
  142. AC_ARG_ENABLE(warnings,
  143. [ --disable-warnings disable compiler warnings],
  144. [if test "${enableval}" = no -o "$GCC" = no; then
  145. AC_MSG_RESULT(no)
  146. WARNINGS=
  147. else
  148. AC_MSG_RESULT(yes)
  149. WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  150. -Wmissing-declarations -Wredundant-decls -Wnested-externs \
  151. -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
  152. -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
  153. fi], [
  154. if test "$GCC" = yes; then
  155. AC_MSG_RESULT(yes)
  156. WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  157. -Wmissing-declarations -Wredundant-decls -Wnested-externs \
  158. -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
  159. -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
  160. else
  161. WARNINGS=
  162. AC_MSG_RESULT(no)
  163. fi])
  164. dnl Checks for functions
  165. AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 posix_spawnp)
  166. dnl Provide implementation of some required functions if necessary
  167. AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
  168. dnl Checks for libraries
  169. if test "$enable_zlib" != "no"; then
  170. AC_CHECK_LIB(z, gzopen)
  171. fi
  172. if test "$enable_bzlib" != "no"; then
  173. AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
  174. fi
  175. if test "$enable_xzlib" != "no"; then
  176. AC_CHECK_LIB(lzma, lzma_stream_decoder)
  177. fi
  178. if test "$enable_zstdlib" != "no"; then
  179. AC_CHECK_LIB(zstd, ZSTD_createDStream)
  180. fi
  181. if test "$enable_lzlib" != "no"; then
  182. AC_CHECK_LIB(lz, LZ_decompress_open)
  183. fi
  184. if test "$enable_libseccomp" != "no"; then
  185. AC_CHECK_LIB(seccomp, seccomp_init)
  186. fi
  187. if test "$MINGW" = 1; then
  188. AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
  189. fi
  190. dnl See if we are cross-compiling
  191. AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
  192. dnl Final sanity checks
  193. if test "$enable_zlib" = "yes"; then
  194. if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
  195. AC_MSG_ERROR([zlib support requested but not found])
  196. fi
  197. fi
  198. if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
  199. AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
  200. fi
  201. if test "$enable_bzlib" = "yes"; then
  202. if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then
  203. AC_MSG_ERROR([bzlib support requested but not found])
  204. fi
  205. fi
  206. if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then
  207. AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support])
  208. fi
  209. if test "$enable_xzlib" = "yes"; then
  210. if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" != "yesyes"; then
  211. AC_MSG_ERROR([xzlib support requested but not found])
  212. fi
  213. fi
  214. if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" = "yesyes"; then
  215. AC_DEFINE([XZLIBSUPPORT], 1, [Enable xzlib compression support])
  216. fi
  217. if test "$enable_zstdlib" = "yes"; then
  218. if test "$ac_cv_header_zstd_h$ac_cv_lib_zstd_ZSTD_createDStream" != "yesyes"; then
  219. AC_MSG_ERROR([zstdlib support requested but not found])
  220. fi
  221. fi
  222. if test "$ac_cv_header_zstd_h$ac_cv_lib_zstd_ZSTD_createDStream" = "yesyes"; then
  223. AC_DEFINE([ZSTDLIBSUPPORT], 1, [Enable zstdlib compression support])
  224. fi
  225. if test "$enable_lzlib" = "yes"; then
  226. if test "$ac_cv_header_lzlib_h$ac_cv_lib_lz_LZ_decompress_open" != "yesyes"; then
  227. AC_MSG_ERROR([lzlib support requested but not found])
  228. fi
  229. fi
  230. if test "$ac_cv_header_lzlib_h$ac_cv_lib_lz_LZ_decompress_open" = "yesyes"; then
  231. AC_DEFINE([LZLIBSUPPORT], 1, [Enable lzlib compression support])
  232. fi
  233. AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile libmagic.pc])
  234. AC_OUTPUT