x86 NCG: fix regUsageOfInstr for VMOVU & friends
[ghc.git] / m4 / fptools_set_platform_vars.m4
blob4c022da52b0e4507f05dc7a64c8cbb80c971491f
1 # FPTOOLS_SET_PLATFORMS_VARS
2 # ----------------------------------
3 # Set all the platform variables. First massage the default autoconf
4 # choices for build, host, and target, then parse it into
5 # <platform>Arch, <platform>Vendor, and <platform>OS, and finally define
6 # the other variables in terms of those.
7 AC_DEFUN([FPTOOLS_SET_PLATFORMS_VARS],
9     # If no argument was given for a configuration variable, then discard
10     # the guessed canonical system and use the configuration of the
11     # bootstrapping ghc. If an argument was given, map it from gnu format
12     # to ghc format.
13     #
14     # For why we do it this way, see: #3637, #1717, #2951
15     #
16     # In bindists, we haven't called AC_CANONICAL_{BUILD,HOST,TARGET}
17     # so this justs uses $bootstrap_target.
19     if test "$build_alias" = ""
20     then
21         FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP([build], [Build])
22     else
23         GHC_CONVERT_PLATFORM_PARTS([build], [Build])
24     fi
26     if test "$host_alias" = ""
27     then
28         FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP([host], [Host])
29     else
30         GHC_CONVERT_PLATFORM_PARTS([host], [Host])
31     fi
33     if test "$target_alias" = ""
34     then
35         if test "$host_alias" != ""
36         then
37             GHC_CONVERT_PLATFORM_PARTS([host], [Target])
38         else
39             FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP([target], [Target])
40         fi
41     else
42         GHC_CONVERT_PLATFORM_PARTS([target], [Target])
43     fi
45     FPTOOLS_SET_PLATFORM_VARS([build], [Build])
46     FPTOOLS_SET_PLATFORM_VARS([host], [Host])
47     FPTOOLS_SET_PLATFORM_VARS([target], [Target])
49     windows=NO
50     case $host in
51     *-unknown-mingw32)
52         windows=YES
53         ;;
54     esac
57 dnl Attempt at arch agnostic distillation of the above, but it
58 dnl doesn't quite work yet. Perhaps after the configure script is
59 dnl more split up (#17191) this wil become more feasible.
61 dnl if test "[$]$1_alias" = ""
62 dnl then
63 dnl     if test "[$]$3_alias" != ""
64 dnl     then
65 dnl         GHC_CONVERT_PLATFORM_PARTS($3, $2)
66 dnl     else
67 dnl         FPTOOLS_SET_PLATFORMS_VARS($1, $2)
68 dnl     fi
69 dnl else
70 dnl     GHC_CONVERT_PLATFORM_PARTS($1, $2)
71 dnl fi
73 # FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP(platform,Platform)
74 # ----------------------------------
75 # Per the comment in FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP's body, we
76 # need to sometimes replace inferred platforms with the bootstrap
77 # compiler's target platform.
78 AC_DEFUN([FPTOOLS_OVERRIDE_PLATFORM_FROM_BOOTSTRAP],
80     if test "$bootstrap_target" != ""
81     then
82         $1=$bootstrap_target
83         echo "$1 platform inferred as: [$]$1"
84     else
85         echo "Can't work out $1 platform"
86         exit 1
87     fi
89     $2[Arch]=`echo "[$]$1" | sed 's/-.*//'`
90     $2[Vendor]=`echo "[$]$1" | sed -e 's/.*-\(.*\)-.*/\1/'`
91     $2[OS]=`echo "[$]$1" | sed 's/.*-//'`
94 # FPTOOLS_SET_PLATFORM_VARS(platform,Platform)
95 # ----------------------------------
96 # Set the platform variables for a single plaform (one of build, host,
97 # or target). Assumes <platform>Arch, <platform>Vendor, and <platform>OS
98 # are defined, and does everything else in terms of them.
99 AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
102     $2Platform="[$]$2Arch-[$]$2Vendor-[$]$2OS"
103     $2Platform_CPP=`echo "[$]$2Platform" | sed -e 's/\./_/g' -e 's/-/_/g'`
104     $2Arch_CPP=`    echo "[$]$2Arch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
105     $2Vendor_CPP=`  echo "[$]$2Vendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`
106     $2OS_CPP=`      echo "[$]$2OS"       | sed -e 's/\./_/g' -e 's/-/_/g'`
108     AC_MSG_NOTICE([GHC ]$1[ : $]$2[Platform])
110     AC_SUBST($2Platform)
111     AC_SUBST($2Platform_CPP)
113     AC_SUBST($2Arch_CPP)
114     AC_SUBST($2OS_CPP)
115     AC_SUBST($2Vendor_CPP)
117     GHC_SELECT_FILE_EXTENSIONS([$]$1, [exeext_]$1, [soext_]$1)
119     AC_SUBST(exeext_$1)
120     AC_SUBST(soext_$1)