xref: /freebsd/contrib/file/configure.ac (revision 271171e0d97b88ba2a7c3bf750c9672b484c1c13)
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([file],[5.42],[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 bzlib support)
43AC_ARG_ENABLE([bzlib],
44[AS_HELP_STRING([--disable-bzlib], [disable bz2lib compression support @<:@default=auto@:>@])])
45AC_MSG_RESULT($enable_bzlib)
46
47AC_MSG_CHECKING(for xzlib support)
48AC_ARG_ENABLE([xzlib],
49[AS_HELP_STRING([--disable-xzlib], [disable liblzma/xz compression support @<:@default=auto@:>@])])
50AC_MSG_RESULT($enable_xzlib)
51
52AC_MSG_CHECKING(for libseccomp support)
53AC_ARG_ENABLE([libseccomp],
54[AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
55AC_MSG_RESULT($enable_libseccomp)
56
57AC_MSG_CHECKING(for file formats in man section 5)
58AC_ARG_ENABLE(fsect-man5,
59[  --enable-fsect-man5      enable file formats in man section 5],
60[if test "${enableval}" = yes; then
61  AC_MSG_RESULT(yes)
62  fsect=5
63else
64  AC_MSG_RESULT(no)
65  fsect=4
66fi], [
67  # disable by default
68  AC_MSG_RESULT(no)
69  fsect=4
70])
71
72AC_CANONICAL_HOST
73case "$host_os" in
74   mingw32*)
75      MINGW=1
76      ;;
77   *)
78      MINGW=0
79      ;;
80esac
81AC_SUBST(MINGW)
82AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
83
84AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
85AC_SUBST(fsect)
86AM_CONDITIONAL(FSECT5, test x$fsect = x5)
87
88AC_SUBST(WARNINGS)
89
90dnl Checks for programs.
91AC_PROG_CC
92AC_USE_SYSTEM_EXTENSIONS
93AM_PROG_CC_C_O
94AC_C_BIGENDIAN
95AC_PROG_INSTALL
96AC_PROG_LN_S
97LT_INIT([disable-static pic-only])
98gl_VISIBILITY
99dnl Checks for headers
100AC_HEADER_MAJOR
101AC_HEADER_SYS_WAIT
102AC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h byteswap.h)
103AC_CHECK_HEADERS(spawn.h utime.h wchar.h wctype.h)
104AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
105AC_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)
106if test "$enable_zlib" != "no"; then
107  AC_CHECK_HEADERS(zlib.h)
108fi
109if test "$enable_bzlib" != "no"; then
110  AC_CHECK_HEADERS(bzlib.h)
111fi
112if test "$enable_xzlib" != "no"; then
113  AC_CHECK_HEADERS(lzma.h)
114fi
115AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
116
117dnl Checks for typedefs, structures, and compiler characteristics.
118AC_TYPE_OFF_T
119AC_TYPE_SIZE_T
120AC_CHECK_MEMBERS([struct stat.st_rdev])
121
122AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
123AC_STRUCT_TIMEZONE
124AC_STRUCT_TIMEZONE_DAYLIGHT
125AC_SYS_LARGEFILE
126AC_FUNC_FSEEKO
127AC_TYPE_MBSTATE_T
128
129AC_STRUCT_OPTION_GETOPT_H
130AC_TYPE_PID_T
131AC_TYPE_UINT8_T
132AC_TYPE_UINT16_T
133AC_TYPE_UINT32_T
134AC_TYPE_INT32_T
135AC_TYPE_UINT64_T
136AC_TYPE_INT64_T
137AC_TYPE_INTPTR_T
138AC_TYPE_UINTPTR_T
139AC_FUNC_MMAP
140AC_FUNC_FORK
141AC_FUNC_MBRTOWC
142
143AC_MSG_CHECKING(for gcc compiler warnings)
144AC_ARG_ENABLE(warnings,
145[  --disable-warnings	disable compiler warnings],
146[if test "${enableval}" = no -o "$GCC" = no; then
147   AC_MSG_RESULT(no)
148   WARNINGS=
149else
150   AC_MSG_RESULT(yes)
151   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
152       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
153       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
154       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
155fi], [
156if test "$GCC" = yes; then
157   AC_MSG_RESULT(yes)
158   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
159       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
160       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
161       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
162else
163   WARNINGS=
164   AC_MSG_RESULT(no)
165fi])
166
167dnl Checks for functions
168AC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 posix_spawnp)
169
170dnl Provide implementation of some required functions if necessary
171AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
172
173dnl Checks for libraries
174if test "$enable_zlib" != "no"; then
175  AC_CHECK_LIB(z, gzopen)
176fi
177if test "$enable_bzlib" != "no"; then
178  AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
179fi
180if test "$enable_xzlib" != "no"; then
181  AC_CHECK_LIB(lzma, lzma_stream_decoder)
182fi
183if test "$enable_libseccomp" != "no"; then
184    AC_CHECK_LIB(seccomp, seccomp_init)
185fi
186if test "$MINGW" = 1; then
187  AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
188fi
189
190dnl See if we are cross-compiling
191AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
192
193dnl Final sanity checks
194if test "$enable_zlib" = "yes"; then
195  if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
196    AC_MSG_ERROR([zlib support requested but not found])
197  fi
198fi
199if  test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
200  AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
201fi
202if test "$enable_bzlib" = "yes"; then
203  if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then
204    AC_MSG_ERROR([bzlib support requested but not found])
205  fi
206fi
207if  test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then
208  AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support])
209fi
210if test "$enable_xzlib" = "yes"; then
211  if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" != "yesyes"; then
212    AC_MSG_ERROR([xzlib support requested but not found])
213  fi
214fi
215if  test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" = "yesyes"; then
216  AC_DEFINE([XZLIBSUPPORT], 1, [Enable xzlib compression support])
217fi
218
219AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile libmagic.pc])
220AC_OUTPUT
221