1186690Sobriendnl Process this file with autoconf to produce a configure script.
2328875SeadlerAC_INIT([file],[5.32],[christos@astron.com])
3268515SdelphijAM_INIT_AUTOMAKE([subdir-objects foreign])
4234449Sobrienm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
5234449Sobrien
6268515SdelphijAC_CONFIG_HEADERS([config.h])
7234449SobrienAC_CONFIG_MACRO_DIR([m4])
8186690Sobrien
9186690SobrienAC_MSG_CHECKING(for builtin ELF support)
10186690SobrienAC_ARG_ENABLE(elf,
11186690Sobrien[  --disable-elf            disable builtin ELF support],
12186690Sobrien[if test "${enableval}" = yes; then
13186690Sobrien  AC_MSG_RESULT(yes)
14186690Sobrien  AC_DEFINE([BUILTIN_ELF], 1, [Define if built-in ELF support is used])
15186690Sobrienelse
16186690Sobrien  AC_MSG_RESULT(no)
17186690Sobrienfi], [
18186690Sobrien  # enable by default
19186690Sobrien  AC_MSG_RESULT(yes)
20186690Sobrien  AC_DEFINE([BUILTIN_ELF], 1, [Define in built-in ELF support is used])
21186690Sobrien])
22186690Sobrien
23186690SobrienAC_MSG_CHECKING(for ELF core file support)
24186690SobrienAC_ARG_ENABLE(elf-core,
25186690Sobrien[  --disable-elf-core       disable ELF core file support],
26186690Sobrien[if test "${enableval}" = yes; then
27186690Sobrien  AC_MSG_RESULT(yes)
28186690Sobrien  AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
29186690Sobrienelse
30186690Sobrien  AC_MSG_RESULT(no)
31186690Sobrienfi], [
32186690Sobrien  # enable by default
33186690Sobrien  AC_MSG_RESULT(yes)
34186690Sobrien  AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
35186690Sobrien])
36186690Sobrien
37302555SdelphijAC_MSG_CHECKING(for zlib support)
38302555SdelphijAC_ARG_ENABLE(zlib,
39302555Sdelphij[AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])])
40302555SdelphijAC_MSG_RESULT($enable_zlib)
41302555Sdelphij
42186690SobrienAC_MSG_CHECKING(for file formats in man section 5)
43186690SobrienAC_ARG_ENABLE(fsect-man5,
44186690Sobrien[  --enable-fsect-man5      enable file formats in man section 5],
45186690Sobrien[if test "${enableval}" = yes; then
46186690Sobrien  AC_MSG_RESULT(yes)
47186690Sobrien  fsect=5
48186690Sobrienelse
49186690Sobrien  AC_MSG_RESULT(no)
50186690Sobrien  fsect=4
51186690Sobrienfi], [
52186690Sobrien  # disable by default
53186690Sobrien  AC_MSG_RESULT(no)
54186690Sobrien  fsect=4
55186690Sobrien])
56186690Sobrien
57234449SobrienAC_CANONICAL_HOST
58234449Sobriencase "$host_os" in
59234449Sobrien   mingw32*)
60234449Sobrien      MINGW=1
61234449Sobrien      ;;
62234449Sobrien   *)
63234449Sobrien      MINGW=0
64234449Sobrien      ;;
65234449Sobrienesac
66234449SobrienAC_SUBST(MINGW)
67234449SobrienAM_CONDITIONAL(MINGW, test "$MINGW" = 1)
68234449Sobrien
69192350SdelphijAC_SUBST([pkgdatadir], ['$(datadir)/misc'])
70186690SobrienAC_SUBST(fsect)
71186690SobrienAM_CONDITIONAL(FSECT5, test x$fsect = x5)
72186690Sobrien
73186690SobrienAC_SUBST(WARNINGS)
74186690Sobrien
75186690Sobriendnl Checks for programs.
76268515SdelphijAC_PROG_CC_STDC
77268515SdelphijAC_USE_SYSTEM_EXTENSIONS
78186690SobrienAM_PROG_CC_C_O
79268515SdelphijAC_C_BIGENDIAN
80186690SobrienAC_PROG_INSTALL
81186690SobrienAC_PROG_LN_S
82268515SdelphijLT_INIT([disable-static pic-only])
83268515Sdelphijgl_VISIBILITY
84186690Sobriendnl Checks for headers
85186690SobrienAC_HEADER_STDC
86186690SobrienAC_HEADER_MAJOR
87186690SobrienAC_HEADER_SYS_WAIT
88186690SobrienAC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
89268515SdelphijAC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
90284778SdelphijAC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h)
91186690SobrienAC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
92302555Sdelphijif test "$enable_zlib" != "no"; then
93302555Sdelphij  AC_CHECK_HEADERS(zlib.h)
94302555Sdelphijfi
95284778SdelphijAC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[
96284778Sdelphij#ifdef HAVE_SIGNAL_H
97284778Sdelphij#include <signal.h>
98284778Sdelphij#endif])
99186690Sobrien
100186690Sobriendnl Checks for typedefs, structures, and compiler characteristics.
101186690SobrienAC_C_CONST
102186690SobrienAC_TYPE_OFF_T
103186690SobrienAC_TYPE_SIZE_T
104186690SobrienAC_CHECK_MEMBERS([struct stat.st_rdev])
105186690Sobrien
106268515SdelphijAC_CHECK_MEMBERS([struct tm.tm_gmtoff])
107268515SdelphijAC_STRUCT_TIMEZONE
108186690SobrienAC_STRUCT_TIMEZONE_DAYLIGHT
109186690SobrienAC_SYS_LARGEFILE
110186690SobrienAC_FUNC_FSEEKO
111186690SobrienAC_TYPE_MBSTATE_T
112186690Sobrien
113192350SdelphijAC_STRUCT_OPTION_GETOPT_H
114268515SdelphijAC_TYPE_PID_T
115268515SdelphijAC_TYPE_UINT8_T
116268515SdelphijAC_TYPE_UINT16_T
117268515SdelphijAC_TYPE_UINT32_T
118268515SdelphijAC_TYPE_INT32_T
119268515SdelphijAC_TYPE_UINT64_T
120268515SdelphijAC_TYPE_INT64_T
121268515SdelphijAC_TYPE_INTPTR_T
122268515SdelphijAC_TYPE_UINTPTR_T
123268515SdelphijAC_FUNC_MMAP
124268515SdelphijAC_FUNC_FORK
125268515SdelphijAC_FUNC_MBRTOWC
126192350Sdelphij
127186690SobrienAC_MSG_CHECKING(for gcc compiler warnings)
128186690SobrienAC_ARG_ENABLE(warnings,
129186690Sobrien[  --disable-warnings	disable compiler warnings],
130192350Sdelphij[if test "${enableval}" = no -o "$GCC" = no; then
131186690Sobrien   AC_MSG_RESULT(no)
132186690Sobrien   WARNINGS=
133186690Sobrienelse
134186690Sobrien   AC_MSG_RESULT(yes)
135186690Sobrien   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
136186690Sobrien       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
137186690Sobrien       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
138234449Sobrien       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
139186690Sobrienfi], [
140234449Sobrienif test "$GCC" = yes; then
141186690Sobrien   AC_MSG_RESULT(yes)
142186690Sobrien   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
143186690Sobrien       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
144186690Sobrien       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
145234449Sobrien       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
146234449Sobrienelse
147234449Sobrien   WARNINGS=
148234449Sobrien   AC_MSG_RESULT(no)
149186690Sobrienfi])
150186690Sobrien
151186690Sobriendnl Checks for functions
152276415SdelphijAC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale)
153186690Sobrien
154186690Sobriendnl Provide implementation of some required functions if necessary
155300899SdelphijAC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
156186690Sobrien
157186690Sobriendnl Checks for libraries
158302555Sdelphijif test "$enable_zlib" != "no"; then
159302555Sdelphij  AC_CHECK_LIB(z, gzopen)
160302555Sdelphijfi
161234449Sobrienif test "$MINGW" = 1; then
162234449Sobrien  AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
163234449Sobrienfi
164186690Sobrien
165186690Sobriendnl See if we are cross-compiling
166186690SobrienAM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
167186690Sobrien
168302555Sdelphijdnl Final sanity checks
169302555Sdelphijif test "$enable_zlib" = "yes"; then
170302555Sdelphij  if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
171302555Sdelphij    AC_MSG_ERROR([zlib support requested but not found])
172302555Sdelphij  fi
173302555Sdelphijelif  test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
174302555Sdelphij  AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
175302555Sdelphijfi
176302555Sdelphij
177186690SobrienAC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
178186690SobrienAC_OUTPUT
179