Tue, 04 Nov 2025 22:26:27 +0100
update uwproj (fixes configure on solaris)
| 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]..." | |
| 89 | cat << __EOF__ | |
| 90 | Installation directories: | |
| 91 | --prefix=PREFIX path prefix for architecture-independent files | |
| 92 | [${D}prefix] | |
| 93 | --exec-prefix=EPREFIX path prefix for architecture-dependent files | |
| 94 | [PREFIX] | |
| 95 | ||
| 96 | --bindir=DIR user executables [EPREFIX/bin] | |
| 97 | --sbindir=DIR system admin executables [EPREFIX/sbin] | |
| 98 | --libexecdir=DIR program executables [EPREFIX/libexec] | |
| 99 | --sysconfdir=DIR system configuration files [PREFIX/etc] | |
| 100 | --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] | |
| 101 | --localstatedir=DIR modifiable single-machine data [PREFIX/var] | |
| 102 | --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] | |
| 103 | --libdir=DIR object code libraries [EPREFIX/lib] | |
| 104 | --includedir=DIR C header files [PREFIX/include] | |
| 105 | --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] | |
| 106 | --datadir=DIR read-only architecture-independent data [DATAROOTDIR] | |
| 107 | --infodir=DIR info documentation [DATAROOTDIR/info] | |
| 108 | --mandir=DIR man documentation [DATAROOTDIR/man] | |
| 109 | --localedir=DIR locale-dependent data [DATAROOTDIR/locale] | |
| 110 | ||
| 111 | Build Types: | |
| 45 | 112 | --debug add extra compile flags for debug builds |
| 113 | --release add extra compile flags for release builds | |
| 0 | 114 | #if( $options.size() > 0 ) |
| 115 | ||
| 116 | Options: | |
| 117 | #foreach( $opt in $options ) | |
| 118 | --${opt.argument}=${opt.valuesString} | |
| 119 | #end | |
| 120 | #end | |
| 121 | #if( $features.size() > 0 ) | |
| 122 | ||
| 123 | Optional Features: | |
| 124 | #foreach( $feature in $features ) | |
| 125 | ${feature.helpText} | |
| 126 | #end | |
| 127 | #end | |
| 128 | ||
| 129 | __EOF__ | |
| 130 | } | |
| 131 | ||
| 132 | # create temporary directory | |
| 133 | TEMP_DIR=".tmp-`uname -n`" | |
| 134 | rm -Rf "$TEMP_DIR" | |
| 135 | if mkdir -p "$TEMP_DIR"; then | |
| 136 | : | |
| 137 | else | |
| 138 | echo "Cannot create tmp dir $TEMP_DIR" | |
| 139 | echo "Abort" | |
| 140 | exit 1 | |
| 141 | fi | |
| 142 | touch "$TEMP_DIR/options" | |
| 143 | touch "$TEMP_DIR/features" | |
| 144 | ||
| 145 | # define standard variables | |
| 146 | # also define standard prefix (this is where we will search for config.site) | |
| 147 | prefix=/usr | |
| 148 | exec_prefix= | |
| 149 | bindir= | |
| 150 | sbindir= | |
| 151 | libdir= | |
| 152 | libexecdir= | |
| 153 | datarootdir= | |
| 154 | datadir= | |
| 155 | sysconfdir= | |
| 156 | sharedstatedir= | |
| 157 | localstatedir= | |
| 158 | runstatedir= | |
| 159 | includedir= | |
| 160 | infodir= | |
| 161 | localedir= | |
| 162 | mandir= | |
| 163 | ||
| 164 | # custom variables | |
| 165 | #foreach( $cfg in $config ) | |
| 166 | if true \ | |
| 167 | #if( $cfg.platform ) | |
| 168 | && isplatform "${cfg.platform}" \ | |
| 169 | #end | |
| 170 | #foreach( $np in $cfg.notList ) | |
| 171 | && notisplatform "${np}" \ | |
| 172 | #end | |
| 173 | ; then | |
| 174 | #foreach( $var in $cfg.vars ) | |
| 175 | #if( $var.exec ) | |
| 176 | ${var.varName}=`${var.value}` | |
| 177 | #else | |
| 178 | ${var.varName}="${var.value}" | |
| 179 | #end | |
| 180 | #end | |
| 181 | fi | |
| 182 | #end | |
| 183 | ||
| 184 | # features | |
| 185 | #foreach( $feature in $features ) | |
| 186 | #if( ${feature.auto} ) | |
| 187 | ${feature.varName}=auto | |
| 188 | #end | |
| 189 | #end | |
| 190 | ||
| 191 | # | |
| 192 | # parse arguments | |
| 193 | # | |
| 194 | BUILD_TYPE="default" | |
| 195 | for ARG in "$@" | |
| 196 | do | |
| 197 | case "$ARG" in | |
| 198 | "--prefix="*) prefix=${D}{ARG#--prefix=} ;; | |
| 199 | "--exec-prefix="*) exec_prefix=${D}{ARG#--exec-prefix=} ;; | |
| 200 | "--bindir="*) bindir=${D}{ARG#----bindir=} ;; | |
| 201 | "--sbindir="*) sbindir=${D}{ARG#--sbindir=} ;; | |
| 202 | "--libdir="*) libdir=${D}{ARG#--libdir=} ;; | |
| 203 | "--libexecdir="*) libexecdir=${D}{ARG#--libexecdir=} ;; | |
| 204 | "--datarootdir="*) datarootdir=${D}{ARG#--datarootdir=} ;; | |
| 205 | "--datadir="*) datadir=${D}{ARG#--datadir=} ;; | |
| 206 | "--sysconfdir="*) sysconfdir=${D}{ARG#--sysconfdir=} ;; | |
| 207 | "--sharedstatedir="*) sharedstatedir=${D}{ARG#--sharedstatedir=} ;; | |
| 208 | "--localstatedir="*) localstatedir=${D}{ARG#--localstatedir=} ;; | |
| 209 | "--includedir="*) includedir=${D}{ARG#--includedir=} ;; | |
| 210 | "--infodir="*) infodir=${D}{ARG#--infodir=} ;; | |
| 211 | "--mandir"*) mandir=${D}{ARG#--mandir} ;; | |
| 212 | "--localedir"*) localedir=${D}{ARG#--localedir} ;; | |
| 213 | "--help"*) printhelp; abort_configure ;; | |
| 214 | "--debug") BUILD_TYPE="debug" ;; | |
| 215 | "--release") BUILD_TYPE="release" ;; | |
| 216 | #foreach( $opt in $options ) | |
| 217 | "--${opt.argument}="*) ${opt.varName}=${D}{ARG#--${opt.argument}=} ;; | |
| 218 | "--${opt.argument}") echo "option '$ARG' needs a value:"; echo " $ARG=${opt.valuesString}"; abort_configure ;; | |
| 219 | #end | |
| 220 | #foreach( $feature in $features ) | |
| 221 | "--enable-${feature.arg}") ${feature.varName}=on ;; | |
| 222 | "--disable-${feature.arg}") unset ${feature.varName} ;; | |
| 223 | #end | |
| 224 | "-"*) echo "unknown option: $ARG"; abort_configure ;; | |
| 225 | esac | |
| 226 | done | |
| 227 | ||
| 228 | ## Begin unparsed content. ** | |
| 229 | #[[ | |
| 230 | ||
| 231 | # set defaults for dir variables | |
| 232 | : ${exec_prefix:="$prefix"} | |
| 233 | : ${bindir:='${exec_prefix}/bin'} | |
| 234 | : ${sbindir:='${exec_prefix}/sbin'} | |
| 235 | : ${libdir:='${exec_prefix}/lib'} | |
| 236 | : ${libexecdir:='${exec_prefix}/libexec'} | |
| 237 | : ${datarootdir:='${prefix}/share'} | |
| 238 | : ${datadir:='${datarootdir}'} | |
| 239 | : ${sysconfdir:='${prefix}/etc'} | |
| 240 | : ${sharedstatedir:='${prefix}/com'} | |
| 241 | : ${localstatedir:='${prefix}/var'} | |
| 242 | : ${runstatedir:='${localstatedir}/run'} | |
| 243 | : ${includedir:='${prefix}/include'} | |
| 244 | : ${infodir:='${datarootdir}/info'} | |
| 245 | : ${mandir:='${datarootdir}/man'} | |
| 246 | : ${localedir:='${datarootdir}/locale'} | |
| 247 | ||
| 45 | 248 | # remember the above values and compare them later |
| 249 | orig_bindir="$bindir" | |
| 250 | orig_sbindir="$sbindir" | |
| 251 | orig_libdir="$libdir" | |
| 252 | orig_libexecdir="$libexecdir" | |
| 253 | orig_datarootdir="$datarootdir" | |
| 254 | orig_datadir="$datadir" | |
| 255 | orig_sysconfdir="$sysconfdir" | |
| 256 | orig_sharedstatedir="$sharedstatedir" | |
| 257 | orig_localstatedir="$localstatedir" | |
| 258 | orig_runstatedir="$runstatedir" | |
| 259 | orig_includedir="$includedir" | |
| 260 | orig_infodir="$infodir" | |
| 261 | orig_mandir="$mandir" | |
| 262 | orig_localedir="$localedir" | |
| 263 | ||
| 0 | 264 | # check if a config.site exists and load it |
| 265 | if [ -n "$CONFIG_SITE" ]; then | |
| 266 | # CONFIG_SITE may contain space separated file names | |
| 267 | for cs in $CONFIG_SITE; do | |
| 268 | printf "loading defaults from $cs... " | |
| 269 | . "$cs" | |
| 270 | echo ok | |
| 271 | done | |
| 272 | elif [ -f "$prefix/share/config.site" ]; then | |
| 273 | printf "loading site defaults... " | |
| 274 | . "$prefix/share/config.site" | |
| 275 | echo ok | |
| 276 | elif [ -f "$prefix/etc/config.site" ]; then | |
| 277 | printf "loading site defaults... " | |
| 278 | . "$prefix/etc/config.site" | |
| 279 | echo ok | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
280 | else |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
281 | # try to detect the correct libdir on our own, except it was changed by the user |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
282 | if test "$libdir" = '${exec_prefix}/lib'; then |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
283 | if [ "$OS" = "SunOS" ]; then |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
284 | test -d "${exec_prefix}/lib/amd64" && libdir='${exec_prefix}/lib/amd64' |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
285 | else |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
286 | # check if the standard libdir even exists |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
287 | if test -d "${exec_prefix}/lib" ; then |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
288 | : |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
289 | else |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
290 | # if it does not, maybe a lib32 exists |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
291 | test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32' |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
292 | fi |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
293 | # now check if there is a special 64bit libdir that we should use |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
294 | for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
295 | if [ $ARCH = $i ]; then |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
296 | test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64' |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
297 | break |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
298 | fi |
|
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
299 | done |
|
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 | prefix=$prefix | |
| 309 | exec_prefix=$exec_prefix | |
| 310 | bindir=$bindir | |
| 311 | sbindir=$sbindir | |
| 312 | libdir=$libdir | |
| 313 | libexecdir=$libexecdir | |
| 314 | datarootdir=$datarootdir | |
| 315 | datadir=$datadir | |
| 316 | sysconfdir=$sysconfdir | |
| 317 | sharedstatedir=$sharedstatedir | |
| 318 | localstatedir=$localstatedir | |
| 319 | runstatedir=$runstatedir | |
| 320 | includedir=$includedir | |
| 321 | infodir=$infodir | |
| 322 | mandir=$mandir | |
| 323 | localedir=$localedir | |
| 324 | #foreach( $var in $vars ) | |
| 325 | ${var.varName}=${D}${var.varName} | |
| 326 | #end | |
| 327 | __EOF__ | |
| 328 | ||
| 329 | # toolchain detection utilities | |
| 330 | . make/toolchain.sh | |
| 331 | ||
| 332 | # | |
| 333 | # DEPENDENCIES | |
| 334 | # | |
| 335 | ||
| 336 | # check languages | |
| 337 | lang_c= | |
| 338 | lang_cpp= | |
| 339 | #foreach( $lang in $languages ) | |
| 340 | if detect_${lang}_compiler ; then | |
| 341 | lang_${lang}=1 | |
| 342 | fi | |
| 343 | #end | |
| 344 | ||
| 345 | # create buffer for make variables required by dependencies | |
| 346 | echo > "$TEMP_DIR/make.mk" | |
| 347 | ||
| 348 | test_pkg_config() | |
| 349 | { | |
| 350 | if "$PKG_CONFIG" --exists "$1" ; then : | |
| 351 | else return 1 ; fi | |
| 352 | if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : | |
| 353 | else return 1 ; fi | |
| 354 | if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : | |
| 355 | else return 1 ; fi | |
| 356 | if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : | |
| 357 | else return 1 ; fi | |
| 358 | return 0 | |
| 359 | } | |
| 360 | ||
| 361 | print_check_msg() | |
| 362 | { | |
| 363 | if [ -z "$1" ]; then | |
| 364 | shift | |
| 365 | printf "$@" | |
| 366 | fi | |
| 367 | } | |
| 368 | ||
| 369 | #foreach( $dependency in $namedDependencies ) | |
| 370 | dependency_error_${dependency.id}() | |
| 371 | { | |
| 372 | print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... " | |
| 373 | #foreach( $sub in $dependency.subdependencies ) | |
| 374 | # dependency $sub.fullName | |
| 375 | while true | |
| 376 | do | |
| 377 | #if( $sub.platform ) | |
| 378 | if notisplatform "${sub.platform}"; then | |
| 379 | break | |
| 380 | fi | |
| 381 | #end | |
| 382 | #if( $sub.toolchain ) | |
| 383 | if notistoolchain "${sub.toolchain}"; then | |
| 384 | break | |
| 385 | fi | |
| 386 | #end | |
| 387 | #foreach( $np in $sub.notList ) | |
| 388 | if isplatform "${np}" || istoolchain "${np}"; then | |
| 389 | break | |
| 390 | fi | |
| 391 | #end | |
| 392 | #foreach( $lang in $sub.lang ) | |
| 393 | if [ -z "$lang_${lang}" ] ; then | |
| 394 | break | |
| 395 | fi | |
| 396 | #end | |
| 397 | #if( $sub.pkgconfig.size() > 0 ) | |
| 398 | if [ -z "$PKG_CONFIG" ]; then | |
| 399 | break | |
| 400 | fi | |
| 401 | #end | |
| 402 | #foreach( $test in $sub.tests ) | |
|
69
f70ba8f14b41
update uwproj (fixes configure on solaris)
Mike Becker <universe@uap-core.de>
parents:
45
diff
changeset
|
403 | if $test > /dev/null 2>&1 ; then |
| 0 | 404 | : |
| 405 | else | |
| 406 | break | |
| 407 | fi | |
| 408 | #end | |
| 409 | #foreach( $pkg in $sub.pkgconfig ) | |
| 410 | if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then | |
| 411 | TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" | |
| 412 | TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" | |
| 413 | else | |
| 414 | break | |
| 415 | fi | |
| 416 | #end | |
| 417 | #foreach( $flags in $sub.flags ) | |
| 418 | #if( $flags.exec ) | |
| 419 | if tmp_flags=`$flags.value` ; then | |
| 420 | TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" | |
| 421 | else | |
| 422 | break | |
| 423 | fi | |
| 424 | #else | |
| 425 | TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" | |
| 426 | #end | |
| 427 | #end | |
| 428 | #if ( $sub.make.length() > 0 ) | |
| 429 | cat >> $TEMP_DIR/make.mk << __EOF__ | |
| 430 | # Dependency: $dependency.name | |
| 431 | $sub.make | |
| 432 | __EOF__ | |
| 433 | #end | |
| 434 | print_check_msg "${D}dep_checked_${dependency.id}" "yes\n" | |
| 435 | dep_checked_${dependency.id}=1 | |
| 436 | return 1 | |
| 437 | done | |
| 438 | ||
| 439 | #end | |
| 440 | print_check_msg "${D}dep_checked_${dependency.id}" "no\n" | |
| 441 | dep_checked_${dependency.id}=1 | |
| 442 | return 0 | |
| 443 | } | |
| 444 | #end | |
| 445 | ||
| 446 | # start collecting dependency information | |
| 447 | echo > "$TEMP_DIR/flags.mk" | |
| 448 | ||
| 449 | DEPENDENCIES_FAILED= | |
| 450 | ERROR=0 | |
| 451 | #if( $dependencies.size() > 0 ) | |
| 452 | # unnamed dependencies | |
| 453 | TEMP_CFLAGS="$CFLAGS" | |
| 454 | TEMP_CXXFLAGS="$CXXFLAGS" | |
| 455 | TEMP_LDFLAGS="$LDFLAGS" | |
| 456 | #foreach( $dependency in $dependencies ) | |
| 457 | while true | |
| 458 | do | |
| 459 | #if( $dependency.platform ) | |
| 460 | if notisplatform "${dependency.platform}"; then | |
| 461 | break | |
| 462 | fi | |
| 463 | #end | |
| 464 | #if( $dependency.toolchain ) | |
| 465 | if notistoolchain "${dependency.toolchain}"; then | |
| 466 | break | |
| 467 | fi | |
| 468 | #end | |
| 469 | #foreach( $np in $dependency.notList ) | |
| 470 | if isplatform "${np}" || istoolchain "${np}"; then | |
| 471 | break | |
| 472 | fi | |
| 473 | #end | |
| 474 | while true | |
| 475 | do | |
| 476 | #foreach( $lang in $dependency.lang ) | |
| 477 | if [ -z "$lang_${lang}" ] ; then | |
| 478 | ERROR=1 | |
| 479 | break | |
| 480 | fi | |
| 481 | #end | |
| 482 | #if( $dependency.pkgconfig.size() > 0 ) | |
| 483 | if [ -z "$PKG_CONFIG" ]; then | |
| 484 | ERROR=1 | |
| 485 | break | |
| 486 | fi | |
| 487 | #end | |
| 488 | #foreach( $pkg in $dependency.pkgconfig ) | |
| 489 | print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... " | |
| 490 | if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then | |
| 491 | print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n" | |
| 492 | dep_pkgconfig_checked_${pkg.id}=1 | |
| 493 | TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" | |
| 494 | TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" | |
| 495 | else | |
| 496 | print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n" | |
| 497 | dep_pkgconfig_checked_${pkg.id}=1 | |
| 498 | ERROR=1 | |
| 499 | break | |
| 500 | fi | |
| 501 | #end | |
| 502 | ||
| 503 | #foreach( $flags in $dependency.flags ) | |
| 504 | #if( $flags.exec ) | |
| 505 | if tmp_flags=`$flags.value` ; then | |
| 506 | TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" | |
| 507 | else | |
| 508 | ERROR=1 | |
| 509 | break | |
| 510 | fi | |
| 511 | #else | |
| 512 | TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" | |
| 513 | #end | |
| 514 | #end | |
| 515 | #if ( $dependency.make.length() > 0 ) | |
| 516 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 517 | $dependency.make | |
| 518 | __EOF__ | |
| 519 | #end | |
| 520 | break | |
| 521 | done | |
| 522 | break | |
| 523 | done | |
| 524 | #end | |
| 525 | ||
| 45 | 526 | # build type |
| 527 | if [ "$BUILD_TYPE" = "debug" ]; then | |
| 528 | TEMP_CFLAGS="\${DEBUG_CFLAGS} $TEMP_CFLAGS" | |
| 529 | TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS} $TEMP_CXXFLAGS" | |
| 530 | fi | |
| 531 | if [ "$BUILD_TYPE" = "release" ]; then | |
| 532 | TEMP_CFLAGS="\${RELEASE_CFLAGS} $TEMP_CFLAGS" | |
| 533 | TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS} $TEMP_CXXFLAGS" | |
| 534 | fi | |
| 535 | ||
| 0 | 536 | # add general dependency flags to flags.mk |
| 537 | echo "# general flags" >> "$TEMP_DIR/flags.mk" | |
| 538 | if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then | |
| 539 | echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 540 | fi | |
| 541 | if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then | |
| 542 | echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 543 | fi | |
| 544 | if [ -n "${TEMP_LDFLAGS}" ]; then | |
| 545 | echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 546 | fi | |
| 547 | #end | |
| 548 | ||
| 549 | # | |
| 550 | # OPTION VALUES | |
| 551 | # | |
| 552 | #foreach( $opt in $options ) | |
| 553 | #foreach( $val in $opt.values ) | |
| 554 | ${val.func}() | |
| 555 | { | |
| 556 | VERR=0 | |
| 557 | #foreach( $dep in $val.dependencies ) | |
| 558 | if dependency_error_$dep ; then | |
| 559 | VERR=1 | |
| 560 | fi | |
| 561 | #end | |
| 562 | if [ $VERR -ne 0 ]; then | |
| 563 | return 1 | |
| 564 | fi | |
| 565 | #foreach( $def in $val.defines ) | |
| 566 | TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" | |
| 567 | TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" | |
| 568 | #end | |
| 569 | #if( $val.hasMake() ) | |
| 570 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 571 | $val.make | |
| 572 | __EOF__ | |
| 573 | #end | |
| 574 | return 0 | |
| 575 | } | |
| 576 | #end | |
| 577 | #end | |
| 578 | ||
| 579 | # | |
| 580 | # TARGETS | |
| 581 | # | |
| 582 | ||
| 583 | #foreach( $target in $targets ) | |
| 584 | echo >> "$TEMP_DIR/flags.mk" | |
| 585 | #if ( $target.name ) | |
| 586 | echo "configuring target: $target.name" | |
| 587 | echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk" | |
| 588 | #else | |
| 589 | echo "configuring global target" | |
| 590 | echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" | |
| 591 | #end | |
| 592 | TEMP_CFLAGS= | |
| 593 | TEMP_CXXFLAGS= | |
| 594 | TEMP_LDFLAGS= | |
| 595 | ||
| 596 | #foreach( $dependency in $target.dependencies ) | |
| 597 | if dependency_error_$dependency; then | |
| 598 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " | |
| 599 | ERROR=1 | |
| 600 | fi | |
| 601 | #end | |
| 602 | ||
| 603 | # Features | |
| 604 | #foreach( $feature in $target.features ) | |
| 605 | if [ -n "${D}${feature.varName}" ]; then | |
| 606 | #foreach( $dependency in $feature.dependencies ) | |
| 607 | # check dependency | |
| 608 | if dependency_error_$dependency ; then | |
| 609 | # "auto" features can fail and are just disabled in this case | |
| 610 | if [ "${D}${feature.varName}" = "auto" ]; then | |
| 611 | DISABLE_${feature.varName}=1 | |
| 612 | else | |
| 613 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " | |
| 614 | ERROR=1 | |
| 615 | fi | |
| 616 | fi | |
| 617 | #end | |
| 618 | if [ -n "$DISABLE_${feature.varName}" ]; then | |
| 619 | unset ${feature.varName} | |
| 620 | fi | |
| 621 | fi | |
| 622 | if [ -n "${D}${feature.varName}" ]; then | |
| 623 | : | |
| 624 | #foreach( $def in $feature.defines ) | |
| 625 | TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" | |
| 626 | TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" | |
| 627 | #end | |
| 628 | #if( $feature.hasMake() ) | |
| 629 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 630 | $feature.make | |
| 631 | __EOF__ | |
| 632 | #end | |
| 633 | else | |
| 634 | : | |
| 635 | #foreach( $def in $feature.disabled.defines ) | |
| 636 | TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" | |
| 637 | TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" | |
| 638 | #end | |
| 639 | #if( $feature.disabled.hasMake() ) | |
| 640 | cat >> "$TEMP_DIR/make.mk" << __EOF__ | |
| 641 | $feature.disabled.make | |
| 642 | __EOF__ | |
| 643 | #end | |
| 644 | #foreach( $dependency in $feature.disabled.dependencies ) | |
| 645 | if dependency_error_$dependency ; then | |
| 646 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " | |
| 647 | ERROR=1 | |
| 648 | fi | |
| 649 | #end | |
| 650 | fi | |
| 651 | #end | |
| 652 | ||
| 653 | #foreach( $opt in $target.options ) | |
| 654 | # Option: --${opt.argument} | |
| 655 | if [ -z "${D}${opt.varName}" ]; then | |
| 656 | echo "auto-detecting option '${opt.argument}'" | |
| 657 | SAVED_ERROR="$ERROR" | |
| 658 | SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" | |
| 659 | ERROR=1 | |
| 660 | while true | |
| 661 | do | |
| 662 | #foreach( $optdef in $opt.defaults ) | |
| 663 | #if( $optdef.platform ) | |
| 664 | if isplatform "$optdef.platform"; then | |
| 665 | #end | |
| 666 | if $optdef.func ; then | |
| 667 | echo " ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options" | |
| 668 | ERROR=0 | |
| 669 | break | |
| 670 | fi | |
| 671 | #if( $optdef.platform ) | |
| 672 | fi | |
| 673 | #end | |
| 674 | #end | |
| 675 | break | |
| 676 | done | |
| 677 | if [ $ERROR -ne 0 ]; then | |
| 678 | SAVED_ERROR=1 | |
| 679 | SAVED_DEPENDENCIES_FAILED="option '${opt.argument}' $SAVED_DEPENDENCIES_FAILED" | |
| 680 | fi | |
| 681 | ERROR="$SAVED_ERROR" | |
| 682 | DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" | |
| 683 | else | |
| 684 | echo "checking option ${opt.argument} = ${D}${opt.varName}" | |
| 685 | if false; then | |
| 686 | false | |
| 687 | #foreach( $optval in $opt.values ) | |
| 688 | elif [ "${D}${opt.varName}" = "${optval.value}" ]; then | |
| 689 | echo " ${opt.argument}: ${D}${opt.varName}" >> $TEMP_DIR/options | |
| 690 | if $optval.func ; then | |
| 691 | : | |
| 692 | else | |
| 693 | ERROR=1 | |
| 694 | DEPENDENCIES_FAILED="option '${opt.argument}' $DEPENDENCIES_FAILED" | |
| 695 | fi | |
| 696 | #end | |
| 697 | else | |
| 698 | echo | |
| 699 | echo "Invalid option value - usage:" | |
| 700 | echo " --${opt.argument}=${opt.valuesString}" | |
| 701 | abort_configure | |
| 702 | fi | |
| 703 | fi | |
| 704 | #end | |
| 705 | ||
| 706 | if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then | |
| 707 | echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 708 | fi | |
| 709 | if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then | |
| 710 | echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 711 | fi | |
| 712 | if [ -n "${TEMP_LDFLAGS}" ]; then | |
| 713 | echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" | |
| 714 | fi | |
| 715 | ||
| 716 | #end | |
| 717 | ||
| 718 | # final result | |
| 719 | if [ $ERROR -ne 0 ]; then | |
| 720 | echo | |
| 721 | echo "Error: Unresolved dependencies" | |
| 722 | echo "$DEPENDENCIES_FAILED" | |
| 723 | abort_configure | |
| 724 | fi | |
| 725 | ||
| 726 | echo "configure finished" | |
| 727 | echo | |
| 45 | 728 | echo "Toolchain" |
| 729 | echo " name: $TOOLCHAIN_NAME" | |
| 730 | if [ -n "$TOOLCHAIN_CC" ]; then | |
| 731 | echo " cc: $TOOLCHAIN_CC" | |
| 732 | fi | |
| 733 | if [ -n "$TOOLCHAIN_CXX" ]; then | |
| 734 | echo " cxx: $TOOLCHAIN_CXX" | |
| 735 | fi | |
| 736 | if [ -n "$TOOLCHAIN_WSIZE" ]; then | |
| 737 | echo " word size: $TOOLCHAIN_WSIZE bit" | |
| 738 | fi | |
| 739 | if [ -n "$TOOLCHAIN_CSTD" ]; then | |
| 740 | echo " default C std: $TOOLCHAIN_CSTD" | |
| 741 | fi | |
| 742 | echo | |
| 0 | 743 | echo "Build Config:" |
| 45 | 744 | echo " prefix: $prefix" |
| 745 | echo " exec_prefix: $exec_prefix" | |
| 746 | if [ "$orig_bindir" != "$bindir" ]; then | |
| 747 | echo " bindir: $bindir" | |
| 748 | fi | |
| 749 | if [ "$orig_sbindir" != "$sbindir" ]; then | |
| 750 | echo " sbindir: $sbindir" | |
| 751 | fi | |
| 752 | if [ "$orig_libdir" != "$libdir" ]; then | |
| 753 | echo " libdir: $libdir" | |
| 754 | fi | |
| 755 | if [ "$orig_libexecdir" != "$libexecdir" ]; then | |
| 756 | echo " libexecdir: $libexecdir" | |
| 757 | fi | |
| 758 | if [ "$orig_datarootdir" != "$datarootdir" ]; then | |
| 759 | echo " datarootdir: $datarootdir" | |
| 760 | fi | |
| 761 | if [ "$orig_datadir" != "$datadir" ]; then | |
| 762 | echo " datadir: $datadir" | |
| 763 | fi | |
| 764 | if [ "$orig_sysconfdir" != "$sysconfdir" ]; then | |
| 765 | echo " sysconfdir: $sysconfdir" | |
| 766 | fi | |
| 767 | if [ "$orig_sharedstatedir" != "$sharedstatedir" ]; then | |
| 768 | echo " sharedstatedir: $sharedstatedir" | |
| 769 | fi | |
| 770 | if [ "$orig_localstatedir" != "$localstatedir" ]; then | |
| 771 | echo " localstatedir: $localstatedir" | |
| 772 | fi | |
| 773 | if [ "$orig_runstatedir" != "$runstatedir" ]; then | |
| 774 | echo " runstatedir: $runstatedir" | |
| 775 | fi | |
| 776 | if [ "$orig_includedir" != "$includedir" ]; then | |
| 777 | echo " includedir: $includedir" | |
| 778 | fi | |
| 779 | if [ "$orig_infodir" != "$infodir" ]; then | |
| 780 | echo " infodir: $infodir" | |
| 781 | fi | |
| 782 | if [ "$orig_mandir" != "$mandir" ]; then | |
| 783 | echo " mandir: $mandir" | |
| 784 | fi | |
| 785 | if [ "$orig_localedir" != "$localedir" ]; then | |
| 786 | echo " localedir: $localedir" | |
| 787 | fi | |
| 0 | 788 | #if ( $options.size() > 0 ) |
| 45 | 789 | echo |
| 0 | 790 | echo "Options:" |
| 791 | cat "$TEMP_DIR/options" | |
| 792 | #end | |
| 793 | #if ( $features.size() > 0 ) | |
| 45 | 794 | echo |
| 0 | 795 | echo "Features:" |
| 796 | #foreach( $feature in $features ) | |
| 797 | if [ -n "${D}${feature.varName}" ]; then | |
| 798 | echo " $feature.name: on" | |
| 799 | else | |
| 800 | echo " $feature.name: off" | |
| 801 | fi | |
| 802 | #end | |
| 803 | #end | |
| 804 | echo | |
| 805 | ||
| 806 | # generate the config.mk file | |
| 45 | 807 | pwd=`pwd` |
| 0 | 808 | cat > "$TEMP_DIR/config.mk" << __EOF__ |
| 809 | # | |
| 45 | 810 | # config.mk generated by: |
| 811 | # pwd: $pwd | |
| 812 | # $0 $@ | |
| 0 | 813 | # |
| 814 | ||
| 815 | __EOF__ | |
| 816 | write_toolchain_defaults "$TEMP_DIR/toolchain.mk" | |
| 45 | 817 | cat "$TEMP_DIR/config.mk" "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
| 0 | 818 | rm -Rf "$TEMP_DIR" |