summaryrefslogtreecommitdiff
path: root/m4/fp_settings.m4
blob: 26e15a163cd4a79c592a876157ad004964905ac1 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# FP_SETTINGS
# ----------------------------------
# Set the variables used in the settings file
AC_DEFUN([FP_SETTINGS],
[
    SettingsUseDistroMINGW="$EnableDistroToolchain"

    if test "$windows" = YES -a "$EnableDistroToolchain" = "NO"; then
        # Handle the Windows toolchain installed in FP_SETUP_WINDOWS_TOOLCHAIN.
        # See Note [tooldir: How GHC finds mingw on Windows]
        mingw_bin_prefix='$$tooldir/mingw/bin/'
        SettingsCCompilerCommand="${mingw_bin_prefix}clang.exe"
        SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2 -I\$\$tooldir/mingw/include"
        SettingsCxxCompilerCommand="${mingw_bin_prefix}clang++.exe"
        SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2 -I\$\$tooldir/mingw/include"
        SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2 -L\$\$tooldir/mingw/lib -L\$\$tooldir/mingw/x86_64-w64-mingw32/lib"
        SettingsHaskellCPPCommand="${mingw_bin_prefix}clang.exe"
        SettingsHaskellCPPFlags="$HaskellCPPArgs -I\$\$tooldir/mingw/include"
        SettingsLdCommand="${mingw_bin_prefix}ld.lld.exe"
        SettingsLdFlags=""
        # LLD does not support object merging (#21068)
        SettingsMergeObjectsCommand=""
        SettingsMergeObjectsFlags=""
        SettingsArCommand="${mingw_bin_prefix}llvm-ar.exe"
        SettingsRanlibCommand="${mingw_bin_prefix}llvm-ranlib.exe"
        SettingsDllWrapCommand="${mingw_bin_prefix}llvm-dllwrap.exe"
        SettingsWindresCommand="${mingw_bin_prefix}llvm-windres.exe"
        SettingsTouchCommand='$$topdir/bin/touchy.exe'

    else
        # This case handles the "normal" platforms (e.g. not Windows) where we
        # don't provide the toolchain.

        SettingsCCompilerCommand="$CC"
        SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
        SettingsCxxCompilerCommand="$CXX"
        SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2"
        SettingsHaskellCPPCommand="$HaskellCPPCmd"
        SettingsHaskellCPPFlags="$HaskellCPPArgs"
        SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
        SettingsLdCommand="$LdCmd"
        SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
        SettingsArCommand="$ArCmd"
        SettingsRanlibCommand="$RanlibCmd"
        SettingsMergeObjectsCommand="$MergeObjsCmd"
        SettingsMergeObjectsFlags="$MergeObjsArgs"

        if test -z "$DllWrapCmd"; then
            SettingsDllWrapCommand="/bin/false"
        else
            SettingsDllWrapCommand="$DllWrapCmd"
        fi
        if test -z "$WindresCmd"; then
            SettingsWindresCommand="/bin/false"
        else
            SettingsWindresCommand="$WindresCmd"
        fi

        if test "$HostOS" = "mingw32"; then
            SettingsTouchCommand='$$topdir/bin/touchy.exe'
        else
            SettingsTouchCommand='touch'
        fi

        if test "$EnableDistroToolchain" = "YES"; then
            # If the user specified --enable-distro-toolchain then we just use the
            # executable names, not paths.
            SettingsCCompilerCommand="$(basename $SettingsCCompilerCommand)"
            SettingsHaskellCPPCommand="$(basename $SettingsHaskellCPPCommand)"
            SettingsLdCommand="$(basename $SettingsLdCommand)"
            SettingsMergeObjectsCommand="$(basename $SettingsMergeObjectsCommand)"
            SettingsArCommand="$(basename $SettingsArCommand)"
            SettingsDllWrapCommand="$(basename $SettingsDllWrapCommand)"
            SettingsWindresCommand="$(basename $SettingsWindresCommand)"
        fi
    fi

    # Platform-agnostic tools
    if test -z "$ClangCmd"; then
        ClangCmd="clang"
    fi
    SettingsClangCommand="$ClangCmd"

    # LLVM backend tools
    if test -z "$LlcCmd"; then
        LlcCmd="llc"
    fi
    SettingsLlcCommand="$LlcCmd"

    if test -z "$OptCmd"; then
        OptCmd="opt"
    fi
    SettingsOptCommand="$OptCmd"

    # Mac-only tools
    if test -z "$OtoolCmd"; then
        OtoolCmd="otool"
    fi
    SettingsOtoolCommand="$OtoolCmd"

    if test -z "$InstallNameToolCmd"; then
        InstallNameToolCmd="install_name_tool"
    fi
    SettingsInstallNameToolCommand="$InstallNameToolCmd"

    SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"

    AC_SUBST(SettingsCCompilerCommand)
    AC_SUBST(SettingsCxxCompilerCommand)
    AC_SUBST(SettingsHaskellCPPCommand)
    AC_SUBST(SettingsHaskellCPPFlags)
    AC_SUBST(SettingsCCompilerFlags)
    AC_SUBST(SettingsCxxCompilerFlags)
    AC_SUBST(SettingsCCompilerLinkFlags)
    AC_SUBST(SettingsCCompilerSupportsNoPie)
    AC_SUBST(SettingsLdCommand)
    AC_SUBST(SettingsLdFlags)
    AC_SUBST(SettingsMergeObjectsCommand)
    AC_SUBST(SettingsMergeObjectsFlags)
    AC_SUBST(SettingsArCommand)
    AC_SUBST(SettingsRanlibCommand)
    AC_SUBST(SettingsOtoolCommand)
    AC_SUBST(SettingsInstallNameToolCommand)
    AC_SUBST(SettingsDllWrapCommand)
    AC_SUBST(SettingsWindresCommand)
    AC_SUBST(SettingsTouchCommand)
    AC_SUBST(SettingsClangCommand)
    AC_SUBST(SettingsLlcCommand)
    AC_SUBST(SettingsOptCommand)
    AC_SUBST(SettingsUseDistroMINGW)
])