blob: dd7a679d5a3a8bd7a4726110a03b764b7b1d61cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# gbos - Game Boy Color Unix-flavored microkernel (scaffold)
# Toolchain: RGBDS (rgbasm/rgblink/rgbfix)
ROM := gbos.gb
BUILD := build
SRCS := $(wildcard src/*.asm)
OBJS := $(patsubst src/%.asm,$(BUILD)/%.o,$(SRCS))
ASFLAGS := -I include -Wall
# MBC5 + RAM + battery; -r 3 = 32 KiB cart RAM (bump for more task banks)
FIXFLAGS := -v -C -m MBC5+RAM+BATTERY -r 4 -p 0xFF -t GBOS
.PHONY: all clean run
all: $(ROM)
# Every .asm INCLUDEs include/gbos.inc, so a change there must rebuild all of
# them: without this, editing a constant (MAX_SOCKS, SK_*, PROG_*) silently
# left every untouched object built against the OLD value, and the kernel ran
# with two different ideas of the same number.
INCS := $(wildcard include/*.inc)
$(BUILD)/%.o: src/%.asm $(INCS) | $(BUILD)
rgbasm $(ASFLAGS) -o $@ $<
# Userland C programs (usr/): compiled with SDCC into ROM-bank blobs under
# $(BUILD)/usr and INCBIN'd by programs.asm
PROGS := chello echo true false uname pid cat wc head args \
ls save rm sh ps kill spin blk mkdir count ptest necho \
wget chat netd ping nslookup dhcp irc uptime ansi \
grep more cp nc httpd
CBLOBS := $(patsubst %,$(BUILD)/usr/%.bin,$(PROGS))
$(BUILD)/programs.o: $(CBLOBS)
# C programs also depend on the shared libc sources
$(CBLOBS): usr/libc.c usr/gbos.h
$(BUILD)/usr/%.bin: usr/%.c usr/crt0.s usr/libc.s usr/build.sh
sh usr/build.sh $< $@
$(ROM): $(OBJS)
rgblink -m $(BUILD)/gbos.map -n $(BUILD)/gbos.sym -o $@ $(OBJS)
rgbfix $(FIXFLAGS) $@
$(BUILD):
mkdir -p $(BUILD)
clean:
rm -rf $(BUILD) $(ROM)
# convenience: run in an emulator if one is on PATH
run: $(ROM)
@which sameboy >/dev/null 2>&1 && sameboy $(ROM) || \
which bgb >/dev/null 2>&1 && bgb $(ROM) || \
echo "no emulator found (sameboy/bgb)"
|