forked from jyoo0515/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-linux.sh
executable file
·62 lines (44 loc) · 1.19 KB
/
build-linux.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
#!/usr/bin/env bash
# Copyright 2021 Dokyung Song. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
CONFIGS=(`basename configs/*defconfig` tinyconfig)
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage: $0 <KERNEL_SRC_DIR> <CONFIG>" >&2
echo " CONFIG: ${CONFIGS[*]}" >&2
exit 1
fi
KERNEL_SRC_DIR=$1
defconfig=csi2115_f21_defconfig
if [ ! -d $KERNEL_SRC_DIR ]; then
echo $KERNEL_SRC_DIR does not exist.
exit 1
fi
if [ $# -eq 2 ]; then
defconfig=$2
fi
BUILD_DIR=$(dirname $0)/build
mkdir -p $BUILD_DIR
IMAGE_OUT_DIR=$BUILD_DIR/linux
IMAGE_OUT_DIR=$PWD/$IMAGE_OUT_DIR
if [ ! -d $IMAGE_OUT_DIR ]; then
echo Creating $IMAGE_OUT_DIR
mkdir -p $IMAGE_OUT_DIR
fi
INSTALL_MOD_PATH=$IMAGE_OUT_DIR/modules
if [ $defconfig = "tinyconfig" ]; then
INSTALL_MOD_PATH=""
else
cp configs/${defconfig} $KERNEL_SRC_DIR/arch/x86/configs
fi
pushd $KERNEL_SRC_DIR
set -eux
export CC=gcc-8
export CXX=g++-8
make ${defconfig} O=$IMAGE_OUT_DIR/csi2115_f21
make -j8 O=$IMAGE_OUT_DIR/csi2115_f21 CC=$CC
if [ "$INSTALL_MOD_PATH" != "" ]; then
pushd $IMAGE_OUT_DIR/csi2115_f21
make modules_install INSTALL_MOD_PATH=$INSTALL_MOD_PATH
popd
fi
popd