1 # Note [Preparing variables for GHC.Toolchain.Target]
2 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 # In configure, we generate default.target and default.host.target files that
4 # contain a value of the Haskell type GHC.Toolchain.Target.Target.
6 # Since we substitute in those files with configured variables, we have to
7 # preparate them as Haskell values, for example, turning YES/NO into
8 # True,False, or empty variables into Nothing or Just something otherwise.
10 # This toolchain will additionally be used to validate the one generated by
11 # ghc-toolchain. See Note [ghc-toolchain consistency checking].
13 # PREP_MAYBE_SIMPLE_PROGRAM
14 # =========================
16 # Issue a substitution of [$1MaybeProg] with
17 # * Nothing, if $1 is empty
18 # * Just (Program {prgPath = "$$1", prgFlags = []}), otherwise
21 AC_DEFUN([PREP_MAYBE_SIMPLE_PROGRAM],[
22 if test -z "$$1"; then
25 $1MaybeProg="Just (Program {prgPath = \"$$1\", prgFlags = @<:@@:>@})"
27 AC_SUBST([$1MaybeProg])
31 # =========================
33 # Issue a substitution of [$1MaybeStr] with
34 # * Nothing, if $1 is empty
35 # * Just "$$1", otherwise
38 AC_DEFUN([PREP_MAYBE_STRING],[
39 if test -z "$$1"; then
42 $1MaybeStr="Just \"$$1\""
44 AC_SUBST([$1MaybeStr])
50 # Issue a substitution with True/False of [$1Bool] when $1 has YES/NO value
51 # $1 = boolean variable to substitute
52 AC_DEFUN([PREP_BOOLEAN],[
61 AC_MSG_WARN([m4/prep_target_file.m4: Expecting YES/NO but got $$1 in $1. Defaulting to False.])
71 # Issue a substitution with True/False of [Not$1Bool] when $1 has NO/YES value
72 # $1 = boolean variable to substitute
73 AC_DEFUN([PREP_NOT_BOOLEAN],[
82 AC_MSG_WARN([m4/prep_target_file.m4: Expecting YES/NO but got $$1 in $1. Defaulting to False.])
92 # Issue a substitution with ["list","of","args"] of [$1List] when $1 is a
93 # space-separated list of args
97 # ["arg1","arg2","arg3"]
99 # $1 = list variable to substitute
100 dnl In autoconf, '@<:@' stands for '[', and '@:>@' for ']'.
101 AC_DEFUN([PREP_LIST],[
105 if test "[$]#" -eq 0; then
109 $1List="${$1List}\"[$]1\""
110 shift # drop first elem
113 $1List="${$1List},\"$arg\""
116 $1List="${$1List}@:>@"
121 # Eventually: PREP_BUILD_TARGET_FILE, PREP_HOST_TARGET_FILE, PREP_TARGET_TARGET_FILE
122 # Prepares required substitutions to generate the target file
123 AC_DEFUN([PREP_TARGET_FILE],[
126 PREP_BOOLEAN([MergeObjsSupportsResponseFiles])
127 PREP_BOOLEAN([TargetHasGnuNonexecStack])
128 PREP_BOOLEAN([LeadingUnderscore])
129 PREP_BOOLEAN([ArSupportsAtFile])
130 PREP_BOOLEAN([ArSupportsDashL])
131 PREP_BOOLEAN([TargetHasIdentDirective])
132 PREP_BOOLEAN([CONF_GCC_SUPPORTS_NO_PIE])
133 PREP_BOOLEAN([LdHasFilelist])
134 PREP_BOOLEAN([LdHasSingleModule])
135 PREP_BOOLEAN([LdIsGNULd])
136 PREP_BOOLEAN([LdHasNoCompactUnwind])
137 PREP_BOOLEAN([TargetHasSubsectionsViaSymbols])
138 PREP_BOOLEAN([Unregisterised])
139 PREP_BOOLEAN([TablesNextToCode])
140 PREP_BOOLEAN([UseLibffiForAdjustors])
141 PREP_BOOLEAN([ArIsGNUAr])
142 PREP_BOOLEAN([ArNeedsRanLib])
143 PREP_NOT_BOOLEAN([CrossCompiling])
144 PREP_LIST([MergeObjsArgs])
146 PREP_LIST([CONF_GCC_LINKER_OPTS_STAGE2])
147 PREP_LIST([HaskellCPPArgs])
148 PREP_LIST([JavaScriptCPPArgs])
149 PREP_LIST([CmmCPPArgs])
150 PREP_LIST([CmmCPPArgs_STAGE0])
151 PREP_MAYBE_SIMPLE_PROGRAM([WindresCmd])
152 PREP_MAYBE_STRING([TargetVendor_CPP])
153 PREP_MAYBE_STRING([HostVendor_CPP])
154 PREP_LIST([CONF_CPP_OPTS_STAGE2])
155 PREP_LIST([CONF_CXX_OPTS_STAGE2])
156 PREP_LIST([CONF_CC_OPTS_STAGE2])
159 PREP_BOOLEAN([ArSupportsAtFile_STAGE0])
160 PREP_BOOLEAN([ArSupportsDashL_STAGE0])
161 PREP_LIST([AR_OPTS_STAGE0])
162 PREP_LIST([CONF_CC_OPTS_STAGE0])
163 PREP_LIST([CONF_CPP_OPTS_STAGE0])
164 PREP_LIST([CONF_CXX_OPTS_STAGE0])
165 PREP_LIST([CONF_GCC_LINKER_OPTS_STAGE0])
168 if test -z "$MergeObjsCmd"; then
169 MergeObjsCmdMaybe=Nothing
171 MergeObjsCmdMaybe="Just (MergeObjs {mergeObjsProgram = Program {prgPath = \"$MergeObjsCmd\", prgFlags = $MergeObjsArgsList}, mergeObjsSupportsResponseFiles = $MergeObjsSupportsResponseFilesBool})"
173 AC_SUBST([MergeObjsCmdMaybe])
176 case "$TargetWordBigEndian" in
178 TargetEndianness=BigEndian
181 TargetEndianness=LittleEndian
184 AC_MSG_ERROR([m4/prep_target_file.m4: Expecting YES/NO but got $TargetWordBigEndian in TargetWordBigEndian])
187 AC_SUBST([TargetEndianness])