-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (77 loc) · 1.96 KB
/
Makefile
File metadata and controls
97 lines (77 loc) · 1.96 KB
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
NAME = flammenwerfer
PREFIX = m68k-elf-
LDFLAGS = -static -nostdlib -T flame.ld
ASFLAGS = -m68000 --register-prefix-optional
CWARN = -Wextra -Wall -Wno-unused-parameter
CFLAGS = $(CWARN) -fomit-frame-pointer -fno-builtin
IFLAGS = --noinform --no-sysinit --no-userinit --disable-debugger
CSRC = main.c level.c sound.c mobs.c soldier.c \
canyon.c alps.c beach.c town.c forest.c
OBJS = rom_header.O $(subst .c,.o,$(CSRC))
SED = 's/lisp:/inc:/;s/(load "/ /;s/")//'
SHA = $(shell git show --format="%h" --no-patch)
DATE = $(shell date +"%F")
ifneq ($(LTO),)
CFLAGS += -flto
LDLAGS += -flto
endif
ifneq ($(JOKE),)
CFLAGS += -DVERBOSE
endif
ifneq ($(OPTIONS),)
CFLAGS += $(OPTIONS)
else
CFLAGS += -Os -DDEBUG
endif
all: build
build:
@$(PREFIX)gcc $(CFLAGS) $(CSRC) -MM -MG > dep.inc
@grep '^(load ' *.lisp | sed $(SED) >> dep.inc
@make -s $(NAME).bin
clean:
@echo Clean $(NAME).bin
@rm -f $(OBJS) $(NAME)* cksum pcx2h images/*.h \
z80.rom z80.hex *.inc *.fasl
disasm: build
$(PREFIX)objdump -D -b binary -m 68000 $(NAME).bin | less
run: build
blastem $(NAME).bin
mame: build
mame -w -r 640x480 genesis -cart $(NAME).bin
release:
make clean
LTO=yes OPTIONS="-O2 -DVERSION='\"$(DATE) $(SHA)\"'" make build
debug: build
rlwrap blastem -d $(NAME).bin
$(NAME).bin: $(OBJS) cksum
@echo Link $(NAME).bin
ifneq ($(LTO),)
@$(PREFIX)gcc $(LDFLAGS) $(OBJS) -o $(NAME).elf
@$(PREFIX)objcopy $(NAME).elf -S -O binary $@
else
@$(PREFIX)ld $(LDFLAGS) $(OBJS) --oformat binary -o $@
endif
@./cksum $(NAME).bin
cksum: cksum.c
@echo Make cksum
@$gcc cksum.c -o cksum
pcx2h: pcx2h.c
@echo Make pcx2h
@$gcc pcx2h.c -o pcx2h
z80.hex: z80.asm
@echo Compile $<
@zasm -v0 -l0 $<
@xxd -i < z80.rom > $@
%.inc: %.lisp
@echo Prepare $@
@sbcl $(IFLAGS) --load $< --eval "(save-and-quit)"
%.o: %.c
@echo Compile $<
@$(PREFIX)gcc $(CFLAGS) -c $< -o $@
%.O: %.S
@echo Compile $<
@$(PREFIX)as $(ASFLAGS) --bitwise-or $< -o $@
%.h: %.pcx pcx2h
@echo Convert $<
@./pcx2h $< $@
-include dep.inc