@@ -39,7 +39,7 @@ GHC1 = _build/stage1/bin/ghc
39
39
GHC2 = _build/stage2/bin/ghc
40
40
41
41
define GHC_INFO
42
- $(shell sh -c " $(GHC0 ) --info | $( GHC0 ) -e 'getContents >>= foldMap putStrLn . lookup \ "$1\" . read'" )
42
+ $(shell $(GHC0 ) --info | grep -oP ' "$1",\s * "\K[^"]+' )
43
43
endef
44
44
45
45
TARGET_PLATFORM := $(call GHC_INFO,target platform string)
@@ -179,12 +179,17 @@ STAGE2_UTIL_EXECUTABLES := \
179
179
# export CABAL := $(shell cabal update 2>&1 >/dev/null && cabal build cabal-install -v0 --disable-tests --project-dir libraries/Cabal && cabal list-bin -v0 --project-dir libraries/Cabal cabal-install:exe:cabal)
180
180
$(abspath _build/stage0/bin/cabal) : _build/stage0/bin/cabal
181
181
182
- .PHONY : _build/stage0/bin/cabal
182
+ # --- Stage 0 build ---
183
+
184
+ # This just builds cabal-install, which is used to build the rest of the project.
185
+
186
+ # We need an absolute path here otherwise cabal will consider the path relative to `the project directory
187
+ _build/stage0/bin/cabal : BUILD_ARGS=-j -w $(GHC0 ) --disable-tests --project-dir libraries/Cabal --builddir=$(abspath _build/stage0)
183
188
_build/stage0/bin/cabal :
184
189
@echo " >>> Building Cabal..."
185
190
@mkdir -p _build/stage0/bin _build/logs
186
- $( call run_and_log, cabal build -j -w $( GHC0 ) --disable-tests --project-dir libraries/Cabal --builddir=_build/stage0/ cabal cabal -install:exe:cabal)
187
- cp -rfp $(shell cabal list-bin -v0 -j -w $( GHC0 ) --project-dir libraries/Cabal --builddir=_build/stage0/cabal cabal-install:exe:cabal) _build/stage0/bin/cabal
191
+ cabal build $( BUILD_ARGS ) cabal-install:exe:cabal
192
+ cp -rfp $(shell cabal list-bin -v0 $( BUILD_ARGS ) cabal-install:exe:cabal) _build/stage0/bin/cabal
188
193
@echo " >>> Cabal built successfully."
189
194
190
195
# --- Stage 1 build ---
@@ -195,7 +200,7 @@ _build/stage1/%: private GHC=$(GHC0)
195
200
.PHONY : $(addprefix _build/stage1/bin/,$(STAGE1_EXECUTABLES ) )
196
201
$(addprefix _build/stage1/bin/,$(STAGE1_EXECUTABLES ) ) & : $(CABAL ) | _build/booted
197
202
# Force cabal to replan
198
- rm -rf _build/stage2 /cache
203
+ rm -rf _build/stage1 /cache
199
204
$(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS ) ' \
200
205
$(CABAL_BUILD ) $(STAGE1_TARGETS ) )
201
206
@@ -357,4 +362,4 @@ test: _build/bindist
357
362
make -C testsuite/tests test THREADS=${THREADS}
358
363
359
364
# Inform Make that these are not actual files if they get deleted by other means
360
- .PHONY : clean distclean test all configure
365
+ .PHONY : clean distclean test all
0 commit comments