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