-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
286 lines (250 loc) · 6.25 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
.ONESHELL:
.SILENT:
.PHONY: clean list
# header
HEADER=./scripts/.header
# menu
MENU=./lib/dialog/menu
GMENU=./lib/dialog/general
CONF=./lib/dialog/config
DIALOGRC=$(shell cp -f lib/dialog/dialogrc ~/.dialogrc)
# misc
RFS=./scripts/rootfs
RFSX=./scripts/rootfs-extra
ROOTFS=sudo ./scripts/rootfs
CLN=./scripts/clean
CLEAN=sudo ./scripts/clean
# purge
PURGE=$(shell sudo rm -fdr sources; if [ -d .cache ]; then sudo rm -f .cache/git_fast.*; fi)
PURGEALL=$(shell sudo rm -fdr sources output; if [ -d .cache ]; then sudo rm -f .cache/git_fast.*; fi)
PURGELOG=$(shell sudo rm -fdr output/logs)
# logger
RIT=./scripts/runit
LIT=./scripts/loggit
# uboot and linux
XUBOOT=./scripts/uboot
UBOOT=sudo ./scripts/uboot
DTCLIST=./scripts/dtclist
XKERNEL=./scripts/linux
KERNEL=sudo ./scripts/linux
# image
IMG=./scripts/stage1
IMAGE=sudo ./scripts/stage1
STG2=./scripts/stage2
XUSB=./scripts/usbboot
USBBOOT=sudo ./scripts/usbboot
# dependencies
CCOMPILE=./scripts/.ccompile
NCOMPILE=./scripts/.ncompile
# miscellaneous
CHECK=./scripts/check
# BOARDS
BOARDS=$(shell sudo rm -f board.txt; if [ -f lib/boards/${board} ]; then sudo cp lib/boards/${board} board.txt; fi)
ifdef board
include lib/boards/${board}
endif
define create_config
@chmod +x ${CONF}
@${CONF}
endef
define build_uboot
@${BOARDS}
@chmod +x ${XUBOOT}
@${UBOOT}
endef
define build_kernel
@${BOARDS}
@chmod +x ${DTCLIST}
@chmod +x ${XKERNEL}
@${DTCLIST}
@${KERNEL}
endef
define build_image
@${BOARDS}
@chmod +x ${IMG}
@chmod +x ${STG2}
@${IMAGE}
endef
define create_rootfs
@${BOARDS}
@chmod +x ${RFS}
@chmod +x ${RFSX}
@${ROOTFS}
endef
define build_usbboot
@${BOARDS}
@chmod +x ${XUSB}
@${USBBOOT}
endef
# USAGE
help:
@echo ""
@${HEADER}
@echo ""
@echo "\e[1;37mCommand List:\e[0m"
@echo " make ccompile\t\t\tInstall x86_64 dependencies"
@echo " make ncompile\t\t\tInstall aarch64 dependencies"
@echo " make config\t\t\tCreate user data file"
@echo " make menu\t\t\tMenu interface"
@echo " make clean\t\t\tClean up rootfs / image errors"
@echo " make purge\t\t\tRemove sources"
@echo " make purge-log\t\tRemove all logs"
@echo " make purge-all\t\tRemove logs, output and sources"
@echo " make check\t\t\tLatest revision of selected branch"
@echo ""
@echo " make list\t\t\tList boards"
@echo " make uboot board=xxxx\t\tBuild u-boot package"
@echo " make kernel board=xxxx\tBuild linux kernel package"
@echo " make rootfs board=xxxx\tCreate rootfs tarball"
@echo " make image board=xxxx\t\tMake bootable image"
@echo " make usbboot board=xxxx\tMake bootable usb SDCARD image"
@echo " make all board=xxxx\t\tFeeling lucky?"
@echo ""
@echo "For details consult the \e[1;37mREADME.md\e[0m file"
@echo
# DEPENDENCIES
ccompile:
# X86_64 dependencies:
@chmod +x ${CCOMPILE}
@${CCOMPILE}
ncompile:
# Aarch64 dependencies:
@chmod +x ${NCOMPILE}
@${NCOMPILE}
# USER DATA
config:
ifdef edit
@if [ -f ${edit}.txt ]; then nano ${edit}.txt; else echo "${edit}.txt: file not found"; fi
exit
endif
$(call create_config)
# MENU
menu:
@chmod +x ${MENU}
@chmod +x ${GMENU}
@chmod +x ${RIT}
@chmod +x ${LIT}
@${MENU}
# U-BOOT
uboot:
@rm -f override.txt
# edit user data file
ifdef build
@$(shell sed -i "s/^BUILD_VERSION=.*/BUILD_VERSION="'"${build}"'"/" userdata.txt)
endif
ifdef compiler
@$(shell sed -i "s/^COMPILER=.*/COMPILER="'"${compiler}"'"/" userdata.txt)
endif
ifdef menuconfig
@$(shell sed -i "s/^MENUCONFIG=.*/MENUCONFIG="'"${menuconfig}"'"/" userdata.txt)
endif
ifdef version
@$(shell sed -i "s/^UBOOT_VERSION=.*/UBOOT_VERSION="'"${version}"'"/" userdata.txt)
endif
ifdef verbose
@$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt)
endif
# edit board file
ifdef precompiled
@echo 'PRECOMPILED_UBOOT="$(precompiled)"' >> override.txt
endif
ifdef force_version
@echo 'FORCE_VERSION="$(force_version)"' >> override.txt
endif
$(call build_uboot)
# KERNEL
kernel:
@rm -f override.txt
# edit user data file
ifdef build
@$(shell sed -i "s/^BUILD_VERSION=.*/BUILD_VERSION="'"${build}"'"/" userdata.txt)
endif
ifdef compiler
@$(shell sed -i "s/^COMPILER=.*/COMPILER="'"${compiler}"'"/" userdata.txt)
endif
ifdef menuconfig
@$(shell sed -i "s/^MENUCONFIG=.*/MENUCONFIG="'"${menuconfig}"'"/" userdata.txt)
endif
ifdef myconfig
@$(shell sed -i "s/^CUSTOM_DEFCONFIG=.*/CUSTOM_DEFCONFIG="'"1"'"/" userdata.txt)
@$(shell sed -i "s/^MYCONFIG=.*/MYCONFIG="'"${myconfig}_defconfig"'"/" userdata.txt)
endif
ifdef verbose
@$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt)
endif
ifdef version
@$(shell sed -i "s/^VERSION=.*/VERSION="'"${version}"'"/" userdata.txt)
endif
# edit board file
ifdef force_git
@echo 'FORCE_GIT="$(force_git)"' > override.txt
endif
ifdef force_version
@echo 'FORCE_VERSION="$(force_version)"' >> override.txt
endif
ifdef patching
@echo 'LINUX_PATCHING="$(patching)"' >> override.txt
endif
$(call build_kernel)
# ROOTFS
rootfs:
@rm -f override.txt
# edit board file
ifdef distro
@$(shell sed -i "s/^DISTRO=.*/DISTRO="'"${distro}"'"/" userdata.txt)
endif
ifdef release
@$(shell sed -i "s/^DISTRO_VERSION=.*/DISTRO_VERSION="'"${release}"'"/" userdata.txt)
endif
ifdef verbose
@$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt)
endif
$(call create_rootfs)
# IMAGE
image:
@rm -f override.txt
# edit user data file
ifdef distro
@$(shell sed -i "s/^DISTRO=.*/DISTRO="'"${distro}"'"/" userdata.txt)
endif
ifdef release
@$(shell sed -i "s/^DISTRO_VERSION=.*/DISTRO_VERSION="'"${release}"'"/" userdata.txt)
endif
ifdef verbose
@$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt)
endif
$(call build_image)
# ALL
all:
$(call build_uboot)
$(call build_kernel)
$(call create_rootfs)
$(call build_image)
usbboot:
$(call build_usbboot)
# MISCELLANEOUS
check:
@chmod +x ${CHECK}
@${CHECK}
reset:
@$(shell sed -i "s/^BUILD_VERSION=.*/BUILD_VERSION="'"1"'"/" userdata.txt)
@$(shell sed -i "s/^MENUCONFIG=.*/MENUCONFIG="'"0"'"/" userdata.txt)
@$(shell sed -i "s/^CUSTOM_DEFCONFIG=.*/CUSTOM_DEFCONFIG="'"0"'"/" userdata.txt)
@$(shell sed -i "s/^MYCONFIG=.*/MYCONFIG="'"_defconfig"'"/" userdata.txt)
list:
# Boards
@ls lib/boards/
dialogrc:
@${DIALOGRC}
clean:
@chmod +x ${CLN}
@${CLEAN}
purge:
# Removing sources
@${PURGE}
purge-all:
# Removing logs, output and sources
@${PURGEALL}
purge-log:
# Removing logs
@${PURGELOG}