forked from nulloy/nulloy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·209 lines (181 loc) · 5.98 KB
/
configure
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
#!/bin/bash
BASENAME=$(basename $0)
CWD="$(dirname $0)"
PREFIX=/usr
LIBDIR=lib
DEBUG=no
APP_NAME=nulloy
XCODE=no
FORCE_VERSION=no
BUILD_GSTREAMER=yes
BUILD_GSTREAMER_TAGREADER=no
BUILD_TAGLIB=yes
BUILD_VLC=no
BUILD_TESTS=no
UPDATE_CHECK=yes
SUPPORT_SKINS=yes
echo_err() {
echo "$BASENAME: $@" >&2
}
echo_help() {
echo "Usage: $BASENAME [options]"
echo ' --no-gstreamer do not build GStreamer plugin'
echo ' --xcode generate Xcode project (macOS only)'
echo ' --gstreamer-tagreader include TagReader in GStreamer plugin'
echo ' --vlc build VLC plugin'
echo ' --no-taglib do not build TagLib plugin'
echo ' --no-skins disable skins support'
echo ' --force-version VERSION overrides version.pri'
echo ' --no-update-check disable online check functionality'
echo ' --prefix PREFIX installation prefix (default: /usr, ignored on macOS)'
echo ' --libdir LIBDIR library directory under prefix (default: lib)'
echo ' --debug build in debug mode'
echo ' --tests build unit tests'
}
echo_try() {
echo
echo "Try \`$BASENAME --help' for more information"
}
while test $# -gt 0; do
case "$1" in
--prefix)
shift
if command -v realpath &> /dev/null && [[ -d $(dirname "$1") ]]; then
PREFIX=$(realpath "$1")
else
PREFIX=$(readlink -m "$1")
fi
;;
--xcode)
XCODE=yes ;;
--debug)
DEBUG=yes ;;
--force-version)
shift; FORCE_VERSION=$1 ;;
--no-gstreamer)
BUILD_GSTREAMER=no ;;
--gstreamer-tagreader)
BUILD_GSTREAMER_TAGREADER=yes ;;
--vlc)
BUILD_VLC=yes ;;
--no-taglib)
BUILD_TAGLIB=no ;;
--tests)
BUILD_TESTS=yes ;;
--no-skins)
SUPPORT_SKINS=no ;;
--libdir)
shift; LIBDIR=$1 ;;
--no-update-check)
UPDATE_CHECK=no ;;
--help|-h)
echo_help; exit 0 ;;
*)
echo_err "invalid argument: $1"
echo_try; exit 1
;;
esac
shift
done
QMAKE_CACHE="$CWD"/.qmake.cache
echo -n > $QMAKE_CACHE
cd "$(dirname "$0")"
PROJECT_DIR=$(pwd)
echo "PROJECT_DIR = $PROJECT_DIR" >> $QMAKE_CACHE
echo "SRC_DIR = $PROJECT_DIR/src" >> $QMAKE_CACHE
TMP_DIR="$PROJECT_DIR/tmp"
echo "TMP_DIR = $TMP_DIR" >> $QMAKE_CACHE
echo "OBJECTS_DIR = $TMP_DIR" >> $QMAKE_CACHE
echo "MOC_DIR = $TMP_DIR" >> $QMAKE_CACHE
echo "RCC_DIR = $TMP_DIR" >> $QMAKE_CACHE
echo "UI_DIR = $TMP_DIR" >> $QMAKE_CACHE
mkdir -p "$TMP_DIR"
check_executable() {
VARNAME="$1"
DEFVALUE="$2"
CURVALUE=""
OUTVALUE=""
echo -n "checking for $DEFVALUE: "
if [[ -z "${!VARNAME}" ]]; then
eval ${VARNAME}="$DEFVALUE"
fi
CURVALUE="${!VARNAME}"
if [[ ! -f "$CURVALUE" ]]; then
OUTVALUE=$(which "$CURVALUE" 2>/dev/null)
if [[ -z "$OUTVALUE" ]]; then
echo "no"
echo "$BASENAME: Unable to find \`$CURVALUE'. Check the PATH environment variable or try \`$VARNAME=/path/to/$CURVALUE $0'"
exit 1
fi
else
OUTVALUE="$CURVALUE"
fi
echo "$OUTVALUE"
}
check_executable QMAKE qmake
check_executable LRELEASE lrelease
echo "LRELEASE = $LRELEASE" >> $QMAKE_CACHE
check_executable PKG_CONFIG pkg-config
echo "PKG_CONFIG = $PKG_CONFIG" >> $QMAKE_CACHE
[[ -n "$CFLAGS" ]] && echo "QMAKE_CFLAGS += ${CFLAGS}" >> $QMAKE_CACHE
[[ -n "$CXXFLAGS" ]] && echo "QMAKE_CXXFLAGS += ${CXXFLAGS}" >> $QMAKE_CACHE
[[ -n "$LDFLAGS" ]] && echo "QMAKE_LFLAGS += ${LDFLAGS}" >> $QMAKE_CACHE
pkg_check_lib() {
for LIB in $@; do
if $PKG_CONFIG --print-errors $LIB; then
echo "Found '$LIB'"
else
echo
exit 1
fi
shift
done
}
[[ $BUILD_GSTREAMER == "yes" ]] && pkg_check_lib gstreamer-1.0
[[ $BUILD_GSTREAMER_TAGREADER == "yes" ]] && pkg_check_lib gstreamer-pbutils-1.0
[[ $BUILD_VLC == "yes" ]] && pkg_check_lib libvlc vlc-plugin
[[ $BUILD_TAGLIB == "yes" ]] && pkg_check_lib taglib
[[ $BUILD_GSTREAMER == "yes" ]] && echo "CONFIG += gstreamer" >> $QMAKE_CACHE
[[ $BUILD_GSTREAMER_TAGREADER == "yes" ]] && echo "CONFIG += gstreamer-tagreader" >> $QMAKE_CACHE
[[ $BUILD_VLC == "yes" ]] && echo "CONFIG += vlc" >> $QMAKE_CACHE
[[ $BUILD_TAGLIB == "yes" ]] && echo "CONFIG += taglib" >> $QMAKE_CACHE
[[ $SUPPORT_SKINS == "no" ]] && echo "CONFIG += no-skins" >> $QMAKE_CACHE
[[ $UPDATE_CHECK == "no" ]] && echo "CONFIG += no-update-check" >> $QMAKE_CACHE
[[ $BUILD_TESTS == "yes" ]] && echo "CONFIG += tests" >> $QMAKE_CACHE \
&& echo "DEFINES += _TESTS_" >> $QMAKE_CACHE
if [[ $DEBUG == "yes" ]]; then
echo "CONFIG += debug" >> $QMAKE_CACHE
else
echo "CONFIG += release" >> $QMAKE_CACHE
fi
if $QMAKE -query "QMAKE_XSPEC" | grep -i win; then
echo "CONFIG += unix_mingw" >> $QMAKE_CACHE
APP_NAME=Nulloy
fi
if [[ $XCODE == "yes" ]]; then
QMAKE_EXTRA_OPTIONS+=' -spec macx-xcode -recursive'
fi
echo "APP_NAME = $APP_NAME" >> $QMAKE_CACHE
echo
if [[ $FORCE_VERSION != "no" ]]; then
echo "Forced version: $FORCE_VERSION"
echo "N_CONFIG_FORCE_VERSION = $FORCE_VERSION" >> $QMAKE_CACHE
fi
if uname | grep -i -v darwin; then
echo "Install prefix: $PREFIX"
fi
echo "PREFIX = $PREFIX" >> $QMAKE_CACHE
echo "LIBDIR = $LIBDIR" >> $QMAKE_CACHE
echo "Library directory: $LIBDIR"
echo "N_CONFIG_SUCCESS = yes" >> $QMAKE_CACHE
echo
echo "Running qmake..."
if ! $QMAKE $QMAKE_EXTRA_OPTIONS; then
echo_err "qmake failed"
exit 1
fi
if [[ $XCODE == "yes" ]]; then
echo "Xcode project has been generated."
else
echo "Nulloy has been configured. Now run 'make'."
fi