forked from pyavitz/rpi-img-builder
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
221 lines (187 loc) · 4.93 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
.ONESHELL:
.SILENT:
.PHONY: clean list
# header
HEADER=./scripts/.header
# menu
MENU=./lib/dialog/menu
CONF=./lib/dialog/config
DIALOGRC=$(shell cp -f lib/dialog/dialogrc ~/.dialogrc)
# rootfs
RFS=./scripts/rootfs
ROOTFS=sudo ./scripts/rootfs
# kernel
XLINUX=./scripts/rpi-linux
LINUX=sudo ./scripts/rpi-linux
# commit
XCOMMIT=./scripts/rpi-commit
COMMIT=sudo ./scripts/rpi-commit
# stages
STG1=./scripts/stage1
STG2=./scripts/stage2
IMAGE=sudo ./scripts/stage1
# clean
CLN=./scripts/clean
CLEAN=sudo ./scripts/clean
# purge
PURGE=$(shell sudo rm -fdr source; if [ -d .cache ]; then sudo rm -f .cache/git_fast.*; fi)
PURGEALL=$(shell sudo rm -fdr source output; if [ -d .cache ]; then sudo rm -f .cache/git_fast.*; fi)
# miscellaneous
XCHECK=./scripts/check
CHECK=./scripts/check
# dependencies
CCOMPILE=./scripts/.ccompile
NCOMPILE=./scripts/.ncompile
# 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 go=rx files/inits/*
@chmod go=rx files/scripts/*
@chmod go=r files/misc/*
@chmod go=r files/users/*
@chmod +x ${CONF}
@${CONF}
endef
define build_kernel
@${BOARDS}
@chmod +x ${XLINUX}
@${LINUX}
endef
define build_commit
@${BOARDS}
@chmod +x ${XCOMMIT}
@${COMMIT}
endef
define build_image
@${BOARDS}
@chmod +x ${STG1}
@chmod +x ${STG2}
@${IMAGE}
endef
define create_rootfs
@${BOARDS}
@chmod +x ${RFS}
@${ROOTFS}
endef
help:
@echo ""
@${HEADER}
@echo ""
@echo "\e[1;37mCommands:\e[0m"
@echo " make ccompile\t\tInstall x86-64 dependencies"
@echo " make ncompile\t\tInstall Aarch64 dependencies"
@echo " make config\t\t\tCreate user data file"
@echo " make menu\t\t\tUser menu interface"
@echo " make clean\t\t\tClean up rootfs and image errors"
@echo " make purge\t\t\tRemove source directory"
@echo " make purge-all\t\tRemove source and output directory"
@echo " make dialogrc\t\tSet builder theme"
@echo " make check\t\t\tLatest revision of selected branch"
@echo ""
@echo " make list\t\t\tList boards"
@echo " make all board=xxx\t\tKernel > rootfs > image"
@echo " make kernel board=xxx\tBuilds linux kernel package"
@echo " make commit board=xxx\tBuilds linux kernel package"
@echo " make rootfs board=xxx\tCreate rootfs tarball"
@echo " make image board=xxx\t\tMake bootable image"
@echo ""
# make commands
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}
@${MENU}
# LINUX
kernel:
# 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
$(call build_kernel)
commit:
$(call build_commit)
# ROOT FILESYSTEM
rootfs:
# 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 create_rootfs)
# IMAGE
image:
# 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:
$(call build_kernel)
$(call create_rootfs)
$(call build_image)
list:
# Boards
@cat lib/boards/* | grep -w "PRETTY_BOARD=" | sed 's/PRETTY_BOARD=//g' | sed 's/"//g' | sed 's/BCM/bcm/g' | sed 's/bcm2711 \/ ARMHF/bcm2711v7 \/ ARMHF/g'
clean:
@chmod +x ${CLN}
@${CLEAN}
purge:
# Removing source directory
@${PURGE}
purge-all:
# Removing source and output directory
@${PURGEALL}
dialogrc:
@${DIALOGRC}
check:
@chmod +x ${XCHECK}
@${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)