/
functions
359 lines (292 loc) · 13.1 KB
/
functions
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
setup_toolchain() {
if [ "$1" = "--optimize" ]; then
OPTIMIZE=yes
shift
fi
if [ "$1" = target ]; then
export DESTIMAGE="target"
export CC=$TARGET_CC
export CXX=$TARGET_CXX
export LD=$TARGET_LD
export AS=$TARGET_AS
export AR=$TARGET_AR
export NM=$TARGET_NM
export RANLIB=$TARGET_RANLIB
export OBJCOPY=$TARGET_OBJCOPY
export OBJDUMP=$TARGET_OBJDUMP
export STRIP=$TARGET_STRIP
export CPPFLAGS="$TARGET_CPPFLAGS"
export CFLAGS="$TARGET_CFLAGS"
export CXXFLAGS="$TARGET_CXXFLAGS"
export LDFLAGS="$TARGET_LDFLAGS"
export PKG_CONFIG_PATH="$TARGET_PKG_CONFIG_PATH"
export PKG_CONFIG_LIBDIR="$TARGET_PKG_CONFIG_LIBDIR"
export PKG_CONFIG_SYSROOT_DIR="$TARGET_PKG_CONFIG_SYSROOT_DIR"
# set CMAKE configfile for target
export CMAKE_CONF=$ROOT/$TOOLCHAIN/etc/cmake-$TARGET_NAME.conf
elif [ "$1" = host ]; then
export DESTIMAGE="host"
export AWK=$HOST_AWK
export CC=$HOST_CC
export CXX=$HOST_CXX
export LD=$HOST_LD
export AS=$HOST_AS
export AR=$HOST_AR
export NM=$HOST_NM
export RANLIB=$HOST_RANLIB
export OBJCOPY=$HOST_OBJCOPY
export STRIP=$HOST_STRIP
export CPPFLAGS="$HOST_CPPFLAGS"
export CFLAGS="$HOST_CFLAGS"
export CXXFLAGS="$HOST_CXXFLAGS"
export LDFLAGS="$HOST_LDFLAGS"
export PKG_CONFIG_PATH="$HOST_PKG_CONFIG_PATH"
export PKG_CONFIG_LIBDIR="$HOST_PKG_CONFIG_LIBDIR"
export PKG_CONFIG_SYSROOT_DIR="$HOST_PKG_CONFIG_SYSROOT_DIR"
# set CMAKE configfile for host
export CMAKE_CONF=$ROOT/$TOOLCHAIN/etc/cmake-$HOST_NAME.conf
fi
}
kernel_path() {
ls -d $ROOT/$BUILD/linux-[0-9]*
}
tolower(){
echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
}
require_eglibc() {
if [ "$TARGET_LIBC" != eglibc ]; then
echo "$1 requires eglibc, aborting."
exit 1
fi
}
require_cxx() {
if [ "$TOOLCHAIN_CXX" != yes ]; then
echo "$1 requires C++ toolchain support, aborting."
exit 1
fi
}
xorg_drv_configure_prepend() {
incdir=${SYSROOT_PREFIX}/usr/include/xorg
for f in dri.h sarea.h dristruct.h exa.h damage.h xf86Module.h; do
incfile="$incdir/$f"
if [ -f "$incfile" ]; then
p=`echo "$incfile" | sed 'y%*+%pp%;s%[^_[:alnum:]]%_%g'`
eval "export ac_cv_file_$p=yes"
fi
done
}
add_user() {
# Usage: add_user "username" "password" "userid" "groupid" "description" "home" "shell"
mkdir -p ${INSTALL}/etc
touch ${INSTALL}/etc/passwd
if [ -z "`grep "$1:" ${INSTALL}/etc/passwd`" ]; then
echo "$1:x:$3:$4:$5:$6:$7" >> ${INSTALL}/etc/passwd
fi
touch ${INSTALL}/etc/shadow
PASSWORD="$2"
if [ "$PASSWORD" = "x" ]; then
PASSWORD="*"
fi
if [ -z "`grep "$1:" ${INSTALL}/etc/shadow`" ]; then
echo "$1:$PASSWORD:::::::" >> ${INSTALL}/etc/shadow
fi
}
add_group() {
# Usage: add_group "groupname" "groupid" ("members")
mkdir -p ${INSTALL}/etc
touch ${INSTALL}/etc/group
if [ -z "`grep "$1:" ${INSTALL}/etc/group`" ]; then
echo "$1:x:$2:$3" >> ${INSTALL}/etc/group
fi
}
do_autoreconf() {
export ACLOCAL_DIR=$SYSROOT_PREFIX/usr/share/aclocal
if [ -e "$ROOT/$TOOLCHAIN/bin/autoconf" ]; then
export AUTOCONF=$ROOT/$TOOLCHAIN/bin/autoconf
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/automake" ]; then
export AUTOMAKE=$ROOT/$TOOLCHAIN/bin/automake
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/autopoint" ]; then
export AUTOPOINT=$ROOT/$TOOLCHAIN/bin/autopoint
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/libtoolize" ]; then
export LIBTOOLIZE=$ROOT/$TOOLCHAIN/bin/libtoolize
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/intltoolize" ]; then
export INTLTOOLIZE=$ROOT/$TOOLCHAIN/bin/intltoolize
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/aclocal" ]; then
export ACLOCAL="$ROOT/$TOOLCHAIN/bin/aclocal -I $ACLOCAL_DIR"
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/autoheader" ]; then
export AUTOHEADER=$ROOT/$TOOLCHAIN/bin/autoheader
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/libtool" ]; then
export LIBTOOL=$ROOT/$TOOLCHAIN/bin/libtool
fi
if [ -e "$ROOT/$TOOLCHAIN/bin/autoreconf" -a -e "$INTLTOOLIZE" ]; then
mkdir -p $ACLOCAL_DIR
export AUTORECONF="$ROOT/$TOOLCHAIN/bin/autoreconf --verbose --force --install -I $ACLOCAL_DIR"
$AUTORECONF $@
fi
}
strip_lto() {
# strip out LTO optimization from *FLAGS
CFLAGS=`echo $CFLAGS | sed -e "s|-flto||g"`
CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-flto||g"`
LDFLAGS=`echo $LDFLAGS | sed -e "s|-flto||g"`
}
strip_linker_plugin() {
# strip out usage from linker plugin
LDFLAGS=`echo $LDFLAGS | sed -e "s|-fuse-linker-plugin||g"`
}
fix_module_depends() {
# modify .modinfo section in kernel module to depends on other required modules
local MODULE="$1"
local DEPENDS="$2"
local OLD_DEPENDS=""
cp ${MODULE} ${MODULE}_orig
$OBJDUMP -s -j .modinfo ${MODULE}_orig | awk 'BEGIN{v=0;} /Contents/ {v=1; next;} {if (v==1) print $0;}' >new.modinfo1
cat new.modinfo1 | cut -c7-41 | awk '{printf($0);}' | sed 's/ //g;s/../\\\x&/g;' >new.modinfo2
/bin/echo -ne `cat new.modinfo2` | tr '\000' '\n' >new.modinfo3
cat new.modinfo3 | awk '/^depends=/ {next;} {print $0;}' | tr '\n' '\000' >new.modinfo
OLD_DEPENDS=$(awk '{FS="="} /depends=/ {print $2}' new.modinfo3)
[ -n "$OLD_DEPENDS" ] && DEPENDS="$OLD_DEPENDS,$DEPENDS"
/bin/echo -ne "depends=$DEPENDS\0" >>new.modinfo
$OBJCOPY --remove-section=.modinfo --add-section=.modinfo=new.modinfo --set-section-flags .modinfo=contents,alloc,load,readonly,data ${MODULE}_orig ${MODULE}
rm new.modinfo*
}
check_config() {
dashes="==========================="
if [ ! -d $PROJECT_DIR/$PROJECT ]; then
check_project="$check_project\n $dashes$dashes$dashes"
check_project="$check_project\n ERROR: Project not found, use a valid project or create a new config"
check_project="$check_project\n $dashes$dashes$dashes"
check_project="$check_project\n\n Valid projects:"
for projects in $PROJECT_DIR/*; do
check_project="$check_project\n - $(basename $projects)"
done
echo -e $check_project
exit 1
fi
if [ ! -f $PROJECT_DIR/$PROJECT/linux/linux.$TARGET_ARCH.conf ]; then
check_arch="$check_arch\n $dashes$dashes$dashes"
check_arch="$check_arch\n ERROR: Architecture not found, use a valid Architecture"
check_arch="$check_arch\n for your project or create a new config"
check_arch="$check_arch\n $dashes$dashes$dashes"
check_arch="$check_arch\n\n Valid Architectures for your project: $PROJECT"
for arch in $PROJECT_DIR/$PROJECT/linux/*.conf; do
check_arch="$check_arch\n - $(basename $arch | cut -f2 -d".")"
done
echo -e $check_arch
exit 1
fi
}
show_config() {
dashes="==========================="
config_message="$config_message\n $dashes$dashes$dashes"
config_message="$config_message\n Configuration for $DISTRONAME"
config_message="$config_message\n $dashes$dashes$dashes"
# Build options
config_message="$config_message\n\n Buildoptions:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - CPU (ARCH):\t\t\t\t $TARGET_CPU ($TARGET_ARCH)"
config_message="$config_message\n - FPU:\t\t\t\t\t $TARGET_FPU"
config_message="$config_message\n - Optimizations:\t\t\t $OPTIMIZATIONS"
config_message="$config_message\n - LTO (Link Time Optimization) support: $LTO_SUPPORT"
config_message="$config_message\n - LLVM support:\t\t\t $LLVM_SUPPORT"
# config_message="$config_message\n - CFLAGS:\t $TARGET_CFLAGS"
# config_message="$config_message\n - LDFLAGS:\t $TARGET_LDFLAGS"
# Graphic configuration
config_message="$config_message\n\n Graphic configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - XORG support:\t\t\t $XORG_SUPPORT"
config_message="$config_message\n - XORG Composite support:\t\t $COMPOSITE_SUPPORT"
config_message="$config_message\n - XORG Xinerama support:\t\t $XINERAMA_SUPPORT"
config_message="$config_message\n - OpenGL (GLX) support (provider):\t $OPENGL_SUPPORT ($OPENGL)"
config_message="$config_message\n - OpenGLES support (provider):\t\t $OPENGLES_SUPPORT ($OPENGLES)"
config_message="$config_message\n - WindowManager:\t\t\t $WINDOWMANAGER"
config_message="$config_message\n - Xorg Graphic Drivers:\t\t $GRAPHIC_DRIVERS"
# Hardware decoder support
config_message="$config_message\n\n Hardware decoder configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - Broadcom CrystalHD Decoder:\t\t $CRYSTALHD"
config_message="$config_message\n - VAAPI Support:\t\t\t $VAAPI"
config_message="$config_message\n - VDPAU Support:\t\t\t $VDPAU"
config_message="$config_message\n - XVBA Support:\t\t\t $XVBA"
# Input device configuration
config_message="$config_message\n\n Input device configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - Remote support:\t\t\t $REMOTE_SUPPORT"
config_message="$config_message\n - ATV Remote support:\t\t\t $ATVCLIENT_SUPPORT"
config_message="$config_message\n - CEC Adapter support:\t\t\t $CEC_SUPPORT"
config_message="$config_message\n - IRTrans support:\t\t\t $IRSERVER_SUPPORT"
config_message="$config_message\n - XBMC Joystick support:\t\t $JOYSTICK_SUPPORT"
# Misc. hardware configuration
config_message="$config_message\n\n Misc. hardware configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - ALSA support:\t\t\t $ALSA_SUPPORT"
config_message="$config_message\n - Pulseaudio support:\t\t\t $PULSEAUDIO_SUPPORT"
config_message="$config_message\n - Blu-Ray support:\t\t\t $BLURAY_SUPPORT"
config_message="$config_message\n - Bluetooth support:\t\t\t $BLUETOOTH_SUPPORT"
config_message="$config_message\n - Hardware Sensors support:\t\t $SENSOR_SUPPORT"
config_message="$config_message\n - LCD drivers:\t\t\t\t $LCD_DRIVER"
for config_driver in $ADDITIONAL_DRIVERS; do
config_message="$config_message\n - Include driver:\t\t\t $config_driver"
done
for config_firmware in $FIRMWARE; do
config_message="$config_message\n - Include firmware:\t\t\t $config_firmware"
done
# Network service configuration
config_message="$config_message\n\n Network service configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - Avahi (Zeroconf) support:\t\t $AVAHI_DAEMON"
config_message="$config_message\n - SAMBA server support:\t\t $SAMBA_SERVER"
config_message="$config_message\n - SFTP server support:\t\t\t $SFTP_SERVER"
config_message="$config_message\n - SSH Guard support:\t\t\t $SSHGUARD_SUPPORT"
config_message="$config_message\n - XBMC Airplay support:\t\t $AIRPLAY_SUPPORT"
config_message="$config_message\n - XBMC Airtunes support:\t\t $AIRTUNES_SUPPORT"
config_message="$config_message\n - XBMC AFP support:\t\t\t $AFP_SUPPORT"
config_message="$config_message\n - XBMC NFS support:\t\t\t $NFS_SUPPORT"
config_message="$config_message\n - XBMC SAMBA client support:\t\t $SAMBA_CLIENT"
config_message="$config_message\n - XBMC Webserver support:\t\t $WEBSERVER"
# OS configuration
config_message="$config_message\n\n OS configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - OEM Support:\t\t\t\t $OEM_SUPPORT"
config_message="$config_message\n - Default Hostname:\t\t\t $HOSTNAME"
config_message="$config_message\n - Default ROOT Password:\t\t $ROOT_PASSWORD"
config_message="$config_message\n - Bootloader:\t\t\t\t $BOOTLOADER"
config_message="$config_message\n - U-Boot configuration:\t\t $UBOOT_CONFIG"
config_message="$config_message\n - UDisks support:\t\t\t $UDISKS"
config_message="$config_message\n - UPower support:\t\t\t $UPOWER"
config_message="$config_message\n - Update support:\t\t\t $UPDATE_SUPPORT"
config_message="$config_message\n - Installer support:\t\t\t $INSTALLER_SUPPORT"
# Misc. Filesystems
config_message="$config_message\n\n Misc. Filesystems:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - NTFS Support (via Fuse):\t\t $NTFS3G"
config_message="$config_message\n - Install HFS Tools:\t\t\t $HFSTOOLS"
# XBMC configuration
config_message="$config_message\n\n XBMC configuration:"
config_message="$config_message\n $dashes$dashes"
config_message="$config_message\n - XBMC version:\t\t\t $MEDIACENTER"
config_message="$config_message\n - XBMC PVR/DVB support:\t\t $PVR"
config_message="$config_message\n - XBMC nonfree support:\t\t $NONFREE_SUPPORT"
config_message="$config_message\n - XBMC DVDCSS support:\t\t\t $DVDCSS_SUPPORT"
for config_skin in $SKINS; do
config_message="$config_message\n - Include Skin:\t\t\t $config_skin"
done
config_message="$config_message\n - Default Skin:\t\t\t $SKIN_DEFAULT"
config_message="$config_message\n - Include extra fonts:\t\t\t $XBMC_EXTRA_FONTS"
config_message="$config_message\n - Include RSXS Screensaver:\t\t $XBMC_SCR_RSXS"
config_message="$config_message\n - Include ProjectM Visualization:\t $XBMC_VIS_PROJECTM"
config_message="$config_message\n - Include Goom Visualization:\t\t $XBMC_VIS_GOOM"
config_message="$config_message\n"
config_message="$config_message\n $dashes$dashes$dashes"
config_message="$config_message\n End Configuration for $DISTRONAME"
config_message="$config_message\n $dashes$dashes$dashes"
config_message="$config_message\n\n\n"
echo -e $config_message
}