Skip to content
Newer
Older
100755 245 lines (211 sloc) 4.76 KB
9cb1755 @houz Helper script for building darktable
houz authored Nov 28, 2010
1 #!/bin/sh
2
d53c6dc @houz Always create build/ inside of dt's source dir
houz authored Dec 8, 2010
3 DT_SRC_DIR=`dirname "$0"`
4 DT_SRC_DIR=`cd "$DT_SRC_DIR"; pwd`
5
6 cd $DT_SRC_DIR;
7
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
8 # ---------------------------------------------------------------------------
9 # Set default values to option vars
10 # ---------------------------------------------------------------------------
11
12 INSTALL_PREFIX=""
13 BUILD_TYPE=""
14 MAKE_TASKS=-1
15 BUILD_DIR="./build"
16
17 PRINT_HELP=0
18
19 OPT_FLICKR=-1
20 OPT_KWALLET=-1
21 OPT_GNOME_KEYRING=-1
22 OPT_OPENMP=-1
23 OPT_OPENCL=-1
24 OPT_UNITY=-1
25 OPT_TETHERING=-1
26 OPT_EXPERIMENTAL_IOP=-1
27
28 # ---------------------------------------------------------------------------
29 # Parse options
30 # ---------------------------------------------------------------------------
31
32 parse_feature()
33 {
34 feature=$1
35 value=$2
36
37 case $feature in
38 flickr)
39 OPT_FLICKR=$value
40 ;;
41 kwallet)
42 OPT_KWALLET=$value
43 ;;
44 gnome-keyring)
45 OPT_GNOME_KEYRING=$value
46 ;;
47 openmp)
48 OPT_OPENMP=$value
49 ;;
50 opencl)
51 OPT_OPENCL=$value
52 ;;
53 unity)
54 OPT_UNITY=$value
55 ;;
56 tethering)
57 OPT_TETHERING=$value
58 ;;
59 experimental)
60 OPT_EXPERIMENTAL_IOP=$value
61 ;;
62 *)
63 echo "warning: unknown feature '$feature'"
64 ;;
65 esac
66 }
67
68 while [ $# -ge 1 ] ; do
69 option="$1"
70 case $option in
71 --prefix)
72 INSTALL_PREFIX="$2"
73 shift
74 ;;
75 --buildtype)
76 BUILD_TYPE="$2"
77 shift
78 ;;
79 --builddir)
80 BUILD_DIR="$2"
81 shift
82 ;;
83 -j|--jobs)
84 MAKE_TASKS="$2"
85 shift
86 ;;
87 --enable-*)
88 feature=${option#--enable-}
89 parse_feature "$feature" 1
90 ;;
91 --disable-*)
92 feature=${option#--disable-}
93 parse_feature "$feature" 0
94 ;;
95 -h|--help)
96 PRINT_HELP=1
97 ;;
98 *)
99 echo "warning: ignoring unknown option $option"
100 ;;
101 esac
102 shift
103 done
104
105 # ---------------------------------------------------------------------------
106 # Process user wishes
107 # ---------------------------------------------------------------------------
108
109 if [ $PRINT_HELP -ne 0 ] ; then
110 cat <<EOF
111 build.sh [OPTIONS]
112
113 Options:
114 Installation:
115 --prefix <string> Install directory prefix (default: /opt/darktable)
116
117 Build:
118 --builddir <string> Building directory (default: $DT_SRC_DIR/build)
119 --buildtype <string> Build type (Release, Debug, default: Release)
120 -j --jobs <integer> Number of tasks (default: number of CPUs)
121
122 Features:
123 All these options have a --disable-* equivalent. By default they are set
124 so that the cmake script autodetects features.
125 --enable-flickr
126 --enable-kwallet
127 --enable-gnome-keyring
128 --enable-openmp
129 --enable-opencl
130 --enable-unity
131 --enable-tethering
132 --enable-experimental
133
134 Extra:
135 -h --help Print help message
136 EOF
137 exit 1
138 fi
139
9cb1755 @houz Helper script for building darktable
houz authored Nov 28, 2010
140 if [ "$INSTALL_PREFIX" = "" ]; then
cdb66c0 @pmjdebruijn Install into /opt/darktable by default
pmjdebruijn authored Feb 20, 2011
141 INSTALL_PREFIX=/opt/darktable/
9cb1755 @houz Helper script for building darktable
houz authored Nov 28, 2010
142 fi
143
144 if [ "$BUILD_TYPE" = "" ]; then
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
145 BUILD_TYPE=Release
9cb1755 @houz Helper script for building darktable
houz authored Nov 28, 2010
146 fi
147
196aae3 Improve tag suggestion query speed Remove erroneous comparison from d…
James C. McPherson authored May 27, 2012
148 KERNELNAME=`uname -s`
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
149 # If no Make tasks given, try to be smart
150 if [ "$(($MAKE_TASKS < 1))" -eq 1 ]; then
196aae3 Improve tag suggestion query speed Remove erroneous comparison from d…
James C. McPherson authored May 26, 2012
151 if [ "$KERNELNAME" = "SunOS" ]; then
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
152 MAKE_TASKS=$( /usr/sbin/psrinfo |wc -l )
153 else
154 if [ -r /proc/cpuinfo ]; then
155 MAKE_TASKS=$(grep -c "^processor" /proc/cpuinfo)
156 elif [ -x /sbin/sysctl ]; then
157 TMP_CORES=$(/sbin/sysctl -n hw.ncpu 2>/dev/null)
158 if [ "$?" = "0" ]; then
159 MAKE_TASKS=$TMP_CORES
160 fi
af6aa6b Update build.sh to provide easier build experience for Solaris 11 Add…
James C. McPherson authored Mar 7, 2012
161 fi
58f81bb @houz Fix detection of CPU cores on FreeBSD
houz authored Jan 2, 2011
162 fi
163 fi
9cb1755 @houz Helper script for building darktable
houz authored Nov 28, 2010
164
196aae3 Improve tag suggestion query speed Remove erroneous comparison from d…
James C. McPherson authored May 26, 2012
165 if [ "$KERNELNAME" = "SunOS" ]; then
166 MAKE=gmake
167 PATH=/usr/gnu/bin:$PATH ; export PATH
168 else
169 MAKE=make
170 fi
171
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
172 # Being smart may fail :D
2ec2edc @houz Forgot to use the cpu number in the make call ...
houz authored Jan 7, 2011
173 if [ "$(($MAKE_TASKS < 1))" -eq 1 ]; then
174 MAKE_TASKS=1
175 fi
176
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
177 cmake_boolean_option()
178 {
179 name=$1
180 value=$2
181 case $value in
182 -1)
183 # Do nothing
184 ;;
185 0)
186 CMAKE_MORE_OPTIONS="$CMAKE_MORE_OPTIONS -D${name}=Off"
187 ;;
188 1)
189 CMAKE_MORE_OPTIONS="$CMAKE_MORE_OPTIONS -D${name}=On"
190 ;;
191 esac
192 }
193
194 CMAKE_MORE_OPTIONS=""
195 cmake_boolean_option USE_FLICKR $OPT_FLICKR
196 cmake_boolean_option USE_KWALLET $OPT_KWALLET
197 cmake_boolean_option USE_GNOME_KEYRING $OPT_GNOME_KEYRING
198 cmake_boolean_option USE_OPENMP $OPT_OPENMP
199 cmake_boolean_option USE_OPENCL $OPT_OPENCL
200 cmake_boolean_option USE_UNITY $OPT_UNITY
201 cmake_boolean_option USE_CAMERA_SUPPORT $OPT_TETHERING
202 cmake_boolean_option INSTALL_IOP_EXPERIMENTAL $OPT_EXPERIMENTAL_IOP
203
0021329 Small tweaks to lensfun and OpenEXR configuration discovery
James C. McPherson authored Jul 17, 2012
204 # Some people might need this, but ignore if unset in environment
205 CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-}
206 CMAKE_MORE_OPTIONS="${CMAKE_MORE_OPTIONS} ${CMAKE_PREFIX_PATH}"
207
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
208 # ---------------------------------------------------------------------------
209 # Let's go
210 # ---------------------------------------------------------------------------
211
212 cat <<EOF
213 Darktable build script
214
215 Building directory: $BUILD_DIR
216 Installation prefix: $INSTALL_PREFIX
217 Build type: $BUILD_TYPE
218 Make program: $MAKE
219 Make tasks: $MAKE_TASKS
220
221
222 EOF
223
224 if [ ! -d "$BUILD_DIR" ]; then
225 mkdir "$BUILD_DIR"
226 fi
227
228 cd "$BUILD_DIR"
229
230 cmake \
231 -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
232 -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
0021329 Small tweaks to lensfun and OpenEXR configuration discovery
James C. McPherson authored Jul 17, 2012
233 ${CMAKE_MORE_OPTIONS} \
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
234 "$DT_SRC_DIR" \
235 && $MAKE -j $MAKE_TASKS
48e9b73 @pmjdebruijn Don't install by default
pmjdebruijn authored Feb 20, 2011
236
ef43f84 @christte Only display "build successful" when build completed successfully.
christte authored Apr 10, 2011
237 if [ $? = 0 ]; then
88016dc @edgomez build: revamp build script for easier configuration
edgomez authored May 18, 2012
238 cat <<EOF
239 Darktable finished building, to actually install darktable you need to type:
240 # cd "$BUILD_DIR"; sudo make install
241 EOF
4e215d0 @KostyaSha Added exit code on fail.
KostyaSha authored Jul 22, 2012
242 else
243 exit 1
ef43f84 @christte Only display "build successful" when build completed successfully.
christte authored Apr 10, 2011
244 fi
Something went wrong with that request. Please try again.