configure.ac revision 298920
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([file],[5.26],[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 file formats in man section 5)
38AC_ARG_ENABLE(fsect-man5,
39[  --enable-fsect-man5      enable file formats in man section 5],
40[if test "${enableval}" = yes; then
41  AC_MSG_RESULT(yes)
42  fsect=5
43else
44  AC_MSG_RESULT(no)
45  fsect=4
46fi], [
47  # disable by default
48  AC_MSG_RESULT(no)
49  fsect=4
50])
51
52AC_CANONICAL_HOST
53case "$host_os" in
54   mingw32*)
55      MINGW=1
56      ;;
57   *)
58      MINGW=0
59      ;;
60esac
61AC_SUBST(MINGW)
62AM_CONDITIONAL(MINGW, test "$MINGW" = 1)
63
64AC_SUBST([pkgdatadir], ['$(datadir)/misc'])
65AC_SUBST(fsect)
66AM_CONDITIONAL(FSECT5, test x$fsect = x5)
67
68AC_SUBST(WARNINGS)
69
70dnl Checks for programs.
71AC_PROG_CC_STDC
72AC_USE_SYSTEM_EXTENSIONS
73AM_PROG_CC_C_O
74AC_C_BIGENDIAN
75AC_PROG_INSTALL
76AC_PROG_LN_S
77LT_INIT([disable-static pic-only])
78gl_VISIBILITY
79dnl Checks for headers
80AC_HEADER_STDC
81AC_HEADER_MAJOR
82AC_HEADER_SYS_WAIT
83AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
84AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
85AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h)
86AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
87AC_CHECK_HEADERS(zlib.h)
88AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[
89#ifdef HAVE_SIGNAL_H
90#include <signal.h>
91#endif])
92
93dnl Checks for typedefs, structures, and compiler characteristics.
94AC_C_CONST
95AC_TYPE_OFF_T
96AC_TYPE_SIZE_T
97AC_CHECK_MEMBERS([struct stat.st_rdev])
98
99AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
100AC_STRUCT_TIMEZONE
101AC_STRUCT_TIMEZONE_DAYLIGHT
102AC_SYS_LARGEFILE
103AC_FUNC_FSEEKO
104AC_TYPE_MBSTATE_T
105
106AC_STRUCT_OPTION_GETOPT_H
107AC_TYPE_PID_T
108AC_TYPE_UINT8_T
109AC_TYPE_UINT16_T
110AC_TYPE_UINT32_T
111AC_TYPE_INT32_T
112AC_TYPE_UINT64_T
113AC_TYPE_INT64_T
114AC_TYPE_INTPTR_T
115AC_TYPE_UINTPTR_T
116AC_FUNC_MMAP
117AC_FUNC_FORK
118AC_FUNC_MBRTOWC
119
120AC_MSG_CHECKING(for gcc compiler warnings)
121AC_ARG_ENABLE(warnings,
122[  --disable-warnings	disable compiler warnings],
123[if test "${enableval}" = no -o "$GCC" = no; then
124   AC_MSG_RESULT(no)
125   WARNINGS=
126else
127   AC_MSG_RESULT(yes)
128   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
129       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
130       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
131       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
132fi], [
133if test "$GCC" = yes; then
134   AC_MSG_RESULT(yes)
135   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
136       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
137       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
138       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
139else
140   WARNINGS=
141   AC_MSG_RESULT(no)
142fi])
143
144dnl Checks for functions
145AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale)
146
147dnl Provide implementation of some required functions if necessary
148AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
149
150dnl Checks for libraries
151AC_CHECK_LIB(z,gzopen)
152if test "$MINGW" = 1; then
153  AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
154fi
155
156dnl See if we are cross-compiling
157AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
158
159AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
160AC_OUTPUT
161