This repository has been archived on 2020-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
php-armadillo/config.m4

65 lines
2.4 KiB
Plaintext

PHP_ARG_ENABLE(arma, for armadillo support,
[ --enable-arma Enable armadillo support])
PHP_ARG_ENABLE(arma-operators, for operator overloading support in armadillo,
[ --enable-arma-operators Enable operator overloading for armadillo ], no, no)
PHP_ARG_ENABLE(arma-pch, build PCH header of armadillo,
[ --enable-arma-pch Enable building PCH header of armadillo ], no, no)
if test "$PHP_ARMA" != "no"; then
PHP_REQUIRE_CXX()
# If enabled, try building pre-compiled header for armadillo.
if test "$PHP_ARMA_PCH" != "no"; then
CXX_INCLEDE_PATHS=($(echo | $CXX -xc++ -E -v - 2>&1 | grep -e '^ /\S*$'))
PCH_FILE='./build/armadillo.gch'
# Note that '-D' option is valid when compiling PCH header, but not when using it.
PCH_COMPILE_FLAGS=(-std=c++17 -xc++-header -DARMA_DONT_PRINT_ERRORS -fPIC -g)
if test "$PHP_DEBUG" != "0"; then
PCH_COMPILE_FLAGS+=(-O0)
else
PCH_COMPILE_FLAGS+=(-O2)
fi
fi
for POSSIBLE_INCLUDE_DIR in ${CXX_INCLEDE_PATHS[[@]]}; do
ARMADILLO_HEADER_FILE=$POSSIBLE_INCLUDE_DIR/armadillo
if test -f "$ARMADILLO_HEADER_FILE"; then
$CXX ${PCH_COMPILE_FLAGS[[@]]} $ARMADILLO_HEADER_FILE -o $PCH_FILE
break
fi
done
# Include PCH file if valid.
EXTRA_CXXFLAGS="-std=c++17 -DARMA_DONT_PRINT_ERRORS"
CLANG_TEST_STR=`echo | $CXX -dM -E - | grep __clang__`
if test -f "$PCH_FILE"; then
if test -n "$CLANG_TEST_STR"; then
EXTRA_CXXFLAGS+=" -include-pch $PCH_FILE"
else
DUMMY_ARMADILLO_HEADER_FILE='./build/armadillo'
touch "$DUMMY_ARMADILLO_HEADER_FILE"
EXTRA_CXXFLAGS+=" -include $DUMMY_ARMADILLO_HEADER_FILE"
fi
AC_DEFINE(PHP_ARMA_ENABLE_PCH, 1, [ Defined if using pre-compiled armadillo header. ])
fi
# Disable some clang warnings, which we don't care.
if test -n "$CLANG_TEST_STR"; then
EXTRA_CXXFLAGS+=' -Wno-undefined-var-template -Wno-deprecated-declarations'
fi
# Enable/disable operator overloading support.
OPERATORS_SRC="src/operators.cc"
ARMA_SRC=`ls -1d src/*.cc | grep -v $OPERATORS_SRC`
if test "$PHP_ARMA_OPERATORS" != "no"; then
AC_DEFINE(PHP_ARMA_OPERATORS, 1, [ Defined if operator overloading is enabled for armadillo. ])
ARMA_SRC+=" $OPERATORS_SRC"
fi
PHP_NEW_EXTENSION(arma, $ARMA_SRC, $ext_shared, , $EXTRA_CXXFLAGS)
PHP_ADD_LIBRARY(armadillo, 1, ARMA_SHARED_LIBADD)
PHP_SUBST(ARMA_SHARED_LIBADD)
fi