1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# FP_HSCPP_CMD_WITH_ARGS()
# ----------------------
# sets HS CPP command and its arguments
#
# $1 = the variable to set to HS CPP command
# $2 = the variable to set to HS CPP command arguments
AC_DEFUN([FP_HSCPP_CMD_WITH_ARGS],[
dnl ** what hs-cpp to use?
dnl --------------------------------------------------------------
AC_ARG_WITH(hs-cpp,
[AS_HELP_STRING([--with-hs-cpp=ARG],
[Path to the Haskell (C) preprocessor for Haskell files [default=autodetect]])],
[
if test "$HostOS" = "mingw32"
then
AC_MSG_WARN([Request to use $withval will be ignored])
else
HS_CPP_CMD=$withval
fi
],
[
# We can't use $CPP here, since HS_CPP_CMD is expected to be a single
# command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
HS_CPP_CMD=$CC
]
)
dnl ** what hs-cpp flags to use?
dnl -----------------------------------------------------------
AC_ARG_WITH(hs-cpp-flags,
[AS_HELP_STRING([--with-hs-cpp-flags=ARG],
[Flags to the Haskell (C) preprocessor for Haskell files [default=autodetect]])],
[
if test "$HostOS" = "mingw32"
then
AC_MSG_WARN([Request to use $withval will be ignored])
else
HS_CPP_ARGS=$withval
USER_HS_CPP_ARGS=$withval
fi
],
[
$HS_CPP_CMD -x c /dev/null -dM -E > conftest.txt 2>&1
if grep "__clang__" conftest.txt >/dev/null 2>&1; then
HS_CPP_ARGS="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
else
$HS_CPP_CMD -v > conftest.txt 2>&1
if grep "gcc" conftest.txt >/dev/null 2>&1; then
HS_CPP_ARGS="-E -undef -traditional"
else
$HS_CPP_CMD --version > conftest.txt 2>&1
if grep "cpphs" conftest.txt >/dev/null 2>&1; then
HS_CPP_ARGS="--cpp -traditional"
else
AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
HS_CPP_ARGS=""
fi
fi
fi
]
)
$1=$HS_CPP_CMD
$2="$$2 $HS_CPP_ARGS"
])
|