-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
80 lines (60 loc) · 1.81 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
ifdef $(GENDEV)
ROOTDIR = $(GENDEV)
else
ROOTDIR = /opt/toolchains/sega
endif
LDSCRIPTSDIR = $(ROOTDIR)/ldscripts
LIBPATH = -L$(ROOTDIR)/sh-elf/lib -L$(ROOTDIR)/sh-elf/lib/gcc/sh-elf/4.6.2 -L$(ROOTDIR)/sh-elf/sh-elf/lib
INCPATH = -I. -I$(ROOTDIR)/sh-elf/include -I$(ROOTDIR)/sh-elf/sh-elf/include
CCFLAGS = -c -std=c11 -g -m2 -mb
CCFLAGS += -Wall -Wextra -pedantic -Wno-unused-parameter -Wimplicit-fallthrough=0 -Wno-missing-field-initializers -Wnonnull
CCFLAGS += -D__32X__ -DMARS
LDFLAGS = -T $(LDSCRIPTSDIR)/mars.ld -Wl,-Map=output.map -nostdlib -Wl,--gc-sections --specs=nosys.specs
ASFLAGS = --big
MARSHWCFLAGS := $(CCFLAGS)
MARSHWCFLAGS += -fno-lto
release: CCFLAGS += -Os -fomit-frame-pointer -ffast-math -funroll-loops -fno-align-loops -fno-align-jumps -fno-align-labels
release: CCFLAGS += -ffunction-sections -fdata-sections -flto
release: MARSHWCFLAGS += -O1
release: LDFLAGS += -flto
debug: CCFLAGS += -Os -funroll-loops -ggdb -fno-omit-frame-pointer
debug: MARSHWCFLAGS += -O1 -ggdb -fno-omit-frame-pointer
PREFIX = $(ROOTDIR)/sh-elf/bin/sh-elf-
CC = $(PREFIX)gcc
AS = $(PREFIX)as
LD = $(PREFIX)ld
OBJC = $(PREFIX)objcopy
DD = dd
RM = rm -f
TARGET = yatssd
LIBS = $(LIBPATH) -lc -lgcc -lgcc-Os-4-200 -lnosys
OBJS = \
crt0.o \
main.o \
draw.o \
sound.o \
hw_32x.o \
sh2_fixed.o \
font.o \
dsprite.o \
dtiles.o
release: $(TARGET).32x
debug: $(TARGET).32x
all: release
m68k.bin:
make -C src-md
$(TARGET).32x: $(TARGET).elf
$(OBJC) -O binary $< temp.bin
$(DD) if=temp.bin of=$@ bs=128K conv=sync
$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(TARGET).elf
crt0.o: crt0.s m68k.bin
hw_32x.o: hw_32x.c
$(CC) $(MARSHWCFLAGS) $(INCPATH) $< -o $@
%.o: %.c
$(CC) $(CCFLAGS) $(INCPATH) $< -o $@
%.o: %.s
$(AS) $(ASFLAGS) $(INCPATH) $< -o $@
clean:
make clean -C src-md
$(RM) *.o *.32x *.elf output.map