-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
67 lines (54 loc) · 1.55 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
ROOTDIR = tools/mips64
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
LDFLAGS = -Llib
CFLAGS = -mtune=vr4300 -march=vr4300 -std=gnu99 -I$(ROOTDIR)/mips64-elf/include -Iinclude -Wall
ASFLAGS = -mtune=vr4300 -march=vr4300
PROG_NAME = bootloader
BOOTLOADER_OBJ := \
build/src/bios.o \
build/src/main.o \
build/src/usb.o \
build/src/disk.o \
build/src/fat.o \
build/src/gfx.o \
build/src/str.o \
build/src/sys.o \
build/src/incs.o
LIBDRAGON_OBJ := \
build/src/libdragon/entrypoint.o \
build/src/libdragon/n64sys.o \
build/src/libdragon/interrupt.o \
build/src/libdragon/rdp.o \
build/src/libdragon/dma.o \
build/src/libdragon/inthandler.o \
build/src/libdragon/display.o \
build/src/libdragon/exception.o
TOOLS_OBJ :=
.PHONY: default
default: build/$(PROG_NAME).bin
.PHONY: clean
clean:
rm -f -r bin build $(TOOLS_OBJ)
build/$(PROG_NAME).bin: build/$(PROG_NAME).elf
$(OBJCOPY) -O binary $< $@
sha1sum -c $(PROG_NAME).sha1
build/$(PROG_NAME).elf: $(BOOTLOADER_OBJ) $(LIBDRAGON_OBJ)
$(LD) $(LDFLAGS) -Tn64ld.x $(BOOTLOADER_OBJ) $(LIBDRAGON_OBJ) -lc -lnosys -Map $(@:.elf=.map) -o $@
$(BOOTLOADER_OBJ): CFLAGS += -fno-toplevel-reorder
$(filter-out build/src/main.o,$(BOOTLOADER_OBJ)): CFLAGS += -G0 -O2
$(LIBDRAGON_OBJ): CFLAGS += -G0 -O1
build/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
build/%.o: %.s
@mkdir -p $(dir $@)
$(CC) $(ASFLAGS) -c $< -o $@
build/%.o: %.S
@mkdir -p $(dir $@)
$(CC) -c $< -o $@
tools/%: tools/%.c
gcc -O2 -o $@ $<