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