-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (26 loc) · 838 Bytes
/
Makefile
File metadata and controls
38 lines (26 loc) · 838 Bytes
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
CROSS_COMPILE = /opt/x-tools/mipsel-unknown-elf/bin/mipsel-unknown-elf-
AS = $(CROSS_COMPILE)as -mips32
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
CFLAGS = -Os -DSTARTADDRESS=$(STARTADDRESS) -Wall -Wextra -nostdlib
CXXFLAGS = -std=c++17 -fno-rtti -fno-unwind-tables -fno-exceptions
STARTADDRESS = 0x1000000
TARGETS = blink.bin
.PHONY: all
all: $(TARGETS)
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
# FIXME: order of objects should not matter
%.elf: start.o %.o
$(LD) -Ttext $(STARTADDRESS) -T linker.lds -Map $(@:.elf=.map) -o $@ $+
%.o: %.[Sc]
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.cpp
$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
.PHONY: clean
clean:
rm -f *.o *.elf *.bin *~ *.map
# ELF images can be used in cutter/radare2
.PRECIOUS: %.elf