1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT([file],[5.37],[christos@astron.com])
3 AM_INIT_AUTOMAKE([subdir-objects foreign])
4 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_MACRO_DIR([m4])
9 AC_MSG_CHECKING(for builtin ELF support)
11 [ --disable-elf disable builtin ELF support],
12 [if test "${enableval}" = yes; then
14 AC_DEFINE([BUILTIN_ELF], 1, [Define if built-in ELF support is used])
20 AC_DEFINE([BUILTIN_ELF], 1, [Define in built-in ELF support is used])
23 AC_MSG_CHECKING(for ELF core file support)
24 AC_ARG_ENABLE(elf-core,
25 [ --disable-elf-core disable ELF core file support],
26 [if test "${enableval}" = yes; then
28 AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
34 AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
37 AC_MSG_CHECKING(for zlib support)
39 [AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])])
40 AC_MSG_RESULT($enable_zlib)
42 AC_MSG_CHECKING(for libseccomp support)
43 AC_ARG_ENABLE([libseccomp],
44 [AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
45 AC_MSG_RESULT($enable_libseccomp)
47 AC_MSG_CHECKING(for file formats in man section 5)
48 AC_ARG_ENABLE(fsect-man5,
49 [ --enable-fsect-man5 enable file formats in man section 5],
50 [if test "${enableval}" = yes; then
72 AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
74 AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
76 AM_CONDITIONAL(FSECT5, test x$fsect = x5)
80 dnl Checks for programs.
82 AC_USE_SYSTEM_EXTENSIONS
87 LT_INIT([disable-static pic-only])
89 dnl Checks for headers
93 AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h)
94 AC_CHECK_HEADERS(utime.h wchar.h wctype.h)
95 AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
96 AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sysmacros.h)
97 if test "$enable_zlib" != "no"; then
98 AC_CHECK_HEADERS(zlib.h)
100 AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
102 dnl Checks for typedefs, structures, and compiler characteristics.
105 AC_CHECK_MEMBERS([struct stat.st_rdev])
107 AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
109 AC_STRUCT_TIMEZONE_DAYLIGHT
114 AC_STRUCT_OPTION_GETOPT_H
128 AC_MSG_CHECKING(for gcc compiler warnings)
129 AC_ARG_ENABLE(warnings,
130 [ --disable-warnings disable compiler warnings],
131 [if test "${enableval}" = no -o "$GCC" = no; then
136 WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
137 -Wmissing-declarations -Wredundant-decls -Wnested-externs \
138 -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
139 -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
141 if test "$GCC" = yes; then
143 WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
144 -Wmissing-declarations -Wredundant-decls -Wnested-externs \
145 -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
146 -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
152 dnl Checks for functions
153 AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem)
155 dnl Provide implementation of some required functions if necessary
156 AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
158 dnl Checks for libraries
159 if test "$enable_zlib" != "no"; then
160 AC_CHECK_LIB(z, gzopen)
162 if test "$enable_libseccomp" != "no"; then
163 AC_CHECK_LIB(seccomp, seccomp_init)
165 if test "$MINGW" = 1; then
166 AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
169 dnl See if we are cross-compiling
170 AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
172 dnl Final sanity checks
173 if test "$enable_zlib" = "yes"; then
174 if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
175 AC_MSG_ERROR([zlib support requested but not found])
178 if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
179 AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
182 AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])