inweb-bootstrap/scripts/makescript.txt
2020-03-26 23:01:14 +00:00

144 lines
4.8 KiB
Text

# This is a makefile for "inweb". It expects the current working folder to be
# the one above the one holding this file (unusually), so it's best called
# with e.g. "make -f inweb/inweb.mk".
#
# To generate inweb.mk from its source, use e.g.:
# inweb/Tangled/inweb inweb -prototype inweb/scripts/makescript.txt -makefile inweb/inweb.mk
ME = inweb
SAFETYCOPY = $(ME)/Tangled/inweb_dev
-include $(ME)/platform-settings.mk
# Making the program:
.PHONY: all
all: $(ME)/platform-settings.mk $(ME)/Tangled/$(ME)
$(ME)/Tangled/$(ME): $(ME)/Contents.w $(ME)/Chapter*/*.w $(ME)/foundation-module/Contents.w $(ME)/foundation-module/Chapter*/*.w
$(call make-me)
.PHONY: force
force: $(ME)/platform-settings.mk
$(call make-me)
.PHONY: macos
macos:
cp -f $(ME)/Materials/macos-make-settings.mk $(ME)/platform-settings.mk
echo "=== Platform set to 64-bit MacOS. Now: make -f inweb/inweb.mk initial ==="
.PHONY: macos32
macos32:
cp -f $(ME)/Materials/macos32-make-settings.mk $(ME)/platform-settings.mk
echo "=== Platform set to 32-bit MacOS. Now: make -f inweb/inweb.mk initial ==="
.PHONY: windows
windows:
cp -f $(ME)/Materials/windows-make-settings.mk $(ME)/platform-settings.mk
echo "=== Platform set to Windows. Now: make -f inweb/inweb.mk initial ==="
.PHONY: linux
linux:
cp -f $(ME)/Materials/linux-make-settings.mk $(ME)/platform-settings.mk
echo "=== Platform set to Linux. Now: make -f inweb/inweb.mk initial ==="
.PHONY: unix
unix:
cp -f $(ME)/Materials/unix-make-settings.mk $(ME)/platform-settings.mk
echo "=== Platform set to generic Unix (non-Linux, non-MacOS, non-Android). Now: make -f inweb/inweb.mk initial ==="
.PHONY: android
android:
cp -f $(ME)/Materials/android-make-settings.mk $(ME)/platform-settings.mk
echo "=== Platform set to Android. Now: make -f inweb/inweb.mk initial ==="
.PHONY: initial
initial: $(ME)/platform-settings.mk
$(call make-me-once-tangled)
.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
$(CC) -o $(ME)/Tangled/$(ME).o $(ME)/Tangled/$(ME).c
$(LINK) -o $(ME)/Tangled/$(ME) $(ME)/Tangled/$(ME).o $(LINKEROPTS)
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
# 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) -advance-build-file $(ME)/build.txt
mkdir -p $(ME)/docs
rm -f $(ME)/docs/*.html
$(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/foundation-module
rm -f $(ME)/docs/foundation-module/*.html
mkdir -p $(ME)/docs/foundation-test
rm -f $(ME)/docs/foundation-test/*.html
$(INWEB) $(ME)/docs/docs-src/webs.inweb -weave-as GitHubCovers -weave-into $(ME)/docs -navigation $(ME)/docs/docs-src/nav-o.html
$(INWEB) $(ME) -weave-docs -weave-into $(ME)/docs/inweb -breadcrumb 'Source:../webs.html' -navigation $(ME)/docs/docs-src/nav.html
$(INWEB) $(ME)/foundation-module -weave-docs -weave-into $(ME)/docs/foundation-module -breadcrumb 'Source:../webs.html' -navigation $(ME)/docs/docs-src/nav.html
$(INWEB) $(ME)/foundation-test -weave-docs -weave-into $(ME)/docs/foundation-test -breadcrumb 'Source:../webs.html' -navigation $(ME)/docs/docs-src/nav.html
# 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