xref: /netbsd-src/external/bsd/file/dist/configure.ac (revision ddb176824c39fb0db5ceef3e9e40dcaa273aec38)
11b108b8bSchristosdnl Process this file with autoconf to produce a configure script.
2*ddb17682SchristosAC_INIT([file],[5.45],[christos@astron.com])
320d96732SchristosAM_INIT_AUTOMAKE([subdir-objects foreign])
457171280SchristosAM_MAINTAINER_MODE(disable)
55ccaa8c0Schristosm4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
65ccaa8c0Schristos
720d96732SchristosAC_CONFIG_HEADERS([config.h])
85ccaa8c0SchristosAC_CONFIG_MACRO_DIR([m4])
91b108b8bSchristos
101b108b8bSchristosAC_MSG_CHECKING(for builtin ELF support)
111b108b8bSchristosAC_ARG_ENABLE(elf,
121b108b8bSchristos[  --disable-elf            disable builtin ELF support],
131b108b8bSchristos[if test "${enableval}" = yes; then
141b108b8bSchristos  AC_MSG_RESULT(yes)
151b108b8bSchristos  AC_DEFINE([BUILTIN_ELF], 1, [Define if built-in ELF support is used])
161b108b8bSchristoselse
171b108b8bSchristos  AC_MSG_RESULT(no)
181b108b8bSchristosfi], [
191b108b8bSchristos  # enable by default
201b108b8bSchristos  AC_MSG_RESULT(yes)
211b108b8bSchristos  AC_DEFINE([BUILTIN_ELF], 1, [Define in built-in ELF support is used])
221b108b8bSchristos])
231b108b8bSchristos
241b108b8bSchristosAC_MSG_CHECKING(for ELF core file support)
251b108b8bSchristosAC_ARG_ENABLE(elf-core,
261b108b8bSchristos[  --disable-elf-core       disable ELF core file support],
271b108b8bSchristos[if test "${enableval}" = yes; then
281b108b8bSchristos  AC_MSG_RESULT(yes)
291b108b8bSchristos  AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
301b108b8bSchristoselse
311b108b8bSchristos  AC_MSG_RESULT(no)
321b108b8bSchristosfi], [
331b108b8bSchristos  # enable by default
341b108b8bSchristos  AC_MSG_RESULT(yes)
351b108b8bSchristos  AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
361b108b8bSchristos])
371b108b8bSchristos
3874db5203SchristosAC_MSG_CHECKING(for zlib support)
39d0c65b7bSchristosAC_ARG_ENABLE([zlib],
4074db5203Schristos[AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])])
4174db5203SchristosAC_MSG_RESULT($enable_zlib)
4274db5203Schristos
4378a23c3aSchristosAC_MSG_CHECKING(for bzlib support)
4478a23c3aSchristosAC_ARG_ENABLE([bzlib],
4578a23c3aSchristos[AS_HELP_STRING([--disable-bzlib], [disable bz2lib compression support @<:@default=auto@:>@])])
4678a23c3aSchristosAC_MSG_RESULT($enable_bzlib)
4778a23c3aSchristos
4878a23c3aSchristosAC_MSG_CHECKING(for xzlib support)
4978a23c3aSchristosAC_ARG_ENABLE([xzlib],
5078a23c3aSchristos[AS_HELP_STRING([--disable-xzlib], [disable liblzma/xz compression support @<:@default=auto@:>@])])
5178a23c3aSchristosAC_MSG_RESULT($enable_xzlib)
5278a23c3aSchristos
531d4cb158SchristosAC_MSG_CHECKING(for zstdlib support)
541d4cb158SchristosAC_ARG_ENABLE([zstdlib],
551d4cb158Schristos[AS_HELP_STRING([--disable-zstdlib], [disable zstdlib compression support @<:@default=auto@:>@])])
561d4cb158SchristosAC_MSG_RESULT($enable_zstdlib)
571d4cb158Schristos
581d4cb158SchristosAC_MSG_CHECKING(for lzlib support)
591d4cb158SchristosAC_ARG_ENABLE([lzlib],
601d4cb158Schristos[AS_HELP_STRING([--disable-lzlib], [disable liblz (lzip) compression support @<:@default=auto@:>@])])
611d4cb158SchristosAC_MSG_RESULT($enable_lzlib)
621d4cb158Schristos
635efe63deSchristosAC_MSG_CHECKING(for libseccomp support)
64d0c65b7bSchristosAC_ARG_ENABLE([libseccomp],
655efe63deSchristos[AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
665efe63deSchristosAC_MSG_RESULT($enable_libseccomp)
675efe63deSchristos
681b108b8bSchristosAC_MSG_CHECKING(for file formats in man section 5)
691b108b8bSchristosAC_ARG_ENABLE(fsect-man5,
701b108b8bSchristos[  --enable-fsect-man5      enable file formats in man section 5],
711b108b8bSchristos[if test "${enableval}" = yes; then
721b108b8bSchristos  AC_MSG_RESULT(yes)
731b108b8bSchristos  fsect=5
741b108b8bSchristoselse
751b108b8bSchristos  AC_MSG_RESULT(no)
761b108b8bSchristos  fsect=4
771b108b8bSchristosfi], [
781b108b8bSchristos  # disable by default
791b108b8bSchristos  AC_MSG_RESULT(no)
801b108b8bSchristos  fsect=4
811b108b8bSchristos])
821b108b8bSchristos
835ccaa8c0SchristosAC_CANONICAL_HOST
845ccaa8c0Schristoscase "$host_os" in
855ccaa8c0Schristos   mingw32*)
865ccaa8c0Schristos      MINGW=1
875ccaa8c0Schristos      ;;
885ccaa8c0Schristos   *)
895ccaa8c0Schristos      MINGW=0
905ccaa8c0Schristos      ;;
915ccaa8c0Schristosesac
925ccaa8c0SchristosAC_SUBST(MINGW)
935ccaa8c0SchristosAM_CONDITIONAL(MINGW, test "$MINGW" = 1)
945ccaa8c0Schristos
951b108b8bSchristosAC_SUBST([pkgdatadir], ['$(datadir)/misc'])
961b108b8bSchristosAC_SUBST(fsect)
971b108b8bSchristosAM_CONDITIONAL(FSECT5, test x$fsect = x5)
981b108b8bSchristos
991b108b8bSchristosAC_SUBST(WARNINGS)
1001b108b8bSchristos
1011b108b8bSchristosdnl Checks for programs.
1021d4cb158SchristosAC_PROG_CC
10320d96732SchristosAC_USE_SYSTEM_EXTENSIONS
1041b108b8bSchristosAM_PROG_CC_C_O
10520d96732SchristosAC_C_BIGENDIAN
1061b108b8bSchristosAC_PROG_INSTALL
1071b108b8bSchristosAC_PROG_LN_S
10820d96732SchristosLT_INIT([disable-static pic-only])
10920d96732Schristosgl_VISIBILITY
1101b108b8bSchristosdnl Checks for headers
1111b108b8bSchristosAC_HEADER_MAJOR
1121b108b8bSchristosAC_HEADER_SYS_WAIT
1131d4cb158SchristosAC_CHECK_HEADERS(stdint.h fcntl.h inttypes.h unistd.h byteswap.h)
1141d4cb158SchristosAC_CHECK_HEADERS(spawn.h utime.h wchar.h wctype.h)
115c02f7f97SchristosAC_CHECK_HEADERS(getopt.h err.h xlocale.h)
1161d4cb158SchristosAC_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)
11774db5203Schristosif test "$enable_zlib" != "no"; then
1181b108b8bSchristos  AC_CHECK_HEADERS(zlib.h)
11974db5203Schristosfi
12078a23c3aSchristosif test "$enable_bzlib" != "no"; then
12178a23c3aSchristos  AC_CHECK_HEADERS(bzlib.h)
12278a23c3aSchristosfi
12378a23c3aSchristosif test "$enable_xzlib" != "no"; then
12478a23c3aSchristos  AC_CHECK_HEADERS(lzma.h)
12578a23c3aSchristosfi
1261d4cb158Schristosif test "$enable_zstdlib" != "no"; then
1271d4cb158Schristos  AC_CHECK_HEADERS(zstd.h zstd_errors.h)
1281d4cb158Schristosfi
1291d4cb158Schristosif test "$enable_lzlib" != "no"; then
1301d4cb158Schristos  AC_CHECK_HEADERS(lzlib.h)
1311d4cb158Schristosfi
132c02f7f97SchristosAC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
1331b108b8bSchristos
1341b108b8bSchristosdnl Checks for typedefs, structures, and compiler characteristics.
1351b108b8bSchristosAC_TYPE_OFF_T
1361b108b8bSchristosAC_TYPE_SIZE_T
1371b108b8bSchristosAC_CHECK_MEMBERS([struct stat.st_rdev])
1381b108b8bSchristos
139d0c65b7bSchristosAC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
14020d96732SchristosAC_STRUCT_TIMEZONE
1411b108b8bSchristosAC_STRUCT_TIMEZONE_DAYLIGHT
1421b108b8bSchristosAC_SYS_LARGEFILE
1431b108b8bSchristosAC_FUNC_FSEEKO
1441b108b8bSchristosAC_TYPE_MBSTATE_T
1451b108b8bSchristos
1461b108b8bSchristosAC_STRUCT_OPTION_GETOPT_H
14720d96732SchristosAC_TYPE_PID_T
14820d96732SchristosAC_TYPE_UINT8_T
14920d96732SchristosAC_TYPE_UINT16_T
15020d96732SchristosAC_TYPE_UINT32_T
15120d96732SchristosAC_TYPE_INT32_T
15220d96732SchristosAC_TYPE_UINT64_T
15320d96732SchristosAC_TYPE_INT64_T
154819e6405SchristosAC_TYPE_INTPTR_T
155819e6405SchristosAC_TYPE_UINTPTR_T
15620d96732SchristosAC_FUNC_MMAP
15720d96732SchristosAC_FUNC_FORK
15820d96732SchristosAC_FUNC_MBRTOWC
1591b108b8bSchristos
1601b108b8bSchristosAC_MSG_CHECKING(for gcc compiler warnings)
1611b108b8bSchristosAC_ARG_ENABLE(warnings,
1621b108b8bSchristos[  --disable-warnings	disable compiler warnings],
1631b108b8bSchristos[if test "${enableval}" = no -o "$GCC" = no; then
1641b108b8bSchristos   AC_MSG_RESULT(no)
1651b108b8bSchristos   WARNINGS=
1661b108b8bSchristoselse
1671b108b8bSchristos   AC_MSG_RESULT(yes)
1681b108b8bSchristos   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
1691b108b8bSchristos       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
1701b108b8bSchristos       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
17179bb278aSchristos       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
1721b108b8bSchristosfi], [
1735ccaa8c0Schristosif test "$GCC" = yes; then
1741b108b8bSchristos   AC_MSG_RESULT(yes)
1751b108b8bSchristos   WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
1761b108b8bSchristos       -Wmissing-declarations -Wredundant-decls -Wnested-externs \
1771b108b8bSchristos       -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
17879bb278aSchristos       -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter -Wformat=2"
1795ccaa8c0Schristoselse
1805ccaa8c0Schristos   WARNINGS=
1815ccaa8c0Schristos   AC_MSG_RESULT(no)
1821b108b8bSchristosfi])
1831b108b8bSchristos
1841b108b8bSchristosdnl Checks for functions
1851d4cb158SchristosAC_CHECK_FUNCS(strndup mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale memmem pipe2 posix_spawnp)
1861b108b8bSchristos
1871b108b8bSchristosdnl Provide implementation of some required functions if necessary
18874db5203SchristosAC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r localtime_r gmtime_r pread strcasestr fmtcheck dprintf)
1891b108b8bSchristos
1901b108b8bSchristosdnl Checks for libraries
19174db5203Schristosif test "$enable_zlib" != "no"; then
1921b108b8bSchristos  AC_CHECK_LIB(z, gzopen)
19374db5203Schristosfi
19478a23c3aSchristosif test "$enable_bzlib" != "no"; then
19578a23c3aSchristos  AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
19678a23c3aSchristosfi
19778a23c3aSchristosif test "$enable_xzlib" != "no"; then
19878a23c3aSchristos  AC_CHECK_LIB(lzma, lzma_stream_decoder)
19978a23c3aSchristosfi
2001d4cb158Schristosif test "$enable_zstdlib" != "no"; then
2011d4cb158Schristos  AC_CHECK_LIB(zstd, ZSTD_createDStream)
2021d4cb158Schristosfi
2031d4cb158Schristosif test "$enable_lzlib" != "no"; then
2041d4cb158Schristos  AC_CHECK_LIB(lz, LZ_decompress_open)
2051d4cb158Schristosfi
2065efe63deSchristosif test "$enable_libseccomp" != "no"; then
2075efe63deSchristos    AC_CHECK_LIB(seccomp, seccomp_init)
2085efe63deSchristosfi
2095ccaa8c0Schristosif test "$MINGW" = 1; then
2105ccaa8c0Schristos  AC_CHECK_LIB(gnurx,regexec,,AC_MSG_ERROR([libgnurx is required to build file(1) with MinGW]))
2115ccaa8c0Schristosfi
2121b108b8bSchristos
2131b108b8bSchristosdnl See if we are cross-compiling
2141b108b8bSchristosAM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
2151b108b8bSchristos
21674db5203Schristosdnl Final sanity checks
21774db5203Schristosif test "$enable_zlib" = "yes"; then
21874db5203Schristos  if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then
21974db5203Schristos    AC_MSG_ERROR([zlib support requested but not found])
22074db5203Schristos  fi
221d0c65b7bSchristosfi
222d0c65b7bSchristosif  test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
22374db5203Schristos  AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
22474db5203Schristosfi
22578a23c3aSchristosif test "$enable_bzlib" = "yes"; then
22678a23c3aSchristos  if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then
22778a23c3aSchristos    AC_MSG_ERROR([bzlib support requested but not found])
22878a23c3aSchristos  fi
22978a23c3aSchristosfi
23078a23c3aSchristosif  test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then
23178a23c3aSchristos  AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support])
23278a23c3aSchristosfi
23378a23c3aSchristosif test "$enable_xzlib" = "yes"; then
23478a23c3aSchristos  if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" != "yesyes"; then
23578a23c3aSchristos    AC_MSG_ERROR([xzlib support requested but not found])
23678a23c3aSchristos  fi
23778a23c3aSchristosfi
23878a23c3aSchristosif  test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" = "yesyes"; then
23978a23c3aSchristos  AC_DEFINE([XZLIBSUPPORT], 1, [Enable xzlib compression support])
24078a23c3aSchristosfi
2411d4cb158Schristosif test "$enable_zstdlib" = "yes"; then
2421d4cb158Schristos  if test "$ac_cv_header_zstd_h$ac_cv_lib_zstd_ZSTD_createDStream" != "yesyes"; then
2431d4cb158Schristos    AC_MSG_ERROR([zstdlib support requested but not found])
2441d4cb158Schristos  fi
2451d4cb158Schristosfi
2461d4cb158Schristosif  test "$ac_cv_header_zstd_h$ac_cv_lib_zstd_ZSTD_createDStream" = "yesyes"; then
2471d4cb158Schristos  AC_DEFINE([ZSTDLIBSUPPORT], 1, [Enable zstdlib compression support])
2481d4cb158Schristosfi
2491d4cb158Schristosif test "$enable_lzlib" = "yes"; then
2501d4cb158Schristos  if test "$ac_cv_header_lzlib_h$ac_cv_lib_lz_LZ_decompress_open" != "yesyes"; then
2511d4cb158Schristos    AC_MSG_ERROR([lzlib support requested but not found])
2521d4cb158Schristos  fi
2531d4cb158Schristosfi
2541d4cb158Schristosif  test "$ac_cv_header_lzlib_h$ac_cv_lib_lz_LZ_decompress_open" = "yesyes"; then
2551d4cb158Schristos  AC_DEFINE([LZLIBSUPPORT], 1, [Enable lzlib compression support])
2561d4cb158Schristosfi
25774db5203Schristos
25829faeba7SchristosAC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile libmagic.pc])
2591b108b8bSchristosAC_OUTPUT
260