make/configure.vm

changeset 76
c2a4fb5024b4
parent 71
0bdb910478cc
equal deleted inserted replaced
75:b0b8bf3c536e 76:c2a4fb5024b4
1 #!/bin/sh 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`
62 ARCH=`uname -m`
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:
112 --debug add extra compile flags for debug builds
113 --release add extra compile flags for release builds
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 }
2 131
3 # create temporary directory 132 # create temporary directory
4 TEMP_DIR=".tmp-`uname -n`" 133 TEMP_DIR=".tmp-`uname -n`"
5 rm -Rf "$TEMP_DIR" 134 rm -Rf "$TEMP_DIR"
6 if mkdir -p "$TEMP_DIR"; then 135 if mkdir -p "$TEMP_DIR"; then
12 fi 141 fi
13 touch "$TEMP_DIR/options" 142 touch "$TEMP_DIR/options"
14 touch "$TEMP_DIR/features" 143 touch "$TEMP_DIR/features"
15 144
16 # define standard variables 145 # define standard variables
17 PREFIX=/usr 146 # also define standard prefix (this is where we will search for config.site)
18 EPREFIX= 147 prefix=/usr
19 BINDIR= 148 exec_prefix=
20 SBINDIR= 149 bindir=
21 LIBDIR= 150 sbindir=
22 LIBEXECDIR= 151 libdir=
23 DATADIR= 152 libexecdir=
24 SYSCONFDIR= 153 datarootdir=
25 SHAREDSTATEDIR= 154 datadir=
26 LOCALSTATEDIR= 155 sysconfdir=
27 INCLUDEDIR= 156 sharedstatedir=
28 INFODIR= 157 localstatedir=
29 MANDIR= 158 runstatedir=
159 includedir=
160 infodir=
161 localedir=
162 mandir=
30 163
31 # custom variables 164 # custom variables
32 #foreach( $var in $vars ) 165 #foreach( $cfg in $config )
33 #if( $var.exec ) 166 if true \
34 ${var.varName}=`${var.value}` 167 #if( $cfg.platform )
35 #else 168 && isplatform "${cfg.platform}" \
36 ${var.varName}=${var.value} 169 #end
37 #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
38 #end 182 #end
39 183
40 # features 184 # features
41 #foreach( $feature in $features ) 185 #foreach( $feature in $features )
42 #if( ${feature.isDefault()} ) 186 #if( ${feature.auto} )
43 ${feature.getVarName()}=auto 187 ${feature.varName}=auto
44 #end 188 #end
45 #end 189 #end
46
47 # clean abort
48 abort_configure()
49 {
50 rm -Rf "$TEMP_DIR"
51 exit 1
52 }
53
54 # help text
55 printhelp()
56 {
57 echo "Usage: $0 [OPTIONS]..."
58 cat << __EOF__
59 Installation directories:
60 --prefix=PREFIX path prefix for architecture-independent files
61 [/usr]
62 --exec-prefix=EPREFIX path prefix for architecture-dependent files
63 [PREFIX]
64
65 --bindir=DIR user executables [EPREFIX/bin]
66 --sbindir=DIR system admin executables [EPREFIX/sbin]
67 --libexecdir=DIR program executables [EPREFIX/libexec]
68 --sysconfdir=DIR system configuration files [PREFIX/etc]
69 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
70 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
71 --libdir=DIR object code libraries [EPREFIX/lib]
72 --includedir=DIR C header files [PREFIX/include]
73 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
74 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
75 --infodir=DIR info documentation [DATAROOTDIR/info]
76 --mandir=DIR man documentation [DATAROOTDIR/man]
77
78 #if( $options.size() > 0 )
79 Options:
80 --debug add extra compile flags for debug builds
81 --release add extra compile flags for release builds
82 #foreach( $opt in $options )
83 --${opt.getArgument()}=${opt.getValuesString()}
84 #end
85
86 #end
87 #if( $features.size() > 0 )
88 Optional Features:
89 #foreach( $feature in $features )
90 #if( $feature.default )
91 --disable-${feature.arg}
92 #else
93 --enable-${feature.arg}
94 #end
95 #end
96
97 #end
98 __EOF__
99 }
100 190
101 # 191 #
102 # parse arguments 192 # parse arguments
103 # 193 #
104 BUILD_TYPE="default" 194 BUILD_TYPE="default"
105 #set( $D = '$' )
106 for ARG in "$@" 195 for ARG in "$@"
107 do 196 do
108 case "$ARG" in 197 case "$ARG" in
109 "--prefix="*) PREFIX=${D}{ARG#--prefix=} ;; 198 "--prefix="*) prefix=${D}{ARG#--prefix=} ;;
110 "--exec-prefix="*) EPREFIX=${D}{ARG#--exec-prefix=} ;; 199 "--exec-prefix="*) exec_prefix=${D}{ARG#--exec-prefix=} ;;
111 "--bindir="*) BINDIR=${D}{ARG#----bindir=} ;; 200 "--bindir="*) bindir=${D}{ARG#----bindir=} ;;
112 "--sbindir="*) SBINDIR=${D}{ARG#--sbindir=} ;; 201 "--sbindir="*) sbindir=${D}{ARG#--sbindir=} ;;
113 "--libdir="*) LIBDIR=${D}{ARG#--libdir=} ;; 202 "--libdir="*) libdir=${D}{ARG#--libdir=} ;;
114 "--libexecdir="*) LIBEXECDIR=${D}{ARG#--libexecdir=} ;; 203 "--libexecdir="*) libexecdir=${D}{ARG#--libexecdir=} ;;
115 "--datadir="*) DATADIR=${D}{ARG#--datadir=} ;; 204 "--datarootdir="*) datarootdir=${D}{ARG#--datarootdir=} ;;
116 "--sysconfdir="*) SYSCONFDIR=${D}{ARG#--sysconfdir=} ;; 205 "--datadir="*) datadir=${D}{ARG#--datadir=} ;;
117 "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;; 206 "--sysconfdir="*) sysconfdir=${D}{ARG#--sysconfdir=} ;;
118 "--localstatedir="*) LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;; 207 "--sharedstatedir="*) sharedstatedir=${D}{ARG#--sharedstatedir=} ;;
119 "--includedir="*) INCLUDEDIR=${D}{ARG#--includedir=} ;; 208 "--localstatedir="*) localstatedir=${D}{ARG#--localstatedir=} ;;
120 "--infodir="*) INFODIR=${D}{ARG#--infodir=} ;; 209 "--includedir="*) includedir=${D}{ARG#--includedir=} ;;
121 "--mandir"*) MANDIR=${D}{ARG#--mandir} ;; 210 "--infodir="*) infodir=${D}{ARG#--infodir=} ;;
122 "--help"*) printhelp; abort_configure ;; 211 "--mandir"*) mandir=${D}{ARG#--mandir} ;;
123 "--debug") BUILD_TYPE="debug" ;; 212 "--localedir"*) localedir=${D}{ARG#--localedir} ;;
124 "--release") BUILD_TYPE="release" ;; 213 "--help"*) printhelp; abort_configure ;;
214 "--debug") BUILD_TYPE="debug" ;;
215 "--release") BUILD_TYPE="release" ;;
125 #foreach( $opt in $options ) 216 #foreach( $opt in $options )
126 "--${opt.getArgument()}="*) ${opt.getVarName()}=${D}{ARG#--${opt.getArgument()}=} ;; 217 "--${opt.argument}="*) ${opt.varName}=${D}{ARG#--${opt.argument}=} ;;
218 "--${opt.argument}") echo "option '$ARG' needs a value:"; echo " $ARG=${opt.valuesString}"; abort_configure ;;
127 #end 219 #end
128 #foreach( $feature in $features ) 220 #foreach( $feature in $features )
129 "--enable-${feature.arg}") ${feature.getVarName()}=on ;; 221 "--enable-${feature.arg}") ${feature.varName}=on ;;
130 "--disable-${feature.arg}") unset ${feature.getVarName()} ;; 222 "--disable-${feature.arg}") unset ${feature.varName} ;;
131 #end 223 #end
132 "-"*) echo "unknown option: $ARG"; abort_configure ;; 224 "-"*) echo "unknown option: $ARG"; abort_configure ;;
133 esac 225 esac
134 done 226 done
135 227
136 ## Begin unparsed content. ** 228 ## Begin unparsed content. **
137 #[[ 229 #[[
138 # set dir variables 230
139 : ${EPREFIX:="$PREFIX"} 231 # set defaults for dir variables
140 : ${BINDIR:="$EPREFIX/bin"} 232 : ${exec_prefix:="$prefix"}
141 : ${SBINDIR:="$EPREFIX/sbin"} 233 : ${bindir:='${exec_prefix}/bin'}
142 : ${LIBDIR:="$EPREFIX/lib"} 234 : ${sbindir:='${exec_prefix}/sbin'}
143 : ${LIBEXECDIR:="$EPREFIX/libexec"} 235 : ${libdir:='${exec_prefix}/lib'}
144 : ${DATADIR:="$PREFIX/share"} 236 : ${libexecdir:='${exec_prefix}/libexec'}
145 : ${SYSCONFDIR:="$PREFIX/etc"} 237 : ${datarootdir:='${prefix}/share'}
146 : ${SHAREDSTATEDIR:="$PREFIX/com"} 238 : ${datadir:='${datarootdir}'}
147 : ${LOCALSTATEDIR:="$PREFIX/var"} 239 : ${sysconfdir:='${prefix}/etc'}
148 : ${INCLUDEDIR:="$PREFIX/include"} 240 : ${sharedstatedir:='${prefix}/com'}
149 : ${INFODIR:="$PREFIX/info"} 241 : ${localstatedir:='${prefix}/var'}
150 : ${MANDIR:="$PREFIX/man"} 242 : ${runstatedir:='${localstatedir}/run'}
151 243 : ${includedir:='${prefix}/include'}
152 # Test for availability of pkg-config 244 : ${infodir:='${datarootdir}/info'}
153 PKG_CONFIG=`command -v pkg-config` 245 : ${mandir:='${datarootdir}/man'}
154 : ${PKG_CONFIG:="false"} 246 : ${localedir:='${datarootdir}/locale'}
155 247
156 # Simple uname based platform detection 248 # remember the above values and compare them later
157 # $PLATFORM is used for platform dependent dependency selection 249 orig_bindir="$bindir"
158 OS=`uname -s` 250 orig_sbindir="$sbindir"
159 OS_VERSION=`uname -r` 251 orig_libdir="$libdir"
160 printf "detect platform... " 252 orig_libexecdir="$libexecdir"
161 if [ "$OS" = "SunOS" ]; then 253 orig_datarootdir="$datarootdir"
162 PLATFORM="solaris sunos unix svr4" 254 orig_datadir="$datadir"
163 fi 255 orig_sysconfdir="$sysconfdir"
164 if [ "$OS" = "Linux" ]; then 256 orig_sharedstatedir="$sharedstatedir"
165 PLATFORM="linux unix" 257 orig_localstatedir="$localstatedir"
166 fi 258 orig_runstatedir="$runstatedir"
167 if [ "$OS" = "FreeBSD" ]; then 259 orig_includedir="$includedir"
168 PLATFORM="freebsd bsd unix" 260 orig_infodir="$infodir"
169 fi 261 orig_mandir="$mandir"
170 if [ "$OS" = "Darwin" ]; then 262 orig_localedir="$localedir"
171 PLATFORM="macos osx bsd unix" 263
172 fi 264 # check if a config.site exists and load it
173 if echo "$OS" | grep -i "MINGW" > /dev/null; then 265 if [ -n "$CONFIG_SITE" ]; then
174 PLATFORM="windows mingw" 266 # CONFIG_SITE may contain space separated file names
175 fi 267 for cs in $CONFIG_SITE; do
176 : ${PLATFORM:="unix"} 268 printf "loading defaults from $cs... "
177 269 . "$cs"
178 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` 270 echo ok
179 echo "$PLATFORM_NAME"
180
181 isplatform()
182 {
183 for p in $PLATFORM
184 do
185 if [ "$p" = "$1" ]; then
186 return 0
187 fi
188 done 271 done
189 return 1 272 elif [ -f "$prefix/share/config.site" ]; then
190 } 273 printf "loading site defaults... "
191 notisplatform() 274 . "$prefix/share/config.site"
192 { 275 echo ok
193 for p in $PLATFORM 276 elif [ -f "$prefix/etc/config.site" ]; then
194 do 277 printf "loading site defaults... "
195 if [ "$p" = "$1" ]; then 278 . "$prefix/etc/config.site"
196 return 1 279 echo ok
197 fi 280 else
198 done 281 # try to detect the correct libdir on our own, except it was changed by the user
199 return 0 282 if test "$libdir" = '${exec_prefix}/lib'; then
200 } 283 if [ "$OS" = "SunOS" ]; then
284 test -d "${exec_prefix}/lib/amd64" && libdir='${exec_prefix}/lib/amd64'
285 else
286 # check if the standard libdir even exists
287 if test -d "${exec_prefix}/lib" ; then
288 :
289 else
290 # if it does not, maybe a lib32 exists
291 test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32'
292 fi
293 # now check if there is a special 64bit libdir that we should use
294 for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do
295 if [ $ARCH = $i ]; then
296 test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64'
297 break
298 fi
299 done
300 fi
301 fi
302 fi
201 ]]# 303 ]]#
202 ## End of unparsed content ** 304 ## End of unparsed content **
203 305
204 # generate vars.mk 306 # generate vars.mk
205 cat > "$TEMP_DIR/vars.mk" << __EOF__ 307 cat > "$TEMP_DIR/vars.mk" << __EOF__
206 PREFIX=$PREFIX 308 prefix=$prefix
207 EPREFIX=$EPREFIX 309 exec_prefix=$exec_prefix
208 BINDIR=$BINDIR 310 bindir=$bindir
209 SBINDIR=$SBINDIR 311 sbindir=$sbindir
210 LIBDIR=$LIBDIR 312 libdir=$libdir
211 LIBEXECDIR=$LIBEXECDIR 313 libexecdir=$libexecdir
212 DATADIR=$DATADIR 314 datarootdir=$datarootdir
213 SYSCONFDIR=$SYSCONFDIR 315 datadir=$datadir
214 SHAREDSTATEDIR=$SHAREDSTATEDIR 316 sysconfdir=$sysconfdir
215 LOCALSTATEDIR=$LOCALSTATEDIR 317 sharedstatedir=$sharedstatedir
216 INCLUDEDIR=$INCLUDEDIR 318 localstatedir=$localstatedir
217 INFODIR=$INFODIR 319 runstatedir=$runstatedir
218 MANDIR=$MANDIR 320 includedir=$includedir
321 infodir=$infodir
322 mandir=$mandir
323 localedir=$localedir
219 #foreach( $var in $vars ) 324 #foreach( $var in $vars )
220 ${var.varName}=$${var.varName} 325 ${var.varName}=${D}${var.varName}
221 #end 326 #end
222 __EOF__ 327 __EOF__
223 sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
224
225 328
226 # toolchain detection utilities 329 # toolchain detection utilities
227 . make/toolchain.sh 330 . make/toolchain.sh
228 331
229 # 332 #
253 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : 356 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
254 else return 1 ; fi 357 else return 1 ; fi
255 return 0 358 return 0
256 } 359 }
257 360
361 print_check_msg()
362 {
363 if [ -z "$1" ]; then
364 shift
365 printf "$@"
366 fi
367 }
368
258 #foreach( $dependency in $namedDependencies ) 369 #foreach( $dependency in $namedDependencies )
259 dependency_error_${dependency.name}() 370 dependency_error_${dependency.id}()
260 { 371 {
261 printf "checking for ${dependency.name}... " 372 print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... "
262 #foreach( $sub in $dependency.getSubdependencies() ) 373 #foreach( $sub in $dependency.subdependencies )
263 # dependency $sub.getFullName() 374 # dependency $sub.fullName
264 while true 375 while true
265 do 376 do
266 #if( $sub.platform ) 377 #if( $sub.platform )
267 if notisplatform "${sub.platform}"; then 378 if notisplatform "${sub.platform}"; then
268 break 379 break
269 fi 380 fi
270 #end 381 #end
271 #foreach( $np in $sub.getNotList() ) 382 #if( $sub.toolchain )
272 if isplatform "${np}"; then 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
273 break 389 break
274 fi 390 fi
275 #end 391 #end
276 #foreach( $lang in $sub.lang ) 392 #foreach( $lang in $sub.lang )
277 if [ -z "$lang_${lang}" ] ; then 393 if [ -z "$lang_${lang}" ] ; then
313 cat >> $TEMP_DIR/make.mk << __EOF__ 429 cat >> $TEMP_DIR/make.mk << __EOF__
314 # Dependency: $dependency.name 430 # Dependency: $dependency.name
315 $sub.make 431 $sub.make
316 __EOF__ 432 __EOF__
317 #end 433 #end
318 echo yes 434 print_check_msg "${D}dep_checked_${dependency.id}" "yes\n"
435 dep_checked_${dependency.id}=1
319 return 1 436 return 1
320 done 437 done
321 438
322 #end 439 #end
323 echo no 440 print_check_msg "${D}dep_checked_${dependency.id}" "no\n"
441 dep_checked_${dependency.id}=1
324 return 0 442 return 0
325 } 443 }
326 #end 444 #end
327
328
329
330 445
331 # start collecting dependency information 446 # start collecting dependency information
332 echo > "$TEMP_DIR/flags.mk" 447 echo > "$TEMP_DIR/flags.mk"
333 448
334 DEPENDENCIES_FAILED= 449 DEPENDENCIES_FAILED=
335 ERROR=0 450 ERROR=0
336 #if( $dependencies.size() > 0 ) 451 #if( $dependencies.size() > 0 )
337 # unnamed dependencies 452 # unnamed dependencies
338 TEMP_CFLAGS= 453 TEMP_CFLAGS="$CFLAGS"
339 TEMP_CXXFLAGS= 454 TEMP_CXXFLAGS="$CXXFLAGS"
340 TEMP_LDFLAGS= 455 TEMP_LDFLAGS="$LDFLAGS"
341 #foreach( $dependency in $dependencies ) 456 #foreach( $dependency in $dependencies )
342 while true 457 while true
343 do 458 do
344 #if( $dependency.platform ) 459 #if( $dependency.platform )
345 if notisplatform "${dependency.platform}"; then 460 if notisplatform "${dependency.platform}"; then
346 break 461 break
347 fi 462 fi
348 #end 463 #end
349 #foreach( $np in $dependency.getNotList() ) 464 #if( $dependency.toolchain )
350 if isplatform "${np}"; then 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
351 break 471 break
352 fi 472 fi
353 #end 473 #end
354 while true 474 while true
355 do 475 do
364 ERROR=1 484 ERROR=1
365 break 485 break
366 fi 486 fi
367 #end 487 #end
368 #foreach( $pkg in $dependency.pkgconfig ) 488 #foreach( $pkg in $dependency.pkgconfig )
369 printf "checking for pkg-config package $pkg.name... " 489 print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... "
370 if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then 490 if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then
371 echo yes 491 print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n"
492 dep_pkgconfig_checked_${pkg.id}=1
372 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" 493 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`"
373 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" 494 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`"
374 else 495 else
375 echo no 496 print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n"
497 dep_pkgconfig_checked_${pkg.id}=1
376 ERROR=1 498 ERROR=1
377 break 499 break
378 fi 500 fi
379 #end 501 #end
380 502
400 done 522 done
401 break 523 break
402 done 524 done
403 #end 525 #end
404 526
527 # build type
528 if [ "$BUILD_TYPE" = "debug" ]; then
529 TEMP_CFLAGS="\${DEBUG_CFLAGS} $TEMP_CFLAGS"
530 TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS} $TEMP_CXXFLAGS"
531 fi
532 if [ "$BUILD_TYPE" = "release" ]; then
533 TEMP_CFLAGS="\${RELEASE_CFLAGS} $TEMP_CFLAGS"
534 TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS} $TEMP_CXXFLAGS"
535 fi
536
405 # add general dependency flags to flags.mk 537 # add general dependency flags to flags.mk
406 echo "# general flags" >> "$TEMP_DIR/flags.mk" 538 echo "# general flags" >> "$TEMP_DIR/flags.mk"
407 if [ -n "${TEMP_CFLAGS}" ]; then 539 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
408 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" 540 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
409 fi 541 fi
410 if [ -n "${TEMP_CXXFLAGS}" ]; then 542 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
411 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" 543 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
412 fi 544 fi
413 if [ -n "${TEMP_LDFLAGS}" ]; then 545 if [ -n "${TEMP_LDFLAGS}" ]; then
414 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" 546 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
415 fi 547 fi
450 # 582 #
451 583
452 #foreach( $target in $targets ) 584 #foreach( $target in $targets )
453 echo >> "$TEMP_DIR/flags.mk" 585 echo >> "$TEMP_DIR/flags.mk"
454 #if ( $target.name ) 586 #if ( $target.name )
455 # Target: $target.name 587 echo "configuring target: $target.name"
456 echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk" 588 echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk"
457 #else 589 #else
458 # Target 590 echo "configuring global target"
459 echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" 591 echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
460 #end 592 #end
461 TEMP_CFLAGS= 593 TEMP_CFLAGS=
462 TEMP_CXXFLAGS= 594 TEMP_CXXFLAGS=
463 TEMP_LDFLAGS= 595 TEMP_LDFLAGS=
469 fi 601 fi
470 #end 602 #end
471 603
472 # Features 604 # Features
473 #foreach( $feature in $target.features ) 605 #foreach( $feature in $target.features )
474 if [ -n "$${feature.getVarName()}" ]; then 606 if [ -n "${D}${feature.varName}" ]; then
475 #foreach( $dependency in $feature.dependencies ) 607 #foreach( $dependency in $feature.dependencies )
476 # check dependency 608 # check dependency
477 if dependency_error_$dependency ; then 609 if dependency_error_$dependency ; then
478 # "auto" features can fail and are just disabled in this case 610 # "auto" features can fail and are just disabled in this case
479 if [ "$${feature.getVarName()}" = "auto" ]; then 611 if [ "${D}${feature.varName}" = "auto" ]; then
480 DISABLE_${feature.getVarName()}=1 612 DISABLE_${feature.varName}=1
481 else 613 else
482 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " 614 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
483 ERROR=1 615 ERROR=1
484 fi 616 fi
485 fi 617 fi
486 #end 618 #end
487 if [ -n "$DISABLE_${feature.getVarName()}" ]; then 619 if [ -n "$DISABLE_${feature.varName}" ]; then
488 unset ${feature.getVarName()} 620 unset ${feature.varName}
489 fi 621 fi
622 fi
623 if [ -n "${D}${feature.varName}" ]; then
624 :
625 #foreach( $def in $feature.defines )
626 TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}"
627 TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}"
628 #end
629 #if( $feature.hasMake() )
630 cat >> "$TEMP_DIR/make.mk" << __EOF__
631 $feature.make
632 __EOF__
633 #end
634 else
635 :
636 #foreach( $def in $feature.disabled.defines )
637 TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}"
638 TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}"
639 #end
640 #if( $feature.disabled.hasMake() )
641 cat >> "$TEMP_DIR/make.mk" << __EOF__
642 $feature.disabled.make
643 __EOF__
644 #end
645 #foreach( $dependency in $feature.disabled.dependencies )
646 if dependency_error_$dependency ; then
647 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
648 ERROR=1
649 fi
650 #end
490 fi 651 fi
491 #end 652 #end
492 653
493 #foreach( $opt in $target.options ) 654 #foreach( $opt in $target.options )
494 # Option: --${opt.argument} 655 # Option: --${opt.argument}
495 if [ -z ${D}${opt.getVarName()} ]; then 656 if [ -z "${D}${opt.varName}" ]; then
657 echo "auto-detecting option '${opt.argument}'"
496 SAVED_ERROR="$ERROR" 658 SAVED_ERROR="$ERROR"
497 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" 659 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
498 ERROR=1 660 ERROR=1
499 while true 661 while true
500 do 662 do
513 #end 675 #end
514 break 676 break
515 done 677 done
516 if [ $ERROR -ne 0 ]; then 678 if [ $ERROR -ne 0 ]; then
517 SAVED_ERROR=1 679 SAVED_ERROR=1
680 SAVED_DEPENDENCIES_FAILED="option '${opt.argument}' $SAVED_DEPENDENCIES_FAILED"
518 fi 681 fi
519 ERROR="$SAVED_ERROR" 682 ERROR="$SAVED_ERROR"
520 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" 683 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
521 else 684 else
685 echo "checking option ${opt.argument} = ${D}${opt.varName}"
522 if false; then 686 if false; then
523 false 687 false
524 #foreach( $optval in $opt.values ) 688 #foreach( $optval in $opt.values )
525 elif [ "${D}${opt.getVarName()}" = "${optval.value}" ]; then 689 elif [ "${D}${opt.varName}" = "${optval.value}" ]; then
526 echo " ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options 690 echo " ${opt.argument}: ${D}${opt.varName}" >> $TEMP_DIR/options
527 if $optval.func ; then 691 if $optval.func ; then
528 : 692 :
529 else 693 else
530 ERROR=1 694 ERROR=1
531 fi 695 DEPENDENCIES_FAILED="option '${opt.argument}' $DEPENDENCIES_FAILED"
532 #end 696 fi
533 fi 697 #end
534 fi 698 else
535 #end 699 echo
536 700 echo "Invalid option value - usage:"
537 if [ -n "${TEMP_CFLAGS}" ]; then 701 echo " --${opt.argument}=${opt.valuesString}"
538 echo "${target.getCFlags()} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" 702 abort_configure
539 fi 703 fi
540 if [ -n "${TEMP_CXXFLAGS}" ]; then 704 fi
541 echo "${target.getCXXFlags()} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" 705 #end
542 fi 706
543 if [ "$BUILD_TYPE" = "debug" ]; then 707 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
544 echo '${target.getCFlags()} += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" 708 echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
545 echo '${target.getCXXFlags()} += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" 709 fi
546 fi 710 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
547 if [ "$BUILD_TYPE" = "release" ]; then 711 echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
548 echo '${target.getCFlags()} += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
549 echo '${target.getCXXFlags()} += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
550 fi 712 fi
551 if [ -n "${TEMP_LDFLAGS}" ]; then 713 if [ -n "${TEMP_LDFLAGS}" ]; then
552 echo "${target.getLDFlags()} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" 714 echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
553 fi 715 fi
554 716
555 #end 717 #end
556 718
557 # final result 719 # final result
562 abort_configure 724 abort_configure
563 fi 725 fi
564 726
565 echo "configure finished" 727 echo "configure finished"
566 echo 728 echo
729 echo "Toolchain"
730 echo " name: $TOOLCHAIN_NAME"
731 if [ -n "$TOOLCHAIN_CC" ]; then
732 echo " cc: $TOOLCHAIN_CC"
733 fi
734 if [ -n "$TOOLCHAIN_CXX" ]; then
735 echo " cxx: $TOOLCHAIN_CXX"
736 fi
737 if [ -n "$TOOLCHAIN_WSIZE" ]; then
738 echo " word size: $TOOLCHAIN_WSIZE bit"
739 fi
740 if [ -n "$TOOLCHAIN_CSTD" ]; then
741 echo " default C std: $TOOLCHAIN_CSTD"
742 fi
743 echo
567 echo "Build Config:" 744 echo "Build Config:"
568 echo " PREFIX: $PREFIX" 745 echo " prefix: $prefix"
569 echo " TOOLCHAIN: $TOOLCHAIN_NAME" 746 echo " exec_prefix: $exec_prefix"
747 if [ "$orig_bindir" != "$bindir" ]; then
748 echo " bindir: $bindir"
749 fi
750 if [ "$orig_sbindir" != "$sbindir" ]; then
751 echo " sbindir: $sbindir"
752 fi
753 if [ "$orig_libdir" != "$libdir" ]; then
754 echo " libdir: $libdir"
755 fi
756 if [ "$orig_libexecdir" != "$libexecdir" ]; then
757 echo " libexecdir: $libexecdir"
758 fi
759 if [ "$orig_datarootdir" != "$datarootdir" ]; then
760 echo " datarootdir: $datarootdir"
761 fi
762 if [ "$orig_datadir" != "$datadir" ]; then
763 echo " datadir: $datadir"
764 fi
765 if [ "$orig_sysconfdir" != "$sysconfdir" ]; then
766 echo " sysconfdir: $sysconfdir"
767 fi
768 if [ "$orig_sharedstatedir" != "$sharedstatedir" ]; then
769 echo " sharedstatedir: $sharedstatedir"
770 fi
771 if [ "$orig_localstatedir" != "$localstatedir" ]; then
772 echo " localstatedir: $localstatedir"
773 fi
774 if [ "$orig_runstatedir" != "$runstatedir" ]; then
775 echo " runstatedir: $runstatedir"
776 fi
777 if [ "$orig_includedir" != "$includedir" ]; then
778 echo " includedir: $includedir"
779 fi
780 if [ "$orig_infodir" != "$infodir" ]; then
781 echo " infodir: $infodir"
782 fi
783 if [ "$orig_mandir" != "$mandir" ]; then
784 echo " mandir: $mandir"
785 fi
786 if [ "$orig_localedir" != "$localedir" ]; then
787 echo " localedir: $localedir"
788 fi
570 #if ( $options.size() > 0 ) 789 #if ( $options.size() > 0 )
790 echo
571 echo "Options:" 791 echo "Options:"
572 cat "$TEMP_DIR/options" 792 cat "$TEMP_DIR/options"
573 #end 793 #end
574 #if ( $features.size() > 0 ) 794 #if ( $features.size() > 0 )
795 echo
575 echo "Features:" 796 echo "Features:"
576 #foreach( $feature in $features ) 797 #foreach( $feature in $features )
577 if [ -n "$${feature.getVarName()}" ]; then 798 if [ -n "${D}${feature.varName}" ]; then
578 echo " $feature.name: on" 799 echo " $feature.name: on"
579 else 800 else
580 echo " $feature.name: off" 801 echo " $feature.name: off"
581 fi 802 fi
582 #end 803 #end
583 #end 804 #end
584 echo 805 echo
585 806
586 # generate the config.mk file 807 # generate the config.mk file
808 pwd=`pwd`
587 cat > "$TEMP_DIR/config.mk" << __EOF__ 809 cat > "$TEMP_DIR/config.mk" << __EOF__
588 # 810 #
589 # config.mk generated by configure 811 # config.mk generated by:
812 # pwd: $pwd
813 # $0 $@
590 # 814 #
591 815
592 __EOF__ 816 __EOF__
593 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" 817 write_toolchain_defaults "$TEMP_DIR/toolchain.mk"
594 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk 818 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
595 rm -Rf "$TEMP_DIR" 819 rm -Rf "$TEMP_DIR"
596
597

mercurial