@@ -87,25 +87,31 @@ GHC0 ?= ghc-9.8.4
87
87
PYTHON ?= python3
88
88
CABAL ?= cabal
89
89
90
+ EMCC ?= emcc
91
+ EMCXX ?= em++
92
+ EMAR ?= emar
93
+ EMRANLIB ?= emranlib
94
+
90
95
# :exploding-head: It turns out override doesn't override the command-line
91
96
# value but it overrides Make's normal behavior of ignoring assignments to
92
97
# command-line variables. This allows the += operations to append to whatever
93
98
# was passed from the command line.
94
99
95
100
override CABAL_ARGS += \
96
101
--remote-repo-cache _build/packages \
97
- --store-dir=_build/$(STAGE ) /store \
102
+ --store-dir=_build/$(STAGE ) /$( TARGET ) / store \
98
103
--logs-dir=_build/$(STAGE ) /logs
99
104
100
105
override CABAL_BUILD_ARGS += \
101
106
-j -w $(GHC ) --with-gcc=$(CC ) \
102
107
--project-file=cabal.project.$(STAGE ) \
103
- --builddir=_build/$(STAGE ) \
108
+ --builddir=_build/$(STAGE ) / $( TARGET ) \
104
109
--ghc-options="-fhide-source-paths"
105
110
106
111
# just some defaults
107
112
STAGE ?= stage1
108
113
GHC ?= $(GHC0 )
114
+ TARGET ?=
109
115
110
116
CABAL_BUILD = $(CABAL ) $(CABAL_ARGS ) build $(CABAL_BUILD_ARGS )
111
117
@@ -231,6 +237,33 @@ STAGE2_UTIL_EXECUTABLES := \
231
237
runghc \
232
238
unlit
233
239
240
+ STAGE2_TARGET_LIBS := \
241
+ Cabal \
242
+ Cabal-syntax \
243
+ array \
244
+ base \
245
+ binary \
246
+ bytestring \
247
+ containers \
248
+ deepseq \
249
+ directory \
250
+ exceptions \
251
+ file-io \
252
+ filepath \
253
+ hpc \
254
+ integer-gmp \
255
+ mtl \
256
+ os-string \
257
+ parsec \
258
+ pretty \
259
+ process \
260
+ stm \
261
+ template-haskell \
262
+ text \
263
+ time \
264
+ transformers \
265
+ xhtml
266
+
234
267
# 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)
235
268
$(abspath _build/stage0/bin/cabal) : _build/stage0/bin/cabal
236
269
@@ -300,6 +333,12 @@ $(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES)) &: $(CABAL) stage1
300
333
@echo " ::group::Building stage2 executables ($( STAGE2_EXECUTABLES) )..."
301
334
# Force cabal to replan
302
335
rm -rf _build/stage2/cache
336
+ # Building of rts:nonthreaded-nodebug should not be necessary as it should be
337
+ # pulled in by the `ghc-bin` target, which is the only one in the STAGE2_TARGETS.
338
+ #
339
+ # HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
340
+ # PATH=$(PWD)/_build/stage1/bin:$(PATH) \
341
+ # $(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) rts:nonthreaded-nodebug
303
342
HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
304
343
PATH=$(PWD)/_build/stage1/bin:$(PATH) \
305
344
$(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) $(STAGE2_TARGETS)
@@ -366,6 +405,50 @@ _build/stage2/lib/template-hsc.h: utils/hsc2hs/data/template-hsc.h
366
405
.PHONY : stage2
367
406
stage2 : $(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES ) ) _build/stage2/lib/settings _build/stage2/lib/package.conf.d/package.cache _build/stage2/lib/template-hsc.h
368
407
408
+ .PHONY : stage2-javascript-unknown-ghcjs
409
+ stage2-javascript-unknown-ghcjs : javascript-unknown-ghcjs-libs _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache
410
+
411
+ _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings : _build/stage1/bin/ghc-toolchain-bin
412
+ @mkdir -p $(@D )
413
+ $(call run_and_log, emconfigure _build/stage1/bin/ghc-toolchain-bin --triple javascript-unknown-ghcjs --output-settings -o $@ --cc $(EMCC ) --cxx $(EMCXX ) --ar $(EMAR ) --ranlib $(EMRANLIB ) )
414
+
415
+ _build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg : _build/stage2/bin/ghc-pkg
416
+ @mkdir -p $(@D )
417
+ ln -sf ghc-pkg $@
418
+
419
+ _build/stage2/bin/javascript-unknown-ghcjs-ghc : _build/stage2/bin/ghc
420
+ @mkdir -p $(@D )
421
+ ln -sf ghc $@
422
+
423
+ _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d :
424
+ @mkdir -p $@
425
+
426
+ _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache : _build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings javascript-unknown-ghcjs-libs
427
+ @mkdir -p $(@D )
428
+ @rm -rf $(@D ) /*
429
+ cp -rfp _build/stage2/javascript-unknown-ghcjs/packagedb/host/* /* $(@D )
430
+ _build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg recache
431
+
432
+ _build/stage2/lib/targets/javascript-unknown-ghcjs/bin/unlit : _build/stage2/bin/unlit
433
+ @mkdir -p $(@D )
434
+ cp -rfp $< $@
435
+
436
+ .PHONY : javascript-unknown-ghcjs-libs
437
+ javascript-unknown-ghcjs-libs : private TARGET=javascript-unknown-ghcjs
438
+ javascript-unknown-ghcjs-libs : private GHC=$(abspath _build/stage2/bin/javascript-unknown-ghcjs-ghc)
439
+ javascript-unknown-ghcjs-libs : private GHC2=$(abspath _build/stage2/bin/ghc)
440
+ javascript-unknown-ghcjs-libs : private STAGE=stage2
441
+ javascript-unknown-ghcjs-libs : private CC=emcc
442
+ javascript-unknown-ghcjs-libs : _build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage2/bin/javascript-unknown-ghcjs-ghc _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings _build/stage2/lib/targets/javascript-unknown-ghcjs/bin/unlit _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d
443
+ # Force cabal to replan
444
+ rm -rf _build/stage2/javascript-unknown-ghcjs/cache
445
+ $(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS ) ' \
446
+ PATH=$(PWD ) /_build/stage2/bin:$(PATH ) \
447
+ $(CABAL_BUILD ) -W $(GHC2 ) --happy-options=" --template=$( abspath _build/stage2/src/happy-lib-2.1.5/data/) " rts:nonthreaded-nodebug )
448
+ $(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS ) ' \
449
+ PATH=$(PWD ) /_build/stage2/bin:$(PATH ) \
450
+ $(CABAL_BUILD ) -W $(GHC2 ) --happy-options=" --template=$( abspath _build/stage2/src/happy-lib-2.1.5/data/) " $(STAGE2_TARGET_LIBS ) )
451
+
369
452
# Target for creating the final binary distribution directory
370
453
_build/bindist : stage2 driver/ghc-usage.txt driver/ghci-usage.txt
371
454
@echo " ::group::Creating binary distribution in _build/bindist"
0 commit comments