File: fp_hs_cpp_cmd_with_args.m4

package info (click to toggle)
ghc 9.10.3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 169,076 kB
  • sloc: haskell: 713,554; ansic: 84,184; cpp: 30,255; javascript: 9,003; sh: 7,870; fortran: 3,527; python: 3,228; asm: 2,523; makefile: 2,324; yacc: 1,570; lisp: 532; xml: 196; perl: 111; csh: 2
file content (69 lines) | stat: -rw-r--r-- 2,041 bytes parent folder | download
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"

])