-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild_submodules
More file actions
executable file
·213 lines (199 loc) · 5.25 KB
/
Copy pathbuild_submodules
File metadata and controls
executable file
·213 lines (199 loc) · 5.25 KB
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
#!/bin/bash
LWS=libwebsockets-3.1.0
UBUNTU_PACKAGES="build-essential cmake git libglu1-mesa-dev libgmp-dev \
libssl-dev m4 pkg-config unzip libgnutls28-dev libunistring-dev"
case $(uname) in
Linux)
NCPUS=$(fgrep processor /proc/cpuinfo | wc -l)
STATIC_LIB_OPTS="-static-libgcc -static-libstdc++"
;;
Darwin)
NCPUS=$(( $(sysctl -n hw.ncpu) + 1 ))
STATIC_LIB_OPTS=""
;;
esac
set -e
winbuild=0
do_clean=0
HOST_SUFFIX=""
if [[ "$(uname)" = Linux ]]; then
ARCH="linux-64"
else
ARCH="mac-64"
fi
while getopts "wcg:p:h" opt; do
case $opt in
w)
winbuild=1
HOST_SUFFIX="--host=x86_64-w64-mingw32"
ARCH="win-64"
;;
c)
do_clean=1
;;
g)
DO_GUI="$OPTARG"
;;
p)
INSTALL_PACKAGES="$OPTARG"
;;
h)
cat << EOF
Usage: $0 [-wcgGpP]
-w : build the submodule dependencies for a build targeting Windows
-c : remove all and clean built dependencies to do a fresh rebuild later
-g <y|n> : enable or disable building GUI dependencies.
If this argument isn't provided, the script will prompt you.
-p <y|n> : enable or disable installing Ubuntu packages.
If this argument isn't provided, the script will prompt you.
EOF
exit
;;
*)
echo "Unrecognized argument $opt. Try \"$0 -h\" for help" >&2
exit 1
;;
esac
done
if [[ "$do_clean" == 0 ]]; then
if [ -n "$DO_GUI" ]; then
REPLY="$DO_GUI"
else
echo -n "Would you like to build the GUI portions as well?" \
"[y/N] "
read
fi
if [[ "$REPLY" == "y" ]] || [[ "$REPLY" == "Y" ]]; then
BUILDGLFW=1
TARGETS="cpdlcd and FANSgui"
if [[ "$(uname)" = "Linux" ]]; then
BUILDWIN=1
else
BUILDWIN=0
fi
else
TARGETS="cpdlcd"
BUILDGLFW=0
BUILDWIN=0
fi
if [[ "$(uname)" = "Linux" ]]; then
if apt show qt4-dev-tools &> /dev/null ; then
UBUNTU_PACKAGES="$UBUNTU_PACKAGES qt4-qmake \
qt4-dev-tools"
else
UBUNTU_PACKAGES="$UBUNTU_PACKAGES qt5-qmake qt5-default"
fi
fi
if [[ "$BUILDWIN" == 1 ]]; then
UBUNTU_PACKAGES="$UBUNTU_PACKAGES autoconf automake libtool \
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev zip \
mingw-w64-x86-64-dev gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64"
fi
if [[ "$(uname)" = "Linux" ]]; then
if [ -n "$INSTALL_PACKAGES" ]; then
REPLY="$INSTALL_PACKAGES"
else
echo "---------------------------------------------------------------
The following packages are required to build $TARGETS:
$UBUNTU_PACKAGES"
echo -n "Would you like me to apt-get these for" \
"you now? [y/N] "
read
fi
if [[ "$REPLY" == "y" ]] || [[ "$REPLY" == "Y" ]]; then
sudo apt-get install $UBUNTU_PACKAGES
fi
fi
fi
# Check cmake version installed:
CMAKE_VERSION=$(cmake --version | awk '/cmake version /{print $3}')
CMAKE_VERSION_MAJOR=$(echo $CMAKE_VERSION | cut -d . -f 1)
if [ "$CMAKE_VERSION_MAJOR" -lt 3 ]; then
cat << EOF
-----------------------------------------------------------
WARNING: your cmake appears to be too old ($CMAKE_VERSION).
libcpdlc requires at least cmake version 3.0.2. You can get a newer version
from the following PPA:
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get install cmake
EOF
echo -n "Would you like to continue anyway? [y/N] "
read
if [[ "$REPLY" != "y" ]] && [[ "$REPLY" != "Y" ]]; then
exit 1
fi
fi
# Refresh & build libacfutils
if ! [ -f libacfutils/build_deps ]; then
git submodule init libacfutils && git submodule update libacfutils
fi
if [[ "$do_clean" == 0 ]]; then
if [[ "$(uname)" = "Linux" ]]; then
ACFUTILS_BUILD_SCRIPT="./build-win-lin"
NATIVE_FILE="libacfutils/qmake/lin64/libacfutils.a"
CROSS_FILE="libacfutils/qmake/lin64/libacfutils.a"
if [[ "$BUILDWIN" == 0 ]]; then
MINIMAL=""
else
MINIMAL="-m"
fi
else
ACFUTILS_BUILD_SCRIPT="./build-mac"
NATIVE_FILE="libacfutils/qmake/mac64/libacfutils.a"
fi
if [[ "$BUILDWIN" == 0 ]]; then
if ! [ -f "$NATIVE_FILE" ]; then
(
cd libacfutils && ./build_deps $MINIMAL && \
cd qmake && "${ACFUTILS_BUILD_SCRIPT}" -ilE
) || exit 1
fi
else
if ! [ -f "$NATIVE_FILE" ] || ! [ -f "$CROSS_FILE" ]; then
(
cd libacfutils && ./build_deps && cd qmake && \
"${ACFUTILS_BUILD_SCRIPT}" -E
) || exit 1
fi
fi
else
( cd libacfutils && ./build_deps -c && \
rm -rf qmake/win64 qmake/lin64 qmake/mac64 )
fi
if [[ "$BUILDGLFW" == 1 ]]; then
( cd libacfutils/glfw && ./build_glfw_deps ) || exit 1
fi
if [[ "$do_clean" == 0 ]]; then
if ! [ -d "${LWS}" ]; then
tar xJf "${LWS}.tar.xz" || exit 1
(
cd "${LWS}"
patch -p1 < ../libwebsockets-msg_nosignal.patch || exit 1
)
fi
if ! [ -f "${LWS}/lib/libwebsockets.a" ]; then
(
cd "${LWS}" && \
cmake . \
-DLWS_OPENSSL_LIBRARIES="$(pwd)/../libacfutils/ssl/openssl-$ARCH/lib" \
-DLWS_OPENSSL_INCLUDE_DIRS="$(pwd)/../libacfutils/ssl/openssl-$ARCH/include" \
-DLWS_WITH_SHARED=OFF \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITHOUT_TEST_SERVER=ON \
-DLWS_WITHOUT_TEST_SERVER_EXTPOLL=ON \
-DLWS_WITHOUT_TEST_PING=ON \
-DLWS_WITHOUT_TEST_CLIENT=ON && \
make -j ${NCPUS}
) || exit 1
fi
else
echo rm -rf "${LWS}"
rm -rf "${LWS}"
fi
./build_gnutls_deps || exit 1
if [[ "$do_clean" == 0 ]]; then
echo "---------------------------------------------------------
ALL DONE! You can now 'cd' into 'cpdlcd' and type 'make'.
---------------------------------------------------------"
fi