UNIXworkcode

1 #!/bin/sh 2 3 # create temporary directory 4 TEMP_DIR=".tmp-`uname -n`" 5 rm -Rf "$TEMP_DIR" 6 if mkdir -p "$TEMP_DIR"; then 7 : 8 else 9 echo "Cannot create tmp dir $TEMP_DIR" 10 echo "Abort" 11 exit 1 12 fi 13 touch "$TEMP_DIR/options" 14 touch "$TEMP_DIR/features" 15 16 # define standard variables 17 # also define standard prefix (this is where we will search for config.site) 18 prefix=/usr 19 exec_prefix= 20 bindir= 21 sbindir= 22 libdir= 23 libexecdir= 24 datarootdir= 25 datadir= 26 sysconfdir= 27 sharedstatedir= 28 localstatedir= 29 runstatedir= 30 includedir= 31 infodir= 32 localedir= 33 mandir= 34 35 # custom variables 36 37 # features 38 39 # clean abort 40 abort_configure() 41 { 42 rm -Rf "$TEMP_DIR" 43 exit 1 44 } 45 46 # help text 47 printhelp() 48 { 49 echo "Usage: $0 [OPTIONS]..." 50 cat << __EOF__ 51 Installation directories: 52 --prefix=PREFIX path prefix for architecture-independent files 53 [/usr] 54 --exec-prefix=EPREFIX path prefix for architecture-dependent files 55 [PREFIX] 56 57 --bindir=DIR user executables [EPREFIX/bin] 58 --sbindir=DIR system admin executables [EPREFIX/sbin] 59 --libexecdir=DIR program executables [EPREFIX/libexec] 60 --sysconfdir=DIR system configuration files [PREFIX/etc] 61 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 62 --localstatedir=DIR modifiable single-machine data [PREFIX/var] 63 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] 64 --libdir=DIR object code libraries [EPREFIX/lib] 65 --includedir=DIR C header files [PREFIX/include] 66 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 67 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 68 --infodir=DIR info documentation [DATAROOTDIR/info] 69 --mandir=DIR man documentation [DATAROOTDIR/man] 70 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] 71 72 Options: 73 --debug add extra compile flags for debug builds 74 --release add extra compile flags for release builds 75 --toolkit=(libadwaita|gtk4|gtk3|gtk2|gtk2legacy|qt5|qt4|motif) 76 77 __EOF__ 78 } 79 80 # 81 # parse arguments 82 # 83 BUILD_TYPE="default" 84 for ARG in "$@" 85 do 86 case "$ARG" in 87 "--prefix="*) prefix=${ARG#--prefix=} ;; 88 "--exec-prefix="*) exec_prefix=${ARG#--exec-prefix=} ;; 89 "--bindir="*) bindir=${ARG#----bindir=} ;; 90 "--sbindir="*) sbindir=${ARG#--sbindir=} ;; 91 "--libdir="*) libdir=${ARG#--libdir=} ;; 92 "--libexecdir="*) libexecdir=${ARG#--libexecdir=} ;; 93 "--datarootdir="*) datarootdir=${ARG#--datarootdir=} ;; 94 "--datadir="*) datadir=${ARG#--datadir=} ;; 95 "--sysconfdir="*) sysconfdir=${ARG#--sysconfdir=} ;; 96 "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;; 97 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; 98 "--includedir="*) includedir=${ARG#--includedir=} ;; 99 "--infodir="*) infodir=${ARG#--infodir=} ;; 100 "--mandir"*) mandir=${ARG#--mandir} ;; 101 "--localedir"*) localedir=${ARG#--localedir} ;; 102 "--help"*) printhelp; abort_configure ;; 103 "--debug") BUILD_TYPE="debug" ;; 104 "--release") BUILD_TYPE="release" ;; 105 "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;; 106 "-"*) echo "unknown option: $ARG"; abort_configure ;; 107 esac 108 done 109 110 111 112 # set defaults for dir variables 113 : ${exec_prefix:="$prefix"} 114 : ${bindir:='${exec_prefix}/bin'} 115 : ${sbindir:='${exec_prefix}/sbin'} 116 : ${libdir:='${exec_prefix}/lib'} 117 : ${libexecdir:='${exec_prefix}/libexec'} 118 : ${datarootdir:='${prefix}/share'} 119 : ${datadir:='${datarootdir}'} 120 : ${sysconfdir:='${prefix}/etc'} 121 : ${sharedstatedir:='${prefix}/com'} 122 : ${localstatedir:='${prefix}/var'} 123 : ${runstatedir:='${localstatedir}/run'} 124 : ${includedir:='${prefix}/include'} 125 : ${infodir:='${datarootdir}/info'} 126 : ${mandir:='${datarootdir}/man'} 127 : ${localedir:='${datarootdir}/locale'} 128 129 # check if a config.site exists and load it 130 if [ -n "$CONFIG_SITE" ]; then 131 # CONFIG_SITE may contain space separated file names 132 for cs in $CONFIG_SITE; do 133 printf "loading defaults from $cs... " 134 . "$cs" 135 echo ok 136 done 137 elif [ -f "$prefix/share/config.site" ]; then 138 printf "loading site defaults... " 139 . "$prefix/share/config.site" 140 echo ok 141 elif [ -f "$prefix/etc/config.site" ]; then 142 printf "loading site defaults... " 143 . "$prefix/etc/config.site" 144 echo ok 145 fi 146 147 # Test for availability of pkg-config 148 PKG_CONFIG=`command -v pkg-config` 149 : ${PKG_CONFIG:="false"} 150 151 # Simple uname based platform detection 152 # $PLATFORM is used for platform dependent dependency selection 153 OS=`uname -s` 154 OS_VERSION=`uname -r` 155 printf "detect platform... " 156 if [ "$OS" = "SunOS" ]; then 157 PLATFORM="solaris sunos unix svr4" 158 elif [ "$OS" = "Linux" ]; then 159 PLATFORM="linux unix" 160 elif [ "$OS" = "FreeBSD" ]; then 161 PLATFORM="freebsd bsd unix" 162 elif [ "$OS" = "OpenBSD" ]; then 163 PLATFORM="openbsd bsd unix" 164 elif [ "$OS" = "NetBSD" ]; then 165 PLATFORM="netbsd bsd unix" 166 elif [ "$OS" = "Darwin" ]; then 167 PLATFORM="macos osx bsd unix" 168 elif echo "$OS" | grep -i "MINGW" > /dev/null; then 169 PLATFORM="windows mingw" 170 fi 171 : ${PLATFORM:="unix"} 172 173 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` 174 echo "$PLATFORM_NAME" 175 176 isplatform() 177 { 178 for p in $PLATFORM 179 do 180 if [ "$p" = "$1" ]; then 181 return 0 182 fi 183 done 184 return 1 185 } 186 notisplatform() 187 { 188 for p in $PLATFORM 189 do 190 if [ "$p" = "$1" ]; then 191 return 1 192 fi 193 done 194 return 0 195 } 196 istoolchain() 197 { 198 for t in $TOOLCHAIN 199 do 200 if [ "$t" = "$1" ]; then 201 return 0 202 fi 203 done 204 return 1 205 } 206 notistoolchain() 207 { 208 for t in $TOOLCHAIN 209 do 210 if [ "$t" = "$1" ]; then 211 return 1 212 fi 213 done 214 return 0 215 } 216 217 218 # generate vars.mk 219 cat > "$TEMP_DIR/vars.mk" << __EOF__ 220 prefix=$prefix 221 exec_prefix=$exec_prefix 222 bindir=$bindir 223 sbindir=$sbindir 224 libdir=$libdir 225 libexecdir=$libexecdir 226 datarootdir=$datarootdir 227 datadir=$datadir 228 sysconfdir=$sysconfdir 229 sharedstatedir=$sharedstatedir 230 localstatedir=$localstatedir 231 runstatedir=$runstatedir 232 includedir=$includedir 233 infodir=$infodir 234 mandir=$mandir 235 localedir=$localedir 236 __EOF__ 237 238 # toolchain detection utilities 239 . make/toolchain.sh 240 241 # 242 # DEPENDENCIES 243 # 244 245 # check languages 246 lang_c= 247 lang_cpp= 248 if detect_c_compiler ; then 249 lang_c=1 250 fi 251 252 # create buffer for make variables required by dependencies 253 echo > "$TEMP_DIR/make.mk" 254 255 test_pkg_config() 256 { 257 if "$PKG_CONFIG" --exists "$1" ; then : 258 else return 1 ; fi 259 if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : 260 else return 1 ; fi 261 if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : 262 else return 1 ; fi 263 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : 264 else return 1 ; fi 265 return 0 266 } 267 268 print_check_msg() 269 { 270 if [ -z "$1" ]; then 271 shift 272 printf "$@" 273 fi 274 } 275 276 dependency_error_gtk2legacy() 277 { 278 print_check_msg "$dep_checked_gtk2legacy" "checking for gtk2legacy... " 279 # dependency gtk2legacy 280 while true 281 do 282 if [ -z "$PKG_CONFIG" ]; then 283 break 284 fi 285 if test_pkg_config "gtk+-2.0" "" "" "" ; then 286 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`" 287 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`" 288 else 289 break 290 fi 291 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY" 292 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" 293 print_check_msg "$dep_checked_gtk2legacy" "yes\n" 294 dep_checked_gtk2legacy=1 295 return 1 296 done 297 298 print_check_msg "$dep_checked_gtk2legacy" "no\n" 299 dep_checked_gtk2legacy=1 300 return 0 301 } 302 dependency_error_curl() 303 { 304 print_check_msg "$dep_checked_curl" "checking for curl... " 305 # dependency curl platform="macos" 306 while true 307 do 308 if notisplatform "macos"; then 309 break 310 fi 311 if tmp_flags=`curl-config --cflags` ; then 312 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" 313 else 314 break 315 fi 316 if tmp_flags=`curl-config --ldflags` ; then 317 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" 318 else 319 break 320 fi 321 print_check_msg "$dep_checked_curl" "yes\n" 322 dep_checked_curl=1 323 return 1 324 done 325 326 # dependency curl 327 while true 328 do 329 if [ -z "$PKG_CONFIG" ]; then 330 break 331 fi 332 if test_pkg_config "libcurl" "" "" "" ; then 333 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libcurl`" 334 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libcurl`" 335 else 336 break 337 fi 338 print_check_msg "$dep_checked_curl" "yes\n" 339 dep_checked_curl=1 340 return 1 341 done 342 343 # dependency curl 344 while true 345 do 346 if tmp_flags=`curl-config --cflags` ; then 347 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" 348 else 349 break 350 fi 351 if tmp_flags=`curl-config --libs` ; then 352 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" 353 else 354 break 355 fi 356 print_check_msg "$dep_checked_curl" "yes\n" 357 dep_checked_curl=1 358 return 1 359 done 360 361 print_check_msg "$dep_checked_curl" "no\n" 362 dep_checked_curl=1 363 return 0 364 } 365 dependency_error_gtk2() 366 { 367 print_check_msg "$dep_checked_gtk2" "checking for gtk2... " 368 # dependency gtk2 369 while true 370 do 371 if [ -z "$PKG_CONFIG" ]; then 372 break 373 fi 374 if pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null ; then 375 : 376 else 377 break 378 fi 379 if test_pkg_config "gtk+-2.0" "" "" "" ; then 380 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`" 381 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`" 382 else 383 break 384 fi 385 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2" 386 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" 387 print_check_msg "$dep_checked_gtk2" "yes\n" 388 dep_checked_gtk2=1 389 return 1 390 done 391 392 print_check_msg "$dep_checked_gtk2" "no\n" 393 dep_checked_gtk2=1 394 return 0 395 } 396 dependency_error_gtk3() 397 { 398 print_check_msg "$dep_checked_gtk3" "checking for gtk3... " 399 # dependency gtk3 400 while true 401 do 402 if [ -z "$PKG_CONFIG" ]; then 403 break 404 fi 405 if test_pkg_config "gtk+-3.0" "" "" "" ; then 406 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-3.0`" 407 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-3.0`" 408 else 409 break 410 fi 411 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK3" 412 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" 413 print_check_msg "$dep_checked_gtk3" "yes\n" 414 dep_checked_gtk3=1 415 return 1 416 done 417 418 print_check_msg "$dep_checked_gtk3" "no\n" 419 dep_checked_gtk3=1 420 return 0 421 } 422 dependency_error_gtk4() 423 { 424 print_check_msg "$dep_checked_gtk4" "checking for gtk4... " 425 # dependency gtk4 426 while true 427 do 428 if [ -z "$PKG_CONFIG" ]; then 429 break 430 fi 431 if test_pkg_config "gtk4" "" "" "" ; then 432 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk4`" 433 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk4`" 434 else 435 break 436 fi 437 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK3" 438 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" 439 print_check_msg "$dep_checked_gtk4" "yes\n" 440 dep_checked_gtk4=1 441 return 1 442 done 443 444 print_check_msg "$dep_checked_gtk4" "no\n" 445 dep_checked_gtk4=1 446 return 0 447 } 448 dependency_error_openssl() 449 { 450 print_check_msg "$dep_checked_openssl" "checking for openssl... " 451 # dependency openssl platform="windows" 452 while true 453 do 454 if notisplatform "windows"; then 455 break 456 fi 457 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" 458 print_check_msg "$dep_checked_openssl" "yes\n" 459 dep_checked_openssl=1 460 return 1 461 done 462 463 # dependency openssl platform="macos" 464 while true 465 do 466 if notisplatform "macos"; then 467 break 468 fi 469 TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation" 470 print_check_msg "$dep_checked_openssl" "yes\n" 471 dep_checked_openssl=1 472 return 1 473 done 474 475 # dependency openssl platform="bsd" 476 while true 477 do 478 if notisplatform "bsd"; then 479 break 480 fi 481 if isplatform "macos" || istoolchain "macos"; then 482 break 483 fi 484 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" 485 print_check_msg "$dep_checked_openssl" "yes\n" 486 dep_checked_openssl=1 487 return 1 488 done 489 490 # dependency openssl 491 while true 492 do 493 if [ -z "$PKG_CONFIG" ]; then 494 break 495 fi 496 if test_pkg_config "openssl" "" "" "" ; then 497 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`" 498 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`" 499 else 500 break 501 fi 502 print_check_msg "$dep_checked_openssl" "yes\n" 503 dep_checked_openssl=1 504 return 1 505 done 506 507 print_check_msg "$dep_checked_openssl" "no\n" 508 dep_checked_openssl=1 509 return 0 510 } 511 dependency_error_libadwaita() 512 { 513 print_check_msg "$dep_checked_libadwaita" "checking for libadwaita... " 514 # dependency libadwaita 515 while true 516 do 517 if [ -z "$PKG_CONFIG" ]; then 518 break 519 fi 520 if test_pkg_config "libadwaita-1" "" "" "" ; then 521 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libadwaita-1`" 522 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libadwaita-1`" 523 else 524 break 525 fi 526 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK4 -DUI_LIBADWAITA" 527 TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" 528 print_check_msg "$dep_checked_libadwaita" "yes\n" 529 dep_checked_libadwaita=1 530 return 1 531 done 532 533 print_check_msg "$dep_checked_libadwaita" "no\n" 534 dep_checked_libadwaita=1 535 return 0 536 } 537 dependency_error_motif() 538 { 539 print_check_msg "$dep_checked_motif" "checking for motif... " 540 # dependency motif platform="bsd" 541 while true 542 do 543 if notisplatform "bsd"; then 544 break 545 fi 546 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF -I/usr/local/include/X11" 547 TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" 548 print_check_msg "$dep_checked_motif" "yes\n" 549 dep_checked_motif=1 550 return 1 551 done 552 553 # dependency motif 554 while true 555 do 556 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF" 557 TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" 558 print_check_msg "$dep_checked_motif" "yes\n" 559 dep_checked_motif=1 560 return 1 561 done 562 563 print_check_msg "$dep_checked_motif" "no\n" 564 dep_checked_motif=1 565 return 0 566 } 567 dependency_error_libxml2() 568 { 569 print_check_msg "$dep_checked_libxml2" "checking for libxml2... " 570 # dependency libxml2 platform="windows" 571 while true 572 do 573 if notisplatform "windows"; then 574 break 575 fi 576 if tmp_flags=`xml2-config --cflags` ; then 577 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" 578 else 579 break 580 fi 581 if tmp_flags=`xml2-config --libs` ; then 582 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" 583 else 584 break 585 fi 586 print_check_msg "$dep_checked_libxml2" "yes\n" 587 dep_checked_libxml2=1 588 return 1 589 done 590 591 # dependency libxml2 platform="macos" 592 while true 593 do 594 if notisplatform "macos"; then 595 break 596 fi 597 if tmp_flags=`xml2-config --cflags` ; then 598 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" 599 else 600 break 601 fi 602 if tmp_flags=`xml2-config --libs` ; then 603 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" 604 else 605 break 606 fi 607 print_check_msg "$dep_checked_libxml2" "yes\n" 608 dep_checked_libxml2=1 609 return 1 610 done 611 612 # dependency libxml2 613 while true 614 do 615 if [ -z "$PKG_CONFIG" ]; then 616 break 617 fi 618 if test_pkg_config "libxml-2.0" "" "" "" ; then 619 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`" 620 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`" 621 else 622 break 623 fi 624 print_check_msg "$dep_checked_libxml2" "yes\n" 625 dep_checked_libxml2=1 626 return 1 627 done 628 629 # dependency libxml2 630 while true 631 do 632 if tmp_flags=`xml2-config --cflags` ; then 633 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags" 634 else 635 break 636 fi 637 if tmp_flags=`xml2-config --libs` ; then 638 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags" 639 else 640 break 641 fi 642 print_check_msg "$dep_checked_libxml2" "yes\n" 643 dep_checked_libxml2=1 644 return 1 645 done 646 647 print_check_msg "$dep_checked_libxml2" "no\n" 648 dep_checked_libxml2=1 649 return 0 650 } 651 dependency_error_cocoa() 652 { 653 print_check_msg "$dep_checked_cocoa" "checking for cocoa... " 654 # dependency cocoa platform="macos" 655 while true 656 do 657 if notisplatform "macos"; then 658 break 659 fi 660 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_COCOA" 661 TEMP_LDFLAGS="$TEMP_LDFLAGS -lobjc -framework Cocoa" 662 print_check_msg "$dep_checked_cocoa" "yes\n" 663 dep_checked_cocoa=1 664 return 1 665 done 666 667 print_check_msg "$dep_checked_cocoa" "no\n" 668 dep_checked_cocoa=1 669 return 0 670 } 671 dependency_error_winui() 672 { 673 print_check_msg "$dep_checked_winui" "checking for winui... " 674 # dependency winui platform="windows" 675 while true 676 do 677 if notisplatform "windows"; then 678 break 679 fi 680 TEMP_CFLAGS="$TEMP_CFLAGS -DUI_WINUI" 681 print_check_msg "$dep_checked_winui" "yes\n" 682 dep_checked_winui=1 683 return 1 684 done 685 686 print_check_msg "$dep_checked_winui" "no\n" 687 dep_checked_winui=1 688 return 0 689 } 690 691 # start collecting dependency information 692 echo > "$TEMP_DIR/flags.mk" 693 694 DEPENDENCIES_FAILED= 695 ERROR=0 696 # unnamed dependencies 697 TEMP_CFLAGS= 698 TEMP_CXXFLAGS= 699 TEMP_LDFLAGS= 700 while true 701 do 702 while true 703 do 704 if [ -z "$lang_c" ] ; then 705 ERROR=1 706 break 707 fi 708 709 break 710 done 711 break 712 done 713 while true 714 do 715 if notisplatform "macos"; then 716 break 717 fi 718 while true 719 do 720 721 cat >> "$TEMP_DIR/make.mk" << __EOF__ 722 OBJ_EXT = .o 723 LIB_EXT = .a 724 PACKAGE_SCRIPT = package_osx.sh 725 __EOF__ 726 break 727 done 728 break 729 done 730 while true 731 do 732 if notisplatform "unix"; then 733 break 734 fi 735 if isplatform "macos" || istoolchain "macos"; then 736 break 737 fi 738 while true 739 do 740 741 cat >> "$TEMP_DIR/make.mk" << __EOF__ 742 OBJ_EXT = .o 743 LIB_EXT = .a 744 PACKAGE_SCRIPT = package_unix.sh 745 __EOF__ 746 break 747 done 748 break 749 done 750 while true 751 do 752 if notisplatform "bsd"; then 753 break 754 fi 755 while true 756 do 757 758 TEMP_CFLAGS="$TEMP_CFLAGS -I/usr/local/include" 759 TEMP_LDFLAGS="$TEMP_LDFLAGS -L/usr/local/lib" 760 break 761 done 762 break 763 done 764 765 # add general dependency flags to flags.mk 766 echo "# general flags" >> "$TEMP_DIR/flags.mk" 767 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then 768 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" 769 fi 770 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then 771 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" 772 fi 773 if [ -n "${TEMP_LDFLAGS}" ]; then 774 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" 775 fi 776 777 # 778 # OPTION VALUES 779 # 780 checkopt_toolkit_libadwaita() 781 { 782 VERR=0 783 if dependency_error_libadwaita ; then 784 VERR=1 785 fi 786 if [ $VERR -ne 0 ]; then 787 return 1 788 fi 789 cat >> "$TEMP_DIR/make.mk" << __EOF__ 790 TOOLKIT = gtk 791 GTKOBJ = draw_cairo.o 792 __EOF__ 793 return 0 794 } 795 checkopt_toolkit_gtk4() 796 { 797 VERR=0 798 if dependency_error_gtk4 ; then 799 VERR=1 800 fi 801 if [ $VERR -ne 0 ]; then 802 return 1 803 fi 804 cat >> "$TEMP_DIR/make.mk" << __EOF__ 805 TOOLKIT = gtk 806 GTKOBJ = draw_cairo.o 807 __EOF__ 808 return 0 809 } 810 checkopt_toolkit_gtk3() 811 { 812 VERR=0 813 if dependency_error_gtk3 ; then 814 VERR=1 815 fi 816 if [ $VERR -ne 0 ]; then 817 return 1 818 fi 819 cat >> "$TEMP_DIR/make.mk" << __EOF__ 820 TOOLKIT = gtk 821 GTKOBJ = draw_cairo.o 822 __EOF__ 823 return 0 824 } 825 checkopt_toolkit_gtk2() 826 { 827 VERR=0 828 if dependency_error_gtk2 ; then 829 VERR=1 830 fi 831 if [ $VERR -ne 0 ]; then 832 return 1 833 fi 834 cat >> "$TEMP_DIR/make.mk" << __EOF__ 835 TOOLKIT = gtk 836 GTKOBJ = draw_cairo.o 837 __EOF__ 838 return 0 839 } 840 checkopt_toolkit_gtk2legacy() 841 { 842 VERR=0 843 if dependency_error_gtk2legacy ; then 844 VERR=1 845 fi 846 if [ $VERR -ne 0 ]; then 847 return 1 848 fi 849 cat >> "$TEMP_DIR/make.mk" << __EOF__ 850 TOOLKIT = gtk 851 GTKOBJ = draw_gdk.o 852 __EOF__ 853 return 0 854 } 855 checkopt_toolkit_qt5() 856 { 857 VERR=0 858 if dependency_error_qt5 ; then 859 VERR=1 860 fi 861 if [ $VERR -ne 0 ]; then 862 return 1 863 fi 864 cat >> "$TEMP_DIR/make.mk" << __EOF__ 865 TOOLKIT = qt 866 LD = $(CXX) 867 __EOF__ 868 return 0 869 } 870 checkopt_toolkit_qt4() 871 { 872 VERR=0 873 if dependency_error_qt4 ; then 874 VERR=1 875 fi 876 if [ $VERR -ne 0 ]; then 877 return 1 878 fi 879 cat >> "$TEMP_DIR/make.mk" << __EOF__ 880 TOOLKIT = qt 881 LD = $(CXX) 882 __EOF__ 883 return 0 884 } 885 checkopt_toolkit_motif() 886 { 887 VERR=0 888 if dependency_error_motif ; then 889 VERR=1 890 fi 891 if [ $VERR -ne 0 ]; then 892 return 1 893 fi 894 cat >> "$TEMP_DIR/make.mk" << __EOF__ 895 TOOLKIT = motif 896 __EOF__ 897 return 0 898 } 899 900 # 901 # TARGETS 902 # 903 904 echo >> "$TEMP_DIR/flags.mk" 905 echo "configuring target: dav" 906 echo "# flags for target dav" >> "$TEMP_DIR/flags.mk" 907 TEMP_CFLAGS= 908 TEMP_CXXFLAGS= 909 TEMP_LDFLAGS= 910 911 if dependency_error_curl; then 912 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl " 913 ERROR=1 914 fi 915 if dependency_error_libxml2; then 916 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 " 917 ERROR=1 918 fi 919 if dependency_error_openssl; then 920 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl " 921 ERROR=1 922 fi 923 924 # Features 925 926 927 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then 928 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" 929 fi 930 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then 931 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" 932 fi 933 if [ "$BUILD_TYPE" = "debug" ]; then 934 if [ -n "$lang_c" ]; then 935 echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" 936 fi 937 if [ -n "$lang_cpp" ]; then 938 echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" 939 fi 940 fi 941 if [ "$BUILD_TYPE" = "release" ]; then 942 if [ -n "$lang_c" ]; then 943 echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" 944 fi 945 if [ -n "$lang_cpp" ]; then 946 echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" 947 fi 948 fi 949 if [ -n "${TEMP_LDFLAGS}" ]; then 950 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" 951 fi 952 953 echo >> "$TEMP_DIR/flags.mk" 954 echo "configuring target: tk" 955 echo "# flags for target tk" >> "$TEMP_DIR/flags.mk" 956 TEMP_CFLAGS= 957 TEMP_CXXFLAGS= 958 TEMP_LDFLAGS= 959 960 961 # Features 962 963 # Option: --toolkit 964 if [ -z "$OPT_TOOLKIT" ]; then 965 echo "auto-detecting option 'toolkit'" 966 SAVED_ERROR="$ERROR" 967 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" 968 ERROR=1 969 while true 970 do 971 if isplatform "windows"; then 972 if checkopt_toolkit_winui ; then 973 echo " toolkit: winui" >> "$TEMP_DIR/options" 974 ERROR=0 975 break 976 fi 977 fi 978 if isplatform "macos"; then 979 if checkopt_toolkit_cocoa ; then 980 echo " toolkit: cocoa" >> "$TEMP_DIR/options" 981 ERROR=0 982 break 983 fi 984 fi 985 if checkopt_toolkit_gtk4 ; then 986 echo " toolkit: gtk4" >> "$TEMP_DIR/options" 987 ERROR=0 988 break 989 fi 990 if checkopt_toolkit_gtk3 ; then 991 echo " toolkit: gtk3" >> "$TEMP_DIR/options" 992 ERROR=0 993 break 994 fi 995 if checkopt_toolkit_qt5 ; then 996 echo " toolkit: qt5" >> "$TEMP_DIR/options" 997 ERROR=0 998 break 999 fi 1000 if checkopt_toolkit_gtk2 ; then 1001 echo " toolkit: gtk2" >> "$TEMP_DIR/options" 1002 ERROR=0 1003 break 1004 fi 1005 if checkopt_toolkit_qt4 ; then 1006 echo " toolkit: qt4" >> "$TEMP_DIR/options" 1007 ERROR=0 1008 break 1009 fi 1010 if checkopt_toolkit_motif ; then 1011 echo " toolkit: motif" >> "$TEMP_DIR/options" 1012 ERROR=0 1013 break 1014 fi 1015 break 1016 done 1017 if [ $ERROR -ne 0 ]; then 1018 SAVED_ERROR=1 1019 SAVED_DEPENDENCIES_FAILED="option 'toolkit' $SAVED_DEPENDENCIES_FAILED" 1020 fi 1021 ERROR="$SAVED_ERROR" 1022 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" 1023 else 1024 echo "checking option toolkit = $OPT_TOOLKIT" 1025 if false; then 1026 false 1027 elif [ "$OPT_TOOLKIT" = "libadwaita" ]; then 1028 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1029 if checkopt_toolkit_libadwaita ; then 1030 : 1031 else 1032 ERROR=1 1033 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1034 fi 1035 elif [ "$OPT_TOOLKIT" = "gtk4" ]; then 1036 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1037 if checkopt_toolkit_gtk4 ; then 1038 : 1039 else 1040 ERROR=1 1041 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1042 fi 1043 elif [ "$OPT_TOOLKIT" = "gtk3" ]; then 1044 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1045 if checkopt_toolkit_gtk3 ; then 1046 : 1047 else 1048 ERROR=1 1049 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1050 fi 1051 elif [ "$OPT_TOOLKIT" = "gtk2" ]; then 1052 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1053 if checkopt_toolkit_gtk2 ; then 1054 : 1055 else 1056 ERROR=1 1057 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1058 fi 1059 elif [ "$OPT_TOOLKIT" = "gtk2legacy" ]; then 1060 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1061 if checkopt_toolkit_gtk2legacy ; then 1062 : 1063 else 1064 ERROR=1 1065 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1066 fi 1067 elif [ "$OPT_TOOLKIT" = "qt5" ]; then 1068 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1069 if checkopt_toolkit_qt5 ; then 1070 : 1071 else 1072 ERROR=1 1073 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1074 fi 1075 elif [ "$OPT_TOOLKIT" = "qt4" ]; then 1076 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1077 if checkopt_toolkit_qt4 ; then 1078 : 1079 else 1080 ERROR=1 1081 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1082 fi 1083 elif [ "$OPT_TOOLKIT" = "motif" ]; then 1084 echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options 1085 if checkopt_toolkit_motif ; then 1086 : 1087 else 1088 ERROR=1 1089 DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" 1090 fi 1091 fi 1092 fi 1093 1094 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then 1095 echo "TK_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" 1096 fi 1097 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then 1098 echo "TK_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" 1099 fi 1100 if [ "$BUILD_TYPE" = "debug" ]; then 1101 if [ -n "$lang_c" ]; then 1102 echo 'TK_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" 1103 fi 1104 if [ -n "$lang_cpp" ]; then 1105 echo 'TK_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" 1106 fi 1107 fi 1108 if [ "$BUILD_TYPE" = "release" ]; then 1109 if [ -n "$lang_c" ]; then 1110 echo 'TK_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" 1111 fi 1112 if [ -n "$lang_cpp" ]; then 1113 echo 'TK_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" 1114 fi 1115 fi 1116 if [ -n "${TEMP_LDFLAGS}" ]; then 1117 echo "TK_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" 1118 fi 1119 1120 1121 # final result 1122 if [ $ERROR -ne 0 ]; then 1123 echo 1124 echo "Error: Unresolved dependencies" 1125 echo "$DEPENDENCIES_FAILED" 1126 abort_configure 1127 fi 1128 1129 echo "configure finished" 1130 echo 1131 echo "Build Config:" 1132 echo " PREFIX: $prefix" 1133 echo " TOOLCHAIN: $TOOLCHAIN_NAME" 1134 echo "Options:" 1135 cat "$TEMP_DIR/options" 1136 echo 1137 1138 # generate the config.mk file 1139 cat > "$TEMP_DIR/config.mk" << __EOF__ 1140 # 1141 # config.mk generated by configure 1142 # 1143 1144 __EOF__ 1145 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" 1146 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk 1147 rm -Rf "$TEMP_DIR" 1148