-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
96 lines (77 loc) · 2.36 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
# List all of the source files that will be compiled into your binary.
#
# For example, if you have the following source files
#
# main.c
# user.c
# driver.s
#
# then your SRCS list would be
#
# SRCS=main.c user.c driver.s
#
# The list may span several lines of text by appending a backslash to each line,
# for example:
#
# SRCS=main.c user.c \
# driver.s
SRCS=main.c
# Specify the CPU type that you are targeting your build towards.
#
# Supported architectures can usually be found with the --target-help argument
# passed to gcc, but a quick summary is:
#
# 68000, 68010, 68020, 68030, 68040, 68060, cpu32 (includes 68332 and 68360),
# 68302
CPU=68000
# Uncomment either of the following depending on how you have installed gcc on
# your system. m68k-linux-gnu for Linux installations, m68k-eabi-elf if gcc was
# built from scratch e.g. on a Mac by running the build script.
# PREFIX=m68k-linux-gnu
PREFIX=m68k-eabi-elf
# Dont modify below this line (unless you know what youre doing).
BUILDDIR=build
CC=$(PREFIX)-gcc
LD=$(PREFIX)-ld
OBJCOPY=$(PREFIX)-objcopy
OBJDUMP=$(PREFIX)-objdump
CFLAGS=-m$(CPU) -Wall -Wextra -g -static -I../include -I. -msoft-float -MMD -MP -O
LFLAGS=--script=platform.ld -L../libmetal -lmetal-$(CPU)
OBJS=$(patsubst %.c,$(BUILDDIR)/%.c.o,$(SRCS))
OBJS:=$(patsubst %.S,$(BUILDDIR)/%.S.o,$(OBJS))
OBJS:=$(patsubst %.s,$(BUILDDIR)/%.s.o,$(OBJS))
DEPS=$(OBJS:.o=.d)
bmbinary: $(OBJS)
$(LD) -o $@ $(OBJS) $(LFLAGS)
$(BUILDDIR):
mkdir -p $@
$(BUILDDIR)/%.c.o: %.c
mkdir -p $(@D)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILDDIR)/%.S.o: %.S
mkdir -p $(@D)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILDDIR)/%.s.o: %.s
mkdir -p $(@D)
$(CC) $(CFLAGS) -c -o $@ $<
-include $(DEPS)
all: bmbinary rom
crt: crt0.S
$(CC) $(CFLAGS) -c -o crt0.o crt0.S
rm -f crt0.d
clean:
rm -rf $(BUILDDIR)/*
rm -f bmbinary*
rom:
$(OBJCOPY) -O binary bmbinary bmbinary.rom
$(OBJCOPY) -O srec bmbinary bmbinary.srec
dump:
$(OBJDUMP) -mm68k:$(CPU) -belf32-m68k -st -j.evt bmbinary
$(OBJDUMP) -mm68k:$(CPU) -belf32-m68k -dt -j.text bmbinary
$(OBJDUMP) -mm68k:$(CPU) -belf32-m68k -st -j.rodata -j.data -j.bss -j.heap -j.stack bmbinary
dumps:
$(OBJDUMP) -mm68k:$(CPU) -belf32-m68k -st -j.evt bmbinary
$(OBJDUMP) -mm68k:$(CPU) -belf32-m68k -St -j.text bmbinary
$(OBJDUMP) -mm68k:$(CPU) -belf32-m68k -st -j.rodata -j.data -j.bss -j.heap -j.stack bmbinary
hexdump:
hexdump -C bmbinary.rom