1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-08 09:28:06 +11:00
collapseos/emul/Makefile

111 lines
3.7 KiB
Makefile
Raw Normal View History

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
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
SHELLTGTS = ${SHELLAPPS:%=cfsin/%}
# Those Forth source files are in a particular order
FORTHSRCS = core.fs str.fs parse.fs readln.fs fmt.fs high.fs z80a.fs dummy.fs
FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%}
CFSIN_CONTENTS = $(SHELLTGTS) cfsin/user.h
OBJS = emul.o libz80/libz80.o
SHELLOBJS = $(OBJS) $(CFSPACK_OBJ)
ZASMOBJS = $(SHELLOBJS)
2019-05-10 04:09:40 +10:00
2019-05-10 02:58:41 +10:00
.PHONY: all
2019-12-14 09:38:40 +11:00
all: $(TARGETS) $(AVRABIN) $(CFSIN_CONTENTS)
2019-05-10 02:58:41 +10:00
# -o in sync with SHELL_CODE in shell/glue.asm
shell/shell.bin: shell/glue.asm $(ZASMBIN)
$(ZASMBIN) $(KERNEL) shell/user.h $(APPS) < shell/glue.asm | tee $@ > /dev/null
shell/shell-bin.h: shell/shell.bin
./bin2c.sh KERNEL < shell/shell.bin | tee $@ > /dev/null
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.
forth/forth0.bin: forth/stage0.asm $(ZASMBIN)
2020-03-25 12:13:02 +11:00
$(ZASMBIN) $(KERNEL) ../forth forth/z80c.bin forth/stagec.asm < forth/stage0.asm | tee $@ > /dev/null
2020-03-10 13:26:02 +11:00
forth/forth0-bin.h: forth/forth0.bin
./bin2c.sh KERNEL < forth/forth0.bin | tee $@ > /dev/null
2020-03-10 13:26:02 +11:00
forth/stage1: forth/stage.c $(OBJS) forth/forth0-bin.h
$(CC) forth/stage.c $(OBJS) -o $@
forth/stage1dbg: forth/stage.c $(OBJS) forth/forth0-bin.h
$(CC) -DDEBUG forth/stage.c $(OBJS) -o $@
2020-03-25 12:13:02 +11:00
forth/core.bin: $(FORTHSRC_PATHS) forth/stage1
cat $(FORTHSRC_PATHS) | ./forth/stage1 | tee $@ > /dev/null
forth/forth1.bin: forth/stage1.asm forth/forth0.bin $(ZASMBIN)
2020-03-25 12:13:02 +11:00
$(ZASMBIN) $(KERNEL) ../forth forth/z80c.bin forth/core.bin forth/stagec.asm < forth/stage1.asm | tee $@ > /dev/null
forth/forth1-bin.h: forth/forth1.bin
./bin2c.sh KERNEL < forth/forth1.bin | tee $@ > /dev/null
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 $@
zasm/kernel-bin.h: zasm/kernel.bin
./bin2c.sh KERNEL < zasm/kernel.bin | tee $@ > /dev/null
zasm/zasm-bin.h: zasm/zasm.bin
./bin2c.sh USERSPACE < zasm/zasm.bin | tee $@ > /dev/null
2019-05-10 02:58:41 +10:00
$(ZASMBIN): zasm/zasm.c $(ZASMOBJS) zasm/kernel-bin.h zasm/zasm-bin.h
$(CC) zasm/zasm.c $(ZASMOBJS) -o $@
2019-12-14 09:38:40 +11:00
zasm/avra.bin: $(ZASMBIN)
$(ZASMBIN) $(KERNEL) $(APPS) zasm/user.h < $(APPS)/zasm/gluea.asm > $@
2019-12-14 09:38:40 +11:00
zasm/avra-bin.h: zasm/avra.bin
./bin2c.sh USERSPACE < zasm/avra.bin | tee $@ > /dev/null
$(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
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
emul.o: emul.c
$(CC) -c -o emul.o emul.c
$(CFSPACK_OBJ): ${@:%.o=%.c}
2020-01-01 05:32:09 +11:00
$(MAKE) -C ../tools/cfspack
# -o in sync with USER_CODE in shell/user.h
$(SHELLTGTS): $(ZASMBIN)
$(ZASMBIN) -o 42 $(KERNEL) $(APPS) shell/user.h < $(APPS)/${@:cfsin/%=%}/glue.asm > $@
cfsin/user.h: shell/user.h
cp shell/user.h $@
.PHONY: updatebootstrap
2019-12-14 09:38:40 +11:00
updatebootstrap: $(ZASMBIN)
$(ZASMBIN) $(KERNEL) < zasm/glue.asm > zasm/kernel.bin
$(ZASMBIN) $(KERNEL) $(APPS) zasm/user.h < $(APPS)/zasm/glue.asm > zasm/zasm.bin
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.
.PHONY: fbootstrap
2020-03-25 12:13:02 +11:00
fbootstrap: forth/stage2
cat ../forth/dummy.fs ../forth/z80c.fs ../forth/dummy.fs | ./forth/stage2 | tee forth/z80c.bin > /dev/null
2019-05-10 02:58:41 +10:00
.PHONY: clean
clean:
rm -f $(TARGETS) $(SHELLTGTS) emul.o zasm/*-bin.h shell/*-bin.h