-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
174 lines (145 loc) · 4.34 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
MAKEROOT_NAME:=makeroot
export MAKEROOT_NAME
DPRINT=@echo
CURDIR=$(shell pwd)
ifeq ($(BUILD_SRC),)
# That's our default target when none is given on the command line
PHONY := _all
_all:
# Cancel implicit rules on top Makefile
$(CURDIR)/Makefile Makefile: ;
endif # ifeq ($(BUILD_SRC),)
PHONY+=all
_all: all
# CURDIR will be $(srctree)
MAKEFLAGS += --include-dir=$(srctree)
CONFIG_FILE ?= .config
export CONFIG_FILE
VERSION_FILE ?= versioning/.config
export VERSION_FILE
srctree := $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR))
-include $(srctree)/$(CONFIG_FILE)
-include $(srctree)/$(VERSION_FILE)
BOARD ?= $(CONFIG_CONFIGNAME:"%"=%)
TOOLCHAIN_PATH ?=$(if $(CONFIG_TOOLCHAIN_PATH:"%"=%),$(CONFIG_TOOLCHAIN_PATH:"%"=%),$(CURDIR)/out/host/toolchain)
root := $(CURDIR)
srctree := $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR))
objtree := $(strip out/target/$(if $(BOARD),$(BOARD)/))
hostobjtree := out/host/
src := $(srctree)
obj :=
sysroot := $(root)/$(objtree)/sysroot
packagesdir := $(root)/$(objtree)/packages
rootfs := $(root)/$(objtree)/rootfs
bootfs := $(root)/$(objtree)/boot
homefs := $(root)/$(objtree)/homefs
objtree := $(root)/$(objtree)
hostobjtree := $(root)/$(hostobjtree)
hostbin := $(hostobjtree)/bin
hostlib := $(hostobjtree)/lib
toolchain_path := $(TOOLCHAIN_PATH)
export root srctree objtree sysroot
export hostobjtree hostbin toolchain_path
export packagesdir rootfs bootfs homefs
SYSTEM := $(CONFIG_SYSTEM:"%"=%)
CONFIGDIR := $(CONFIG_CONFIGDIR:"%"=%)
export SYSTEM CONFIGDIR
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%-)
KERNEL ?= $(if $(findstring y,$(CONFIG_LINUX)),linux,none)
ARCH ?= $(CONFIG_ARCH:"%"=%)
SUBARCH ?= $(CONFIG_SUBARCH:"%"=%)
HFP ?= $(CONFIG_HFP_CPU:"%"=%)
THUMB ?= $(CONFIG_THUMB:"%"=%)
ABI?=$(strip \
$(if $(findstring arm,$(ARCH)), \
$(if $(findstring y,$(THUMB)),thumb,\
eabi\
)\
))
ifeq ($(CONFIG_LIBC_TOOLCHAIN),y)
LIBC?= \
$(if $(findstring gnu,$(CROSS_COMPILE)),gnu,\
$(if $(findstring uclibc,$(CROSS_COMPILE)),uclibc,\
$(if $(findstring android,$(CROSS_COMPILE)),android,\
$(if $(findstring musl,$(CROSS_COMPILE)),gnumusl,\
$(if $(findstring dietlibc,$(CROSS_COMPILE)),dietlibc,\
) \
) \
) \
) \
)
TRIPLET:=$(ARCH)-unknown-$(KERNEL)-$(LIBC)$(ABI)
else
LIBC:=$(strip \
$(if $(findstring y,$(CONFIG_LIBC_GLIBC_SP)) $(findstring y,$(CONFIG_LIBC_EGLIBC_SP)),gnu,\
$(if $(findstring y,$(CONFIG_LIBC_UCLIBC)),uclibc,\
$(if $(findstring y,$(CONFIG_LIBC_BIONIC)),android,\
$(if $(findstring y,$(CONFIG_LIBC_MUSL_SP)),gnumusl,\
$(if $(findstring y,$(CONFIG_LIBC_DIETLIBC)),dietlibc,\
$(if $(findstring y,$(CONFIG_LIBC_NEWLIB)),) \
) \
) \
) \
) \
))
TRIPLET:=$(ARCH)-unknown-$(KERNEL)-$(LIBC)$(ABI)
endif
LIBC:=$(if $(LIBC),$(LIBC),newlib)
LDSO:=ld.so.1
export CROSS_COMPILE KERNEL ARCH LIBC BOARD SUBARCH HFP THUMB TRIPLET LDSO
GCC_FLAGS ?= $(CONFIG_GCC_FLAGS:"%"=%)
export GCC_FLAGS
PATH:=$(hostbin):$(toolchain_path)/bin:$(PATH)
export PATH
# We need some generic definitions.
$(srctree)/scripts/include.mk: ;
include $(srctree)/scripts/include.mk
$(objtree):
$(MKDIR) $(objtree)
# Basic helpers built in scripts/
PHONY += scripts_basic
scripts_basic:
$(Q)$(MAKE) $(build)=scripts/basic
# To avoid any implicit rule to kick in, define an empty command.
scripts/basic/%: scripts_basic ;
PHONY+=menuconfig
menuconfig: scripts_basic
$(Q)$(MAKE) $(build)=scripts/kconfig $@
%config: FORCE scripts_basic
@echo Make $@
$(Q)$(MAKE) $(build)=scripts/kconfig $@
$(CONFIG_FILE):
$(error run " make menuconfig " first)
$(objtree)/auto.conf: $(CONFIG_FILE)
$(Q)mkdir -p $(dir $@)
$(Q)cp $(CONFIG_FILE) $@
SUBDIRS +=tools bootloader kernel system custom image
ifeq ($(CONFIG_TOOLCHAIN_INSTALL),y)
all: toolchain $(SUBDIRS)
toolchain:
$(Q)$(MAKE) $(build)=tools/gcc
else
all: $(SUBDIRS)
endif
install: target:="force-install=y install"
install: $(SUBDIRS)
download: target:=download
download: $(SUBDIRS)
tree: system/tree
$(Q)$(MAKE) $(build)=$< $(target)
libc: system/libc
$(Q)$(MAKE) $(build)=$< $(target)
base: system/base
$(Q)$(MAKE) $(build)=$< $(target)
init: system/init
$(Q)$(MAKE) $(build)=$< $(target)
egl: system/lowlevel/graphics/egl
$(Q)$(MAKE) $(build)=$< $(target)
.PHONY:test
test:
echo $(TRIPLET) $(HFP) $(LIBC) $(CONFIG_CONFIG_LIBC_TOOLCHAIN)
# $(Q)$(MAKE) $(build)=$@ $(target)
PHONY += $(SUBDIRS) test
$(SUBDIRS): FORCE
$(Q)$(MAKE) $(build)=$@ $(target)
FORCE:;