1VERSION ?= 2021.4 2KEYPAIR ?= 2021-04 3PREFIX ?= /usr/local 4DATADIR ?= $(PREFIX)/share/RETRO12 5DOCSDIR ?= $(PREFIX)/share/doc/RETRO12 6EXAMPLESDIR ?= $(PREFIX)/share/examples/RETRO12 7MANDIR ?= $(PREFIX)/share/man/man1 8LIBM ?= -lm 9CFLAGS ?= -O2 10ENABLED ?= 11ENABLED += -DENABLE_FLOATS 12ENABLED += -DENABLE_FILES 13ENABLED += -DENABLE_UNIX 14ENABLED += -DENABLE_RNG 15ENABLED += -DENABLE_CLOCK 16ENABLED += -DENABLE_SCRIPTING 17ENABLED += -DNEEDS_STRL 18 19all: build 20 21help: 22 23build: dirs toolchain ngaImage bin/retro bin/retro-describe 24 25optional: build bin/retro-repl 26 27toolchain: dirs bin/retro-embedimage bin/retro-extend bin/retro-muri bin/retro-unu 28 29image: vm/nga-c/image.c 30 31repl: bin/retro-repl 32 33dirs: 34 mkdir -p bin 35 cp tools/retro-document.sh bin/retro-document 36 37clean: 38 rm -f bin/* 39 40 41# installation targets 42 43install: build install-data install-docs install-examples install-manpages 44 install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin 45 install -c -m 755 bin/retro-embedimage $(DESTDIR)$(PREFIX)/bin/retro-embedimage 46 install -c -m 755 bin/retro-extend $(DESTDIR)$(PREFIX)/bin/retro-extend 47 install -c -m 755 bin/retro-muri $(DESTDIR)$(PREFIX)/bin/retro-muri 48 install -c -m 755 bin/retro $(DESTDIR)$(PREFIX)/bin/retro 49 install -c -m 755 bin/retro-unu $(DESTDIR)$(PREFIX)/bin/retro-unu 50 install -c -m 755 bin/retro-describe $(DESTDIR)$(PREFIX)/bin/retro-describe 51 install -c -m 755 bin/retro-document $(DESTDIR)$(PREFIX)/bin/retro-document 52 install -c -m 755 example/retro-tags.retro $(DESTDIR)$(PREFIX)/bin/retro-tags 53 install -c -m 755 example/retro-locate.retro $(DESTDIR)$(PREFIX)/bin/retro-locate 54 55install-strip: build install-data install-docs install-examples 56 install -m 755 -d -- $(DESTDIR)/bin 57 install -c -m 755 -s bin/retro-embedimage $(DESTDIR)$(PREFIX)/bin/retro-embedimage 58 install -c -m 755 -s bin/retro-extend $(DESTDIR)$(PREFIX)/bin/retro-extend 59 install -c -m 755 -s bin/retro-muri $(DESTDIR)$(PREFIX)/bin/retro-muri 60 install -c -m 755 -s bin/retro $(DESTDIR)$(PREFIX)/bin/retro 61 install -c -m 755 -s bin/retro-unu $(DESTDIR)$(PREFIX)/bin/retro-unu 62 install -c -m 755 bin/retro-describe $(DESTDIR)$(PREFIX)/bin/retro-describe 63 install -c -m 755 bin/retro-document $(DESTDIR)$(PREFIX)/bin/retro-document 64 install -c -m 755 example/retro-tags.retro $(DESTDIR)$(PREFIX)/bin/retro-tags 65 install -c -m 755 example/retro-locate.retro $(DESTDIR)$(PREFIX)/bin/retro-locate 66 67install-data: 68 install -m 755 -d -- $(DESTDIR)$(DATADIR) 69 install -c -m 644 tools/glossary.retro $(DESTDIR)$(DATADIR)/glossary.retro 70 install -c -m 644 ngaImage $(DESTDIR)$(DATADIR)/ngaImage 71 cp -fpR tests $(DESTDIR)$(DATADIR)/ 72 install -c -m 644 doc/words.tsv $(DESTDIR)$(DATADIR)/words.tsv 73 74install-docs: 75 install -m 755 -d -- $(DESTDIR)$(DOCSDIR) 76 install -c -m 644 README $(DESTDIR)$(DOCSDIR)/README 77 install -c -m 644 RELEASE-NOTES $(DESTDIR)$(DOCSDIR)/RELEASE-NOTES 78 install -c -m 644 doc/RETRO-Book.md $(DESTDIR)$(DOCSDIR)/RETRO-Book.md 79 install -c -m 644 doc/words.tsv $(DESTDIR)$(DOCSDIR)/words.tsv 80 81install-examples: 82 install -m 755 -d -- $(DESTDIR)$(EXAMPLESDIR) 83 cp -fpR example $(DESTDIR)$(EXAMPLESDIR) 84 85install-manpages: 86 install -m 755 -d -- $(DESTDIR)$(MANDIR) 87 install -c -m 644 man/retro.1 $(DESTDIR)$(MANDIR)/retro.1 88 install -c -m 644 man/retro-embedimage.1 $(DESTDIR)$(MANDIR)/retro-embedimage.1 89 install -c -m 644 man/retro-extend.1 $(DESTDIR)$(MANDIR)/retro-extend.1 90 install -c -m 644 man/retro-describe.1 $(DESTDIR)$(MANDIR)/retro-describe.1 91 install -c -m 644 man/retro-document.1 $(DESTDIR)$(MANDIR)/retro-document.1 92 install -c -m 644 man/retro-muri.1 $(DESTDIR)$(MANDIR)/retro-muri.1 93 install -c -m 644 man/retro-unu.1 $(DESTDIR)$(MANDIR)/retro-unu.1 94 install -c -m 644 man/retro-tags.1 $(DESTDIR)$(MANDIR)/retro-tags.1 95 install -c -m 644 man/retro-locate.1 $(DESTDIR)$(MANDIR)/retro-locate.1 96 97 98 99# toolchain targets 100 101bin/retro-describe: tools/retro-describe.retro doc/words.tsv 102 cat tools/retro-describe.retro doc/words.tsv >bin/retro-describe 103 chmod +x bin/retro-describe 104 105bin/retro-embedimage: tools/retro-embedimage.c 106 $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o $@ tools/retro-embedimage.c 107 108bin/retro-extend: tools/retro-extend.c 109 $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o $@ tools/retro-extend.c 110 111bin/retro-muri: tools/retro-muri.c 112 $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o $@ tools/retro-muri.c 113 114bin/retro-unu: tools/retro-unu.c 115 $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o $@ tools/retro-unu.c 116 117 118 119# basic image target 120 121ngaImage: image/retro.muri image/retro.forth bin/retro-muri bin/retro-extend 122 ./bin/retro-muri image/retro.muri 123 ./bin/retro-extend ngaImage image/retro.forth 124 125 126 127# minimal system 128 129bin/retro-repl: vm/nga-c/repl.c vm/nga-c/image.c 130 cd vm/nga-c && $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o ../../bin/retro-repl repl.c 131 132 133 134# retro on unix 135 136update-extensions: bin/retro 137 cd package/extensions && ../../bin/retro -f ../../tools/generate-extensions-list.retro >../load-extensions.retro 138 139vm/nga-c/image.c: ngaImage bin/retro-embedimage bin/retro-extend interface/filesystem.retro interface/floatingpoint.retro interface/unix.retro interface/rng.retro interface/sockets.retro interface/scripting.retro interface/retro-unix.retro interface/clock.retro 140 cp ngaImage rre.image 141 ./bin/retro-extend rre.image interface/filesystem.retro interface/floatingpoint.retro interface/unix.retro interface/rng.retro interface/sockets.retro interface/scripting.retro interface/clock.retro interface/retro-unix.retro 142 ./bin/retro-embedimage rre.image >vm/nga-c/image.c 143 144bin/retro: vm/nga-c/image.c vm/nga-c/retro.c package/list.forth package/load-extensions.retro 145 cd vm/nga-c && $(CC) $(OPTIONS) $(ENABLED) $(CFLAGS) $(LDFLAGS) -o ../../bin/retro retro.c $(LIBM) 146 cd package && ../bin/retro -u rre.image -f list.forth 147 ./bin/retro-embedimage rre.image >vm/nga-c/image.c 148 rm rre.image 149 cd vm/nga-c && $(CC) $(OPTIONS) $(ENABLED) $(CFLAGS) $(LDFLAGS) -o ../../bin/retro retro.c $(LIBM) 150 151 152 153# optional targets 154 155bin/retro-compiler: bin/retro-extend vm/nga-c/retro-compiler.c vm/nga-c/retro-runtime.c vm/nga-c/bsd-strl.c vm/nga-c/config.h vm/nga-c/dev-clock.c vm/nga-c/dev-files.c vm/nga-c/dev-floatingpoint.c vm/nga-c/dev-image.c vm/nga-c/dev-rng.c vm/nga-c/dev-sockets.c vm/nga-c/dev-unix.c vm/nga-c/prototypes.h 156 cp ngaImage runtime.image 157 ./bin/retro-extend runtime.image interface/scripting.retro interface/filesystem.retro interface/floatingpoint.retro interface/unix.retro interface/rng.retro interface/retro-unix.retro interface/clock.retro 158 cd vm/nga-c && $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o ../../retro-runtime retro-runtime.c $(LIBM) 159 cd vm/nga-c && $(CC) $(OPTIONS) $(CFLAGS) $(LDFLAGS) -o ../../bin/retro-compiler retro-compiler.c 160 objcopy --add-section .ngaImage=runtime.image --set-section-flags .ngaImage=noload,readonly bin/retro-compiler 161 objcopy --add-section .runtime=retro-runtime --set-section-flags .runtime=noload,readonly bin/retro-compiler 162 rm runtime.image retro-runtime 163 164image-js: bin/retro 165 ./bin/retro example/retro-generate-image-js.retro >vm/nga-js/image.js 166 167 168 169# documentation targets 170 171glossary: doc/Glossary.txt doc/Glossary.html doc/Glossary-Concise.txt doc/Glossary-Names-and-Stack.txt doc/words.tsv 172 173sorted: doc/words.tsv 174 LC_ALL=C sort -o sorted.tsv doc/words.tsv 175 mv sorted.tsv doc/words.tsv 176 177doc/Glossary.txt: bin/retro sorted 178 ./bin/retro tools/glossary.retro export glossary >doc/Glossary.txt 179 180doc/Glossary.html: bin/retro sorted 181 ./bin/retro tools/glossary.retro export html >doc/Glossary.html 182 183doc/Glossary-Concise.txt: bin/retro sorted 184 ./bin/retro tools/glossary.retro export concise >doc/Glossary-Concise.txt 185 186doc/Glossary-Names-and-Stack.txt: bin/retro sorted 187 ./bin/retro tools/glossary.retro export concise-stack >doc/Glossary-Names-and-Stack.txt 188 189 190 191# other targets 192 193release: clean build glossary 194 fossil tarball tip R12.tar.gz 195 mkdir release 196 cd release && tar xzvf ../R12.tar.gz 197 cd release && mv * RETRO12-$(VERSION) 198 cd release && tar cf RETRO12-$(VERSION).tar RETRO12-$(VERSION) 199 cd release && gzip RETRO12-$(VERSION).tar 200 mv release/RETRO12-$(VERSION).tar.gz . 201 rm -rf release 202 signify -S -s /home/crc/keys/$(KEYPAIR).sec -m RETRO12-$(VERSION).tar.gz 203 signify -V -p security/$(KEYPAIR).pub -m RETRO12-$(VERSION).tar.gz 204 205test: bin/retro 206 ./bin/retro tests/test-core.forth 207 208