diff --git a/.hgignore b/.hgignore index 1105d6c..49d34a0 100644 --- a/.hgignore +++ b/.hgignore @@ -1,3 +1,5 @@ .obj .vscode +__pycache__ +.*\.orig diff --git a/arch/brother/pn8510/build.py b/arch/brother/pn8510/build.py index 88e532d..8344ae0 100644 --- a/arch/brother/pn8510/build.py +++ b/arch/brother/pn8510/build.py @@ -138,17 +138,17 @@ bootfile=".+bootfile_img", map={ "-readme.txt": ".+readme", - #"dump.com": "cpmtools+dump", - #"stat.com": "cpmtools+stat", - #"asm.com": "cpmtools+asm", - #"copy.com": "cpmtools+copy", - #"submit.com": "cpmtools+submit", + "dump.com": "cpmtools+dump", + "stat.com": "cpmtools+stat", + "asm.com": "cpmtools+asm", + "copy.com": "cpmtools+copy", + "submit.com": "cpmtools+submit", #"asm80.com": "third_party/dr/asm80", #"camel80.com": "third_party/camelforth", #"bbcbasic.com": "third_party/bbcbasic+bbcbasic_ADM3A", - #"mkfs.com": "cpmtools+mkfs", - #"rawdisk.com": "cpmtools+rawdisk", - #"qe.com": "cpmtools+qe_BROTHER_POWERNOTE", + "mkfs.com": "cpmtools+mkfs", + "rawdisk.com": "cpmtools+rawdisk", + "qe.com": "cpmtools+qe_BROTHER_POWERNOTE", #"z8e.com": "third_party/z8e+z8e_POWERNOTE", #"ted.com": "third_party/ted+ted_POWERNOTE", }, diff --git a/build/ab.mk b/build/ab.mk new file mode 100644 index 0000000..024cefa --- /dev/null +++ b/build/ab.mk @@ -0,0 +1,54 @@ +ifeq ($(findstring 4.,$(MAKE_VERSION)),) +$(error You need GNU Make 4.x for this (if you're on OSX, use gmake).) +endif + +OBJ ?= .obj +PYTHON ?= python3 +CC ?= gcc +CXX ?= g++ +AR ?= ar +CFLAGS ?= -g -Og +LDFLAGS ?= -g +PKG_CONFIG ?= pkg-config +ECHO ?= echo +TARGETS ?= +all + +ifdef VERBOSE + hide = +else + ifdef V + hide = + else + hide = @ + endif +endif + +ifeq ($(OS), Windows_NT) + EXT ?= .exe +endif +EXT ?= + +include $(OBJ)/build.mk + +MAKEFLAGS += -r +.DELETE_ON_ERROR: + +.PHONY: update-ab +update-ab: + @echo "Press RETURN to update ab from the repository, or CTRL+C to cancel." \ + && read a \ + && (curl -L https://github.com/davidgiven/ab/releases/download/dev/distribution.tar.xz | tar xvJf -) \ + && echo "Done." + +.PHONY: clean +clean:: + @echo CLEAN + $(hide) rm -rf $(OBJ) + +export PYTHONHASHSEED = 1 +build-files = $(shell find . -name 'build.py') $(wildcard build/*.py) $(wildcard config.py) +$(OBJ)/build.mk: Makefile $(build-files) + @echo "AB" + @mkdir -p $(OBJ) + $(hide) $(PYTHON) -X pycache_prefix=$(OBJ) build/ab.py -o $@ build.py \ + || rm -f $@ diff --git a/build/ack.py b/build/ack.py index cde9484..e133583 100644 --- a/build/ack.py +++ b/build/ack.py @@ -1,13 +1,27 @@ -from build.c import cprogram +from build.ab import emit +from build.c import cprogram, clibrary + +emit( + """ +ACKCC ?= ack +ACKAAL ?= aal + """ +) + class AckToolchain: label = "ACK" - cfile = ["$(CC) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"] - cxxfile = ["$(CXX) -c -o {outs[0]} {ins[0]} $(CFLAGS) {cflags}"] - clibrary = ["$(AR) cqs {outs[0]} {ins}"] - cxxlibrary = ["$(AR) cqs {outs[0]} {ins}"] - cprogram = ["$(CC) -o {outs[0]} {ins} {ldflags} $(LDFLAGS)"] - cxxprogram = ["$(CXX) -o {outs[0]} {ins} {ldflags} $(LDFLAGS)"] + cfile = ["$(ACKCC) -mcpm -c -o {outs[0]} {ins[0]} $(ACKCFLAGS) {cflags}"] + cxxfile = (["false"],) + clibrary = ["$(ACKAAL) cq {outs[0]} {ins}"] + cxxlibrary = (["false"],) + cprogram = ["$(ACKCC) -mcpm -.c -o {outs[0]} {ins} {ldflags} $(ACKLDFLAGS)"] + cxxprogram = (["false"],) + + +def acklibrary(**kwargs): + return clibrary(**kwargs, toolchain=AckToolchain) + def ackprogram(**kwargs): return cprogram(**kwargs, toolchain=AckToolchain) diff --git a/cpmtools/libcuss/build.py b/cpmtools/libcuss/build.py new file mode 100644 index 0000000..ce5eb3e --- /dev/null +++ b/cpmtools/libcuss/build.py @@ -0,0 +1,31 @@ +from build.ack import acklibrary, ackprogram +from glob import glob + +libcuss_terminals = [ + "KAYPROII", + "NC200", + "BROTHEROP2", + "BROTHER_WP1", + "BROTHER_WP2450DS", + "BROTHER_POWERNOTE", + "SPECTRUM_PLUS_THREE", + "SPECTRUM_NEXT", +] + +for terminal in libcuss_terminals: + acklibrary( + name="libcuss_" + terminal, + cflags=["-DLIBCUSS_" + terminal], + srcs=glob("cpmtools/libcuss/*.c"), + hdrs={"libcuss.h": "./libcuss.h"}, + ) + + +def libcuss_ackprogram(name, deps=[], cflags=[], **kwargs): + for terminal in libcuss_terminals: + ackprogram( + name=name + "_" + terminal, + deps=deps + ["cpmtools/libcuss+libcuss_" + terminal], + cflags=["-DLIBCUSS_"+terminal] + cflags, + **kwargs + ) diff --git a/third_party/ld80/build.py b/third_party/ld80/build.py index a68efa6..a969694 100644 --- a/third_party/ld80/build.py +++ b/third_party/ld80/build.py @@ -39,6 +39,7 @@ def ld80(self, name, address=0x0100, objs: ListOfTargetsMap = {}): + (" ".join(args)), f"tail -c+{address+1} {{outs[0]}}.all > {{outs[0]}}", ], + label="LD80", )