forked from darktable-org/darktable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·266 lines (233 loc) · 5.07 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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/sh
DT_SRC_DIR=`dirname "$0"`
DT_SRC_DIR=`cd "$DT_SRC_DIR"; pwd`
cd $DT_SRC_DIR;
# ---------------------------------------------------------------------------
# Set default values to option vars
# ---------------------------------------------------------------------------
INSTALL_PREFIX=""
BUILD_TYPE=""
MAKE_TASKS=-1
BUILD_DIR="./build"
PRINT_HELP=0
OPT_FLICKR=-1
OPT_KWALLET=-1
OPT_GNOME_KEYRING=-1
OPT_OPENMP=-1
OPT_OPENCL=-1
OPT_UNITY=-1
OPT_TETHERING=-1
OPT_GEO=-1
OPT_LUA=-1
OPT_OPENEXR=-1
OPT_WEBP=-1
# ---------------------------------------------------------------------------
# Parse options
# ---------------------------------------------------------------------------
parse_feature()
{
feature=$1
value=$2
case $feature in
flickr)
OPT_FLICKR=$value
;;
libsecret)
OPT_LIBSECRET=$value
;;
kwallet)
OPT_KWALLET=$value
;;
gnome-keyring)
OPT_GNOME_KEYRING=$value
;;
openmp)
OPT_OPENMP=$value
;;
opencl)
OPT_OPENCL=$value
;;
unity)
OPT_UNITY=$value
;;
tethering)
OPT_TETHERING=$value
;;
lua)
OPT_LUA=$value
;;
geo)
OPT_GEO=$value
;;
openexr)
OPT_OPENEXR=$value
;;
webp)
OPT_WEBP=$value
;;
*)
echo "warning: unknown feature '$feature'"
;;
esac
}
while [ $# -ge 1 ] ; do
option="$1"
case $option in
--prefix)
INSTALL_PREFIX="$2"
shift
;;
--buildtype)
BUILD_TYPE="$2"
shift
;;
--builddir)
BUILD_DIR="$2"
shift
;;
-j|--jobs)
MAKE_TASKS="$2"
shift
;;
--enable-*)
feature=${option#--enable-}
parse_feature "$feature" 1
;;
--disable-*)
feature=${option#--disable-}
parse_feature "$feature" 0
;;
-h|--help)
PRINT_HELP=1
;;
*)
echo "warning: ignoring unknown option $option"
;;
esac
shift
done
# ---------------------------------------------------------------------------
# Process user wishes
# ---------------------------------------------------------------------------
if [ $PRINT_HELP -ne 0 ] ; then
cat <<EOF
build.sh [OPTIONS]
Options:
Installation:
--prefix <string> Install directory prefix (default: /opt/darktable)
Build:
--builddir <string> Building directory (default: $DT_SRC_DIR/build)
--buildtype <string> Build type (Release, Debug, default: Release)
-j --jobs <integer> Number of tasks (default: number of CPUs)
Features:
All these options have a --disable-* equivalent. By default they are set
so that the cmake script autodetects features.
--enable-flickr
--enable-kwallet
--enable-gnome-keyring
--enable-openmp
--enable-opencl
--enable-unity
--enable-tethering
--enable-geo
--enable-lua
--enable-openexr
--enable-webp
Extra:
-h --help Print help message
EOF
exit 1
fi
if [ "$INSTALL_PREFIX" = "" ]; then
INSTALL_PREFIX=/opt/darktable/
fi
if [ "$BUILD_TYPE" = "" ]; then
BUILD_TYPE=Release
fi
KERNELNAME=`uname -s`
# If no Make tasks given, try to be smart
if [ "$(($MAKE_TASKS < 1))" -eq 1 ]; then
if [ "$KERNELNAME" = "SunOS" ]; then
MAKE_TASKS=$( /usr/sbin/psrinfo |wc -l )
else
if [ -r /proc/cpuinfo ]; then
MAKE_TASKS=$(grep -c "^processor" /proc/cpuinfo)
elif [ -x /sbin/sysctl ]; then
TMP_CORES=$(/sbin/sysctl -n hw.ncpu 2>/dev/null)
if [ "$?" = "0" ]; then
MAKE_TASKS=$TMP_CORES
fi
fi
fi
fi
if [ "$KERNELNAME" = "SunOS" ]; then
MAKE=gmake
PATH=/usr/gnu/bin:$PATH ; export PATH
else
MAKE=make
fi
# Being smart may fail :D
if [ "$(($MAKE_TASKS < 1))" -eq 1 ]; then
MAKE_TASKS=1
fi
cmake_boolean_option()
{
name=$1
value=$2
case $value in
-1)
# Do nothing
;;
0)
CMAKE_MORE_OPTIONS="$CMAKE_MORE_OPTIONS -D${name}=Off"
;;
1)
CMAKE_MORE_OPTIONS="$CMAKE_MORE_OPTIONS -D${name}=On"
;;
esac
}
CMAKE_MORE_OPTIONS=""
cmake_boolean_option USE_FLICKR $OPT_FLICKR
cmake_boolean_option USE_LIBSECRET $OPT_LIBSECRET
cmake_boolean_option USE_KWALLET $OPT_KWALLET
cmake_boolean_option USE_GNOME_KEYRING $OPT_GNOME_KEYRING
cmake_boolean_option USE_OPENMP $OPT_OPENMP
cmake_boolean_option USE_OPENCL $OPT_OPENCL
cmake_boolean_option USE_UNITY $OPT_UNITY
cmake_boolean_option USE_CAMERA_SUPPORT $OPT_TETHERING
cmake_boolean_option USE_GEO $OPT_GEO
cmake_boolean_option USE_LUA $OPT_LUA
cmake_boolean_option USE_OPENEXR $OPT_OPENEXR
cmake_boolean_option USE_WEBP $OPT_WEBP
# Some people might need this, but ignore if unset in environment
CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-}
CMAKE_MORE_OPTIONS="${CMAKE_MORE_OPTIONS} ${CMAKE_PREFIX_PATH}"
# ---------------------------------------------------------------------------
# Let's go
# ---------------------------------------------------------------------------
cat <<EOF
Darktable build script
Building directory: $BUILD_DIR
Installation prefix: $INSTALL_PREFIX
Build type: $BUILD_TYPE
Make program: $MAKE
Make tasks: $MAKE_TASKS
EOF
if [ ! -d "$BUILD_DIR" ]; then
mkdir "$BUILD_DIR"
fi
cd "$BUILD_DIR"
cmake \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${CMAKE_MORE_OPTIONS} \
"$DT_SRC_DIR" \
&& $MAKE -j $MAKE_TASKS
if [ $? = 0 ]; then
cat <<EOF
Darktable finished building, to actually install darktable you need to type:
# cd "$BUILD_DIR"; sudo make install
EOF
else
exit 1
fi