-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (47 loc) · 1.77 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
TARGET := armv7
PLATFORM := zynq
BINARY := kernel.elf
include config/$(TARGET)-config.mk
CC=$(PREFIX)gcc
#CC=clang
CXX=clang++
LD=$(PREFIX)gcc
CFLAGS := -std=c11 -g -O2 -ffreestanding -Isrc/include/ -Wall -Wno-unused -fdiagnostics-color=always $(TARGET_CFLAGS) -Wstrict-aliasing
ASFLAGS := -Wall -g -ffreestanding -fdiagnostics-color=always $(TARGET_ASFLAGS)
LDFLAGS := -Wall -g -Tlink/$(LDSCRIPT) -nostdlib $(TARGET_LDFLAGS) -lgcc
# - Generic sources - #
SOURCES := $(shell find src/ \
-path src/arch -prune -o \
-path src/drivers -prune -o \
-path src/platform -prune -o \
-type f -name *.c -print)
# - Platform-specific drivers - #
SOURCES += $(shell find src/platform/$(PLATFORM) \
-type f -name *.c -print)
# - Generic drivers, as specified in <target>-config.mk - #
SOURCES += $(shell find src/drivers -false \
$(patsubst %, -o -name %.c , $(DRIVER_LIST)))
# - Architecture-specific code - #
SOURCES += $(shell find src/arch/$(TARGET) -type f -name *.s)
SOURCES += $(shell find src/arch/$(TARGET) -type f -name *.c)
SOURCES += $(shell find src/arch/subarch/$(SUBARCH) -type f -name *.s)
SOURCES += $(shell find src/arch/subarch/$(SUBARCH) -type f -name *.c)
OBJECTS := $(patsubst %.s, %.o, \
$(patsubst %.c, %.o, \
$(SOURCES)))
all: $(BINARY) $(PLATFORM_BINARY)
$(PLATFORM_BINARY): $(BINARY)
@$(PLATFORM_OBJCOPY)
$(info Built $(PLATFORM_BINARY))
$(BINARY): $(OBJECTS)
@$(LD) $(sort $(OBJECTS)) -o $(BINARY) $(LDFLAGS)
$(info LD $(OBJECTS))
$(info Built $(BINARY))
.c.o:
@$(CC) $(CFLAGS) -c $< -o $@
$(info CC $<)
.s.o:
@$(CC) $(ASFLAGS) -c $< -o $@
$(info AS $<)
clean:
rm -f $(OBJECTS)