configure.ac 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT(file, 5.11, christos@astron.com)
  3. AM_INIT_AUTOMAKE()
  4. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  5. AM_CONFIG_HEADER(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 file formats in man section 5)
  34. AC_ARG_ENABLE(fsect-man5,
  35. [ --enable-fsect-man5 enable file formats in man section 5],
  36. [if test "${enableval}" = yes; then
  37. AC_MSG_RESULT(yes)
  38. fsect=5
  39. else
  40. AC_MSG_RESULT(no)
  41. fsect=4
  42. fi], [
  43. # disable by default
  44. AC_MSG_RESULT(no)
  45. fsect=4
  46. ])
  47. AC_CANONICAL_HOST
  48. case "$host_os" in
  49. mingw32*)
  50. MINGW=1
  51. ;;
  52. *)
  53. MINGW=0
  54. ;;
  55. esac
  56. AC_SUBST(MINGW)
  57. AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
  58. AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
  59. AC_SUBST(fsect)
  60. AM_CONDITIONAL(FSECT5, test x$fsect = x5)
  61. AC_SUBST(WARNINGS)
  62. AC_GNU_SOURCE
  63. dnl Checks for programs.
  64. AC_PROG_CC
  65. AM_PROG_CC_C_O
  66. AC_PROG_INSTALL
  67. AC_PROG_LN_S
  68. AC_PROG_LIBTOOL
  69. dnl Checks for headers
  70. AC_HEADER_STDC
  71. AC_HEADER_MAJOR
  72. AC_HEADER_SYS_WAIT
  73. AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
  74. AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
  75. AC_CHECK_HEADERS(getopt.h err.h)
  76. AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
  77. AC_CHECK_HEADERS(zlib.h)
  78. dnl Checks for typedefs, structures, and compiler characteristics.
  79. AC_C_CONST
  80. AC_TYPE_OFF_T
  81. AC_TYPE_SIZE_T
  82. AC_CHECK_MEMBERS([struct stat.st_rdev])
  83. AC_STRUCT_TM
  84. AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.tm_zone])
  85. AC_STRUCT_TIMEZONE_DAYLIGHT
  86. AC_SYS_LARGEFILE
  87. AC_FUNC_FSEEKO
  88. AC_TYPE_MBSTATE_T
  89. AC_STRUCT_OPTION_GETOPT_H
  90. AC_CHECK_TYPES([pid_t, uint8_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t])
  91. AC_CHECK_SIZEOF(long long)
  92. AH_BOTTOM([
  93. #ifndef HAVE_UINT8_T
  94. typedef unsigned char uint8_t;
  95. #endif
  96. #ifndef HAVE_UINT16_T
  97. typedef unsigned short uint16_t;
  98. #endif
  99. #ifndef HAVE_UINT32_T
  100. typedef unsigned int uint32_t;
  101. #endif
  102. #ifndef HAVE_INT32_T
  103. typedef int int32_t;
  104. #endif
  105. #ifndef HAVE_UINT64_T
  106. #if SIZEOF_LONG_LONG == 8
  107. typedef unsigned long long uint64_t;
  108. #else
  109. typedef unsigned long uint64_t;
  110. #endif
  111. #endif
  112. #ifndef HAVE_INT64_T
  113. #if SIZEOF_LONG_LONG == 8
  114. typedef long long int64_t;
  115. #else
  116. typedef long int64_t;
  117. #endif
  118. #endif
  119. ])
  120. AC_MSG_CHECKING(for gcc compiler warnings)
  121. AC_ARG_ENABLE(warnings,
  122. [ --disable-warnings disable compiler warnings],
  123. [if test "${enableval}" = no -o "$GCC" = no; then
  124. AC_MSG_RESULT(no)
  125. WARNINGS=
  126. else
  127. AC_MSG_RESULT(yes)
  128. WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  129. -Wmissing-declarations -Wredundant-decls -Wnested-externs \
  130. -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
  131. -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
  132. fi], [
  133. if test "$GCC" = yes; then
  134. AC_MSG_RESULT(yes)
  135. WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  136. -Wmissing-declarations -Wredundant-decls -Wnested-externs \
  137. -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
  138. -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
  139. else
  140. WARNINGS=
  141. AC_MSG_RESULT(no)
  142. fi])
  143. dnl Checks for functions
  144. AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp utimes utime wcwidth strtof fork)
  145. dnl Provide implementation of some required functions if necessary
  146. AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline)
  147. dnl Checks for libraries
  148. AC_CHECK_LIB(z,gzopen)
  149. if test "$MINGW" = 1; then
  150. AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
  151. fi
  152. dnl See if we are cross-compiling
  153. AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
  154. AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
  155. AC_OUTPUT