-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·83 lines (73 loc) · 2.29 KB
/
build.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
#!/usr/bin/env bash
# set -x
DATA_HOME="/opt/deps"
WORK_HOME="$(dirname $(readlink -f "$0"))"
source "$WORK_HOME/lib/utils.sh"
# parse args
while getopts "l:a:v:c:n:t:d:mh" OPT; do
case $OPT in
l) # load libc compile functions
if [ ! -f "$WORK_HOME/lib/build-$OPTARG.sh" ]; then
echo "$WORK_HOME/lib/build-$OPTARG.sh is not exist"
exit 1
else
source "$WORK_HOME/lib/build-$OPTARG.sh"
fi ;;
a) LIBC_ARCH="$OPTARG" ;;
v) LIBC_VERSION="$OPTARG" ;;
c) CUSTOM_CONFIG="$OPTARG" ;;
n) CUSTOM_NAME="$OPTARG" ;;
t) COMPILE_THREAD="$OPTARG" ;;
m) # compile with more debug info
CFLAGS="-g -g3 -ggdb -gdwarf-4 -Og -w"
CXXFLAGS="-g -g3 -ggdb -gdwarf-4 -Og -w"
;;
d) # download libc source code
init_libc_home
download_libc_source "$OPTARG"
clean_libc_trash "$OPTARG"
exit 0
;;
h) print_help ;;
?) print_help ;;
esac
done
### init vars
CURRENT_TIME=$(date "+%Y-%m-%d_%H:%M:%S")
LIBC_HOME="$DATA_HOME/$LIBC_FULL_NAME"
BUILD_LOG="/tmp/logs/build-$LIBC_FULL_NAME"
LOG_CONFIGURE="$BUILD_LOG/configure_$CURRENT_TIME.log"
LOG_MAKE="$BUILD_LOG/make_$CURRENT_TIME.log"
LOG_MAKE_INSTALL="$BUILD_LOG/make-install_$CURRENT_TIME.log"
CUSTOM_NAME="\"ignore this unless you set custom config (-c)\""
### check args
if [ -z "$LIBC_ARCH" ] && [[ "${LIBC_ARCH_ARRAY[@]}" =~ "$LIBC_ARCH" ]]; then
echo -e "please set LIBC_ARCH\n"
print_help
fi
if [ -z "$LIBC_VERSION" ] && [[ "${LIBC_VERSION_ARRAY[@]}" =~ "$LIBC_VERSION" ]]; then
echo -e "please set correct LIBC_VERSION\n"
print_help
fi
### init build env
init_libc_home
init_complie_args "$LIBC_ARCH"
install_complie_dependence "$LIBC_ARCH"
### print start info
print_start_info
pause
if [ -n "$LIBC_VERSION" ] && [ "$LIBC_VERSION" != "all" ]; then
echo -e "\n### compile $LIBC_VERSION ###\n"
download_libc_source "$LIBC_VERSION"
clean_libc_trash "$LIBC_VERSION"
install_libc "$LIBC_ARCH" "$LIBC_VERSION"
print_end_info
else
for LIBC_VERSION in ${LIBC_VERSION_ARRAY[@]}; do
echo -e "\n### compile $LIBC_VERSION ###\n"
download_libc_source "$LIBC_VERSION"
clean_libc_trash "$LIBC_VERSION"
install_libc "$LIBC_ARCH" "$LIBC_VERSION"
print_end_info
done
fi