Sun, 30 Nov 2025 22:55:34 +0100
update uwproj
| 0 | 1 | #!/bin/sh |
| 2 | ||
| 3 | #set( $D = '$' ) | |
| 4 | #[[ | |
| 5 | # some utility functions | |
| 6 | isplatform() | |
| 7 | { | |
| 8 | for p in $PLATFORM | |
| 9 | do | |
| 10 | if [ "$p" = "$1" ]; then | |
| 11 | return 0 | |
| 12 | fi | |
| 13 | done | |
| 14 | return 1 | |
| 15 | } | |
| 16 | notisplatform() | |
| 17 | { | |
| 18 | for p in $PLATFORM | |
| 19 | do | |
| 20 | if [ "$p" = "$1" ]; then | |
| 21 | return 1 | |
| 22 | fi | |
| 23 | done | |
| 24 | return 0 | |
| 25 | } | |
| 26 | istoolchain() | |
| 27 | { | |
| 28 | for t in $TOOLCHAIN | |
| 29 | do | |
| 30 | if [ "$t" = "$1" ]; then | |
| 31 | return 0 | |
| 32 | fi | |
| 33 | done | |
| 34 | return 1 | |
| 35 | } | |
| 36 | notistoolchain() | |
| 37 | { | |
| 38 | for t in $TOOLCHAIN | |
| 39 | do | |
| 40 | if [ "$t" = "$1" ]; then | |
| 41 | return 1 | |
| 42 | fi | |
| 43 | done | |
| 44 | return 0 | |
| 45 | } | |
| 46 | ||
| 47 | # clean abort | |
| 48 | abort_configure() | |
| 49 | { | |
| 50 | rm -Rf "$TEMP_DIR" | |
| 51 | exit 1 | |
| 52 | } | |
| 53 | ||
| 54 | # Test for availability of pkg-config | |
| 55 | PKG_CONFIG=`command -v pkg-config` | |
| 56 | : ${PKG_CONFIG:="false"} | |
| 57 | ||
| 58 | # Simple uname based platform detection | |
| 59 | # $PLATFORM is used for platform dependent dependency selection | |
| 60 | OS=`uname -s` | |
| 61 | OS_VERSION=`uname -r` | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
62 | ARCH=`uname -m` |
| 0 | 63 | printf "detect platform... " |
| 64 | if [ "$OS" = "SunOS" ]; then | |
| 65 | PLATFORM="solaris sunos unix svr4" | |
| 66 | elif [ "$OS" = "Linux" ]; then | |
| 67 | PLATFORM="linux unix" | |
| 68 | elif [ "$OS" = "FreeBSD" ]; then | |
| 69 | PLATFORM="freebsd bsd unix" | |
| 70 | elif [ "$OS" = "OpenBSD" ]; then | |
| 71 | PLATFORM="openbsd bsd unix" | |
| 72 | elif [ "$OS" = "NetBSD" ]; then | |
| 73 | PLATFORM="netbsd bsd unix" | |
| 74 | elif [ "$OS" = "Darwin" ]; then | |
| 75 | PLATFORM="macos osx bsd unix" | |
| 76 | elif echo "$OS" | grep -i "MINGW" > /dev/null; then | |
| 77 | PLATFORM="windows mingw" | |
| 78 | fi | |
| 79 | : ${PLATFORM:="unix"} | |
| 80 | ||
| 81 | PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` | |
| 82 | echo "$PLATFORM_NAME" | |
| 83 | ]]# | |
| 84 | ||
| 85 | # help text | |
| 86 | printhelp() | |
| 87 | { | |
| 88 | echo "Usage: $0 [OPTIONS]..." | |
| 70 | 89 | echo 'Configuration:' |
| 90 | #foreach( $cfg in $config ) | |
| 91 | if true \ | |
| 92 | #if( $cfg.platform ) | |
| 93 | && isplatform "${cfg.platform}" \ | |
| 94 | #end | |
| 95 | #foreach( $np in $cfg.notList ) | |
| 96 | && notisplatform "${np}" \ | |
| 97 | #end | |
| 98 | ; then | |
| 99 | : | |
| 100 | #foreach( $var in $cfg.vars ) | |
| 101 | #if( $var.overridable ) | |
| 102 | if test -z "${D}${var.varName}__described__"; then | |
| 103 | ${var.varName}__described__=1 | |
| 104 | cat << '__EOF__' | |
| 105 | ${var.helpText} | |
| 106 | __EOF__ | |
| 107 | fi | |
| 108 | #end | |
| 109 | #end | |
| 110 | fi | |
| 111 | #end | |
| 112 | cat << '__EOF__' | |
| 0 | 113 | |
| 114 | Build Types: | |
| 45 | 115 | --debug add extra compile flags for debug builds |
| 116 | --release add extra compile flags for release builds | |
| 0 | 117 | #if( $options.size() > 0 ) |
| 118 | ||
| 119 | Options: | |
| 120 | #foreach( $opt in $options ) | |
| 70 | 121 | ${opt.helpText} |
| 0 | 122 | #end |
| 123 | #end | |
| 124 | #if( $features.size() > 0 ) | |
| 125 | ||
| 126 | Optional Features: | |
| 127 | #foreach( $feature in $features ) | |
| 128 | ${feature.helpText} | |
| 129 | #end | |
| 130 | #end | |
| 131 | ||
| 132 | __EOF__ | |
| 70 | 133 | abort_configure |
| 0 | 134 | } |
| 135 | ||
| 136 | # create temporary directory | |
| 137 | TEMP_DIR=".tmp-`uname -n`" | |
| 138 | rm -Rf "$TEMP_DIR" | |
| 139 | if mkdir -p "$TEMP_DIR"; then | |
| 140 | : | |
| 141 | else | |
| 142 | echo "Cannot create tmp dir $TEMP_DIR" | |
| 143 | echo "Abort" | |
| 144 | exit 1 | |
| 145 | fi | |
| 146 | touch "$TEMP_DIR/options" | |
| 147 | touch "$TEMP_DIR/features" | |
| 148 | ||
| 70 | 149 | # config variables |
| 0 | 150 | #foreach( $cfg in $config ) |
| 151 | if true \ | |
| 152 | #if( $cfg.platform ) | |
| 153 | && isplatform "${cfg.platform}" \ | |
| 154 | #end | |
| 155 | #foreach( $np in $cfg.notList ) | |
| 156 | && notisplatform "${np}" \ | |
| 157 | #end | |
| 158 | ; then | |
| 70 | 159 | : |
| 0 | 160 | #foreach( $var in $cfg.vars ) |
| 70 | 161 | if test -z "${D}${var.varName}__initialized__"; then |
| 162 | ${var.varName}__initialized__=1 | |
| 163 | #if( $var.exec ) | |
| 164 | ${var.varName}=`${var.value}` | |
| 165 | #else | |
| 166 | ${var.varName}='${var.value}' | |
| 167 | #end | |
| 168 | fi | |
| 0 | 169 | #end |
| 170 | fi | |
| 171 | #end | |
| 172 | ||
| 173 | # features | |
| 174 | #foreach( $feature in $features ) | |
| 175 | #if( ${feature.auto} ) | |
| 176 | ${feature.varName}=auto | |
| 177 | #end | |
| 178 | #end | |
| 179 | ||
| 180 | # | |
| 181 | # parse arguments | |
| 182 | # | |
| 183 | BUILD_TYPE="default" | |
| 184 | for ARG in "$@" | |
| 185 | do | |
| 186 | case "$ARG" in | |
| 70 | 187 | #foreach( $var in $vars ) |
| 188 | #if ($var.overridable) | |
| 189 | "--${var.arg}="*) ${var.varName}=${D}{ARG#--${var.arg}=} ;; | |
| 190 | #end | |
| 191 | #end | |
| 192 | "--help"*) printhelp ;; | |
| 193 | "--debug") BUILD_TYPE="debug" ;; | |
| 194 | "--release") BUILD_TYPE="release" ;; | |
| 0 | 195 | #foreach( $opt in $options ) |
| 70 | 196 | "--${opt.arg}="*) ${opt.varName}=${D}{ARG#--${opt.arg}=} ;; |
| 197 | "--${opt.arg}") echo "option '$ARG' needs a value:"; echo " $ARG=${opt.valuesString}"; abort_configure ;; | |
| 0 | 198 | #end |
| 199 | #foreach( $feature in $features ) | |
| 200 | "--enable-${feature.arg}") ${feature.varName}=on ;; | |
| 201 | "--disable-${feature.arg}") unset ${feature.varName} ;; | |
| 202 | #end | |
| 203 | "-"*) echo "unknown option: $ARG"; abort_configure ;; | |
| 204 | esac | |
| 205 | done | |
| 206 | ||
| 70 | 207 | # toolchain detection utilities |
| 208 | . make/toolchain.sh | |
| 209 | ||
| 210 | # check languages | |
| 211 | lang_c= | |
| 212 | lang_cpp= | |
| 213 | #foreach( $lang in $languages ) | |
| 214 | if detect_${lang}_compiler ; then | |
| 215 | lang_${lang}=1 | |
| 216 | fi | |
| 217 | #end | |
| 218 | ||
| 0 | 219 | ## Begin unparsed content. ** |
| 220 | #[[ | |
| 221 | ||
| 222 | # set defaults for dir variables | |
| 223 | : ${exec_prefix:="$prefix"} | |
| 224 | : ${bindir:='${exec_prefix}/bin'} | |
| 225 | : ${sbindir:='${exec_prefix}/sbin'} | |
| 226 | : ${libdir:='${exec_prefix}/lib'} | |
| 227 | : ${libexecdir:='${exec_prefix}/libexec'} | |
| 228 | : ${datarootdir:='${prefix}/share'} | |
| 229 | : ${datadir:='${datarootdir}'} | |
| 230 | : ${sharedstatedir:='${prefix}/com'} | |
| 70 | 231 | if [ -z "$sysconfdir" ]; then |
| 232 | if [ "$prefix" = '/usr' ]; then | |
| 233 | sysconfdir='/etc' | |
| 234 | else | |
| 235 | sysconfdir='${prefix}/etc' | |
| 236 | fi | |
| 237 | fi | |
| 238 | if [ -z "$localstatedir" ]; then | |
| 239 | if [ "$prefix" = '/usr' ]; then | |
| 240 | localstatedir='/var' | |
| 241 | else | |
| 242 | localstatedir='${prefix}/var' | |
| 243 | fi | |
| 244 | fi | |
| 245 | if [ -z "$runstatedir" ]; then | |
| 246 | if [ "$prefix" = '/usr' ]; then | |
| 247 | runstatedir='/var/run' | |
| 248 | else | |
| 249 | runstatedir='${prefix}/var' | |
| 250 | fi | |
| 251 | fi | |
| 0 | 252 | : ${includedir:='${prefix}/include'} |
| 253 | : ${infodir:='${datarootdir}/info'} | |
| 254 | : ${mandir:='${datarootdir}/man'} | |
| 255 | : ${localedir:='${datarootdir}/locale'} | |
| 256 | ||
| 45 | 257 | |
| 0 | 258 | # check if a config.site exists and load it |
| 70 | 259 | CONFIG_SITE_OK=0 |
| 0 | 260 | if [ -n "$CONFIG_SITE" ]; then |
| 261 | # CONFIG_SITE may contain space separated file names | |
| 262 | for cs in $CONFIG_SITE; do | |
| 263 | printf "loading defaults from $cs... " | |
| 70 | 264 | if [ -f "$cs" ]; then |
| 265 | . "$cs" | |
| 266 | echo ok | |
| 267 | CONFIG_SITE_OK=1 | |
| 268 | break | |
| 269 | else | |
| 270 | echo "not found" | |
| 271 | fi | |
| 0 | 272 | done |
| 273 | elif [ -f "$prefix/share/config.site" ]; then | |
| 274 | printf "loading site defaults... " | |
| 275 | . "$prefix/share/config.site" | |
| 276 | echo ok | |
| 70 | 277 | CONFIG_SITE_OK=1 |
| 0 | 278 | elif [ -f "$prefix/etc/config.site" ]; then |
| 279 | printf "loading site defaults... " | |
| 280 | . "$prefix/etc/config.site" | |
| 281 | echo ok | |
| 70 | 282 | CONFIG_SITE_OK=1 |
| 283 | fi | |
| 284 | ||
| 285 | if [ $CONFIG_SITE_OK -eq 0 ]; then | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
286 | # try to detect the correct libdir on our own, except it was changed by the user |
| 70 | 287 | if [ "$libdir" = '${exec_prefix}/lib' ] ; then |
| 288 | if [ "$TOOLCHAIN_WSIZE" = "64" ] ; then | |
| 289 | if [ "$OS" = "SunOS" ]; then | |
| 290 | [ -d "${exec_prefix}/lib/64" ] && libdir='${exec_prefix}/lib/64' | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
291 | else |
| 70 | 292 | [ -d "${exec_prefix}/lib64" ] && libdir='${exec_prefix}/lib64' |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
293 | fi |
| 70 | 294 | elif [ "$TOOLCHAIN_WSIZE" = "32" ] ; then |
| 295 | if [ "$OS" = "SunOS" ]; then | |
| 296 | [ -d "${exec_prefix}/lib/32" ] && libdir='${exec_prefix}/lib/32' | |
| 297 | else | |
| 298 | [ -d "${exec_prefix}/lib32" ] && libdir='${exec_prefix}/lib32' | |
| 299 | fi | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
300 | fi |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
301 | fi |
| 0 | 302 | fi |
| 303 | ]]# | |
| 304 | ## End of unparsed content ** | |
| 305 | ||
| 306 | # generate vars.mk | |
| 307 | cat > "$TEMP_DIR/vars.mk" << __EOF__ | |
| 308 | #foreach( $var in $vars ) | |
| 309 | ${var.varName}=${D}${var.varName} | |
| 310 | #end | |
| 311 | __EOF__ | |
| 312 | ||
| 313 | ||
| 314 | # | |
| 315 | # DEPENDENCIES | |
| 316 | # | |
| 317 | ||
| 70 | 318 | |
| 0 | 319 | |
| 320 | # create buffer for make variables required by dependencies | |
| 321 | echo > "$TEMP_DIR/make.mk" | |
| 322 | ||
| 323 | test_pkg_config() | |
| 324 | { | |
| 325 | if "$PKG_CONFIG" --exists "$1" ; then : | |
| 326 | else return 1 ; fi | |
| 327 | if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : | |
| 328 | else return 1 ; fi | |
| 329 | if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : | |
| 330 | else return 1 ; fi | |
| 331 | if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : | |
| 332 | else return 1 ; fi | |
| 333 | return 0 | |
| 334 | } | |
| 335 | ||
| 336 | print_check_msg() | |
| 337 | { | |
| 338 | if [ -z "$1" ]; then | |
| 339 | shift | |
| 340 | printf "$@" | |
| 341 | fi | |
| 342 | } | |
| 343 | ||
| 344 | #foreach( $dependency in $namedDependencies ) | |
| 345 | dependency_error_${dependency.id}() | |
| 346 | { | |
| 347 | print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... " | |
| 348 | #foreach( $sub in $dependency.subdependencies ) | |
| 349 | # dependency $sub.fullName | |
| 350 | while true | |
| 351 | do | |
| 352 | #if( $sub.platform ) | |
| 353 | if notisplatform "${sub.platform}"; then | |
| 354 | break | |
| 355 | fi | |
| 356 | #end | |
| 357 | #if( $sub.toolchain ) | |
| 358 | if notistoolchain "${sub.toolchain}"; then | |
| 359 | break | |
| 360 | fi | |
| 361 | #end | |
| 362 | #foreach( $np in $sub.notList ) | |
| 363 | if isplatform "${np}" || istoolchain "${np}"; then | |
| 364 | break | |
| 365 | fi | |
| 366 | #end | |
| 367 | #foreach( $lang in $sub.lang ) | |
| 368 | if [ -z "$lang_${lang}" ] ; then | |
| 369 | break | |
| 370 | fi | |
| 371 | #end | |
| 372 | #if( $sub.pkgconfig.size() > 0 ) | |
| 373 | if [ -z "$PKG_CONFIG" ]; then | |
| 374 | break | |
| 375 | fi | |
| 376 | #end | |
| 377 | #foreach( $test in $sub.tests ) | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
378 | if $test > /dev/null 2>&1 ; then |
| 0 | 379 | : |
| 380 | else | |
| 381 | break | |
| 382 | fi | |
| 383 | #end | |
| 384 | #foreach( $pkg in $sub.pkgconfig ) | |
| 385 | if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then | |
| 386 | TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" | |
| 387 | TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" | |
| 388 | else | |
| 389 | break | |
| 390 | fi | |
| 391 | #end | |
| 392 | #foreach( $flags in $sub.flags ) | |
| 393 | #if( $flags.exec ) | |
| 394 | if tmp_flags=`$flags.value` ; then | |
| 395 | TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" | |
| 396 | else | |
| 397 | break | |
| 398 | fi | |
| 399 | #else | |
| 400 | TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" | |
| 401 | #end | |
| 402 | #end | |
| 403 | #if ( $sub.make.length() > 0 ) | |
| 404 | cat >> $TEMP_DIR/make.mk << __EOF__ | |
| 405 | # Dependency: $dependency.name | |
| 406 | $sub.make | |
| 407 | __EOF__ | |
| 408 | #end | |
| 409 | print_check_msg "${D}dep_checked_${dependency.id}" "yes\n" | |
| 410 | dep_checked_${dependency.id}=1 | |
| 411 | return 1 | |
| 412 | done | |
| 413 | ||
| 414 | #end | |
| 415 | print_check_msg "${D}dep_checked_${dependency.id}" "no\n" | |
| 416 | dep_checked_${dependency.id}=1 | |
| 417 | return 0 | |
| 418 | } | |
| 419 | #end | |
| 420 | ||
| 421 | # start collecting dependency information | |
| 422 | echo > "$TEMP_DIR/flags.mk" | |
| 423 | ||
| 424 | DEPENDENCIES_FAILED= | |
| 425 | ERROR=0 | |
| 426 | #if( $dependencies.size() > 0 ) | |
| 427 | # unnamed dependencies | |
| 428 | TEMP_CFLAGS="$CFLAGS" | |
| 429 | TEMP_CXXFLAGS="$CXXFLAGS" | |
| 430 | TEMP_LDFLAGS="$LDFLAGS" | |
| 431 | #foreach( $dependency in $dependencies ) | |
| 432 | while true | |
| 433 | do | |
| 434 | #if( $dependency.platform ) | |
| 435 | if notisplatform "${dependency.platform}"; then | |
| 436 | break | |
| 437 | fi | |
| 438 | #end | |
| 439 | #if( $dependency.toolchain ) | |
| 440 | if notistoolchain "${dependency.toolchain}"; then | |
| 441 | break | |
| 442 | fi | |
| 443 | #end | |
| 444 | #foreach( $np in $dependency.notList ) | |
| 445 | if isplatform "${np}" || istoolchain "${np}"; then | |
| 446 | break | |
| 447 | fi | |
| 448 | #end | |
| 449 | while true | |
| 450 | do | |
| 451 | #foreach( $lang in $dependency.lang ) | |
| 452 | if [ -z "$lang_${lang}" ] ; then | |
| 453 | ERROR=1 | |
| 454 | break | |
| 455 | fi | |
| 456 | #end | |
| 457 | #if( $dependency.pkgconfig.size() > 0 ) | |
| 458 | if [ -z "$PKG_CONFIG" ]; then | |
| 459 | ERROR=1 | |
| 460 | break | |
| 461 | fi | |
| 462 | #end | |
| 463 | #foreach( $pkg in $dependency.pkgconfig ) | |
| 464 | print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... " | |
| 465 | if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then | |
| 466 | print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n" | |
| 467 | dep_pkgconfig_checked_${pkg.id}=1 | |
| 468 | TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" | |
| 469 | TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" | |
| 470 | else | |
| 471 | print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n" | |
| 472 | dep_pkgconfig_checked_${pkg.id}=1 | |
| 473 | ERROR=1 | |
| 474 | break | |
| 475 | fi | |
| 476 | #end | |
| 477 | ||
| 478 | #foreach( $flags in $dependency.flags ) | |
| 479 | #if( $flags.exec ) | |
| 480 | if tmp_flags=`$flags.value` ; then | |
| 481 | TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" | |
| 482 | else | |
| 483 | ERROR=1 | |
| 484 | break | |
| 485 | fi | |
| 486 | #else | |
| 487 | TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" | |
| 488 | #end | |
| 489 | #end | |
| 490 | #if ( $dependency.make.length() > 0 ) | |
| 491 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 492 | $dependency.make | |
| 493 | __EOF__ | |
| 494 | #end | |
| 495 | break | |
| 496 | done | |
| 497 | break | |
| 498 | done | |
| 499 | #end | |
| 500 | ||
| 45 | 501 | # build type |
| 502 | if [ "$BUILD_TYPE" = "debug" ]; then | |
| 503 | TEMP_CFLAGS="\${DEBUG_CFLAGS} $TEMP_CFLAGS" | |
| 504 | TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS} $TEMP_CXXFLAGS" | |
| 505 | fi | |
| 506 | if [ "$BUILD_TYPE" = "release" ]; then | |
| 507 | TEMP_CFLAGS="\${RELEASE_CFLAGS} $TEMP_CFLAGS" | |
| 508 | TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS} $TEMP_CXXFLAGS" | |
| 509 | fi | |
| 510 | ||
| 0 | 511 | # add general dependency flags to flags.mk |
| 512 | echo "# general flags" >> "$TEMP_DIR/flags.mk" | |
| 513 | if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then | |
| 514 | echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 515 | fi | |
| 516 | if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then | |
| 517 | echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 518 | fi | |
| 519 | if [ -n "${TEMP_LDFLAGS}" ]; then | |
| 520 | echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 521 | fi | |
| 522 | #end | |
| 523 | ||
| 524 | # | |
| 525 | # OPTION VALUES | |
| 526 | # | |
| 527 | #foreach( $opt in $options ) | |
| 528 | #foreach( $val in $opt.values ) | |
| 529 | ${val.func}() | |
| 530 | { | |
| 531 | VERR=0 | |
| 532 | #foreach( $dep in $val.dependencies ) | |
| 533 | if dependency_error_$dep ; then | |
| 534 | VERR=1 | |
| 535 | fi | |
| 536 | #end | |
| 537 | if [ $VERR -ne 0 ]; then | |
| 538 | return 1 | |
| 539 | fi | |
| 540 | #foreach( $def in $val.defines ) | |
| 541 | TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" | |
| 542 | TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" | |
| 543 | #end | |
| 544 | #if( $val.hasMake() ) | |
| 545 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 546 | $val.make | |
| 547 | __EOF__ | |
| 548 | #end | |
| 549 | return 0 | |
| 550 | } | |
| 551 | #end | |
| 552 | #end | |
| 553 | ||
| 554 | # | |
| 555 | # TARGETS | |
| 556 | # | |
| 557 | ||
| 558 | #foreach( $target in $targets ) | |
| 559 | echo >> "$TEMP_DIR/flags.mk" | |
| 560 | #if ( $target.name ) | |
| 561 | echo "configuring target: $target.name" | |
| 562 | echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk" | |
| 563 | #else | |
| 564 | echo "configuring global target" | |
| 565 | echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" | |
| 566 | #end | |
| 567 | TEMP_CFLAGS= | |
| 568 | TEMP_CXXFLAGS= | |
| 569 | TEMP_LDFLAGS= | |
| 570 | ||
| 571 | #foreach( $dependency in $target.dependencies ) | |
| 572 | if dependency_error_$dependency; then | |
| 573 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " | |
| 574 | ERROR=1 | |
| 575 | fi | |
| 576 | #end | |
| 577 | ||
| 578 | # Features | |
| 579 | #foreach( $feature in $target.features ) | |
| 580 | if [ -n "${D}${feature.varName}" ]; then | |
| 581 | #foreach( $dependency in $feature.dependencies ) | |
| 582 | # check dependency | |
| 583 | if dependency_error_$dependency ; then | |
| 584 | # "auto" features can fail and are just disabled in this case | |
| 585 | if [ "${D}${feature.varName}" = "auto" ]; then | |
| 586 | DISABLE_${feature.varName}=1 | |
| 587 | else | |
| 588 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " | |
| 589 | ERROR=1 | |
| 590 | fi | |
| 591 | fi | |
| 592 | #end | |
| 593 | if [ -n "$DISABLE_${feature.varName}" ]; then | |
| 594 | unset ${feature.varName} | |
| 595 | fi | |
| 596 | fi | |
| 597 | if [ -n "${D}${feature.varName}" ]; then | |
| 598 | : | |
| 599 | #foreach( $def in $feature.defines ) | |
| 600 | TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" | |
| 601 | TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" | |
| 602 | #end | |
| 603 | #if( $feature.hasMake() ) | |
| 604 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 605 | $feature.make | |
| 606 | __EOF__ | |
| 607 | #end | |
| 608 | else | |
| 609 | : | |
| 610 | #foreach( $def in $feature.disabled.defines ) | |
| 611 | TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" | |
| 612 | TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" | |
| 613 | #end | |
| 614 | #if( $feature.disabled.hasMake() ) | |
| 615 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 616 | $feature.disabled.make | |
| 617 | __EOF__ | |
| 618 | #end | |
| 619 | #foreach( $dependency in $feature.disabled.dependencies ) | |
| 620 | if dependency_error_$dependency ; then | |
| 621 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " | |
| 622 | ERROR=1 | |
| 623 | fi | |
| 624 | #end | |
| 625 | fi | |
| 626 | #end | |
| 627 | ||
| 628 | #foreach( $opt in $target.options ) | |
| 70 | 629 | # Option: --${opt.arg} |
| 0 | 630 | if [ -z "${D}${opt.varName}" ]; then |
| 70 | 631 | echo "auto-detecting option '${opt.arg}'" |
| 0 | 632 | SAVED_ERROR="$ERROR" |
| 633 | SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" | |
| 634 | ERROR=1 | |
| 635 | while true | |
| 636 | do | |
| 637 | #foreach( $optdef in $opt.defaults ) | |
| 638 | #if( $optdef.platform ) | |
| 639 | if isplatform "$optdef.platform"; then | |
| 640 | #end | |
| 641 | if $optdef.func ; then | |
| 70 | 642 | echo " ${opt.arg}: ${optdef.valueName}" >> "$TEMP_DIR/options" |
| 0 | 643 | ERROR=0 |
| 644 | break | |
| 645 | fi | |
| 646 | #if( $optdef.platform ) | |
| 647 | fi | |
| 648 | #end | |
| 649 | #end | |
| 650 | break | |
| 651 | done | |
| 652 | if [ $ERROR -ne 0 ]; then | |
| 653 | SAVED_ERROR=1 | |
| 70 | 654 | SAVED_DEPENDENCIES_FAILED="option '${opt.arg}' $SAVED_DEPENDENCIES_FAILED" |
| 0 | 655 | fi |
| 656 | ERROR="$SAVED_ERROR" | |
| 657 | DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" | |
| 658 | else | |
| 70 | 659 | echo "checking option ${opt.arg} = ${D}${opt.varName}" |
| 0 | 660 | if false; then |
| 661 | false | |
| 662 | #foreach( $optval in $opt.values ) | |
| 663 | elif [ "${D}${opt.varName}" = "${optval.value}" ]; then | |
| 70 | 664 | echo " ${opt.arg}: ${D}${opt.varName}" >> $TEMP_DIR/options |
| 0 | 665 | if $optval.func ; then |
| 666 | : | |
| 667 | else | |
| 668 | ERROR=1 | |
| 70 | 669 | DEPENDENCIES_FAILED="option '${opt.arg}' $DEPENDENCIES_FAILED" |
| 0 | 670 | fi |
| 671 | #end | |
| 672 | else | |
| 673 | echo | |
| 674 | echo "Invalid option value - usage:" | |
| 70 | 675 | echo " --${opt.arg}=${opt.valuesString}" |
| 0 | 676 | abort_configure |
| 677 | fi | |
| 678 | fi | |
| 679 | #end | |
| 680 | ||
| 681 | if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then | |
| 682 | echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 683 | fi | |
| 684 | if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then | |
| 685 | echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 686 | fi | |
| 687 | if [ -n "${TEMP_LDFLAGS}" ]; then | |
| 688 | echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 689 | fi | |
| 690 | ||
| 691 | #end | |
| 692 | ||
| 693 | # final result | |
| 694 | if [ $ERROR -ne 0 ]; then | |
| 695 | echo | |
| 696 | echo "Error: Unresolved dependencies" | |
| 697 | echo "$DEPENDENCIES_FAILED" | |
| 698 | abort_configure | |
| 699 | fi | |
| 700 | ||
| 701 | echo "configure finished" | |
| 702 | echo | |
| 70 | 703 | echo "Toolchain:" |
| 45 | 704 | echo " name: $TOOLCHAIN_NAME" |
| 705 | if [ -n "$TOOLCHAIN_CC" ]; then | |
| 706 | echo " cc: $TOOLCHAIN_CC" | |
| 707 | fi | |
| 708 | if [ -n "$TOOLCHAIN_CXX" ]; then | |
| 709 | echo " cxx: $TOOLCHAIN_CXX" | |
| 710 | fi | |
| 711 | if [ -n "$TOOLCHAIN_WSIZE" ]; then | |
| 712 | echo " word size: $TOOLCHAIN_WSIZE bit" | |
| 713 | fi | |
| 714 | if [ -n "$TOOLCHAIN_CSTD" ]; then | |
| 715 | echo " default C std: $TOOLCHAIN_CSTD" | |
| 716 | fi | |
| 717 | echo | |
| 70 | 718 | echo "Config:" |
| 719 | #foreach( $var in $vars ) | |
| 720 | #if ($var.overridable) | |
| 721 | printf ' %-16s' '${var.arg}:' | |
| 722 | echo "${D}${var.varName}" | |
| 723 | #end | |
| 724 | #end | |
| 0 | 725 | #if ( $options.size() > 0 ) |
| 45 | 726 | echo |
| 0 | 727 | echo "Options:" |
| 728 | cat "$TEMP_DIR/options" | |
| 729 | #end | |
| 730 | #if ( $features.size() > 0 ) | |
| 45 | 731 | echo |
| 0 | 732 | echo "Features:" |
| 733 | #foreach( $feature in $features ) | |
| 70 | 734 | printf ' %-16s' '$feature.name:' |
| 0 | 735 | if [ -n "${D}${feature.varName}" ]; then |
| 70 | 736 | echo 'on' |
| 0 | 737 | else |
| 70 | 738 | echo 'off' |
| 0 | 739 | fi |
| 740 | #end | |
| 741 | #end | |
| 742 | echo | |
| 743 | ||
| 744 | # generate the config.mk file | |
| 45 | 745 | pwd=`pwd` |
| 0 | 746 | cat > "$TEMP_DIR/config.mk" << __EOF__ |
| 747 | # | |
| 45 | 748 | # config.mk generated by: |
| 749 | # pwd: $pwd | |
| 750 | # $0 $@ | |
| 0 | 751 | # |
| 752 | ||
| 753 | __EOF__ | |
| 754 | write_toolchain_defaults "$TEMP_DIR/toolchain.mk" | |
| 45 | 755 | cat "$TEMP_DIR/config.mk" "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
| 0 | 756 | rm -Rf "$TEMP_DIR" |