summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Mesquita <rodrigo.m.mesquita@gmail.com>2023-05-12 13:48:08 +0100
committerRodrigo Mesquita <rodrigo.m.mesquita@gmail.com>2023-05-12 15:03:13 +0100
commit10c05b78aed4d031e7314f821e97bd6d0708f322 (patch)
tree7834a5c3e3fc8a82b06da085d4351ee2f17dbde1
parent5effd62701e8e0a62e3cf1dbbf162c1d61a09907 (diff)
downloadhaskell-10c05b78aed4d031e7314f821e97bd6d0708f322.tar.gz
Handle passing CPP cmd and flags from configure to ghc-toolchain
-rw-r--r--configure.ac34
-rw-r--r--m4/fp_cpp_cmd_with_args.m469
-rw-r--r--m4/ghc_toolchain.m410
3 files changed, 36 insertions, 77 deletions
diff --git a/configure.ac b/configure.ac
index 6e80d1e1fe..5079a3bc7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -448,11 +448,37 @@ MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
dnl make extensions visible to allow feature-tests to detect them lateron
AC_USE_SYSTEM_EXTENSIONS
-dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
-AC_PROG_CPP
-
# --with-hs-cpp/--with-hs-cpp-flags
-FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
+AC_ARG_WITH(hs-cpp,
+[AS_HELP_STRING([--with-hs-cpp=ARG],
+ [Path to the (C) preprocessor for Haskell files [default=autodetect]])],
+[
+ if test "$HostOS" = "mingw32"
+ then
+ AC_MSG_WARN([Request to use $withval will be ignored])
+ else
+ HaskellCPPCmd=$withval
+ fi
+],
+[
+ # We can't use $CPP here, since HaskellCPPCmd is expected to be a single
+ # command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
+ HaskellCPPCmd=$CC
+]
+)
+AC_ARG_WITH(hs-cpp-flags,
+ [AS_HELP_STRING([--with-hs-cpp-flags=ARG],
+ [Flags to the (C) preprocessor for Haskell files [default=autodetect]])],
+ [
+ if test "$HostOS" = "mingw32"
+ then
+ AC_MSG_WARN([Request to use $withval will be ignored])
+ else
+ HaskellCPPArgs=$withval
+ fi
+ ],
+[ HaskellCPPArgs="" ]
+)
AC_SUBST([HaskellCPPCmd])
AC_SUBST([HaskellCPPArgs])
diff --git a/m4/fp_cpp_cmd_with_args.m4 b/m4/fp_cpp_cmd_with_args.m4
deleted file mode 100644
index 5090ba3610..0000000000
--- a/m4/fp_cpp_cmd_with_args.m4
+++ /dev/null
@@ -1,69 +0,0 @@
-# FP_CPP_CMD_WITH_ARGS()
-# ----------------------
-# sets CPP command and its arguments
-#
-# $1 = the variable to set to CPP command
-# $2 = the variable to set to CPP command arguments
-
-AC_DEFUN([FP_CPP_CMD_WITH_ARGS],[
-dnl ** what cpp to use?
-dnl --------------------------------------------------------------
-AC_ARG_WITH(hs-cpp,
-[AS_HELP_STRING([--with-hs-cpp=ARG],
- [Path to the (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 cpp flags to use?
-dnl -----------------------------------------------------------
-AC_ARG_WITH(hs-cpp-flags,
- [AS_HELP_STRING([--with-hs-cpp-flags=ARG],
- [Flags to the (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
- 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=$HS_CPP_ARGS
-
-])
-
diff --git a/m4/ghc_toolchain.m4 b/m4/ghc_toolchain.m4
index fde1b9f981..aa07f23a5d 100644
--- a/m4/ghc_toolchain.m4
+++ b/m4/ghc_toolchain.m4
@@ -20,11 +20,13 @@ AC_DEFUN([FIND_GHC_TOOLCHAIN],
echo "--triple=$target" >> acargs
echo "--cc=$CC" >> acargs
ADD_GHC_TOOLCHAIN_ARG([cc-opt], [$CONF_CC_OPTS_STAGE1])
- # TODO (previously we had in configure script use of --traditional??)
- # First thing disable the comment:
- # Also, differentiatiate between hscpp and cpp?
- #echo "--cpp=$CPP" >> acargs
+
+ # We can't use $CPP, since HS_CPP_CMD is expected to be a single
+ # command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
+ echo "--cpp=$HaskellCPPCmd" >> acargs
+ # ROMES:TODO: CONF_CPP_OPTS_STAGE1 vs HaskellCPPArgs
ADD_GHC_TOOLCHAIN_ARG([cpp-opt], [$CONF_CPP_OPTS_STAGE1])
+
echo "--cc-link=$CC" >> acargs
ADD_GHC_TOOLCHAIN_ARG([cc-link-opt], [$CONF_GCC_LINK_OPTS_STAGE1])
echo "--cxx=$CXX" >> acargs