forked from rodw-au/rpi-img-builder-lcnc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
221 lines (187 loc) · 4.22 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
# header
HEADER=./scripts/.header
# menu
MENU=./lib/dialog/menu
CONF=./lib/dialog/config
DIALOGRC=$(shell cp -f lib/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)
PURGEALL=$(shell sudo rm -fdr source output)
# miscellaneous
XCHECK=./scripts/check
CHECK=./scripts/check
XCOMP=./scripts/compress
COMP=sudo ./scripts/compress
# dependencies
CCOMPILE=./scripts/.ccompile
CCOMPILE64=./scripts/.ccompile64
NCOMPILE=./scripts/.ncompile
# boards
BOARDS=$(shell sudo cp lib/boards/${board} board.txt)
ifdef board
include lib/boards/${board}
endif
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 cross dependencies"
@echo " make ccompile64\t\tInstall Arm64 cross dependencies"
@echo " make ncompile\t\tInstall native dependencies"
@echo " make config\t\t\tCreate user data file"
@echo " make menu\t\t\tUser menu interface"
@echo " make cleanup\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 rootfs board=xxx\tCreate rootfs tarball"
@echo " make image board=xxx\t\tMake bootable image"
@echo ""
# make commands
ccompile:
# Installing x86_64 cross dependencies:
@chmod +x ${CCOMPILE}
@${CCOMPILE}
ccompile64:
# Installing arm64 cross dependencies:
@chmod +x ${CCOMPILE64}
@${CCOMPILE64}
ncompile:
# Installing native dependencies:
@chmod +x ${NCOMPILE}
@${NCOMPILE}
kernel:
@rm -f override.txt
# architecture
ifdef arch
@echo 'ARCH_EXT="$(arch)"' > override.txt
endif
# Compiling kernel
$(call build_kernel)
commit:
# Compiling kernel
$(call build_commit)
image:
@rm -f override.txt
# distro and release
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
# architecture
ifdef arch
@echo 'ARCH_EXT="$(arch)"' > override.txt
endif
# Creating image
$(call build_image)
all:
# Compiling kernel
$(call build_kernel)
# Creating ROOTFS tarball
$(call create_rootfs)
# Creating image
$(call build_image)
# root filesystem
rootfs:
@rm -f override.txt
# distro and release
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
# architecture
ifdef arch
@echo 'ARCH_EXT="$(arch)"' > override.txt
endif
# Root Filesystem
$(call create_rootfs)
# LIST BOARDS
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 and purge
cleanup:
# Cleaning up
@chmod +x ${CLN}
@${CLEAN}
purge:
# Removing source directory
@${PURGE}
purge-all:
# Removing source and output directory
@${PURGEALL}
# miscellaneous
dialogrc:
# Builder theme set
@${DIALOGRC}
check:
# Check kernel revisions
@chmod +x ${XCHECK}
@${CHECK}
# kernel run
run:
@chmod +x ${XRUN}
@${RUN}
compress:
@chmod +x ${XCOMP}
@${COMP}
# menu
menu:
# User menu interface
@chmod +x ${MENU}
@${MENU}
config:
# User config menu
@chmod go=rx files/inits/*
@chmod go=rx files/scripts/*
@chmod go=r files/misc/*
@chmod go=r files/users/*
@chmod +x ${CONF}
@${CONF}