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