-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (83 loc) · 2.51 KB
/
Makefile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
UC = $(shell echo '$1' | tr '[:lower:]' '[:upper:]')
PROJECT := 2rx16
AS := ca65
LD := ld65
MKDIR := mkdir -p
RMDIR := rmdir -p
CONFIG := ./$(PROJECT).cfg
ASFLAGS := --cpu 65C02 -g
LDFLAGS := -C $(CONFIG)
SRC := ./src
OBJ := ./obj
SRCS := $(wildcard $(SRC)/*.s)
OBJS := $(patsubst $(SRC)/%.s,$(OBJ)/%.o,$(SRCS))
EXE := $(call UC,$(PROJECT).PRG)
EXE2 := ./SECOND.PRG
SDCARD := ./sdcard.img
SDCARD2 := ./sdcard2.img
MAPFILE := ./$(PROJECT).map
SYMFILE := ./$(PROJECT).sym
GIT_REV_INC := ./src/git_rev.inc
ifdef ASSETBLOB
ASFLAGS += -D ASSETBLOB=1
endif
default: all
all: $(EXE)
blob: clean $(EXE2)
blobcard: $(SDCARD2)
$(EXE2):
make clean
make all
(cd scripts; ./create-blob-offsets.py)
rm -f blob.tmp
# keep building until the loadfile blob is consistent
# it seems to take three passes to do so
until diff -q blob.tmp src/blob_loadfile.inc; do \
cp -v src/blob_loadfile.inc blob.tmp && \
make clean && \
ASSETBLOB=1 make all && \
(cd scripts; ./create-blob-offsets.py) ; \
done
rm -f blob.tmp
mv -v $(EXE) $(EXE2)
$(EXE): $(OBJS) $(CONFIG)
$(LD) $(LDFLAGS) $(OBJS) -m $(MAPFILE) -Ln $(SYMFILE) extern/zsmkit.lib -o $@
ifndef ASSETBLOB
cp -v $(EXE) ROOT/
endif
$(GIT_REV_INC):
/bin/echo -n '.byte "' > $@
if git diff --quiet; then\
/bin/echo -n $$(git rev-parse --short=8 HEAD || /bin/echo "00000000") >> $@;\
else\
/bin/echo -n $$(/bin/echo -n $$(git rev-parse --short=7 HEAD || /bin/echo "0000000"); /bin/echo -n '+') >> $@;\
fi
/bin/echo '",0' >> $@
cat $@
$(OBJ)/%.o: $(SRC)/%.s $(SRC)/*.inc | $(GIT_REV_INC) $(OBJ)
$(AS) $(ASFLAGS) $< -o $@
$(OBJ):
$(MKDIR) $@
$(SDCARD): $(EXE)
$(RM) $(SDCARD)
truncate -s 32M $(SDCARD)
parted -s $(SDCARD) mklabel msdos mkpart primary fat32 2048s -- -1
mformat -i $(SDCARD)@@1M -v $(call UC,$(PROJECT)) -F
mcopy -i $(SDCARD)@@1M -o -s -v -m ROOT/* ::
$(SDCARD2): $(EXE2)
$(RM) $(SDCARD2)
truncate -s 32M $(SDCARD2)
parted -s $(SDCARD2) mklabel msdos mkpart primary fat32 2048s -- -1
mformat -i $(SDCARD2)@@1M -v $(call UC,$(PROJECT)) -F
mcopy -i $(SDCARD2)@@1M -o -s -v -m SECOND.PRG REALITY.X16 ::
.PHONY: clean run blobrun box blobbox
clean:
$(RM) $(EXE) $(EXE2) $(OBJS) $(SDCARD) $(SDCARD2) $(MAPFILE) $(SYMFILE) $(GIT_REV_INC) ROOT/*.BIN ROOT/*.PRG
box: $(EXE) $(SDCARD)
box16 -sdcard $(SDCARD) -prg $(EXE) -run
run: $(EXE) $(SDCARD)
x16emu -sdcard $(SDCARD) -prg $(EXE) -debug -scale 2 -run
blobbox: $(EXE2) $(SDCARD2)
box16 -sdcard $(SDCARD2) -prg $(EXE2) -run
blobrun: $(EXE2) $(SDCARD2)
x16emu -sdcard $(SDCARD2) -prg $(EXE2) -debug -scale 2 -run