summaryrefslogtreecommitdiff
path: root/m4/ghc_llvm_target.m4
blob: 33150e9a8c0b27b6aa29a8520a0be6d51cfe2e4a (plain)
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
# GHC_LLVM_TARGET(target, target_cpu, target_vendor, target_os, llvm_target_var)
# --------------------------------
# converts the canonicalized target into something llvm can understand
AC_DEFUN([GHC_LLVM_TARGET], [
  llvm_target_cpu=$2
  case "$1" in
    *-freebsd*-gnueabihf)
      llvm_target_vendor="unknown"
      llvm_target_os="freebsd-gnueabihf"
      ;;
    *-hardfloat-*eabi)
      llvm_target_vendor="unknown"
      llvm_target_os="$4""hf"
      ;;
    *-mingw32|*-mingw64|*-msys)
      llvm_target_vendor="unknown"
      llvm_target_os="windows"
      ;;
    # apple is a bit about their naming scheme for
    # aarch64; and clang on macOS doesn't know that
    # aarch64 would be arm64. So for LLVM we'll need
    # to call it arm64; while we'll refer to it internally
    # as aarch64 for consistency and sanity.
    aarch64-apple-*|arm64-apple-*)
      llvm_target_cpu="arm64"
      GHC_CONVERT_VENDOR([$3],[llvm_target_vendor])
      GHC_CONVERT_OS([$4],[$2],[llvm_target_os])
      ;;
    *)
      GHC_CONVERT_VENDOR([$3],[llvm_target_vendor])
      GHC_CONVERT_OS([$4],[$2],[llvm_target_os])
      ;;
  esac
  case "$4" in
      # retain any android and gnueabi linux flavours
      # for the LLVM Target. Otherwise these would be
      # turned into just `-linux` and fail to be found
      # in the `llvm-targets` file.
      *-android*|*-gnueabi*|*-musleabi*)
        GHC_CONVERT_VENDOR([$3],[llvm_target_vendor])
        llvm_target_os="$4"
        ;;
  esac
  $5="$llvm_target_cpu-$llvm_target_vendor-$llvm_target_os"
])