1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT([file],[5.45],[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 bzlib support)
43 AC_ARG_ENABLE([bzlib],
44 [AS_HELP_STRING([--disable-bzlib], [disable bz2lib compression support @<:@default=auto@:>@])])
45 AC_MSG_RESULT($enable_bzlib)
47 AC_MSG_CHECKING(for xzlib support)
48 AC_ARG_ENABLE([xzlib],
49 [AS_HELP_STRING([--disable-xzlib], [disable liblzma/xz compression support @<:@default=auto@:>@])])
50 AC_MSG_RESULT($enable_xzlib)
52 AC_MSG_CHECKING(for zstdlib support)
53 AC_ARG_ENABLE([zstdlib],
54 [AS_HELP_STRING([--disable-zstdlib], [disable zstdlib compression support @<:@default=auto@:>@])])
55 AC_MSG_RESULT($enable_zstdlib)
57 AC_MSG_CHECKING(for lzlib support)
58 AC_ARG_ENABLE([lzlib],
59 [AS_HELP_STRING([--disable-lzlib], [disable liblz (lzip) compression support @<:@default=auto@:>@])])
60 AC_MSG_RESULT($enable_lzlib)
62 AC_MSG_CHECKING(for libseccomp support)
63 AC_ARG_ENABLE([libseccomp],
64 [AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
65 AC_MSG_RESULT($enable_libseccomp)
67 AC_MSG_CHECKING(for file formats in man section 5)
68 AC_ARG_ENABLE(fsect-man5,
69 [ --enable-fsect-man5 enable file formats in man section 5],
70 [if test "${enableval}" = yes; then
92 AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
94 AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
96 AM_CONDITIONAL(FSECT5, test x$fsect = x5)
100 dnl Checks for programs.
102 AC_USE_SYSTEM_EXTENSIONS
107 LT_INIT([disable-static pic-only])
109 dnl Checks for headers
112 AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h byteswap.h)
113 AC_CHECK_HEADERS(spawn.h utime.h wchar.h wctype.h)
114 AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
115 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)
116 if test "$enable_zlib" != "no"; then
117 AC_CHECK_HEADERS(zlib.h)
119 if test "$enable_bzlib" != "no"; then
120 AC_CHECK_HEADERS(bzlib.h)
122 if test "$enable_xzlib" != "no"; then
123 AC_CHECK_HEADERS(lzma.h)
125 if test "$enable_zstdlib" != "no"; then
126 AC_CHECK_HEADERS(zstd.h zstd_errors.h)
128 if test "$enable_lzlib" != "no"; then
129 AC_CHECK_HEADERS(lzlib.h)
131 AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
133 dnl Checks for typedefs, structures, and compiler characteristics.
136 AC_CHECK_MEMBERS([struct stat.st_rdev])
138 AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
140 AC_STRUCT_TIMEZONE_DAYLIGHT
145 AC_STRUCT_OPTION_GETOPT_H
159 AC_MSG_CHECKING(for gcc compiler warnings)
160 AC_ARG_ENABLE(warnings,
161 [ --disable-warnings disable compiler warnings],
162 [if test "${enableval}" = no -o "$GCC" = no; then
167 WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
168 -Wmissing-declarations -Wredundant-decls -Wnested-externs \
169 -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
170 -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
172 if test "$GCC" = yes; then
174 WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
175 -Wmissing-declarations -Wredundant-decls -Wnested-externs \
176 -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
177 -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
183 dnl Checks for functions
184 AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 posix_spawnp)
186 dnl Provide implementation of some required functions if necessary
187 AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
189 dnl Checks for libraries
190 if test "$enable_zlib" != "no"; then
191 AC_CHECK_LIB(z, gzopen)
193 if test "$enable_bzlib" != "no"; then
194 AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
196 if test "$enable_xzlib" != "no"; then
197 AC_CHECK_LIB(lzma, lzma_stream_decoder)
199 if test "$enable_zstdlib" != "no"; then
200 AC_CHECK_LIB(zstd, ZSTD_createDStream)
202 if test "$enable_lzlib" != "no"; then
203 AC_CHECK_LIB(lz, LZ_decompress_open)
205 if test "$enable_libseccomp" != "no"; then
206 AC_CHECK_LIB(seccomp, seccomp_init)
208 if test "$MINGW" = 1; then
209 AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
212 dnl See if we are cross-compiling
213 AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
215 dnl Final sanity checks
216 if test "$enable_zlib" = "yes"; then
217 if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
218 AC_MSG_ERROR([zlib support requested but not found])
221 if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
222 AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
224 if test "$enable_bzlib" = "yes"; then
225 if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then
226 AC_MSG_ERROR([bzlib support requested but not found])
229 if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then
230 AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support])
232 if test "$enable_xzlib" = "yes"; then
233 if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" != "yesyes"; then
234 AC_MSG_ERROR([xzlib support requested but not found])
237 if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" = "yesyes"; then
238 AC_DEFINE([XZLIBSUPPORT], 1, [Enable xzlib compression support])
240 if test "$enable_zstdlib" = "yes"; then
241 if test "$ac_cv_header_zstd_h$ac_cv_lib_zstd_ZSTD_createDStream" != "yesyes"; then
242 AC_MSG_ERROR([zstdlib support requested but not found])
245 if test "$ac_cv_header_zstd_h$ac_cv_lib_zstd_ZSTD_createDStream" = "yesyes"; then
246 AC_DEFINE([ZSTDLIBSUPPORT], 1, [Enable zstdlib compression support])
248 if test "$enable_lzlib" = "yes"; then
249 if test "$ac_cv_header_lzlib_h$ac_cv_lib_lz_LZ_decompress_open" != "yesyes"; then
250 AC_MSG_ERROR([lzlib support requested but not found])
253 if test "$ac_cv_header_lzlib_h$ac_cv_lib_lz_LZ_decompress_open" = "yesyes"; then
254 AC_DEFINE([LZLIBSUPPORT], 1, [Enable lzlib compression support])
257 AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile libmagic.pc])