ref: a9ac58af31c1f793739da9ac9182438b107f184a
dir: /Makefile.old/
# installtion prefix PREFIX=/usr/local BIN=bin BOOTDIR=ghc-boot OUTDIR=ghc-out TOOLS=Tools PROF= -prof -fprof-late #-prof -fprof-auto EXTS= -XScopedTypeVariables -XTupleSections GHCB=ghc $(PROF) -outputdir $(BOOTDIR) GHCFLAGS=-i -ighc -ilib -i$(BOOTDIR) -hide-all-packages -XNoImplicitPrelude -XRebindableSyntax $(EXTS) -F -pgmF $(TOOLS)/convertY.sh GHCC=$(GHCB) $(GHCFLAGS) GHC=ghc # $(CURDIR) might not be quite right GHCE=$(GHC) $(EXTS) -package mtl -package pretty -F -pgmF Tools/convertX.sh -outputdir $(OUTDIR) GCC=gcc UPX=upx ALLSRC=src/*/*.hs lib/*.hs lib/*/*.hs ghc/*.hs ghc/*/*.hs MHS=mhs COMB=comb/ EVAL=$(BIN)/mhseval .PHONY: all alltest everytest runtest bootcombtest $(MHS)test test alltest time example bootstraptest all: $(EVAL) $(BIN)/$(MHS) everytest: runtest example examplecomb bootcombtest ### ### Build evaluator (runtime system) ### # On MINGW you might need the additional flags -Wl,--stack,50000000 to increase stack space. $(EVAL): src/runtime/eval.c @mkdir -p bin $(GCC) -Wall -Wno-deprecated-declarations -O3 src/runtime/eval.c src/runtime/comb.c -lm -o $(EVAL) ### ### Build the compiler with ghc, using standard libraries (Prelude, Data.List, etc) ### $(BIN)/$(MHS): src/*/*.hs $(TOOLS)/convertX.sh $(GHCE) -ighc -isrc -Wall -Wno-unrecognised-warning-flags -Wno-x-partial -O src/MicroHs/Main.hs -main-is MicroHs.Main -o $(BIN)/$(MHS) # Self compile using comb/mhs.comb $(COMB)$(MHS)-new.comb: $(EVAL) $(EVAL) +RTS -r$(COMB)$(MHS).comb -RTS -ilib -isrc -o$(COMB)$(MHS)-new.comb MicroHs.Main # Compare version compiled with GHC, and bootstrapped combinator version bootcombtest: $(BIN)/$(MHS) $(EVAL) $(COMB)$(MHS).comb $(BIN)/$(MHS) -ilib -isrc -omain-$(MHS).comb MicroHs.Main $(EVAL) +RTS -v -r$(COMB)$(MHS).comb -RTS -ilib -isrc -omain-comb.comb MicroHs.Main cmp main-$(MHS).comb main-comb.comb ### ### Run test examples with ghc-compiled compiler ### runtest: $(EVAL) $(BIN)/$(MHS) tests/*.hs cd tests; make alltest ### ### Run test examples with MicroHs compiler ### runtestcomb: $(EVAL) $(COMB)$(MHS).comb cd tests; make MHS='../$(EVAL) +RTS -r../$(COMB)$(MHS).comb -RTS -i../lib' ### ### Build combinator file for the compiler, using ghc-compiled compiler ### $(COMB)$(MHS).comb: $(BIN)/$(MHS) $(ALLSRC) $(BIN)/$(MHS) -ilib -isrc -o$(COMB)$(MHS).comb MicroHs.Main time: $(EVAL) $(BIN)/$(MHS) tests/*.hs cd tests; make time example: $(EVAL) $(BIN)/$(MHS) Example.hs $(BIN)/$(MHS) -ilib Example && $(EVAL) # does not work exampleboot: $(BIN)/boot$(MHS) Example.hs $(BIN)/boot$(MHS) -r -ilib Example && $(EVAL) examplecomb: $(EVAL) $(COMB)$(MHS).comb Example.hs $(EVAL) +RTS -r$(COMB)$(MHS).comb -RTS -r -ilib Example clean: rm -rf src/*/*.hi src/*/*.o eval Main *.comb *.tmp *~ $(BIN)/* a.out $(BOOTDIR) $(OUTDIR) tmp/eval.c Tools/*.o Tools/*.hi dist-newstyle cd tests; make clean ### ### Make an eval.c that contains the combinator code. ### tmp/eval.c: src/runtime/eval.c $(EVAL) $(COMB)$(MHS).comb @mkdir -p tmp cp src/runtime/eval.c tmp/eval.c $(EVAL) +RTS -r$(COMB)$(MHS).comb -o$(COMB)$(MHS)-gc.comb -RTS $(EVAL) +RTS -K10M -r$(COMB)$(MHS).comb -RTS -ilib -iTools -r Compress < $(COMB)$(MHS)-gc.comb | \ $(EVAL) +RTS -K10M -r$(COMB)$(MHS).comb -RTS -ilib -iTools -r Addcombs >> tmp/eval.c ### ### Make an executable that contains the combinator code. ### $(BIN)/cmhs: tmp/eval.c $(GCC) -Wall -O3 tmp/eval.c -o $(BIN)/cmhs strip $(BIN)/cmhs ### ### Compress the binary (broken on MacOS) ### $(BIN)/umhs: $(BIN)/cmhs rm -f $(BIN)/umhs $(UPX) -q -q -o$(BIN)/umhs $(BIN)/cmhs ### ### Test that the compiler can bootstrap ### bootstraptest: $(EVAL) @mkdir -p tmp @echo Build stage 1 with distribution combinator file $(EVAL) +RTS -rcomb/mhs.comb -RTS -ilib -isrc -otmp/mhs.comb.1 MicroHs.Main @echo Build stage 2 with output from stage 1 $(EVAL) +RTS -rtmp/mhs.comb.1 -RTS -ilib -isrc -otmp/mhs.comb.2 MicroHs.Main cmp tmp/mhs.comb.1 tmp/mhs.comb.2 && echo Success # installs linraries the the following binaries: # bin/mhseval - the evaluator that can read a combinator file and run it # bin/mhsc - a compiler that produces a proper binary # bin/mhs - a compiler/repl that can compile to combinators install: $(EVAL) mkdir -p $(PREFIX)/bin cp $(EVAL) $(PREFIX)/bin (echo "prefix=$(PREFIX)"; cat Tools/mhsc.sh) > $(PREFIX)/bin/mhsc chmod +x $(PREFIX)/bin/mhsc mkdir -p $(PREFIX)/lib/mhs/Tools mkdir -p $(PREFIX)/lib/mhs/comb mkdir -p $(PREFIX)/lib/mhs/src/runtime cp Tools/* $(PREFIX)/lib/mhs/Tools cp comb/mhs.comb $(PREFIX)/lib/mhs/comb cp src/runtime/eval.c $(PREFIX)/lib/mhs/src/runtime cp -r lib $(PREFIX)/lib/mhs $(PREFIX)/bin/mhsc -isrc -o$(PREFIX)/bin/mhs MicroHs.Main