-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
66 lines (48 loc) · 1.5 KB
/
makefile
File metadata and controls
66 lines (48 loc) · 1.5 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
ARCH = armv7-a
MCPU = cortex-a8
TARGET = rvpb
CC = arm-none-eabi-gcc
AS = arm-none-eabi-as
LD = arm-none-eabi-gcc
OC = arm-none-eabi-objcopy
LINKER_SCRIPT = ./cruzeros.ld
MAP_FILE = build/cruzeros.map
ASM_SRCS = $(wildcard boot/*.S)
ASM_OBJS = $(patsubst boot/%.S, build/%.os, $(ASM_SRCS))
VPATH = boot \
hal/$(TARGET) \
lib \
kernel
C_SRCS = $(notdir $(wildcard boot/*.c))
C_SRCS += $(notdir $(wildcard hal/$(TARGET)/*.c))
C_SRCS += $(notdir $(wildcard lib/*.c))
C_SRCS += $(notdir $(wildcard kernel/*.c))
C_OBJS = $(patsubst %.c, build/%.o, $(C_SRCS))
INC_DIRS = -I include \
-I hal \
-I hal/$(TARGET) \
-I lib \
-I kernel
CFLAGS = -c -g -std=c11
LDFLAGS = -nostartfiles -nostdlib -nodefaultlibs -static -lgcc
cruzeros = build/cruzeros.axf
cruzeros_bin = build/cruzeros.bin
.PHONY: all clean run debug gdb
all: $(cruzeros)
clean:
@rm -fr build
run: $(cruzeros)
qemu-system-arm -M realview-pb-a8 -kernel $(cruzeros) -nographic
debug: $(cruzeros)
qemu-system-arm -M realview-pb-a8 -kernel $(cruzeros) -S -gdb tcp::1234,ipv4
gdb:
arm-none-eabi-gdb
$(cruzeros): $(ASM_OBJS) $(C_OBJS) $(LINKER_SCRIPT)
$(LD) -n -T $(LINKER_SCRIPT) -o $(cruzeros) $(ASM_OBJS) $(C_OBJS) -Wl,-Map=$(MAP_FILE) $(LDFLAGS)
$(OC) -O binary $(cruzeros) $(cruzeros_bin)
build/%.os: %.S
mkdir -p $(shell dirname $@)
$(CC) -mcpu=$(MCPU) $(INC_DIRS) $(CFLAGS) -o $@ $<
build/%.o: %.c
mkdir -p $(shell dirname $@)
$(CC) -mcpu=$(MCPU) $(INC_DIRS) $(CFLAGS) -o $@ $<