Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (68 loc) · 2.39 KB
/
Copy pathMakefile
File metadata and controls
96 lines (68 loc) · 2.39 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
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
CROSS_COMPILE ?= aarch64-linux-gnu-
CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
MKSUNXIBOOT ?= tools/mksunxiboot
BUILDID := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
CFLAGS := -march=armv8-a -mgeneral-regs-only -Os -g \
-ffreestanding -fno-builtin -nostdlib -nostartfiles \
-fno-stack-protector -fomit-frame-pointer \
-Wall -Wextra -Iinclude -DBUILDID=\"$(BUILDID)\"
LDFLAGS = -nostdlib
ASFLAGS := -march=armv8-a
OBJS = arch/$(ARCH)/start.o arch/$(ARCH)/helper.o psci.o psci_trampoline.o
# helpers for Kbuild, taken from Linux
include Makefile.kbuild
ifndef mixed-build
ifndef config-build
# end of helpers for Kbuild
export CC AS
export KBUILD_CFLAGS := $(CFLAGS)
export KBUILD_AFLAGS := $(ASFLAGS)
all: spl-bootable.img
main.o: main.c
$(CC) $(CFLAGS) -c -o $@ $<
start.o: arch/arm64/start.S
$(CC) $(ASFLAGS) -c -o $@ $<
spl-raw.elf: start.o main.o arch/arm64/linker.lds built-in.a
$(CC) $(CFLAGS) $(LDFLAGS) -T arch/arm64/linker.lds -o $@ start.o main.o -Wl,--whole-archive built-in.a -Wl,--no-whole-archive
spl-raw.bin: spl-raw.elf
$(OBJCOPY) -O binary $< $@
spl.bin: spl-raw.bin
$(MKSUNXIBOOT) $< $@
spl-bootable.img: spl.bin tools/mkbootableimage.py
python3 tools/mkbootableimage.py
PHONY += built-in.a
built-in.a: $(build-dir)
PHONY += $(build-dir)
$(build-dir):
$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 $(single-goals)
CLEAN_FILES += spl-bootable.img spl.bin spl-raw.bin spl-raw.elf
MRPROPER_FILES += include/config include/generated \
.config .config.old
mrproper-dirs := $(addprefix _mrproper_,scripts)
PHONY += $(mrproper-dirs) mrproper
$(mrproper-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
mrproper: clean $(mrproper-dirs)
$(call cmd,rmfiles)
clean: private rm-files := $(CLEAN_FILES)
mrproper: private rm-files := $(MRPROPER_FILES)
clean-dirs := $(addprefix _clean_, $(clean-dirs))
PHONY += $(clean-dirs) clean
$(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
clean: $(clean-dirs)
$(call cmd,rmfiles)
@find . $(RCS_FIND_IGNORE) \
\( -name '*.[oad]' -o -name '.*.cmd' \
-o -name '*.lex.c' -o -name '*.tab.[ch]' \
\) -type f -print \
| xargs rm -rf
.PHONY: clean
quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
cmd_rmfiles = rm -rf $(rm-files)
endif # config-build
endif # mixed-build
PHONY += FORCE
FORCE:
.PHONY: $(PHONY)