inweb-bootstrap/scripts/inweb.mkscript
2022-04-22 00:06:45 +01:00

197 lines
6.8 KiB
Text

# This is "inweb.mkscript", a script used to generate the makefile "inweb.mk"
# used to build the tool "inweb". Do not edit "inweb.mk" directly. Instead,
# edit this script, and then rebuild "inweb.mk" with the command:
# inweb/Tangled/inweb inweb -prototype inweb/scripts/inweb.mkscript -makefile inweb/inweb.mk
# See the inweb manual for documentation on the *.mkscript file format, i.e.,
# the format in which this file is written. But it is essentially just a makefile
# with a number of special macro and loop features whose syntax involves braces
# { ... }, so anywhere that you see braces, you're looking at something special
# to *.mkscript; anything else is straightforward make syntax.
# -----------------------------------------------------------------------------
# Note that the resulting makescript expects to be used from a current working
# directory which is the _one above_ "inweb", _not_ from "inweb" itself. So it
# should usually be invoked as e.g. "make -f inweb/inweb.mk".
# -----------------------------------------------------------------------------
{platform-settings}
ME = inweb
FTEST = $(ME)/foundation-test
SAFETYCOPY = $(ME)/Tangled/inweb_dev
# The colony file for this collection of webs contains information about their
# paths, where they are woven to, and so on
COLONY = $(ME)/colony.txt
-include $(ME)/platform-settings.mk
# Making the program:
.PHONY: all
all: $(ME)/platform-settings.mk $(ME)/Tangled/$(ME) $(FTEST)/Tangled/foundation-test
$(ME)/Tangled/$(ME): $(ME)/Contents.w $(ME)/Chapter*/*.w $(ME)/foundation-module/Contents.w $(ME)/foundation-module/Chapter*/*.w
$(call make-me)
$(FTEST)/Tangled/foundation-test: $(FTEST)/Contents.w $(FTEST)/Sections/*.w $(ME)/foundation-module/Contents.w $(ME)/foundation-module/Chapter*/*.w
$(call make-ftest)
.PHONY: force
force: $(ME)/platform-settings.mk
$(call make-me)
$(call make-ftest)
{define: make-settings platform: PLATFORM}
$(INWEB) -prototype $(ME)/Materials/platforms/{PLATFORM}.mkscript -makefile $(ME)/Materials/platforms/{PLATFORM}.mk
{end-define}
.PHONY: makers
makers:
$(INWEB) $(FTEST) -makefile $(FTEST)/foundation-test.mk
{make-settings platform: macos}
{make-settings platform: macos32}
{make-settings platform: windows}
{make-settings platform: linux}
{make-settings platform: unix}
{define: target-to-choose platform: PLATFORM}
.PHONY: {PLATFORM}
{PLATFORM}:
cp -f $(ME)/Materials/platforms/{PLATFORM}.mk $(ME)/platform-settings.mk
echo "=== Platform set to '{PLATFORM}'. Now: make -f inweb/inweb.mk initial ==="
{end-define}
{target-to-choose platform: macos}
{target-to-choose platform: macos32}
{target-to-choose platform: windows}
{target-to-choose platform: linux}
{target-to-choose platform: unix}
.PHONY: initial
initial: $(ME)/platform-settings.mk
$(call make-me-once-tangled)
$(call make-ftest)
.PHONY: safe
safe:
$(call make-me-using-safety-copy)
# One of inweb's tasks is to tangle webs: but since inweb is itself a web,
# that means it can only be compiled using itself. To avoid a logical
# impossibility, a ready-tangled inweb.c is supplied as part of the Core
# Inform tarball. The following builds inweb from this:
define make-me-once-tangled
{compile from: $(ME)/Tangled/$(ME).c to: $(ME)/Tangled/$(ME).o}
{link from: $(ME)/Tangled/$(ME).o to: $(ME)/Tangled/$(ME)$(EXEEXTENSION)}
endef
# If inweb exists already, we can compile it using itself like so:
define make-me
$(ME)/Tangled/$(ME) $(ME) -tangle
$(call make-me-once-tangled)
endef
# When developing inweb, it's all too easy to break it and therefore to get
# into a cleft stick: inweb has a bug, so it can't tangle inweb any more, and
# therefore the bug can't be fixed. To get around this, we maintain a spare
# copy of the inweb executable which is known to work. "make inwebdev" uses
# the safety copy of inweb to recompile inweb.
define make-me-using-safety-copy
$(SAFETYCOPY) $(ME) -tangle
$(call make-me-once-tangled)
endef
# Now foundation-test...
define make-ftest
$(INWEB) $(FTEST) -makefile $(FTEST)/foundation-test.mk
make -f $(FTEST)/foundation-test.mk
endef
# Testing the program - which requires intest to be installed too.
.PHONY: test
test:
$(INTEST) -from $(ME) all
# "make commit" should be used only by the Benevolent Overlord of Inweb.
# It updates the build code and commits to the repository.
.PHONY: commit
commit:
$(INWEB) -advance-build-file $(ME)/build.txt
$(INWEB) -prototype inweb/scripts/READMEscript.txt -write-me inweb/README.md
cd $(ME); git commit -a
# Weaving the web for GitHub Pages:
.PHONY: pages
pages:
$(INWEB) -help > $(ME)/Figures/help.txt
$(INWEB) -show-languages > $(ME)/Figures/languages.txt
$(INWEB) -colony $(COLONY) -member twinprimes -scan > $(ME)/Figures/scan.txt
$(INWEB) -colony $(COLONY) -member twinprimes -weave-as TestingInweb -weave-to $(ME)/Figures/tree.txt
cp -f $(COLONY) $(ME)/Figures/colony.txt
cp -f $(ME)/docs-src/nav.html $(ME)/Figures/nav.txt
$(INWEB) -advance-build-file $(ME)/build.txt
mkdir -p $(ME)/docs
rm -f $(ME)/docs/*.html
mkdir -p $(ME)/docs/docs-assets
rm -f $(ME)/docs/docs-assets/*.css
rm -f $(ME)/docs/docs-assets/*.png
rm -f $(ME)/docs/docs-assets/*.gif
cp -f $(ME)/docs-src/Octagram.png $(ME)/docs/docs-assets/Octagram.png
$(INWEB) -prototype inweb/scripts/READMEscript.txt -write-me inweb/README.md
mkdir -p $(ME)/docs/inweb
rm -f $(ME)/docs/inweb/*.html
mkdir -p $(ME)/docs/goldbach
rm -f $(ME)/docs/goldbach/*.html
mkdir -p $(ME)/docs/twinprimes
rm -f $(ME)/docs/twinprimes/*.html
mkdir -p $(ME)/docs/eastertide
rm -f $(ME)/docs/eastertide/*.html
mkdir -p $(ME)/docs/foundation-module
rm -f $(ME)/docs/foundation-module/*.html
mkdir -p $(ME)/docs/foundation-test
rm -f $(ME)/docs/foundation-test/*.html
$(INWEB) -colony $(COLONY) -member overview -weave
$(INWEB) -colony $(COLONY) -member goldbach -weave
$(INWEB) -colony $(COLONY) inweb/Examples/goldbach all -weave-as Plain -weave-to inweb/docs/goldbach/goldbach.txt
$(INWEB) -colony $(COLONY) inweb/Examples/goldbach all -weave-as TestingInweb -weave-to inweb/docs/goldbach/goldbach-test.txt
$(INWEB) -colony $(COLONY) inweb/Examples/goldbach all -weave-as PDFTeX -weave-to inweb/docs/goldbach/goldbach.pdf
$(INWEB) -colony $(COLONY) inweb/Examples/goldbach all -weave-as TeX -weave-to inweb/docs/goldbach/goldbach.tex
$(INWEB) -colony $(COLONY) -member twinprimes -weave
$(INWEB) -colony $(COLONY) -member eastertide -weave
$(INWEB) -colony $(COLONY) -member inweb -weave
$(INWEB) -colony $(COLONY) -member foundation -weave
$(INWEB) -colony $(COLONY) -member foundation-test -weave
# Cleaning up:
.PHONY: clean
clean:
$(call clean-up)
.PHONY: purge
purge:
$(call clean-up)
# Note that the tangled inweb.c is not cleaned up: it's needed to bootstrap
# the use of inweb from a fresh installation where there's no executable
# inweb yet with which to tangle inweb.c (see below).
define clean-up
rm -f $(ME)/Tangled/*.o
rm -f $(ME)/Tangled/*.h
endef