test/configure

changeset 67
e43d30273f74
parent 66
dc758dcd4645
child 68
c997c0978665
equal deleted inserted replaced
66:dc758dcd4645 67:e43d30273f74
27 INCLUDEDIR= 27 INCLUDEDIR=
28 INFODIR= 28 INFODIR=
29 MANDIR= 29 MANDIR=
30 30
31 # custom variables 31 # custom variables
32 HOST=`uname -n`
33 PREFIX=`pwd`/work
34 INSTALL_DIR=$PREFIX
32 35
33 # features 36 # features
34 FEATURE_DB=auto 37 FEATURE_PG=auto
35 38
36 # clean abort 39 # clean abort
37 abort_configure() 40 abort_configure()
38 { 41 {
39 rm -Rf "$TEMP_DIR" 42 rm -Rf "$TEMP_DIR"
62 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 65 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
63 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 66 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
64 --infodir=DIR info documentation [DATAROOTDIR/info] 67 --infodir=DIR info documentation [DATAROOTDIR/info]
65 --mandir=DIR man documentation [DATAROOTDIR/man] 68 --mandir=DIR man documentation [DATAROOTDIR/man]
66 69
67 Options:
68 --debug add extra compile flags for debug builds
69 --release add extra compile flags for release builds
70 --toolkit=(gtk3|cli|gtk2|wpf)
71
72 Optional Features: 70 Optional Features:
73 --disable-db 71 --disable-pg
74 --enable-gui
75 72
76 __EOF__ 73 __EOF__
77 } 74 }
78 75
79 # 76 #
97 "--infodir="*) INFODIR=${ARG#--infodir=} ;; 94 "--infodir="*) INFODIR=${ARG#--infodir=} ;;
98 "--mandir"*) MANDIR=${ARG#--mandir} ;; 95 "--mandir"*) MANDIR=${ARG#--mandir} ;;
99 "--help"*) printhelp; abort_configure ;; 96 "--help"*) printhelp; abort_configure ;;
100 "--debug") BUILD_TYPE="debug" ;; 97 "--debug") BUILD_TYPE="debug" ;;
101 "--release") BUILD_TYPE="release" ;; 98 "--release") BUILD_TYPE="release" ;;
102 "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;; 99 "--enable-pg") FEATURE_PG=on ;;
103 "--enable-db") FEATURE_DB=on ;; 100 "--disable-pg") unset FEATURE_PG ;;
104 "--disable-db") unset FEATURE_DB ;;
105 "--enable-gui") FEATURE_GUI=on ;;
106 "--disable-gui") unset FEATURE_GUI ;;
107 "-"*) echo "unknown option: $ARG"; abort_configure ;; 101 "-"*) echo "unknown option: $ARG"; abort_configure ;;
108 esac 102 esac
109 done 103 done
110 104
111 105
186 SHAREDSTATEDIR=$SHAREDSTATEDIR 180 SHAREDSTATEDIR=$SHAREDSTATEDIR
187 LOCALSTATEDIR=$LOCALSTATEDIR 181 LOCALSTATEDIR=$LOCALSTATEDIR
188 INCLUDEDIR=$INCLUDEDIR 182 INCLUDEDIR=$INCLUDEDIR
189 INFODIR=$INFODIR 183 INFODIR=$INFODIR
190 MANDIR=$MANDIR 184 MANDIR=$MANDIR
185 HOST=$HOST
186 PREFIX=$PREFIX
187 INSTALL_DIR=$INSTALL_DIR
191 __EOF__ 188 __EOF__
192 sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk" 189 sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
193 190
194 191
195 # toolchain detection utilities 192 # toolchain detection utilities
196 . make/toolchain.sh 193 . make/toolchain.sh
197 194
198 # 195 #
199 # DEPENDENCIES 196 # DEPENDENCIES
200 # 197 #
198
199 # check languages
200 lang_c=
201 lang_cpp=
202 if detect_c_compiler ; then
203 lang_c=1
204 fi
205 if detect_cpp_compiler ; then
206 lang_cpp=1
207 fi
201 208
202 # create buffer for make variables required by dependencies 209 # create buffer for make variables required by dependencies
203 echo > "$TEMP_DIR/make.mk" 210 echo > "$TEMP_DIR/make.mk"
204 211
205 test_pkg_config() 212 test_pkg_config()
213 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : 220 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
214 else return 1 ; fi 221 else return 1 ; fi
215 return 0 222 return 0
216 } 223 }
217 224
218 dependency_error_qt4() 225 dependency_error_cpp()
219 { 226 {
220 printf "checking for qt4... " 227 printf "checking for cpp... "
221 # dependency qt4 228 # dependency cpp
222 while true 229 while true
223 do 230 do
224 if which qmake-qt4 > /dev/null ; then 231 if [ -z "$lang_cpp" ] ; then
225 : 232 break
233 fi
234 echo yes
235 return 1
236 done
237
238 echo no
239 return 0
240 }
241 dependency_error_libpq()
242 {
243 printf "checking for libpq... "
244 # dependency libpq
245 while true
246 do
247 if [ -z "$PKG_CONFIG" ]; then
248 break
249 fi
250 if test_pkg_config "libpq" "" "" "" ; then
251 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libpq`"
252 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libpq`"
226 else 253 else
227 break 254 break
228 fi 255 fi
229 echo yes 256 echo yes
230 return 1 257 return 1
231 done 258 done
232 259
233 echo no 260 echo no
234 return 0 261 return 0
235 } 262 }
236 dependency_error_curl() 263 dependency_error_openssl()
237 { 264 {
238 printf "checking for curl... " 265 printf "checking for openssl... "
239 # dependency curl platform="windows" 266 # dependency openssl
240 while true 267 while true
241 do 268 do
242 if notisplatform "windows"; then 269 if [ -z "$lang_c" ] ; then
243 break 270 break
244 fi 271 fi
245 TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include" 272 if [ -z "$PKG_CONFIG" ]; then
246 TEMP_LDFLAGS="$TEMP_LDFLAGS -lcurl" 273 break
247 echo yes 274 fi
248 return 1 275 if test_pkg_config "openssl" "" "" "" ; then
249 done 276 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
250 277 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
251 # dependency curl platform="macos" 278 else
279 break
280 fi
281 echo yes
282 return 1
283 done
284
285 # dependency openssl platform="bsd"
286 while true
287 do
288 if notisplatform "bsd"; then
289 break
290 fi
291 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
292 echo yes
293 return 1
294 done
295
296 echo no
297 return 0
298 }
299 dependency_error_libxml2()
300 {
301 printf "checking for libxml2... "
302 # dependency libxml2 platform="macos"
252 while true 303 while true
253 do 304 do
254 if notisplatform "macos"; then 305 if notisplatform "macos"; then
255 break 306 break
256 fi 307 fi
257 if tmp_flags=`curl-config --cflags` ; then 308 if tmp_flags=`xml2-config --cflags` ; then
258 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" 309 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
259 else 310 else
260 break 311 break
261 fi 312 fi
262 if tmp_flags=`curl-config --ldflags` ; then 313 if tmp_flags=`xml2-config --libs` ; then
263 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" 314 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
264 else 315 else
265 break 316 break
266 fi 317 fi
267 echo yes 318 echo yes
268 return 1 319 return 1
269 done 320 done
270 321
271 # dependency curl 322 # dependency libxml2
272 while true 323 while true
273 do 324 do
325 if [ -z "$lang_c" ] ; then
326 break
327 fi
274 if [ -z "$PKG_CONFIG" ]; then 328 if [ -z "$PKG_CONFIG" ]; then
275 break 329 break
276 fi 330 fi
277 if test_pkg_config "libcurl" "" "" "" ; then 331 if test_pkg_config "libxml-2.0" "" "" "" ; then
278 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libcurl`"
279 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libcurl`"
280 else
281 break
282 fi
283 echo yes
284 return 1
285 done
286
287 echo no
288 return 0
289 }
290 dependency_error_gtk2()
291 {
292 printf "checking for gtk2... "
293 # dependency gtk2
294 while true
295 do
296 if [ -z "$PKG_CONFIG" ]; then
297 break
298 fi
299 if test_pkg_config "gtk+-2.0" "" "" "" ; then
300 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`"
301 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`"
302 else
303 break
304 fi
305 echo yes
306 return 1
307 done
308
309 echo no
310 return 0
311 }
312 dependency_error_sqlite()
313 {
314 printf "checking for sqlite... "
315 # dependency sqlite
316 while true
317 do
318 if [ -z "$PKG_CONFIG" ]; then
319 break
320 fi
321 if test_pkg_config "sqlite3" "" "" "" ; then
322 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags sqlite3`"
323 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs sqlite3`"
324 else
325 break
326 fi
327 echo yes
328 return 1
329 done
330
331 echo no
332 return 0
333 }
334 dependency_error_test()
335 {
336 printf "checking for test... "
337 # dependency test platform="bsd"
338 while true
339 do
340 if notisplatform "bsd"; then
341 break
342 fi
343 if isplatform "macos"; then
344 break
345 fi
346 TEMP_CFLAGS="$TEMP_CFLAGS -DBSD"
347 echo yes
348 return 1
349 done
350
351 # dependency test
352 while true
353 do
354 TEMP_CFLAGS="$TEMP_CFLAGS -DTEST"
355 echo yes
356 return 1
357 done
358
359 echo no
360 return 0
361 }
362 dependency_error_gtk3()
363 {
364 printf "checking for gtk3... "
365 # dependency gtk3
366 while true
367 do
368 if [ -z "$PKG_CONFIG" ]; then
369 break
370 fi
371 if test_pkg_config "gtk+-5.0" "" "" "" ; then
372 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-5.0`"
373 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-5.0`"
374 else
375 break
376 fi
377 echo yes
378 return 1
379 done
380
381 echo no
382 return 0
383 }
384 dependency_error_deptest()
385 {
386 printf "checking for deptest... "
387 # dependency deptest
388 while true
389 do
390 TEMP_CFLAGS="$TEMP_CFLAGS -DDEPTEST"
391 echo yes
392 return 1
393 done
394
395 echo no
396 return 0
397 }
398 dependency_error_libxml2()
399 {
400 printf "checking for libxml2... "
401 # dependency libxml2
402 while true
403 do
404 if [ -z "$PKG_CONFIG" ]; then
405 break
406 fi
407 if test_pkg_config "libxml-2.0" "2.8" "" "" ; then
408 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`" 332 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`"
409 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`" 333 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`"
410 else 334 else
411 break 335 break
412 fi 336 fi
413 cat >> $TEMP_DIR/make.mk << __EOF__
414 # Dependency: libxml2
415 xml = libxml2
416
417 __EOF__
418 echo yes 337 echo yes
419 return 1 338 return 1
420 done 339 done
421 340
422 echo no 341 echo no
423 return 0 342 return 0
424 } 343 }
344
345
346
425 347
426 # start collecting dependency information 348 # start collecting dependency information
427 echo > "$TEMP_DIR/flags.mk" 349 echo > "$TEMP_DIR/flags.mk"
428 350
429 DEPENDENCIES_FAILED= 351 DEPENDENCIES_FAILED=
434 TEMP_LDFLAGS= 356 TEMP_LDFLAGS=
435 while true 357 while true
436 do 358 do
437 while true 359 while true
438 do 360 do
439 if detect_c_compiler ; then 361 if [ -z "$lang_c" ] ; then
440 :
441 else
442 ERROR=1 362 ERROR=1
443 break 363 break
444 fi 364 fi
445 365
446 cat >> "$TEMP_DIR/make.mk" << __EOF__
447 MVAR = 123
448 MVAR += 123
449
450 __EOF__
451 break 366 break
452 done 367 done
453 break 368 break
454 done 369 done
455 370
466 fi 381 fi
467 382
468 # 383 #
469 # OPTION VALUES 384 # OPTION VALUES
470 # 385 #
471 checkopt_toolkit_gtk3()
472 {
473 VERR=0
474 if dependency_error_gtk3 ; then
475 VERR=1
476 fi
477 if [ $VERR -ne 0 ]; then
478 return 1
479 fi
480 TEMP_CFLAGS="$TEMP_CFLAGS -Da=b"
481 TEMP_CXXFLAGS="$TEMP_CXXFLAGS -Da=b"
482 cat >> "$TEMP_DIR/make.mk" << __EOF__
483 UIOBJ += graphics_cairo.o
484
485 __EOF__
486 return 0
487 }
488 checkopt_toolkit_cli()
489 {
490 VERR=0
491 if dependency_error_curl ; then
492 VERR=1
493 fi
494 if dependency_error_test ; then
495 VERR=1
496 fi
497 if [ $VERR -ne 0 ]; then
498 return 1
499 fi
500 return 0
501 }
502 checkopt_toolkit_gtk2()
503 {
504 VERR=0
505 if dependency_error_gtk2 ; then
506 VERR=1
507 fi
508 if [ $VERR -ne 0 ]; then
509 return 1
510 fi
511 return 0
512 }
513 checkopt_toolkit_wpf()
514 {
515 VERR=0
516 if dependency_error_test ; then
517 VERR=1
518 fi
519 if [ $VERR -ne 0 ]; then
520 return 1
521 fi
522 return 0
523 }
524 386
525 # 387 #
526 # TARGETS 388 # TARGETS
527 # 389 #
528
529 echo >> "$TEMP_DIR/flags.mk"
530 # Target: dav
531 echo "# flags for target dav" >> "$TEMP_DIR/flags.mk"
532 TEMP_CFLAGS=
533 TEMP_CXXFLAGS=
534 TEMP_LDFLAGS=
535
536 if dependency_error_curl; then
537 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
538 ERROR=1
539 fi
540 if dependency_error_libxml2; then
541 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
542 ERROR=1
543 fi
544 if dependency_error_test; then
545 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED test "
546 ERROR=1
547 fi
548
549 # Features
550 if [ -n "$FEATURE_DB" ]; then
551 # check dependency
552 if dependency_error_sqlite ; then
553 # "auto" features can fail and are just disabled in this case
554 if [ "$FEATURE_DB" = "auto" ]; then
555 unset FEATURE_DB
556 else
557 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED sqlite "
558 ERROR=1
559 fi
560 fi
561 fi
562 if [ -n "$FEATURE_GUI" ]; then
563 # check dependency
564 if dependency_error_gtk3 ; then
565 # "auto" features can fail and are just disabled in this case
566 if [ "$FEATURE_GUI" = "auto" ]; then
567 unset FEATURE_GUI
568 else
569 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED gtk3 "
570 ERROR=1
571 fi
572 fi
573 fi
574
575 # Option: --toolkit
576 if [ -z $OPT_TOOLKIT ]; then
577 SAVED_ERROR="$ERROR"
578 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
579 ERROR=1
580 while true
581 do
582 if isplatform "windows"; then
583 if checkopt_toolkit_wpf ; then
584 echo " toolkit: wpf" >> "$TEMP_DIR/options"
585 ERROR=0
586 break
587 fi
588 fi
589 if checkopt_toolkit_gtk3 ; then
590 echo " toolkit: gtk3" >> "$TEMP_DIR/options"
591 ERROR=0
592 break
593 fi
594 if checkopt_toolkit_gtk2 ; then
595 echo " toolkit: gtk2" >> "$TEMP_DIR/options"
596 ERROR=0
597 break
598 fi
599 break
600 done
601 if [ $ERROR -ne 0 ]; then
602 SAVED_ERROR=1
603 fi
604 ERROR="$SAVED_ERROR"
605 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
606 else
607 if false; then
608 false
609 elif [ "$OPT_TOOLKIT" = "gtk3" ]; then
610 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
611 if checkopt_toolkit_gtk3 ; then
612 :
613 else
614 ERROR=1
615 fi
616 elif [ "$OPT_TOOLKIT" = "cli" ]; then
617 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
618 if checkopt_toolkit_cli ; then
619 :
620 else
621 ERROR=1
622 fi
623 elif [ "$OPT_TOOLKIT" = "gtk2" ]; then
624 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
625 if checkopt_toolkit_gtk2 ; then
626 :
627 else
628 ERROR=1
629 fi
630 elif [ "$OPT_TOOLKIT" = "wpf" ]; then
631 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
632 if checkopt_toolkit_wpf ; then
633 :
634 else
635 ERROR=1
636 fi
637 fi
638 fi
639
640 if [ -n "${TEMP_CFLAGS}" ]; then
641 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
642 fi
643 if [ -n "${TEMP_CXXFLAGS}" ]; then
644 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
645 fi
646 if [ "$BUILD_TYPE" = "debug" ]; then
647 echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
648 echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
649 fi
650 if [ "$BUILD_TYPE" = "release" ]; then
651 echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
652 echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
653 fi
654 if [ -n "${TEMP_LDFLAGS}" ]; then
655 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
656 fi
657 390
658 echo >> "$TEMP_DIR/flags.mk" 391 echo >> "$TEMP_DIR/flags.mk"
659 # Target 392 # Target
660 echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" 393 echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
661 TEMP_CFLAGS= 394 TEMP_CFLAGS=
662 TEMP_CXXFLAGS= 395 TEMP_CXXFLAGS=
663 TEMP_LDFLAGS= 396 TEMP_LDFLAGS=
664 397
665 if dependency_error_deptest; then 398 if dependency_error_libxml2; then
666 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED deptest " 399 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
667 ERROR=1 400 ERROR=1
668 fi 401 fi
402 if dependency_error_openssl; then
403 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
404 ERROR=1
405 fi
406 if dependency_error_libpq; then
407 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
408 ERROR=1
409 fi
669 410
670 # Features 411 # Features
412 if [ -n "$FEATURE_PG" ]; then
413 # check dependency
414 if dependency_error_libpq ; then
415 # "auto" features can fail and are just disabled in this case
416 if [ "$FEATURE_PG" = "auto" ]; then
417 unset FEATURE_PG
418 else
419 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libpq "
420 ERROR=1
421 fi
422 fi
423 # check dependency
424 if dependency_error_cpp ; then
425 # "auto" features can fail and are just disabled in this case
426 if [ "$FEATURE_PG" = "auto" ]; then
427 unset FEATURE_PG
428 else
429 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED cpp "
430 ERROR=1
431 fi
432 fi
433 fi
671 434
672 435
673 if [ -n "${TEMP_CFLAGS}" ]; then 436 if [ -n "${TEMP_CFLAGS}" ]; then
674 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" 437 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
675 fi 438 fi
700 echo "configure finished" 463 echo "configure finished"
701 echo 464 echo
702 echo "Build Config:" 465 echo "Build Config:"
703 echo " PREFIX: $PREFIX" 466 echo " PREFIX: $PREFIX"
704 echo " TOOLCHAIN: $TOOLCHAIN_NAME" 467 echo " TOOLCHAIN: $TOOLCHAIN_NAME"
705 echo "Options:"
706 cat "$TEMP_DIR/options"
707 echo "Features:" 468 echo "Features:"
708 if [ -n "$FEATURE_DB" ]; then 469 if [ -n "$FEATURE_PG" ]; then
709 echo " db: on" 470 echo " pg: on"
710 else 471 else
711 echo " db: off" 472 echo " pg: off"
712 fi
713 if [ -n "$FEATURE_GUI" ]; then
714 echo " gui: on"
715 else
716 echo " gui: off"
717 fi 473 fi
718 echo 474 echo
719 475
720 # generate the config.mk file 476 # generate the config.mk file
721 cat > "$TEMP_DIR/config.mk" << __EOF__ 477 cat > "$TEMP_DIR/config.mk" << __EOF__

mercurial