configure.ac 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT([file],[5.34],[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 libseccomp support)
  38. AC_ARG_ENABLE(libseccomp,
  39. [AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
  40. AC_MSG_RESULT($enable_libseccomp)
  41. AC_MSG_CHECKING(for file formats in man section 5)
  42. AC_ARG_ENABLE(fsect-man5,
  43. [ --enable-fsect-man5 enable file formats in man section 5],
  44. [if test "${enableval}" = yes; then
  45. AC_MSG_RESULT(yes)
  46. fsect=5
  47. else
  48. AC_MSG_RESULT(no)
  49. fsect=4
  50. fi], [
  51. # disable by default
  52. AC_MSG_RESULT(no)
  53. fsect=4
  54. ])
  55. AC_CANONICAL_HOST
  56. case "$host_os" in
  57. mingw32*)
  58. MINGW=1
  59. ;;
  60. *)
  61. MINGW=0
  62. ;;
  63. esac
  64. AC_SUBST(MINGW)
  65. AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
  66. AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
  67. AC_SUBST(fsect)
  68. AM_CONDITIONAL(FSECT5, test x$fsect = x5)
  69. AC_SUBST(WARNINGS)
  70. dnl Checks for programs.
  71. AC_PROG_CC_STDC
  72. AC_USE_SYSTEM_EXTENSIONS
  73. AM_PROG_CC_C_O
  74. AC_C_BIGENDIAN
  75. AC_PROG_INSTALL
  76. AC_PROG_LN_S
  77. LT_INIT([disable-static pic-only])
  78. gl_VISIBILITY
  79. dnl Checks for headers
  80. AC_HEADER_STDC
  81. AC_HEADER_MAJOR
  82. AC_HEADER_SYS_WAIT
  83. AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
  84. AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
  85. AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h)
  86. AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
  87. if test "$enable_zlib" != "no"; then
  88. AC_CHECK_HEADERS(zlib.h)
  89. fi
  90. AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[
  91. #ifdef HAVE_SIGNAL_H
  92. #include <signal.h>
  93. #endif])
  94. dnl Checks for typedefs, structures, and compiler characteristics.
  95. AC_C_CONST
  96. AC_TYPE_OFF_T
  97. AC_TYPE_SIZE_T
  98. AC_CHECK_MEMBERS([struct stat.st_rdev])
  99. AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
  100. AC_STRUCT_TIMEZONE
  101. AC_STRUCT_TIMEZONE_DAYLIGHT
  102. AC_SYS_LARGEFILE
  103. AC_FUNC_FSEEKO
  104. AC_TYPE_MBSTATE_T
  105. AC_STRUCT_OPTION_GETOPT_H
  106. AC_TYPE_PID_T
  107. AC_TYPE_UINT8_T
  108. AC_TYPE_UINT16_T
  109. AC_TYPE_UINT32_T
  110. AC_TYPE_INT32_T
  111. AC_TYPE_UINT64_T
  112. AC_TYPE_INT64_T
  113. AC_TYPE_INTPTR_T
  114. AC_TYPE_UINTPTR_T
  115. AC_FUNC_MMAP
  116. AC_FUNC_FORK
  117. AC_FUNC_MBRTOWC
  118. AC_MSG_CHECKING(for gcc compiler warnings)
  119. AC_ARG_ENABLE(warnings,
  120. [ --disable-warnings disable compiler warnings],
  121. [if test "${enableval}" = no -o "$GCC" = no; then
  122. AC_MSG_RESULT(no)
  123. WARNINGS=
  124. else
  125. AC_MSG_RESULT(yes)
  126. WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  127. -Wmissing-declarations -Wredundant-decls -Wnested-externs \
  128. -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
  129. -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
  130. fi], [
  131. if test "$GCC" = yes; then
  132. AC_MSG_RESULT(yes)
  133. WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  134. -Wmissing-declarations -Wredundant-decls -Wnested-externs \
  135. -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
  136. -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
  137. else
  138. WARNINGS=
  139. AC_MSG_RESULT(no)
  140. fi])
  141. dnl Checks for functions
  142. AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale)
  143. dnl Provide implementation of some required functions if necessary
  144. AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
  145. dnl Checks for libraries
  146. if test "$enable_zlib" != "no"; then
  147. AC_CHECK_LIB(z, gzopen)
  148. fi
  149. if test "$enable_libseccomp" != "no"; then
  150. AC_CHECK_LIB(seccomp, seccomp_init)
  151. fi
  152. if test "$MINGW" = 1; then
  153. AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
  154. fi
  155. dnl See if we are cross-compiling
  156. AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
  157. dnl Final sanity checks
  158. if test "$enable_zlib" = "yes"; then
  159. if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
  160. AC_MSG_ERROR([zlib support requested but not found])
  161. fi
  162. elif test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
  163. AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
  164. fi
  165. AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
  166. AC_OUTPUT