test/configure

branch
configure-evo
changeset 52
afcb57893858
parent 51
5c12e9e29733
child 53
704368f1bb23
equal deleted inserted replaced
51:5c12e9e29733 52:afcb57893858
1 #!/bin/sh 1 #!/bin/sh
2 2
3 HOST=`uname -n` 3 # create temporary directory
4 PREFIX=`pwd`/work 4 TEMP_DIR=".tmp-$(uname -n)"
5 INSTALL_DIR=$PREFIX 5 rm -Rf "$TEMP_DIR"
6 6 if ! mkdir -p "$TEMP_DIR"; then
7 EPREFIX=$PREFIX 7 echo "Cannot create tmp dir $TEMP_DIR"
8 8 echo "Abort"
9 exit 1
10 fi
11 touch "$TEMP_DIR/options"
12 touch "$TEMP_DIR/features"
13
14 # define standard variables
15 PREFIX=/usr
16 EPREFIX=/usr
9 BINDIR= 17 BINDIR=
10 SBINDIR= 18 SBINDIR=
11 LIBDIR= 19 LIBDIR=
12 LIBEXECDIR= 20 LIBEXECDIR=
13 DATADIR= 21 DATADIR=
16 LOCALSTATEDIR= 24 LOCALSTATEDIR=
17 INCLUDEDIR= 25 INCLUDEDIR=
18 INFODIR= 26 INFODIR=
19 MANDIR= 27 MANDIR=
20 28
21 OS=`uname -s` 29 # custom variables
22 OS_VERSION=`uname -r` 30 HOST=$(uname -n)
23 31 PREFIX=$(pwd)/work
24 TEMP_DIR=".tmp-`uname -n`" 32 INSTALL_DIR=$PREFIX
25 mkdir -p "$TEMP_DIR"
26 if [ $? -ne 0 ]; then
27 echo "Cannot create tmp dir"
28 echo "Abort"
29 fi
30 touch "$TEMP_DIR/options"
31 touch "$TEMP_DIR/features"
32 33
33 # features 34 # features
34 FEATURE_PG=auto 35 FEATURE_PG=auto
36
37 # clean abort
38 abort_configure()
39 {
40 rm -Rf "$TEMP_DIR"
41 exit 1
42 }
35 43
36 # help text 44 # help text
37 printhelp() 45 printhelp()
38 { 46 {
39 echo "Usage: $0 [OPTIONS]..." 47 echo "Usage: $0 [OPTIONS]..."
81 "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;; 89 "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
82 "--localstatedir="*) LOCALSTATEDIR=${ARG#--localstatedir=} ;; 90 "--localstatedir="*) LOCALSTATEDIR=${ARG#--localstatedir=} ;;
83 "--includedir="*) INCLUDEDIR=${ARG#--includedir=} ;; 91 "--includedir="*) INCLUDEDIR=${ARG#--includedir=} ;;
84 "--infodir="*) INFODIR=${ARG#--infodir=} ;; 92 "--infodir="*) INFODIR=${ARG#--infodir=} ;;
85 "--mandir"*) MANDIR=${ARG#--mandir} ;; 93 "--mandir"*) MANDIR=${ARG#--mandir} ;;
86 "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;; 94 "--help"*) printhelp; abort_configure ;;
87 "--debug") BUILD_TYPE="debug" ;; 95 "--debug") BUILD_TYPE="debug" ;;
88 "--release") BUILD_TYPE="release" ;; 96 "--release") BUILD_TYPE="release" ;;
89 "--enable-pg") FEATURE_PG=on ;; 97 "--enable-pg") FEATURE_PG=on ;;
90 "--disable-pg") unset FEATURE_PG ;; 98 "--disable-pg") unset FEATURE_PG ;;
91 "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;; 99 "-"*) echo "unknown option: $ARG"; abort_configure ;;
92 esac 100 esac
93 done 101 done
94 102
103
95 # set dir variables 104 # set dir variables
96 if [ -z "$BINDIR" ]; then 105 BINDIR=${BINDIR:-"$EPREFIX/bin"}
97 BINDIR=$EPREFIX/bin 106 SBINDIR=${SBINDIR:-"$EPREFIX/sbin"}
98 fi 107 LIBDIR=${LIBDIR:-"$EPREFIX/lib"}
99 if [ -z "$SBINDIR" ]; then 108 LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"}
100 SBINDIR=$EPREFIX/sbin 109 DATADIR=${DATADIR:-"$PREFIX/share"}
101 fi 110 SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"}
102 if [ -z "$LIBDIR" ]; then 111 SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"}
103 LIBDIR=$EPREFIX/lib 112 LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"}
104 fi 113 INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"}
105 if [ -z "$LIBEXEC" ]; then 114 INFODIR=${INFODIR:-"$PREFIX/info"}
106 LIBEXECDIR=$EPREFIX/libexec 115 MANDIR=${MANDIR:-"$PREFIX/man"}
107 fi 116
108 if [ -z "$DATADIR" ]; then 117 # Test for availability of pkg-config
109 DATADIR=$PREFIX/share 118 PKG_CONFIG=$(command -v pkg-config)
110 fi 119 PKG_CONFIG=${PKG_CONFIG:-"false"}
111 if [ -z "$SYSCONFDIR" ]; then
112 SYSCONFDIR=$PREFIX/etc
113 fi
114 if [ -z "$SHAREDSTATEDIR" ]; then
115 SHAREDSTATEDIR=$PREFIX/com
116 fi
117 if [ -z "$LOCALSTATEDIR" ]; then
118 LOCALSTATEDIR=$PREFIX/var
119 fi
120 if [ -z "$INCLUDEDIR" ]; then
121 INCLUDEDIR=$PREFIX/include
122 fi
123 if [ -z "$INFODIR" ]; then
124 INFODIR=$PREFIX/info
125 fi
126 if [ -z "$MANDIR" ]; then
127 MANDIR=$PREFIX/man
128 fi
129
130 which pkg-config > /dev/null
131 if [ $? -eq 0 ]; then
132 PKG_CONFIG=pkg-config
133 else
134 PKG_CONFIG=false
135 fi
136 120
137 # Simple uname based platform detection 121 # Simple uname based platform detection
138 # $PLATFORM is used for platform dependent dependency selection 122 # $PLATFORM is used for platform dependent dependency selection
123 OS=$(uname -s)
124 OS_VERSION=$(uname -r)
139 printf "detect platform... " 125 printf "detect platform... "
140 if [ "$OS" = "SunOS" ]; then 126 if [ "$OS" = "SunOS" ]; then
141 PLATFORM="solaris sunos unix svr4" 127 PLATFORM="solaris sunos unix svr4"
142 fi 128 fi
143 if [ "$OS" = "Linux" ]; then 129 if [ "$OS" = "Linux" ]; then
147 PLATFORM="freebsd bsd unix" 133 PLATFORM="freebsd bsd unix"
148 fi 134 fi
149 if [ "$OS" = "Darwin" ]; then 135 if [ "$OS" = "Darwin" ]; then
150 PLATFORM="macos osx bsd unix" 136 PLATFORM="macos osx bsd unix"
151 fi 137 fi
152 echo "$OS" | grep -i "MINGW" > /dev/null 138 if echo "$OS" | grep -i "MINGW" > /dev/null; then
153 if [ $? -eq 0 ]; then
154 PLATFORM="windows mingw" 139 PLATFORM="windows mingw"
155 fi 140 fi
156 141 PLATFORM=${PLATFORM:-"unix"}
157 if [ -z "$PLATFORM" ]; then 142
158 PLATFORM="unix" 143 PLATFORM_NAME=$(echo "$PLATFORM" | cut -f1 -d' ' -)
159 fi 144 echo "$PLATFORM_NAME"
160
161 for p in $PLATFORM
162 do
163 PLATFORM_NAME=$p
164 break
165 done
166 echo $PLATFORM_NAME
167 145
168 isplatform() 146 isplatform()
169 { 147 {
170 for p in $PLATFORM 148 for p in $PLATFORM
171 do 149 do
173 return 0 151 return 0
174 fi 152 fi
175 done 153 done
176 return 1 154 return 1
177 } 155 }
178 isnotplatform() 156
179 { 157
180 for p in $PLATFORM 158 # generate config.mk
181 do 159 cat > "$TEMP_DIR/vars.mk" << __EOF__
182 if [ "$p" = "$1" ]; then
183 return 1
184 fi
185 done
186 return 0
187 }
188
189 # generate config.mk and config.h
190 cat > "$TEMP_DIR/config.mk" << __EOF__
191 #
192 # config.mk generated by configure
193 #
194
195 # general vars
196 HOST=$HOST
197 PREFIX=$PREFIX 160 PREFIX=$PREFIX
198 INSTALL_DIR=$INSTALL_DIR
199
200 EPREFIX=$EPREFIX 161 EPREFIX=$EPREFIX
201
202 BINDIR=$BINDIR 162 BINDIR=$BINDIR
203 SBINDIR=$SBINDIR 163 SBINDIR=$SBINDIR
204 LIBDIR=$LIBDIR 164 LIBDIR=$LIBDIR
205 LIBEXECDIR=$LIBEXECDIR 165 LIBEXECDIR=$LIBEXECDIR
206 DATADIR=$DATADIR 166 DATADIR=$DATADIR
208 SHAREDSTATEDIR=$SHAREDSTATEDIR 168 SHAREDSTATEDIR=$SHAREDSTATEDIR
209 LOCALSTATEDIR=$LOCALSTATEDIR 169 LOCALSTATEDIR=$LOCALSTATEDIR
210 INCLUDEDIR=$INCLUDEDIR 170 INCLUDEDIR=$INCLUDEDIR
211 INFODIR=$INFODIR 171 INFODIR=$INFODIR
212 MANDIR=$MANDIR 172 MANDIR=$MANDIR
213 173 HOST=$HOST
174 PREFIX=$PREFIX
175 INSTALL_DIR=$INSTALL_DIR
214 __EOF__ 176 __EOF__
215 177 cat > "$TEMP_DIR/config.mk" << __EOF__
216 echo > "$TEMP_DIR/make.mk" 178 #
217 179 # config.mk generated by configure
218 ENV_CFLAGS=$CFLAGS 180 #
219 ENV_LDFLAGS=$LDFLAGS 181 __EOF__
220 ENV_CXXFLAGS=$CXXFLAGS 182 sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk"
221 183
222 # Toolchain detection 184
185 # toolchain detection
223 # this will insert make vars to config.mk 186 # this will insert make vars to config.mk
224 . make/toolchain.sh 187 . make/toolchain.sh
225 188 if [ -n "$TOOLCHAIN_ERROR" ]; then
226 # add user specified flags to config.mk 189 echo "Toolchain error: $TOOLCHAIN_ERROR"
227 echo "# project specific flags" >> "$TEMP_DIR/config.mk" 190 echo "Abort."
228 if [ -n "${ENV_CFLAGS}" ]; then 191 abort_configure
229 echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
230 fi
231 if [ -n "${ENV_CXXFLAGS}" ]; then
232 echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
233 fi
234 if [ -n "${ENV_LDFLAGS}" ]; then
235 echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
236 fi 192 fi
237 193
238 # 194 #
239 # DEPENDENCIES 195 # DEPENDENCIES
240 # 196 #
197
198 # create buffer for make variables required by dependencies
199 echo > "$TEMP_DIR/make.mk"
241 200
242 dependency_libpq() 201 dependency_libpq()
243 { 202 {
244 printf "checking for libpq... " 203 printf "checking for libpq... "
245 # dependency libpq 204 # dependency libpq
246 while true 205 while true
247 do 206 do
248 if [ -z "$PKG_CONFIG" ]; then 207 if [ -z "$PKG_CONFIG" ]; then
249 break 208 break
250 fi 209 fi
251 $PKG_CONFIG libpq 210 if ! $PKG_CONFIG libpq ; then
252 if [ $? -ne 0 ] ; then 211 break
253 break 212 fi
254 fi 213 TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libpq)"
255 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libpq`" 214 TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libpq)"
256 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libpq`"
257 echo yes 215 echo yes
258 return 0 216 return 0
259 done 217 done
260 218
261 echo no 219 echo no
268 while true 226 while true
269 do 227 do
270 if [ -z "$PKG_CONFIG" ]; then 228 if [ -z "$PKG_CONFIG" ]; then
271 break 229 break
272 fi 230 fi
273 $PKG_CONFIG openssl 231 if ! $PKG_CONFIG openssl ; then
274 if [ $? -ne 0 ] ; then 232 break
275 break 233 fi
276 fi 234 TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags openssl)"
277 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags openssl`" 235 TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs openssl)"
278 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs openssl`"
279 echo yes 236 echo yes
280 return 0 237 return 0
281 done 238 done
282 239
283 # dependency openssl platform="bsd" 240 # dependency openssl platform="bsd"
284 while true 241 while true
285 do 242 do
286 if isnotplatform "bsd"; then 243 if ! isplatform "bsd"; then
287 break 244 break
288 fi 245 fi
289 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" 246 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
290 echo yes 247 echo yes
291 return 0 248 return 0
298 { 255 {
299 printf "checking for libxml2... " 256 printf "checking for libxml2... "
300 # dependency libxml2 platform="macos" 257 # dependency libxml2 platform="macos"
301 while true 258 while true
302 do 259 do
303 if isnotplatform "macos"; then 260 if ! isplatform "macos"; then
304 break 261 break
305 fi 262 fi
306 xml2-config --cflags > /dev/null 263 if tmp_flags=$(xml2-config --cflags) ; then
307 if [ $? -eq 0 ]; then 264 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
308 TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
309 else 265 else
310 break 266 break
311 fi 267 fi
312 xml2-config --libs > /dev/null 268 if tmp_flags=$(xml2-config --libs) ; then
313 if [ $? -eq 0 ]; then 269 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
314 TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
315 else 270 else
316 break 271 break
317 fi 272 fi
318 echo yes 273 echo yes
319 return 0 274 return 0
323 while true 278 while true
324 do 279 do
325 if [ -z "$PKG_CONFIG" ]; then 280 if [ -z "$PKG_CONFIG" ]; then
326 break 281 break
327 fi 282 fi
328 $PKG_CONFIG libxml-2.0 283 if ! $PKG_CONFIG libxml-2.0 ; then
329 if [ $? -ne 0 ] ; then 284 break
330 break 285 fi
331 fi 286 TEMP_CFLAGS="$TEMP_CFLAGS $("$PKG_CONFIG" --cflags libxml-2.0)"
332 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libxml-2.0`" 287 TEMP_LDFLAGS="$TEMP_LDFLAGS $("$PKG_CONFIG" --libs libxml-2.0)"
333 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libxml-2.0`"
334 echo yes 288 echo yes
335 return 0 289 return 0
336 done 290 done
337 291
338 echo no 292 echo no
339 return 1 293 return 1
340 } 294 }
341 295
342 DEPENDENCIES_FAILED= 296 DEPENDENCIES_FAILED=
343 ERROR=0 297 ERROR=0
344 # general dependencies 298 # unnamed dependencies
345 TEMP_CFLAGS= 299 TEMP_CFLAGS=
346 TEMP_LDFLAGS= 300 TEMP_LDFLAGS=
347 while true 301 while true
348 do 302 do
349 while true 303 while true
350 do 304 do
351 305
352
353 break 306 break
354 done 307 done
355
356 break 308 break
357 done 309 done
358 310
359 # add general dependency flags to config.mk 311 # add unnamed dependency flags to config.mk
360 echo >> "$TEMP_DIR/config.mk" 312 echo >> "$TEMP_DIR/config.mk"
361 if [ -n "${TEMP_CFLAGS}" ]; then 313 if [ -n "${TEMP_CFLAGS}" ]; then
362 echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk 314 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
363 fi
364 if [ -n "${TEMP_CXXFLAGS}" ]; then
365 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
366 fi 315 fi
367 if [ -n "${TEMP_LDFLAGS}" ]; then 316 if [ -n "${TEMP_LDFLAGS}" ]; then
368 echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk 317 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
369 fi 318 fi
370 319
371 # 320 #
372 # OPTION VALUES 321 # OPTION VALUES
373 # 322 #
374 323
375 # 324 #
376 # TARGETS 325 # TARGETS
377 # 326 #
378 TEMP_CFLAGS=
379 TEMP_CXXFLAGS=
380 TEMP_LDFLAGS=
381 327
382 # Target 328 # Target
383 TEMP_CFLAGS= 329 TEMP_CFLAGS=
384 TEMP_LDFLAGS= 330 TEMP_LDFLAGS=
385 TEMP_CXXFLAGS= 331
386 332 if ! dependency_libxml2; then
387 dependency_libxml2
388 if [ $? -ne 0 ]; then
389 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 " 333 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
390 ERROR=1 334 ERROR=1
391 fi 335 fi
392 dependency_openssl 336 if ! dependency_openssl; then
393 if [ $? -ne 0 ]; then
394 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl " 337 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
395 ERROR=1 338 ERROR=1
396 fi 339 fi
397 340
398 # Features 341 # Features
399 if [ -n "$FEATURE_PG" ]; then 342 if [ -n "$FEATURE_PG" ]; then
400 # check dependency 343 # check dependency
401 dependency_libpq 344 if ! dependency_libpq ; then
402 if [ $? -ne 0 ]; then
403 # "auto" features can fail and are just disabled in this case 345 # "auto" features can fail and are just disabled in this case
404 if [ "$FEATURE_PG" != "auto" ]; then 346 if [ "$FEATURE_PG" = "auto" ]; then
347 unset FEATURE_PG
348 else
405 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq " 349 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
406 ERROR=1 350 ERROR=1
407 else
408 unset FEATURE_PG
409 fi 351 fi
410 fi 352 fi
411 fi 353 fi
412 354
413 355
414 echo >> "$TEMP_DIR/config.mk" 356 echo >> "$TEMP_DIR/config.mk"
415 if [ -n "${TEMP_CFLAGS}" ]; then 357 if [ -n "${TEMP_CFLAGS}" ]; then
416 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk" 358 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
417 fi 359 fi
418 if [ -n "${TEMP_CXXFLAGS}" ]; then
419 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
420 fi
421 if [ "$BUILD_TYPE" = "debug" ]; then 360 if [ "$BUILD_TYPE" = "debug" ]; then
422 echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk" 361 echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
423 echo 'CXXFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
424 fi 362 fi
425 if [ "$BUILD_TYPE" = "release" ]; then 363 if [ "$BUILD_TYPE" = "release" ]; then
426 echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk" 364 echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
427 echo 'CXXFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
428 fi 365 fi
429 if [ -n "${TEMP_LDFLAGS}" ]; then 366 if [ -n "${TEMP_LDFLAGS}" ]; then
430 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk" 367 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
431 fi 368 fi
432 369
433 if [ $ERROR -ne 0 ]; then 370 if [ $ERROR -ne 0 ]; then
434 echo 371 echo
435 echo "Error: Unresolved dependencies" 372 echo "Error: Unresolved dependencies"
436 echo "$DEPENDENCIES_FAILED" 373 echo "$DEPENDENCIES_FAILED"
437 rm -Rf "$TEMP_DIR" 374 abort_configure
438 exit 1
439 fi 375 fi
440 376
441 echo "configure finished" 377 echo "configure finished"
442 echo 378 echo
443 echo "Build Config:" 379 echo "Build Config:"

mercurial