xref: /netbsd-src/external/bsd/file/dist/configure.ac (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([file],[5.33],[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 locale.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 signal.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])],,[
102#ifdef HAVE_SIGNAL_H
103#include <signal.h>
104#endif])
105
106dnl Checks for typedefs, structures, and compiler characteristics.
107AC_C_CONST
108AC_TYPE_OFF_T
109AC_TYPE_SIZE_T
110AC_CHECK_MEMBERS([struct stat.st_rdev])
111
112AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
113AC_STRUCT_TIMEZONE
114AC_STRUCT_TIMEZONE_DAYLIGHT
115AC_SYS_LARGEFILE
116AC_FUNC_FSEEKO
117AC_TYPE_MBSTATE_T
118
119AC_STRUCT_OPTION_GETOPT_H
120AC_TYPE_PID_T
121AC_TYPE_UINT8_T
122AC_TYPE_UINT16_T
123AC_TYPE_UINT32_T
124AC_TYPE_INT32_T
125AC_TYPE_UINT64_T
126AC_TYPE_INT64_T
127AC_TYPE_INTPTR_T
128AC_TYPE_UINTPTR_T
129AC_FUNC_MMAP
130AC_FUNC_FORK
131AC_FUNC_MBRTOWC
132
133AC_MSG_CHECKING(for gcc compiler warnings)
134AC_ARG_ENABLE(warnings,
135[  --disable-warnings	disable compiler warnings],
136[if test "${enableval}" = no -o "$GCC" = no; then
137   AC_MSG_RESULT(no)
138   WARNINGS=
139else
140   AC_MSG_RESULT(yes)
141   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
142       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
143       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
144       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
145fi], [
146if test "$GCC" = yes; then
147   AC_MSG_RESULT(yes)
148   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
149       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
150       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
151       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
152else
153   WARNINGS=
154   AC_MSG_RESULT(no)
155fi])
156
157dnl Checks for functions
158AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale)
159
160dnl Provide implementation of some required functions if necessary
161AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
162
163dnl Checks for libraries
164if test "$enable_zlib" != "no"; then
165  AC_CHECK_LIB(z, gzopen)
166fi
167if test "$enable_libseccomp" != "no"; then
168    AC_CHECK_LIB(seccomp, seccomp_init)
169fi
170if test "$MINGW" = 1; then
171  AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
172fi
173
174dnl See if we are cross-compiling
175AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
176
177dnl Final sanity checks
178if test "$enable_zlib" = "yes"; then
179  if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
180    AC_MSG_ERROR([zlib support requested but not found])
181  fi
182elif  test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
183  AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
184fi
185
186AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
187AC_OUTPUT
188