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