-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (34 loc) · 787 Bytes
/
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
PRG = hello
SRC = src
BUILD = build
ASMFILES := $(wildcard src/*.s)
ASMOBJS := $(subst $(SRC), $(BUILD), $(patsubst %.s, %.rel, $(ASMFILES)))
CFILES := $(wildcard src/*.c)
all: main
$(BUILD):
mkdir -p $(BUILD)
$(BUILD)/%.rel: $(SRC)/%.s $(BUILD)
sdasz80 -o $@ $<
$(BUILD)/$(PRG): $(SRC)/$(PRG).c $(ASMOBJS)
sdcc -mz80 --code-loc 0x0138 --data-loc 0 --no-std-crt0 \
$(ASMOBJS) \
$(SRC)/$(PRG).c \
-o $(BUILD)/$(PRG)
main: $(BUILD)/$(PRG)
format: format-c format-asm
format-c: $(CFILES)
for f in $(CFILES) ; do \
clang-format -i $$f ; \
done
format-asm: $(ASMFILES)
for f in $(ASMFILES) ; do \
cat $$f \
| sed 's/;;/\/\//g' \
| asmfmt \
| sed 's/\/\//;;/g' \
| sed 's/^\t/ /g'\
> $$f.tmp ; \
mv -f $$f.tmp $$f ; \
done
clean:
rm -fR $(BUILD)