forked from blt4linux/blt4l
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·128 lines (99 loc) · 3.5 KB
/
install.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
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
SCR_HOME=$(dirname "$(readlink -f $0)")
source $SCR_HOME/installer/framework.sh
STEAM_BASE=${STEAM_BASE:-$HOME/.steam/steam}
# Set STEAM_LIBRARY to sane default *if unset*
STEAM_LIBRARY=${STEAM_LIBRARY:-$STEAM_BASE}
###############################################################################
# Pre-Install
# - Check Source Tree
# - Check System Packages
# - Check Steam
###############################################################################
## Update submodules if git repo
if git rev-parse --git-dir >/dev/null 2>&1; then
logf "Updating submodules: "
if git submodule update --init --recursive >/dev/null 2>&1; then
log $_c_success"OK"$_c_normal
else
log $_c_fail"Failed (git: $?)"$_c_normal
exit
fi
else
logf $_c_fail"It looks like BLT wasn't cloned from Git. Be sure SubHook and the Lua are present!"
fi
## Build check
check_file "$SCR_HOME/CMakeLists.txt" || exit
## System deps check
MISSING_PKGS=()
WANTED_PKGS=()
case $DISTRIB_ID in
Arch|ManjaroLinux)
WANTED_PKGS=(curl zlib glibc base-devel cmake)
;;
Debian|Ubuntu|LinuxMint)
WANTED_PKGS=(libcurl4-openssl-dev zlib1g-dev cmake build-essential)
;;
*)
log $_c_note"Note: No package list for $DISTRIB_ID"$_c_normal
;;
esac
for pk in ${WANTED_PKGS[@]}; do
if ! dist_check_package $pk; then
MISSING_PKGS+=$pk
fi
done
if [ ${#MISSING_PKGS} -gt 1 ]; then
logf $_c_note"You are missing packages. Do you want to install them now? [Y/n]: "
read yn
if [ x$yn != "xn" ]; then
dist_install_packages ${MISSING_PKGS[@]}
else
log $_c_warn"Continuing without installing packages"$_c_normal
fi
fi
## Game/Steam
PD2_DATA="$(__locate_payday2_dir)" || exit $?
STEAM_USERCONFIG="$(__locate_userconfig)" || exit $?
###############################################################################
# Build
###############################################################################
_CMAKE_CFLAGS="-march=native -mtune=native"
_CMAKE_CXXFLAGS=$_CMAKE_CFLAGS
_CMAKE_PROJECT_OPTS=""
logf $_c_note"Would you like to build against libc++? Clang and libc++ must be installed already. [Y/n]: "
read _libcxx_yn
if [ x$_libcxx_yn != "xn" ]; then
_CMAKE_PROJECT_OPTS="$_CMAKE_PROJECT_OPTS -DUSE_LIBCXX=ON"
fi
_CMAKE_COMMAND="cmake $_CMAKE_PROJECT_OPTS '$SCR_HOME/CMakeLists.txt' -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='$_CMAKE_CXXFLAGS' -DCMAKE_C_FLAGS='$_CMAKE_CFLAGS'"
echo $_c_normal$_CMAKE_COMMAND
_CMAKE_LOGFILE=installer_cmake.log
_MAKE_LOGFILE=installer_make.log
BUILD_DIR=$SCR_HOME/installer_build
if check_file $BUILD_DIR; then
rm -r $BUILD_DIR
fi
mkdir $BUILD_DIR
cd $BUILD_DIR
logf "Running CMake: "
if ! eval $_CMAKE_COMMAND -B$BUILD_DIR >$PWD/$_CMAKE_LOGFILE 2>&1
then
log $_c_fail"Failed"$_c_normal
log $_c_note"Please see the CMake log at "$(realpath "$PWD/$_CMAKE_LOGFILE")$_c_normal
exit $_cmake_status
else
log $_c_success"OK"$_c_normal
logf $_c_normal"Building BLT: "$_c_normal
if ! make >$PWD/$_MAKE_LOGFILE 2>&1; then
log $_c_fail"Failed"
log $_c_note"Please see the Make log at "$(realpath "$PWD/$_MAKE_LOGFILE")$_c_normal
exit $_make_status
else
log $_c_success"OK"$_c_normal
fi
fi
install_artifact "loader" "$BUILD_DIR/libblt_loader.so" "$PD2_DATA/libblt_loader.so" || exit 1
install_artifact "lua base" "$SCR_HOME/lua/mods" "$PD2_DATA/mods" noupdate || exit 1
__modify_userconfig $STEAM_USERCONFIG
# vim: set ts=4 softtabstop=0 sw=4 expandtab: