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 -p '^ /'))
PHP_INCLUDES=`php-config --includes`
PCH_FILE='./build/armadillo.gch'
# Note that '-D' option is valid when compiling PCH header, but not when using it.
CXX_TMP_COMPILE_FLAGS="-std=c++17 -x c++-header $PHP_INCLUDES -DARMA_DONT_PRINT_ERRORS"
if test -z "$PHP_DEBUG"; then
CXX_TMP_COMPILE_FLAGS+=' -O2'
else
CXX_TMP_COMPILE_FLAGS+=' -g -O0'
fi
fi
for TEMP_INCLUDE_DIR in "$CXX_INCLEDE_PATHS"; do
ARMADILLO_HEADER_FILE=$TEMP_INCLUDE_DIR/armadillo
if test -f "$ARMADILLO_HEADER_FILE"; then
$CXX $CXX_TMP_COMPILE_FLAGS $TEMP_INCLUDE_DIR/armadillo -o $PCH_FILE
break
fi
done
# Include PCH file if valid.
EXTRA_CXXFLAGS="-std=c++17 -DARMA_DONT_PRINT_ERRORS"
CLANG_TEST_STR=`$CXX --version | grep clang`
if test -f "$PCH_FILE"; then
if test -n "$CLANG_TEST_STR"; then
EXTRA_CXXFLAGS+=" -include-pch $PCH_FILE"
# Define this only for clang, in gcc we still need the include directive.
AC_DEFINE(PHP_ARMA_ENABLE_PCH, 1, [ Defined if using pre-compiled armadillo header. ])
else
EXTRA_CXXFLAGS+=' -I./build'
fi
fi
# Disable some clang warnings 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