@@ -92,6 +92,15 @@ EMCXX ?= em++
92
92
EMAR ?= emar
93
93
EMRANLIB ?= emranlib
94
94
95
+ EXTRA_LIB_DIRS ?=
96
+ EXTRA_INCLUDE_DIRS ?=
97
+
98
+ MUSL_EXTRA_LIB_DIRS ?=
99
+ MUSL_EXTRA_INCLUDE_DIRS ?=
100
+
101
+ JS_EXTRA_LIB_DIRS ?=
102
+ JS_EXTRA_INCLUDE_DIRS ?=
103
+
95
104
# :exploding-head: It turns out override doesn't override the command-line
96
105
# value but it overrides Make's normal behavior of ignoring assignments to
97
106
# command-line variables. This allows the += operations to append to whatever
@@ -104,7 +113,9 @@ override CABAL_ARGS += \
104
113
105
114
override CABAL_BUILD_ARGS += \
106
115
-j -w $(GHC ) --with-gcc=$(CC ) \
107
- --project-file=cabal.project.$(STAGE ) \
116
+ --project-file=cabal.project.$(STAGE )$(if $(TARGET ) ,".$(TARGET ) ",) \
117
+ $(foreach lib,$(EXTRA_LIB_DIRS ) ,--extra-lib-dirs=$(lib ) ) \
118
+ $(foreach include,$(EXTRA_INCLUDE_DIRS ) ,--extra-include-dirs=$(include ) ) \
108
119
--builddir=_build/$(STAGE ) /$(TARGET ) \
109
120
--ghc-options="-fhide-source-paths"
110
121
@@ -237,7 +248,7 @@ STAGE2_UTIL_EXECUTABLES := \
237
248
runghc \
238
249
unlit
239
250
240
- STAGE2_TARGET_LIBS := \
251
+ STAGE3_LIBS := \
241
252
Cabal \
242
253
Cabal-syntax \
243
254
array \
@@ -250,6 +261,7 @@ STAGE2_TARGET_LIBS := \
250
261
exceptions \
251
262
file-io \
252
263
filepath \
264
+ ghc-bignum \
253
265
hpc \
254
266
integer-gmp \
255
267
mtl \
@@ -405,49 +417,131 @@ _build/stage2/lib/template-hsc.h: utils/hsc2hs/data/template-hsc.h
405
417
.PHONY : stage2
406
418
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
407
419
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
420
+ # --- Stage 3 javascript build ---
410
421
411
- _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings : _build/stage1/bin/ghc-toolchain-bin
422
+ .PHONY : stage3-javascript-unknown-ghcjs
423
+ stage3-javascript-unknown-ghcjs : javascript-unknown-ghcjs-libs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache
424
+
425
+ _build/stage3/lib/targets/javascript-unknown-ghcjs/lib :
426
+ @mkdir -p $@
427
+ @mkdir -p _build/stage2/lib/targets/
428
+ @ln -sf ../../../stage3/lib/targets/javascript-unknown-ghcjs _build/stage2/lib/targets/javascript-unknown-ghcjs
429
+
430
+ _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/settings : _build/stage3/lib/targets/javascript-unknown-ghcjs/lib _build/stage1/bin/ghc-toolchain-bin
431
+ @mkdir -p $(@D )
432
+ $(call run_and_log, _build/stage1/bin/ghc-toolchain-bin --triple javascript-unknown-ghcjs --output-settings -o $@ --cc $(EMCC ) --cxx $(EMCXX ) --ar $(EMAR ) --ranlib $(EMRANLIB ) )
433
+
434
+ _build/stage3/bin/javascript-unknown-ghcjs-ghc-pkg : _build/stage2/bin/ghc-pkg
412
435
@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 ) )
436
+ @ln -sf ../../stage2/ bin/ghc-pkg $@
414
437
415
- _build/stage2 /bin/javascript-unknown-ghcjs-ghc-pkg : _build/stage2/bin/ghc-pkg
438
+ _build/stage3 /bin/javascript-unknown-ghcjs-ghc : _build/stage2/bin/ghc
416
439
@mkdir -p $(@D )
417
- ln -sf ghc-pkg $@
440
+ @ ln -sf ../../stage2/bin/ ghc $@
418
441
419
- _build/stage2 /bin/javascript-unknown-ghcjs-ghc : _build/stage2/bin/ghc
442
+ _build/stage3 /bin/javascript-unknown-ghcjs-hsc2hs : _build/stage2/bin/hsc2hs
420
443
@mkdir -p $(@D )
421
- ln -sf ghc $@
444
+ @ ln -sf ../../stage2/bin/hsc2hs $@
422
445
423
- _build/stage2 /lib/targets/javascript-unknown-ghcjs/lib/package.conf.d :
446
+ _build/stage3 /lib/targets/javascript-unknown-ghcjs/lib/package.conf.d : _build/stage3/lib/targets/javascript-unknown-ghcjs/lib
424
447
@mkdir -p $@
425
448
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
449
+ _build/stage3 /lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache : _build/stage3 /bin/javascript-unknown-ghcjs-ghc-pkg _build/stage3 /lib/targets/javascript-unknown-ghcjs/lib/settings javascript-unknown-ghcjs-libs
427
450
@mkdir -p $(@D )
428
451
@rm -rf $(@D ) /*
429
- cp -rfp _build/stage2 /javascript-unknown-ghcjs/packagedb/host/* /* $(@D )
430
- _build/stage2 /bin/javascript-unknown-ghcjs-ghc-pkg recache
452
+ cp -rfp _build/stage3 /javascript-unknown-ghcjs/packagedb/host/* /* $(@D )
453
+ _build/stage3 /bin/javascript-unknown-ghcjs-ghc-pkg recache
431
454
432
- _build/stage2/lib/targets/javascript-unknown-ghcjs/bin/unlit : _build/stage2/bin/unlit
455
+ # ghc-toolchain borks unlit
456
+ _build/stage3/lib/targets/javascript-unknown-ghcjs/bin/unlit : _build/stage2/bin/unlit
433
457
@mkdir -p $(@D )
434
458
cp -rfp $< $@
435
459
436
460
.PHONY : javascript-unknown-ghcjs-libs
437
461
javascript-unknown-ghcjs-libs : private TARGET=javascript-unknown-ghcjs
438
- javascript-unknown-ghcjs-libs : private GHC=$(abspath _build/stage2 /bin/javascript-unknown-ghcjs-ghc)
462
+ javascript-unknown-ghcjs-libs : private GHC=$(abspath _build/stage3 /bin/javascript-unknown-ghcjs-ghc)
439
463
javascript-unknown-ghcjs-libs : private GHC2=$(abspath _build/stage2/bin/ghc)
440
- javascript-unknown-ghcjs-libs : private STAGE=stage2
464
+ javascript-unknown-ghcjs-libs : private STAGE=stage3
441
465
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
466
+ javascript-unknown-ghcjs-libs : _build/stage3/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage3/bin/javascript-unknown-ghcjs-ghc _build/stage3/bin/javascript-unknown-ghcjs-hsc2hs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/settings _build/stage3/lib/targets/javascript-unknown-ghcjs/bin/unlit _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d
467
+ # Force cabal to replan
468
+ rm -rf _build/stage3/javascript-unknown-ghcjs/cache
469
+ $(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS ) ' \
470
+ PATH=$(PWD ) /_build/stage2/bin:$(PWD ) /_build/stage3/bin:$(PATH ) \
471
+ $(CABAL_BUILD ) -W $(GHC2 ) --happy-options=" --template=$( abspath _build/stage2/src/happy-lib-2.1.5/data/) " --with-hsc2hs=javascript-unknown-ghcjs-hsc2hs --hsc2hs-options=' -x' --configure-option=' --host=javascript-unknown-ghcjs' \
472
+ $(foreach lib,$(JS_EXTRA_LIB_DIRS ) ,--extra-lib-dirs=$(lib ) ) \
473
+ $(foreach include,$(JS_EXTRA_INCLUDE_DIRS ) ,--extra-include-dirs=$(include ) ) \
474
+ rts:nonthreaded-nodebug )
475
+ $(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS ) ' \
476
+ PATH=$(PWD ) /_build/stage2/bin:$(PWD ) /_build/stage3/bin:$(PATH ) \
477
+ $(CABAL_BUILD ) -W $(GHC2 ) --happy-options=" --template=$( abspath _build/stage2/src/happy-lib-2.1.5/data/) " --with-hsc2hs=javascript-unknown-ghcjs-hsc2hs --hsc2hs-options=' -x' --configure-option=' --host=javascript-unknown-ghcjs' \
478
+ $(foreach lib,$(JS_EXTRA_LIB_DIRS ) ,--extra-lib-dirs=$(lib ) ) \
479
+ $(foreach include,$(JS_EXTRA_INCLUDE_DIRS ) ,--extra-include-dirs=$(include ) ) \
480
+ $(STAGE3_LIBS ) )
481
+
482
+ # --- Stage 3 musl build ---
483
+
484
+ .PHONY : stage3-x86_64-unknown-linux-musl
485
+ stage3-x86_64-unknown-linux-musl : x86_64-unknown-linux-musl-libs _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/package.conf.d/package.cache
486
+
487
+ _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib :
488
+ @mkdir -p $@
489
+ @mkdir -p _build/stage2/lib/targets/
490
+ @ln -sf ../../../stage3/lib/targets/x86_64-unknown-linux-musl _build/stage2/lib/targets/x86_64-unknown-linux-musl
491
+
492
+ _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/settings : _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib _build/stage1/bin/ghc-toolchain-bin
493
+ @mkdir -p $(@D )
494
+ $(call run_and_log, _build/stage1/bin/ghc-toolchain-bin --triple x86_64-unknown-linux-musl --output-settings -o $@ --cc x86_64-unknown-linux-musl-cc --cxx x86_64-unknown-linux-musl-c++ --ar x86_64-unknown-linux-musl-ar --ranlib x86_64-unknown-linux-musl-ranlib --ld x86_64-unknown-linux-musl-ld)
495
+
496
+ _build/stage3/bin/x86_64-unknown-linux-musl-ghc-pkg : _build/stage2/bin/ghc-pkg
497
+ @mkdir -p $(@D )
498
+ @ln -sf ../../stage2/bin/ghc-pkg $@
499
+
500
+ _build/stage3/bin/x86_64-unknown-linux-musl-ghc : _build/stage2/bin/ghc
501
+ @mkdir -p $(@D )
502
+ @ln -sf ../../stage2/bin/ghc $@
503
+
504
+ _build/stage3/bin/x86_64-unknown-linux-musl-hsc2hs : _build/stage2/bin/hsc2hs
505
+ @mkdir -p $(@D )
506
+ @ln -sf ../../stage2/bin/hsc2hs $@
507
+
508
+ _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/package.conf.d : _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib
509
+ @mkdir -p $@
510
+
511
+ _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/package.conf.d/package.cache : _build/stage3/bin/x86_64-unknown-linux-musl-ghc-pkg _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/settings x86_64-unknown-linux-musl-libs
512
+ @mkdir -p $(@D )
513
+ @rm -rf $(@D ) /*
514
+ cp -rfp _build/stage3/x86_64-unknown-linux-musl/packagedb/host/* /* $(@D )
515
+ _build/stage3/bin/x86_64-unknown-linux-musl-ghc-pkg recache
516
+
517
+ # ghc-toolchain borks unlit
518
+ _build/stage3/lib/targets/x86_64-unknown-linux-musl/bin/unlit : _build/stage2/bin/unlit
519
+ @mkdir -p $(@D )
520
+ cp -rfp $< $@
521
+
522
+ .PHONY : x86_64-unknown-linux-musl-libs
523
+ x86_64-unknown-linux-musl-libs : private TARGET=x86_64-unknown-linux-musl
524
+ x86_64-unknown-linux-musl-libs : private GHC=$(abspath _build/stage3/bin/x86_64-unknown-linux-musl-ghc)
525
+ x86_64-unknown-linux-musl-libs : private GHC2=$(abspath _build/stage2/bin/ghc)
526
+ x86_64-unknown-linux-musl-libs : private STAGE=stage3
527
+ x86_64-unknown-linux-musl-libs : private CC=x86_64-unknown-linux-musl-cc
528
+ x86_64-unknown-linux-musl-libs : _build/stage3/bin/x86_64-unknown-linux-musl-ghc-pkg _build/stage3/bin/x86_64-unknown-linux-musl-ghc _build/stage3/bin/x86_64-unknown-linux-musl-hsc2hs _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/settings _build/stage3/lib/targets/x86_64-unknown-linux-musl/bin/unlit _build/stage3/lib/targets/x86_64-unknown-linux-musl/lib/package.conf.d
443
529
# Force cabal to replan
444
- rm -rf _build/stage2/javascript -unknown-ghcjs /cache
530
+ rm -rf _build/stage3/x86_64 -unknown-linux-musl /cache
445
531
$(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 )
532
+ PATH=$(PWD ) /_build/stage2/bin:$(PWD ) /_build/stage3/bin:$(PATH ) \
533
+ $(CABAL_BUILD ) -W $(GHC2 ) --happy-options=" --template=$( abspath _build/stage2/src/happy-lib-2.1.5/data/) " --with-hsc2hs=x86_64-unknown-linux-musl-hsc2hs --hsc2hs-options=' -x' --with-ld=x86_64-unknown-linux-musl-ld --configure-option=' --host=x86_64-unknown-linux-musl' \
534
+ $(foreach lib,$(MUSL_EXTRA_LIB_DIRS ) ,--extra-lib-dirs=$(lib ) ) \
535
+ $(foreach include,$(MUSL_EXTRA_INCLUDE_DIRS ) ,--extra-include-dirs=$(include ) ) \
536
+ rts:nonthreaded-nodebug )
448
537
$(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 ) )
538
+ PATH=$(PWD ) /_build/stage2/bin:$(PWD ) /_build/stage3/bin:$(PATH ) \
539
+ $(CABAL_BUILD ) -W $(GHC2 ) --happy-options=" --template=$( abspath _build/stage2/src/happy-lib-2.1.5/data/) " --with-hsc2hs=x86_64-unknown-linux-musl-hsc2hs --hsc2hs-options=' -x' --with-ld=x86_64-unknown-linux-musl-ld --configure-option=' --host=x86_64-unknown-linux-musl' \
540
+ $(foreach lib,$(MUSL_EXTRA_LIB_DIRS ) ,--extra-lib-dirs=$(lib ) ) \
541
+ $(foreach include,$(MUSL_EXTRA_INCLUDE_DIRS ) ,--extra-include-dirs=$(include ) ) \
542
+ $(STAGE3_LIBS ) )
543
+
544
+ # --- Bindist ---
451
545
452
546
# Target for creating the final binary distribution directory
453
547
_build/bindist : stage2 driver/ghc-usage.txt driver/ghci-usage.txt
@@ -502,6 +596,12 @@ clean-stage2:
502
596
rm -rf _build/stage2
503
597
@echo " ::endgroup::"
504
598
599
+ clean-stage3 :
600
+ @echo " >>> Cleaning stage3 build artifacts..."
601
+ rm -rf _build/stage3
602
+ rm -rf _build/stage2/lib/targets
603
+ @echo " >>> Stage3 build artifacts cleaned."
604
+
505
605
distclean : clean
506
606
@echo " ::group::Cleaning all generated files (distclean)..."
507
607
rm -rf autom4te.cache
@@ -525,4 +625,4 @@ test: _build/bindist
525
625
@echo " ::endgroup::" >&2
526
626
527
627
# Inform Make that these are not actual files if they get deleted by other means
528
- .PHONY : clean distclean test all
628
+ .PHONY : clean distclean test all configure clean-stage1 clean-stage2 clean-stage3
0 commit comments