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