-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
53 lines (42 loc) · 1.18 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
NAME = gb-test
MKDIR = mkdir -p
ASM = wla-gb
ASMFLAGS = -q -I $(INCDIR)
LD = wlalink
LDFLAGS = -v -S -A
LINKFILE = linkfile
PNGCONVERT = superfamiconv tiles
CONVERTFLAGS = -v -M gb -D -p $(PNGDIR)/palette.json
CONVERTIN = -i
CONVERTOUT = -d
SRCDIR = src
INCDIR = inc
DEPDIR = dep
OBJDIR = obj
OUTDIR = out
CHRDIR = chr
PNGDIR = png
SRCS = $(wildcard $(SRCDIR)/*.asm)
OBJS = $(subst $(SRCDIR)/, $(OBJDIR)/, $(SRCS:.asm=.o))
DEPS = $(subst $(SRCDIR)/, $(DEPDIR)/, $(SRCS:.asm=.d))
PNGS = $(wildcard $(PNGDIR)/*.png)
CHRS = $(subst $(PNGDIR)/, $(CHRDIR)/, $(PNGS:.png=.chr))
BIN = $(OUTDIR)/$(NAME).gb
.PHONY: all clean
all: $(BIN)
$(DEPDIR)/%.d: $(SRCDIR)/%.asm
@$(MKDIR) $(DEPDIR)
$(ASM) $(ASMFLAGS) -M $< | sed 's,$(SRCDIR)/\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@: ,g' > $@;
include $(DEPS)
$(CHRDIR)/%.chr: $(PNGDIR)/%.png
$(PNGCONVERT) $(CONVERTFLAGS) $(CONVERTIN) $< $(CONVERTOUT) $@
$(OBJDIR)/%.o: $(SRCDIR)/%.asm
@$(MKDIR) $(OBJDIR)
$(ASM) $(ASMFLAGS) -o $@ $<
$(BIN): $(OBJS)
@cp $(LINKFILE)_base $(LINKFILE)
@echo '[objects]' >> $(LINKFILE)
@for item in $(OBJS); do echo $$item >> $(LINKFILE); done
$(LD) $(LDFLAGS) $(LINKFILE) $@
clean:
rm $(OBJDIR)/* $(DEPDIR)/* $(CHRDIR)/* $(BIN)