This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
94 lines (73 loc) · 2.08 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Makefile for Allwinner Babelfish FEX-to-DT translator
AS := $(CROSS_COMPILE)as
CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
LD := $(CROSS_COMPILE)ld
DTC := dtc
CFLAGS := -Wall -ffreestanding -nostdinc -marm -fpic
CFLAGS += -I$(CURDIR)/include -I$(CURDIR)/include/generated
CFLAGS += -I$(CURDIR)/include/linux -I$(CURDIR)/lib/libfdt
LOADADDR ?= 0x40008000
LDFLAGS := -static -nostdlib
LDFLAGS += -T babelfish.lds
OBJS :=
DTBS :=
ifndef ZIMAGE
$(error Please provide the path to the zImage)
endif
define my-dir
$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
endef
define register-objs
OBJS += $(addprefix $(1), $(2))
endef
include lib/Makefile
include src/Makefile
OBJS := $(addprefix out/, $(OBJS))
ifndef DTB
include dtsi/Makefile
DTBS += $(addprefix $(FILE_PATH), $(FILE_DTBS))
DTBS := $(addprefix out/, $(DTBS))
DTBS := $(addsuffix .o, $(DTBS))
else
DTBS := out/dtsi/custom.dtb.o
CFLAGS += -DCUSTOM_DTB
endif
.PHONY: include/generated/version.h
include/generated/version.h:
mkdir -p include/generated
./genver.sh > include/generated/version.h
out/%.o: %.c include/generated/version.h
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -D__KERNEL__ -c -o $@ $<
out/%.o: %.S
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $^
out/dtsi/custom.dtb: $(DTB)
mkdir -p $(dir $@)
cp $(DTB) $@
out/%.dtb: %.dtsi
mkdir -p $(dir $@)
$(DTC) -I dts -O dtb -o $@ $^
out/%.dtb.S: out/%.dtb
mkdir -p $(dir $@)
@echo '.section .dtbs.$(*F),"aw"' > $@
@echo '.global dtb_$(subst -,_,$(*F))' >> $@
@echo 'dtb_$(subst -,_,$(*F)):' >> $@
@echo '.incbin "$^"' >> $@
out/zImage.S: $(ZIMAGE)
@echo '.section .zimage,"a"' > $@
@echo '.global zImage_start' >> $@
@echo 'zImage_start:' >> $@
@echo '.incbin "$^"' >> $@
babelfish: $(OBJS) $(DTBS) out/zImage.o
$(LD) $(LDFLAGS) -o $@ $^
all: zImage
zImage: babelfish
$(OBJCOPY) -O binary --set-section-flags .bss=alloc,load,contents $^ $@
uImage: zImage
mkimage -A arm -O linux -C none -T kernel \
-a $(LOADADDR) -e $(LOADADDR) \
-n "Allwinner BabelFish" -d $^ $@
clean:
rm -fr babelfish zImage include/generated out uImage