2020-01-01 05:57:52 +11:00
|
|
|
CFSPACK_OBJ = ../tools/cfspack/libcfs.o
|
2020-03-10 13:26:02 +11:00
|
|
|
TARGETS = shell/shell zasm/zasm runbin/runbin forth/forth
|
2020-01-01 05:32:09 +11:00
|
|
|
KERNEL = ../kernel
|
|
|
|
APPS = ../apps
|
2019-05-20 05:03:34 +10:00
|
|
|
ZASMBIN = zasm/zasm
|
2019-12-14 09:38:40 +11:00
|
|
|
AVRABIN = zasm/avra
|
2020-03-10 13:26:02 +11:00
|
|
|
SHELLAPPS = zasm ed
|
2019-12-12 05:01:51 +11:00
|
|
|
SHELLTGTS = ${SHELLAPPS:%=cfsin/%}
|
2020-04-08 07:56:55 +10:00
|
|
|
BIN2C = ../tools/bin2c
|
2020-03-18 12:44:32 +11:00
|
|
|
# Those Forth source files are in a particular order
|
2020-04-03 02:29:23 +11:00
|
|
|
FORTHSRCS = core.fs str.fs parse.fs readln.fs fmt.fs z80a.fs
|
2020-03-19 13:25:44 +11:00
|
|
|
FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%}
|
2019-12-10 01:36:38 +11:00
|
|
|
CFSIN_CONTENTS = $(SHELLTGTS) cfsin/user.h
|
|
|
|
OBJS = emul.o libz80/libz80.o
|
2020-01-01 05:57:52 +11:00
|
|
|
SHELLOBJS = $(OBJS) $(CFSPACK_OBJ)
|
2020-01-01 07:07:39 +11:00
|
|
|
ZASMOBJS = $(SHELLOBJS)
|
2019-05-10 04:09:40 +10:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
.PHONY: all tools
|
2019-12-14 09:38:40 +11:00
|
|
|
all: $(TARGETS) $(AVRABIN) $(CFSIN_CONTENTS)
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
tools:
|
|
|
|
$(MAKE) -C ../tools
|
2020-04-06 04:04:05 +10:00
|
|
|
|
2019-11-16 07:37:49 +11:00
|
|
|
# -o in sync with SHELL_CODE in shell/glue.asm
|
2020-04-08 07:56:55 +10:00
|
|
|
shell/shell.bin: shell/glue.asm $(ZASMBIN) tools
|
2020-01-01 07:07:39 +11:00
|
|
|
$(ZASMBIN) $(KERNEL) shell/user.h $(APPS) < shell/glue.asm | tee $@ > /dev/null
|
2019-11-16 07:37:49 +11:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
shell/shell-bin.h: shell/shell.bin tools
|
2020-04-06 04:04:05 +10:00
|
|
|
$(BIN2C) KERNEL < shell/shell.bin | tee $@ > /dev/null
|
2019-11-25 02:24:15 +11:00
|
|
|
|
2020-01-01 05:57:52 +11:00
|
|
|
shell/shell: shell/shell.c $(SHELLOBJS) shell/shell-bin.h
|
|
|
|
$(CC) shell/shell.c $(SHELLOBJS) -o $@
|
2019-12-14 09:38:40 +11:00
|
|
|
|
2020-03-25 12:13:02 +11:00
|
|
|
# z80c.bin is not in the prerequisites because its a bootstrap binary that
|
|
|
|
# should be updated manually through make fbootstrap.
|
2020-04-02 13:19:37 +11:00
|
|
|
forth/forth0.bin:
|
|
|
|
cat forth/boot.bin forth/z80c.bin > $@
|
2020-03-10 13:26:02 +11:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
forth/forth0-bin.h: forth/forth0.bin tools
|
2020-04-06 04:04:05 +10:00
|
|
|
$(BIN2C) KERNEL < forth/forth0.bin | tee $@ > /dev/null
|
2020-03-10 13:26:02 +11:00
|
|
|
|
2020-03-23 12:46:43 +11:00
|
|
|
forth/stage1: forth/stage.c $(OBJS) forth/forth0-bin.h
|
|
|
|
$(CC) forth/stage.c $(OBJS) -o $@
|
2020-03-12 15:14:44 +11:00
|
|
|
|
2020-03-23 12:46:43 +11:00
|
|
|
forth/stage1dbg: forth/stage.c $(OBJS) forth/forth0-bin.h
|
2020-04-02 13:19:37 +11:00
|
|
|
$(CC) -DDEBUG -DBOOT forth/stage.c $(OBJS) -o $@
|
2020-03-14 07:01:09 +11:00
|
|
|
|
2020-03-25 12:13:02 +11:00
|
|
|
forth/core.bin: $(FORTHSRC_PATHS) forth/stage1
|
2020-04-03 02:29:23 +11:00
|
|
|
cat $(FORTHSRC_PATHS) ./forth/stop.fs | ./forth/stage1 | tee $@ > /dev/null
|
2020-03-25 12:13:02 +11:00
|
|
|
|
2020-04-01 23:54:01 +11:00
|
|
|
forth/forth1.bin: forth/forth0.bin forth/core.bin
|
|
|
|
cat forth/forth0.bin forth/core.bin > $@
|
2020-03-12 15:14:44 +11:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
forth/forth1-bin.h: forth/forth1.bin tools
|
2020-04-06 04:04:05 +10:00
|
|
|
$(BIN2C) KERNEL < forth/forth1.bin | tee $@ > /dev/null
|
2020-03-12 15:14:44 +11:00
|
|
|
|
2020-03-25 04:46:05 +11:00
|
|
|
forth/stage2: forth/stage.c $(OBJS) forth/forth1-bin.h
|
|
|
|
$(CC) -DSTAGE2 forth/stage.c $(OBJS) -o $@
|
|
|
|
|
2020-03-25 12:13:02 +11:00
|
|
|
forth/forth: forth/forth.c $(OBJS) forth/forth1-bin.h
|
2020-03-10 13:26:02 +11:00
|
|
|
$(CC) forth/forth.c $(OBJS) -o $@
|
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
zasm/kernel-bin.h: zasm/kernel.bin tools
|
2020-04-06 04:04:05 +10:00
|
|
|
$(BIN2C) KERNEL < zasm/kernel.bin | tee $@ > /dev/null
|
2019-05-20 05:03:34 +10:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
zasm/zasm-bin.h: zasm/zasm.bin tools
|
2020-04-06 04:04:05 +10:00
|
|
|
$(BIN2C) USERSPACE < zasm/zasm.bin | tee $@ > /dev/null
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2020-01-01 07:07:39 +11:00
|
|
|
$(ZASMBIN): zasm/zasm.c $(ZASMOBJS) zasm/kernel-bin.h zasm/zasm-bin.h
|
|
|
|
$(CC) zasm/zasm.c $(ZASMOBJS) -o $@
|
2019-12-10 01:36:38 +11:00
|
|
|
|
2019-12-14 09:38:40 +11:00
|
|
|
zasm/avra.bin: $(ZASMBIN)
|
2020-01-01 07:07:39 +11:00
|
|
|
$(ZASMBIN) $(KERNEL) $(APPS) zasm/user.h < $(APPS)/zasm/gluea.asm > $@
|
2019-12-14 09:38:40 +11:00
|
|
|
|
2020-04-08 07:56:55 +10:00
|
|
|
zasm/avra-bin.h: zasm/avra.bin tools
|
2020-04-06 04:04:05 +10:00
|
|
|
$(BIN2C) USERSPACE < zasm/avra.bin | tee $@ > /dev/null
|
2019-12-14 09:38:40 +11:00
|
|
|
|
2020-01-01 07:07:39 +11:00
|
|
|
$(AVRABIN): zasm/zasm.c $(ZASMOBJS) zasm/kernel-bin.h zasm/avra-bin.h
|
|
|
|
$(CC) -D AVRA zasm/zasm.c $(ZASMOBJS) -o $@
|
2019-12-14 09:38:40 +11:00
|
|
|
|
2019-12-10 01:36:38 +11:00
|
|
|
runbin/runbin: runbin/runbin.c $(OBJS)
|
|
|
|
$(CC) runbin/runbin.c $(OBJS) -o $@
|
2019-05-10 02:58:41 +10:00
|
|
|
|
|
|
|
libz80/libz80.o: libz80/z80.c
|
2019-07-12 11:21:54 +10:00
|
|
|
$(MAKE) -C libz80/codegen opcodes
|
2019-05-20 22:20:00 +10:00
|
|
|
$(CC) -Wall -ansi -g -c -o libz80/libz80.o libz80/z80.c
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2019-12-03 08:35:49 +11:00
|
|
|
emul.o: emul.c
|
|
|
|
$(CC) -c -o emul.o emul.c
|
|
|
|
|
2020-01-01 07:07:39 +11:00
|
|
|
$(CFSPACK_OBJ): ${@:%.o=%.c}
|
2020-01-01 05:32:09 +11:00
|
|
|
$(MAKE) -C ../tools/cfspack
|
2019-05-13 01:20:31 +10:00
|
|
|
|
2019-11-16 07:37:49 +11:00
|
|
|
# -o in sync with USER_CODE in shell/user.h
|
2019-12-10 01:36:38 +11:00
|
|
|
$(SHELLTGTS): $(ZASMBIN)
|
2020-01-01 07:07:39 +11:00
|
|
|
$(ZASMBIN) -o 42 $(KERNEL) $(APPS) shell/user.h < $(APPS)/${@:cfsin/%=%}/glue.asm > $@
|
2019-06-03 22:32:25 +10:00
|
|
|
|
2019-06-03 23:25:47 +10:00
|
|
|
cfsin/user.h: shell/user.h
|
2019-12-10 01:36:38 +11:00
|
|
|
cp shell/user.h $@
|
2019-06-03 23:25:47 +10:00
|
|
|
|
2019-05-20 05:03:34 +10:00
|
|
|
.PHONY: updatebootstrap
|
2019-12-14 09:38:40 +11:00
|
|
|
updatebootstrap: $(ZASMBIN)
|
2020-01-01 07:07:39 +11:00
|
|
|
$(ZASMBIN) $(KERNEL) < zasm/glue.asm > zasm/kernel.bin
|
|
|
|
$(ZASMBIN) $(KERNEL) $(APPS) zasm/user.h < $(APPS)/zasm/glue.asm > zasm/zasm.bin
|
2019-05-20 05:03:34 +10:00
|
|
|
|
2020-03-25 12:13:02 +11:00
|
|
|
# We need to double wrap around dummy.fs because at stage3, we have high-level
|
|
|
|
# words and they write to HERE at initialization.
|
2020-03-25 04:46:05 +11:00
|
|
|
.PHONY: fbootstrap
|
2020-03-25 12:13:02 +11:00
|
|
|
fbootstrap: forth/stage2
|
2020-04-02 13:19:37 +11:00
|
|
|
cat ./forth/conf.fs ../forth/boot.fs | ./forth/stage2 > forth/boot.bin
|
2020-04-03 02:39:40 +11:00
|
|
|
cat ./forth/conf.fs ../forth/z80c.fs forth/emul.fs ../forth/icore.fs | ./forth/stage2 | tee forth/z80c.bin > /dev/null
|
2020-03-25 04:46:05 +11:00
|
|
|
|
2019-05-10 02:58:41 +10:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2019-12-10 01:36:38 +11:00
|
|
|
rm -f $(TARGETS) $(SHELLTGTS) emul.o zasm/*-bin.h shell/*-bin.h
|
2020-04-08 07:56:55 +10:00
|
|
|
$(MAKE) -C ../tools clean
|