2015-12-03 21:40:19 +00:00
2015-12-04 10:36:51 +00:00
AC_INIT([kvazaar], m4_esyscmd([printf $(awk '/#define KVZ_VERSION/ { print $3 }' src/global.h)]))
2015-12-03 21:40:19 +00:00
AC_CONFIG_SRCDIR([src/encmain.c])
2015-12-04 10:36:51 +00:00
2016-01-15 17:29:22 +00:00
# Library version number, modify:
# - When modifying kvazaar.h.
# - Modify either major or minor.
# - When making a new release.
# - If major or minor did not change since last release.
# - Check git history to see if someone forgot to increment major or minor.
# - Increment release.
#
# major:
# - Increment when ABI changes, meaning lib users need to be recompiled.
# - ABI changes when anything existing gets modified, including sizes of structs.
# minor:
2016-01-21 13:08:34 +00:00
# - Increment when only API changes in a backwards compatible way without breaking ABI.
# - We count adding parameters to bottom of kvz_config as ABI compatible, because user
# shouldn't copy that struct or care about it's size.
2016-01-15 17:29:22 +00:00
# - If not sure, increment major instead.
# release:
# - Increment when making new releases and major or minor was not changed since last release.
#
# Here is a somewhat sane guide to lib versioning: http://apr.apache.org/versioning.html
2022-02-06 18:08:28 +00:00
ver_major=7
2022-03-18 05:59:39 +00:00
ver_minor=1
2015-12-19 07:24:35 +00:00
ver_release=0
2016-05-31 08:56:34 +00:00
# Prevents configure from adding a lot of defines to the CFLAGS
2015-12-03 21:40:19 +00:00
AC_CONFIG_HEADERS([config.h])
2015-12-04 10:36:51 +00:00
2015-12-03 21:40:19 +00:00
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
2017-04-11 10:11:18 +00:00
AM_INIT_AUTOMAKE([-Wall dist-bzip2 dist-xz foreign subdir-objects])
2015-12-03 21:40:19 +00:00
AM_SILENT_RULES([yes])
AC_PROG_CC
2015-12-21 15:33:52 +00:00
AC_PROG_CC_C99
2015-12-03 21:40:19 +00:00
AM_PROG_AR
2016-06-06 14:23:47 +00:00
AC_PROG_CXX
2015-12-03 21:40:19 +00:00
2016-01-22 13:15:02 +00:00
# Get fread that can read more than 2GB on 32 bit systems.
AC_SYS_LARGEFILE
2015-12-03 21:40:19 +00:00
LT_INIT([win32-dll])
2020-04-02 15:31:05 +00:00
AC_CANONICAL_HOST
flag_gcc_on_mingw="false"
case x"${host_os}" in
x"cygwin"*|x"mingw"*)
if test x"${CC}" = x"gcc" ; then
flag_gcc_on_mingw="true"
fi
esac
2018-07-02 22:59:25 +00:00
AX_CHECK_COMPILE_FLAG([-maltivec],[flag_altivec="true"])
2016-02-16 09:09:47 +00:00
AX_CHECK_COMPILE_FLAG([-mavx2], [flag_avx2="true"])
AX_CHECK_COMPILE_FLAG([-msse4.1], [flag_sse4_1="true"])
AX_CHECK_COMPILE_FLAG([-msse2], [flag_sse2="true"])
2018-12-14 14:29:22 +00:00
AX_CHECK_COMPILE_FLAG([-mbmi], [flag_bmi="true"])
AX_CHECK_COMPILE_FLAG([-mabm], [flag_abm="true"])
2020-03-26 16:48:48 +00:00
AX_CHECK_COMPILE_FLAG([-mpopcnt], [flag_popcnt="true"])
AX_CHECK_COMPILE_FLAG([-mlzcnt], [flag_lzcnt="true"])
2018-12-14 14:29:22 +00:00
AX_CHECK_COMPILE_FLAG([-mbmi2], [flag_bmi2="true"])
2016-01-20 16:19:05 +00:00
2020-03-26 16:48:48 +00:00
# Do we need -mpopcnt and -mlzcnt, or -mabm to use POPCNT and LZCNT
# instructions? Ask GCC and Clang, and they have different answers.
2018-07-02 22:59:25 +00:00
AM_CONDITIONAL([HAVE_ALTIVEC], [test x"$flag_altivec" = x"true"])
2020-04-02 15:31:05 +00:00
AM_CONDITIONAL([HAVE_AVX2_GCC], [test x"$flag_avx2" = x"true" -a x"$flag_bmi" = x"true" -a x"$flag_abm" = x"true" -a x"$flag_bmi2" = x"true" -a x"$flag_gcc_on_mingw" = x"false"])
AM_CONDITIONAL([HAVE_AVX2_CLANG], [test x"$flag_avx2" = x"true" -a x"$flag_bmi" = x"true" -a x"$flag_popcnt" = x"true" -a x"$flag_lzcnt" = x"true" -a x"$flag_bmi2" = x"true" -a x"$flag_gcc_on_mingw" = x"false"])
2016-01-20 16:19:05 +00:00
AM_CONDITIONAL([HAVE_SSE4_1], [test x"$flag_sse4_1" = x"true"])
AM_CONDITIONAL([HAVE_SSE2], [test x"$flag_sse2" = x"true"])
2018-06-12 08:20:42 +00:00
KVZ_CFLAGS="-Wall -Wextra -Wvla -Wno-sign-compare -Wno-unused-parameter -I$srcdir/src -I$srcdir/src/extras -ftree-vectorize -fvisibility=hidden"
2016-05-31 08:56:34 +00:00
CFLAGS="$KVZ_CFLAGS $CFLAGS"
2016-06-06 14:23:47 +00:00
2017-06-16 22:03:46 +00:00
AC_SEARCH_LIBS([log], [m c], [], [exit 1])
AC_SEARCH_LIBS([pow], [m c], [], [exit 1])
AC_SEARCH_LIBS([sqrt], [m c], [], [exit 1])
2016-06-07 10:33:09 +00:00
AC_ARG_WITH([cryptopp],
2016-06-06 14:23:47 +00:00
AS_HELP_STRING([--with-cryptopp],
2016-06-07 10:33:09 +00:00
[Build with cryptopp Enables selective encryption.]))
2016-10-10 06:03:32 +00:00
AS_IF([test "x$with_cryptopp" = "xyes"],
[PKG_CHECK_MODULES([cryptopp], [cryptopp],
2016-08-01 11:35:42 +00:00
[AC_DEFINE([KVZ_SEL_ENCRYPTION], [1], [With cryptopp])],
2016-10-10 06:03:32 +00:00
[PKG_CHECK_MODULES([cryptopp], [libcrypto++],
[AC_DEFINE([KVZ_SEL_ENCRYPTION], [1], [With cryptopp])],
2018-03-04 15:03:37 +00:00
[PKG_CHECK_MODULES([cryptopp], [libcryptopp],
[AC_DEFINE([KVZ_SEL_ENCRYPTION], [1], [With cryptopp])],
[AC_MSG_ERROR([neither cryptopp, libcrypto++ nor libcryptopp found with pkg-config])]
)]
2016-10-10 06:03:32 +00:00
)]
)]
)
2016-06-06 14:23:47 +00:00
2016-06-07 12:36:48 +00:00
AM_CONDITIONAL([USE_CRYPTOPP], [test "x$with_cryptopp" = "xyes"])
2016-06-07 10:33:09 +00:00
CPPFLAGS="$CPPFLAGS $cryptopp_CFLAGS"
LIBS="$LIBS $cryptopp_LIBS"
2016-06-06 14:23:47 +00:00
2015-12-21 15:33:52 +00:00
CPPFLAGS="-DKVZ_DLL_EXPORTS $CPPFLAGS"
2015-12-03 21:40:19 +00:00
2016-06-06 14:23:47 +00:00
2017-10-26 12:21:28 +00:00
# We need to force AX_PTHREAD to check -pthread -lpthread since otherwise
# it only outputs -pthread for GCC. Without -lpthread GCC does not link the
# shared library against the pthread library (even though it does link the
# executable).
PTHREAD_CFLAGS=-pthread
PTHREAD_LIBS=-lpthread
2016-05-31 08:56:34 +00:00
# This does workarounds for pthreads on various compilers.
2017-10-26 12:21:28 +00:00
AX_PTHREAD([],[AC_MSG_ERROR([POSIX threads not found])])
2016-05-31 08:56:34 +00:00
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CC="$PTHREAD_CC"
2015-12-03 21:40:19 +00:00
2017-04-11 10:11:18 +00:00
# --enable-werror
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [treat warnings as errors [no]])],
[CFLAGS="-Werror $CFLAGS"], []
2015-12-03 21:40:19 +00:00
)
# host and cpu specific settings
AS_CASE([$host_cpu],
[i?86], [BITS="32" ASFLAGS="$ASFLAGS -DARCH_X86_64=0" X86="true"],
[x86_64], [BITS="64" ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -m amd64" X86="true"],
2015-12-21 15:33:52 +00:00
[powerpc*], [PPC="true"]
2015-12-03 21:40:19 +00:00
)
AS_CASE([$host_os],
[darwin*], [
ASFLAGS="$ASFLAGS -f macho$BITS -DPREFIX"
],
[cygwin*|msys*|mingw*], [
CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
AS_IF(
[test "x$BITS" = "x32"], [
ASFLAGS="$ASFLAGS -fwin32 -DPREFIX -DHAVE_ALIGNED_STACK=0"
], [
ASFLAGS="$ASFLAGS -fwin64 -DHAVE_ALIGNED_STACK=1"
]
)
2019-07-22 13:43:02 +00:00
],
[midipix*], [
AS_IF(
[test "x$BITS" = "x32"], [
ASFLAGS="$ASFLAGS -fwin32 -DPREFIX -DHAVE_ALIGNED_STACK=0"
], [
ASFLAGS="$ASFLAGS -fwin64 -DHAVE_ALIGNED_STACK=1"
]
)
2015-12-21 15:33:52 +00:00
],
[linux*|*kfreebsd*], [
ASFLAGS="$ASFLAGS -f elf$BITS"
LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
LIBS="$LIBS -lrt"
2015-12-03 21:40:19 +00:00
], [
ASFLAGS="$ASFLAGS -f elf$BITS"
2015-12-21 15:33:52 +00:00
LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
2015-12-03 21:40:19 +00:00
]
)
# YASM checks
AS_IF([test "x$X86" = "xtrue"], [
AC_CHECK_TOOL([YASM], [yasm], [no])
])
AS_IF([test "x$YASM" != "xno"], [have_yasm="yes"])
AC_ARG_ENABLE([asm], [AS_HELP_STRING([--disable-asm], [disable assembly [no]])],
[], [enable_asm="yes"]
)
AS_IF([test "x$enable_asm" != "xno" -a $have_yasm != "yes"],
[enable_asm="no"]
)
AM_CONDITIONAL([HAVE_X86], [test "x$X86" = "xtrue"])
AM_CONDITIONAL([HAVE_PPC], [test "x$PPC" = "xtrue"])
AM_CONDITIONAL([HAVE_ARM], [test "x$ARM" = "xtrue"])
AM_CONDITIONAL([ENABLE_ASM], [test "x$enable_asm" = "xyes" -a "x$have_yasm" = "xyes" ])
AC_ARG_VAR([ASFLAGS], [ASFLAGS to use for assembler])
AC_SUBST([ASFLAGS])
2015-12-04 10:36:51 +00:00
KVZ_API_VERSION="$ver_major:$ver_minor:$ver_release"
2015-12-03 21:40:19 +00:00
AC_SUBST([KVZ_API_VERSION])
2015-12-19 07:24:35 +00:00
AC_CONFIG_FILES([Makefile
src/Makefile
src/kvazaar.pc
tests/Makefile])
2015-12-03 21:40:19 +00:00
AC_OUTPUT