| 1 | AC_PREREQ([2.69]) |
| 2 | AC_INIT([bzip3], [m4_esyscmd(build-aux/git-version-gen .tarball-version)], [https://github.com/iczelia/bzip3]) |
| 3 | AC_CONFIG_AUX_DIR([build-aux]) |
| 4 | AM_INIT_AUTOMAKE([foreign subdir-objects tar-ustar dist-bzip2 dist-xz dist-zip color-tests]) |
| 5 | AM_SILENT_RULES([yes]) |
| 6 | AC_CONFIG_MACRO_DIR([build-aux]) |
| 7 | |
| 8 | AC_MSG_CHECKING([whether system or user specified compiler flags are set]) |
| 9 | AM_CONDITIONAL([PASSED_CFLAGS], [test -n "$CFLAGS"]) |
| 10 | AM_COND_IF([PASSED_CFLAGS], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) |
| 11 | |
| 12 | AC_PROG_CC([clang gcc icc]) |
| 13 | AC_PROG_AWK |
| 14 | LT_INIT |
| 15 | |
| 16 | PKG_PROG_PKG_CONFIG |
| 17 | PKG_INSTALLDIR |
| 18 | |
| 19 | AC_C_RESTRICT |
| 20 | |
| 21 | AC_ARG_WITH([pthread], |
| 22 | AS_HELP_STRING([--without-pthread], [Disable use of pthread library])) |
| 23 | AM_CONDITIONAL([WITH_PTHREAD], [test x"$with_pthread" != xno]) |
| 24 | AM_COND_IF([WITH_PTHREAD], [ |
| 25 | AC_CHECK_HEADER(pthread.h, |
| 26 | [AX_PTHREAD([CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DPTHREAD" LIBS="$LIBS $PTHREAD_LIBS"])], |
| 27 | [AC_MSG_ERROR([pthread.h not found, use --without-pthread to skip])]) |
| 28 | ]) |
| 29 | |
| 30 | AC_ARG_ENABLE([arch-native], |
| 31 | AS_HELP_STRING([--disable-arch-native], [Disable CPU-specific optimizations])) |
| 32 | AM_CONDITIONAL([ENABLE_ARCH_NATIVE], [test x"$enable_arch_native" != xno]) |
| 33 | |
| 34 | AC_ARG_ENABLE([static-exe], |
| 35 | AS_HELP_STRING([--enable-static-exe], [Enable static builds of the executable.])) |
| 36 | AM_CONDITIONAL([ENABLE_STATIC], [test x"$enable_static_exe" = xyes]) |
| 37 | AC_SUBST([extra_cflags], []) |
| 38 | |
| 39 | AM_COND_IF([PASSED_CFLAGS], [ |
| 40 | AC_MSG_NOTICE([skipping compiler feature detection, using '$CFLAGS']) |
| 41 | ], [ |
| 42 | AX_CHECK_COMPILE_FLAG([-O2], [CFLAGS="$CFLAGS -O2"], []) |
| 43 | AX_CHECK_COMPILE_FLAG([-g3], [CFLAGS="$CFLAGS -g3"], []) |
| 44 | AX_CHECK_COMPILE_FLAG([-fPIC], [CFLAGS="$CFLAGS -fPIC"], []) |
| 45 | AC_MSG_NOTICE([using '$CFLAGS' plus compiler feature detection]) |
| 46 | |
| 47 | AM_COND_IF([ENABLE_ARCH_NATIVE], [ |
| 48 | AX_CHECK_COMPILE_FLAG([-march=native], [CFLAGS="$CFLAGS -march=native"], |
| 49 | [AC_MSG_ERROR([Compiler does not support native optimizations, use --disable-arch-native])]) |
| 50 | AX_CHECK_COMPILE_FLAG([-mtune=native], [CFLAGS="$CFLAGS -mtune=native"], |
| 51 | [AC_MSG_ERROR([Compiler does not support native optimizations, use --disable-arch-native])]) |
| 52 | ]) |
| 53 | |
| 54 | AM_COND_IF([ENABLE_STATIC], [ |
| 55 | AX_CHECK_COMPILE_FLAG([-static], [LIBS="$LIBS -all-static"], |
| 56 | [AC_MSG_ERROR([Compiler does not support static linking.])]) |
| 57 | ]) |
| 58 | ]) |
| 59 | |
| 60 | AX_SUBST_TRANSFORMED_PACKAGE_NAME |
| 61 | AX_SUBST_MAN_DATE |
| 62 | |
| 63 | AC_CONFIG_FILES([Makefile bzip3.pc]) |
| 64 | AC_CONFIG_FILES([bzip3.1 bz3grep.1 bz3less.1 bz3more.1 bz3most.1]) |
| 65 | AC_ARG_PROGRAM |
| 66 | AC_OUTPUT |