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