Use the right compiler and flags for configure tests, but don't use
CFLAGS/CXXFLAGS when checking headers because if building universal
the multiple -arch flags would cause this error:
clang: error: cannot use 'c++-cpp-output' output with multiple -arch options
This patch replaces "cc" or "c++" at the beginning of $1 with the right
compiler and flags from the environment variables. This is done (instead
of just checking if $1 is exactly equal to "cc" or "c++") to accommodate
the use case where $1 also contains some flags, which currently occurs
when configure invokes headercheck to find evas.
--- config/functions.bak 2015-02-23 08:26:30.000000000 -0600
+++ config/functions 2019-01-10 14:25:50.000000000 -0600
+# Remove at the beginning of a variable.
+# var_remove_prefix var separator prefix
+ eval '[ "$'$1'" = "$3" ] && '$1'="" || true'
+ eval $1'="${'$1'#$b$a}"'
+# Replace at the beginning of a variable.
+# var_replace_prefix var separator prefix content
+ eval 'case "$'$1'$2" in "$3$2"*) true;; *) false;; esac;' || return 0
+ var_remove_prefix "$1" "$2" "$3"
+ var_insert "$1" "$2" "$4"
# Test for a key in a give "array".
+ var_replace_prefix COMPILER " " cc "$CC $CPPFLAGS $CFLAGS"
+ var_replace_prefix COMPILER " " c++ "$CXX $CPPFLAGS $CXXFLAGS"
local file="config/$PROG-$1"
cflags="`grep -a CFLAGS= $file | sed 's/.* CFLAGS="\(.*\)".*/\1/'`"
libs="`grep -a LIBS= $file | sed 's/.* LIBS="\(.*\)".*/\1/'`"
- if $PROG -c $cflags $libs $file -o config.tmp \
+ if $COMPILER -c $cflags $libs $file -o config.tmp \
>/dev/null 2>> config.log ; then
+ var_replace_prefix COMPILER " " cc "$CC $CPPFLAGS"
+ var_replace_prefix COMPILER " " c++ "$CXX $CPPFLAGS"
echo "#include <$1>" > conftest.c
status "checking for header "$1" ... "
- if $PROG -E conftest.c >/dev/null 2>> config.log ; then
+ if $COMPILER -E conftest.c >/dev/null 2>> config.log ; then
status_result "not found"
if [ $mode = lib -o $mode = header ]; then
+ var_replace_prefix prg " " cc "$CC $CPPFLAGS $CFLAGS"
+ var_replace_prefix prg " " c++ "$CXX $CPPFLAGS $CXXFLAGS"
local args="$*"; shift $#
elif [ $mode = shell ]; then