forked from torvalds/linux
/
build_sun4i-lite.sh
executable file
·119 lines (98 loc) · 2.5 KB
/
build_sun4i-lite.sh
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
#!/bin/bash
set -e
#########################################################################
#
# Simple build scripts to build krenel(with rootfs) -- by Benn
#
#########################################################################
#Setup common variables
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
export AS=${CROSS_COMPILE}as
export LD=${CROSS_COMPILE}ld
export CC=${CROSS_COMPILE}gcc
export AR=${CROSS_COMPILE}ar
export NM=${CROSS_COMPILE}nm
export STRIP=${CROSS_COMPILE}strip
export OBJCOPY=${CROSS_COMPILE}objcopy
export OBJDUMP=${CROSS_COMPILE}objdump
KERNEL_VERSION="3.0"
LICHEE_KDIR=`pwd`
LICHEE_MOD_DIR==${LICHEE_KDIR}/output/lib/modules/${KERNEL_VERSION}
CONFIG_CHIP_ID=1123
update_kern_ver()
{
if [ -r include/generated/utsrelease.h ]; then
KERNEL_VERSION=`cat include/generated/utsrelease.h |awk -F\" '{print $2}'`
fi
LICHEE_MOD_DIR=${LICHEE_KDIR}/output/lib/modules/${KERNEL_VERSION}
}
show_help()
{
printf "Build script for Lichee system\n"
printf " Invalid Option:\n"
printf " help - show this help\n"
printf " kernel - build kernel for sun4i\n"
printf " modules - build external modules for sun4i\n"
printf " clean - clean all\n"
printf "\n"
}
build_kernel()
{
if [ ! -e .config ]; then
echo -e "\n\t\tUsing default config... ...!\n"
cp arch/arm/configs/sun4i_defconfig .config
fi
make KALLSYMS_EXTRA_PASS=1 ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -j8
update_kern_ver
if [ -d output ]; then
rm -rf output
fi
mkdir -p $LICHEE_MOD_DIR
${OBJCOPY} -R .note.gnu.build-id -S -O binary vmlinux output/bImage
cp -vf arch/arm/boot/[zu]Image output/
cp .config output/
for file in $(find drivers sound crypto block fs security net -name "*.ko"); do
cp $file ${LICHEE_MOD_DIR}
done
cp -f Module.symvers modules.* ${LICHEE_MOD_DIR}
}
build_modules()
{
echo "Building modules"
}
clean_kernel()
{
make clean
rm -rf output/*
}
clean_modules()
{
echo "Cleaning modules"
}
#####################################################################
#
# Main Runtine
#
#####################################################################
LICHEE_ROOT=`(cd ${LICHEE_KDIR}/..; pwd)`
export PATH=${LICHEE_ROOT}/buildroot/output/external-toolchain/bin:$PATH
case "$1" in
kernel)
build_kernel
;;
modules)
build_modules
;;
clean)
clean_kernel
clean_modules
;;
all)
build_kernel
build_modules
;;
*)
show_help
;;
esac