1
0
Fork 0
arangodb/m4/configure.basics

311 lines
8.9 KiB
Plaintext

dnl -*- mode: Autoconf; -*-
dnl ----------------------------------------------------------------------------
dnl checks build system
dnl ----------------------------------------------------------------------------
AC_MSG_NOTICE([................................................................................])
AC_MSG_NOTICE([CHECKING BUILD SYSTEM])
AC_MSG_NOTICE([................................................................................])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
dnl ----------------------------------------------------------------------------
dnl check for special OS like MacOS X or FreeBSD
dnl ----------------------------------------------------------------------------
tr_DARWIN="no"
tr_FREEBSD="no"
tr_ARM="no"
case $target in
*-apple-darwin*)
tr_DARWIN="yes"
;;
*-*-freebsd*)
tr_FREEBSD="yes"
;;
armv7l-*-linux-gnueabihf)
tr_ARM="yes"
tr_ARM7="yes"
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS"
CPPFLAGS="$CPPFLAGS"
;;
armv6l-*-linux-gnueabihf)
dnl ----------------------------------------------------------------------------
dnl special flags for Arm V6 (pi)
dnl ----------------------------------------------------------------------------
CPPFLAGS="${CPPFLAGS} -DUSE_EABI_HARDFLOAT -march=armv6 -mfloat-abi=hard"
tr_ARM="yes"
tr_ARM6="yes"
;;
esac
AM_CONDITIONAL(ENABLE_DARWIN, test "x$tr_DARWIN" = xyes)
AM_CONDITIONAL(ENABLE_FREEBSD, test "x$tr_FREEBSD" = xyes)
AM_CONDITIONAL(ENABLE_ARM, test "x$tr_ARM" = xyes)
AM_CONDITIONAL(ENABLE_ARMV6, test "x$tr_ARM6" = xyes)
AM_CONDITIONAL(ENABLE_ARMV7, test "x$tr_ARM7" = xyes)
dnl ----------------------------------------------------------------------------
dnl bits
dnl ----------------------------------------------------------------------------
tr_BITS=32
case $target_cpu in
amd64*)
tr_BITS=64
;;
x86_64*)
tr_BITS=64
;;
esac
TRI_BITS="$tr_BITS"
AC_SUBST(TRI_BITS)
CPPFLAGS="${CPPFLAGS} -DTRI_BITS=${TRI_BITS}"
dnl ----------------------------------------------------------------------------
dnl use automake to generate Makfile.in
dnl ----------------------------------------------------------------------------
AM_INIT_AUTOMAKE([foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
dnl ----------------------------------------------------------------------------
dnl checks if the CC compiler supports an option
dnl
dnl usage: TRI_TRY_CC_OPTION(flag, action-if-ok, action-if-no-ok)
dnl ----------------------------------------------------------------------------
AC_DEFUN([TRI_TRY_CC_OPTION],
[AC_MSG_CHECKING([$1 for $CC])
AS_IF([AC_TRY_COMMAND([${CC} -Werror $1 -xc /dev/null -S -o /dev/null])],
AC_MSG_RESULT([yes])
[$2],
AC_MSG_RESULT([no])
[$3])])
dnl ----------------------------------------------------------------------------
dnl checks if the C++ compiler supports an option
dnl
dnl usage: TRI_TRY_CXX_OPTION(flag, action-if-ok, action-if-no-ok)
dnl ----------------------------------------------------------------------------
AC_DEFUN([TRI_TRY_CXX_OPTION],
[AC_MSG_CHECKING([$1] for $CXX)
AS_IF([AC_TRY_COMMAND([${CXX} -Werror $1 -xc++ /dev/null -S -o /dev/null])],
AC_MSG_RESULT([yes])
[$2],
AC_MSG_RESULT([no])
[$3])])
dnl ----------------------------------------------------------------------------
dnl checks for compiler and basic settings
dnl ----------------------------------------------------------------------------
AC_MSG_NOTICE([................................................................................])
AC_MSG_NOTICE([CHECKING C/C++ COMPILER AND LINKER])
AC_MSG_NOTICE([................................................................................])
case $target in
*-*-cygwin)
LDFLAGS="$LDFLAGS -Wl,--enable-auto-import"
enable_static="yes"
enable_shared="no"
list_cc="[gcc-4 gcc-3 gcc cc]"
list_cxx="[g++-4 g++-3 g++ cxx]"
;;
*)
list_cc="[${CC} gcc clang cc]"
list_cxx="[${CXX} g++ clang++ cxx]"
;;
esac
AC_PROG_CXXCPP
AC_PROG_CC($list_cc)
AC_PROG_CXX($list_cxx)
AC_PROG_CPP
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AX_CXX_COMPILE_STDCXX_11(noext, mandatory)
dnl ----------------------------------------------------------------------------
dnl error & warnings && C/C++ standard
dnl ----------------------------------------------------------------------------
AC_ARG_ENABLE(error-on-warning,
AS_HELP_STRING([--enable-error-on-warning], [treat warnings as errors (default: no)]),
[tr_WERROR="${enableval:-yes}"],
[tr_WERROR=no]
)
AC_ARG_ENABLE(eff-cpp,
AS_HELP_STRING([--enable-eff-cpp], [use -Weffc++ (default: no)]),
[tr_WEFFCXX="${enableval:-yes}"],
[tr_WEFFCXX=no]
)
CFLAGS="$CFLAGS $RPM_OPT_FLAGS"
CXXFLAGS="$CXXFLAGS $RPM_OPT_FLAGS"
if test x$GCC == xyes; then
WALL="-Wall -Winit-self -Wno-long-long -Wno-variadic-macros"
if test x$tr_WERROR == xyes; then
WALL="${WALL} -Werror"
fi
if test x$tr_DARWIN == xyes; then
WALL="${WALL} -Wno-deprecated-declarations"
fi
WALLC="${WALL} -Wshadow -Wstrict-prototypes -Wdeclaration-after-statement"
WALLCXX="${WALL} -Woverloaded-virtual"
TRI_TRY_CXX_OPTION([-Wstrict-null-sentinel],
[WALLCXX="${WALLCXX} -Wstrict-null-sentinel"])
# suppress warnings about unused compiler options.
# this is useful for clang as it complains about -std=... in linking
TRI_TRY_CXX_OPTION([-Qunused-arguments],
[WALLCXX="${WALLCXX} -Qunused-arguments"])
# try to select the correct C standard: gnu90 is nice, because it warns about constructs
# the Visual Studio Compiler does not like
GCCSTD=""
TRI_TRY_CC_OPTION([-std=gnu90],
[GCCSTD="-std=gnu90"],
[TRI_TRY_CC_OPTION([-std=gnu89],
[GCCSTD="-std=gnu89"])])
GXXSTD=""
TRI_TRY_CXX_OPTION([-std=c++11],
[GXXSTD="-std=c++11"])
if test x$tr_WEFFCXX == xyes; then
WALLCXX="${WALLCXX} -Weffc++"
fi
CFLAGS="${GCCSTD} ${CFLAGS} ${WALLC}"
CXXFLAGS="${GXXSTD} ${CXXFLAGS} ${WALLCXX}"
fi
dnl ----------------------------------------------------------------------------
dnl option for gnu style include
dnl ----------------------------------------------------------------------------
AC_ARG_ENABLE(isystem,
AS_HELP_STRING([--enable-isystem], [enables the use of -isystem instead of -I for system headers (default: no)]),
[tr_ISYSTEM="${enableval:-yes}"],
[tr_ISYSTEM=no]
)
if test x$GCC == xyes; then
INCPREFIX="-isystem " # note that the trailing blank is important
else
INCPREFIX="-I"
fi
if test "x$tr_ISYSTEM" = "xno"; then
INCPREFIX="-I"
fi
dnl ----------------------------------------------------------------------------
dnl GOLD
dnl ----------------------------------------------------------------------------
AC_ARG_ENABLE(gold,
AS_HELP_STRING([--enable-gold], [use new gold linker (default: no)]),
[tr_GOLD="${enableval:-yes}"],
[tr_GOLD=no]
)
AM_CONDITIONAL(ENABLE_GOLD, test "x$tr_GOLD" = xyes)
if test "x$tr_GOLD" = xyes; then
CFLAGS="$CFLAGS -fuse-ld=gold"
CXXFLAGS="$CXXFLAGS -fuse-ld=gold"
fi
dnl ----------------------------------------------------------------------------
dnl generate correct include, either -I oder -isystem
dnl ----------------------------------------------------------------------------
AC_DEFUN([TR_INCLUDE],[
if test "x$1" != "x"; then
if test "x$INCPREFIX" != "x-I"; then
$1=`echo $[]$1 | sed -e "s:-I:$INCPREFIX:g"`
fi
fi
])
dnl ----------------------------------------------------------------------------
dnl find absolute path for library
dnl
dnl usage: TR_LIBRARY(library name)
dnl
dnl returns: tr_library
dnl ----------------------------------------------------------------------------
AC_DEFUN([TR_LIBRARY],[
tr_library=""
for tr_path in $LDFLAGS; do
case $tr_path in
-L*)
path=`echo $tr_path | sed -e 's:^-L::'`
if test -f "$path/lib$1.a"; then
tr_library="$path/lib$1.a"
fi
;;
esac
done
])
dnl ----------------------------------------------------------------------------
dnl check for std::unordered_map::emplace()
dnl ----------------------------------------------------------------------------
AC_DEFUN([AX_CXX_CHECK_UNORDERED_MAP_EMPLACE], [
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether C++ has support for std::unordered_map::emplace()])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE[
#include <unordered_map>
void test () {
std::unordered_map<int, int> x;
x.emplace(1, 1);
}
]],
[eval unordered_map_emplace=yes],
[eval unordered_map_emplace=no]
)
AC_MSG_RESULT([$unordered_map_emplace])
AC_LANG_POP([C++])
if test x$unordered_map_emplace = xno; then
AC_MSG_ERROR([C++ has no support for std::unordered_map::emplace()])
fi
])
AX_CXX_CHECK_UNORDERED_MAP_EMPLACE