3 #foreach( $var in $vars )
5 ${var.varName}=`${var.value}`
7 ${var.varName}=${var.value}
11 #if ( ! $project.hasVar("PREFIX") )
14 #if ( ! $project.hasVar("EPREFIX") )
18 #if ( ! $project.hasVar("BINDIR") )
21 #if ( ! $project.hasVar("SBINDIR") )
24 #if ( ! $project.hasVar("LIBDIR") )
27 #if ( ! $project.hasVar("LIBEXECDIR") )
30 #if ( ! $project.hasVar("DATADIR") )
33 #if ( ! $project.hasVar("SYSCONFDIR") )
36 #if ( ! $project.hasVar("SHAREDSTATEDIR") )
39 #if ( ! $project.hasVar("LOCALSTATEDIR") )
42 #if ( ! $project.hasVar("INCLUDEDIR") )
45 #if ( ! $project.hasVar("INFODIR") )
48 #if ( ! $project.hasVar("MANDIR") )
55 TEMP_DIR=".tmp-`uname -n`"
58 echo "Cannot create tmp dir"
61 touch "$TEMP_DIR/options"
62 touch "$TEMP_DIR/features"
65 #foreach( $feature in $features )
66 #if( ${feature.isDefault()} )
67 ${feature.getVarName()}=on
74 echo "Usage: $0 [OPTIONS]..."
76 Installation directories:
77 --prefix=PREFIX path prefix for architecture-independent files
79 --exec-prefix=EPREFIX path prefix for architecture-dependent files
82 --bindir=DIR user executables [EPREFIX/bin]
83 --sbindir=DIR system admin executables [EPREFIX/sbin]
84 --libexecdir=DIR program executables [EPREFIX/libexec]
85 --sysconfdir=DIR system configuration files [PREFIX/etc]
86 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
87 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
88 --libdir=DIR object code libraries [EPREFIX/lib]
89 --includedir=DIR C header files [PREFIX/include]
90 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
91 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
92 --infodir=DIR info documentation [DATAROOTDIR/info]
93 --mandir=DIR man documentation [DATAROOTDIR/man]
95 #if( $options.size() > 0 )
97 #foreach( $opt in $options )
98 --${opt.getArgument()}=${opt.getValuesString()}
102 #if( $features.size() > 0 )
104 #foreach( $feature in $features )
105 #if( $feature.default )
106 --disable-${feature.arg}
108 --enable-${feature.arg}
123 "--prefix="*) PREFIX=${D}{ARG#--prefix=} ;;
124 "--exec-prefix="*) EPREFIX=${D}{ARG#--exec-prefix=} ;;
125 "--bindir="*) BINDIR=${D}{ARG#----bindir=} ;;
126 "--sbindir="*) SBINDIR=${D}{ARG#--sbindir=} ;;
127 "--libdir="*) LIBDIR=${D}{ARG#--libdir=} ;;
128 "--libexecdir="*) LIBEXECDIR=${D}{ARG#--libexecdir=} ;;
129 "--datadir="*) DATADIR=${D}{ARG#--datadir=} ;;
130 "--sysconfdir="*) SYSCONFDIR=${D}{ARG#--sysconfdir=} ;;
131 "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;;
132 "--localstatedir="*) LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;;
133 "--includedir="*) INCLUDEDIR=${D}{ARG#--includedir=} ;;
134 "--infodir="*) INFODIR=${D}{ARG#--infodir=} ;;
135 "--mandir"*) MANDIR=${D}{ARG#--mandir} ;;
136 "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
137 #foreach( $opt in $options )
138 "--${opt.getArgument()}="*) ${opt.getVarName()}=${D}{ARG#--${opt.getArgument()}=} ;;
140 #foreach( $feature in $features )
141 "--enable-${feature.arg}") ${feature.getVarName()}=on ;;
142 "--disable-${feature.arg}") unset ${feature.getVarName()} ;;
144 "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
149 if [ -z "$BINDIR" ]; then
152 if [ -z "$SBINDIR" ]; then
153 SBINDIR=$EPREFIX/sbin
155 if [ -z "$LIBDIR" ]; then
158 if [ -z "$LIBEXEC" ]; then
159 LIBEXECDIR=$EPREFIX/libexec
161 if [ -z "$DATADIR" ]; then
162 DATADIR=$PREFIX/share
164 if [ -z "$SYSCONFDIR" ]; then
165 SYSCONFDIR=$PREFIX/etc
167 if [ -z "$SHAREDSTATEDIR" ]; then
168 SHAREDSTATEDIR=$PREFIX/com
170 if [ -z "$LOCALSTATEDIR" ]; then
171 LOCALSTATEDIR=$PREFIX/var
173 if [ -z "$INCLUDEDIR" ]; then
174 INCLUDEDIR=$PREFIX/include
176 if [ -z "$INFODIR" ]; then
179 if [ -z "$MANDIR" ]; then
183 which pkg-config > /dev/null
184 if [ $? -eq 0 ]; then
185 PKG_CONFIG=pkg-config
190 # Simple uname based platform detection
191 # $PLATFORM is used for platform dependent dependency selection
192 printf "detect platform... "
193 if [ "$OS" = "SunOS" ]; then
194 PLATFORM="solaris sunos unix svr4"
196 if [ "$OS" = "Linux" ]; then
197 PLATFORM="linux unix"
199 if [ "$OS" = "FreeBSD" ]; then
200 PLATFORM="freebsd bsd unix"
202 if [ "$OS" = "Darwin" ]; then
203 PLATFORM="macos osx bsd unix"
205 echo "$OS" | grep -i "MINGW" > /dev/null
206 if [ $? -eq 0 ]; then
207 PLATFORM="windows mingw"
210 if [ -z "$PLATFORM" ]; then
225 if [ "$p" = "$1" ]; then
235 if [ "$p" = "$1" ]; then
242 # generate config.mk and config.h
243 cat > "$TEMP_DIR/config.mk" << __EOF__
245 # config.mk generated by configure
249 #foreach( $var in $vars )
250 ${var.varName}=$${var.varName}
253 #if ( ! $project.hasVar("PREFIX") )
256 #if ( ! $project.hasVar("EPREFIX") )
260 #if ( ! $project.hasVar("BINDIR") )
263 #if ( ! $project.hasVar("SBINDIR") )
266 #if ( ! $project.hasVar("LIBDIR") )
269 #if ( ! $project.hasVar("LIBEXECDIR") )
270 LIBEXECDIR=$LIBEXECDIR
272 #if ( ! $project.hasVar("DATADIR") )
275 #if ( ! $project.hasVar("SYSCONFDIR") )
276 SYSCONFDIR=$SYSCONFDIR
278 #if ( ! $project.hasVar("SHAREDSTATEDIR") )
279 SHAREDSTATEDIR=$SHAREDSTATEDIR
281 #if ( ! $project.hasVar("LOCALSTATEDIR") )
282 LOCALSTATEDIR=$LOCALSTATEDIR
284 #if ( ! $project.hasVar("INCLUDEDIR") )
285 INCLUDEDIR=$INCLUDEDIR
287 #if ( ! $project.hasVar("INFODIR") )
290 #if ( ! $project.hasVar("MANDIR") )
296 echo > "$TEMP_DIR/make.mk"
300 ENV_CXXFLAGS=$CXXFLAGS
302 # Toolchain detection
303 # this will insert make vars to config.mk
306 # add user specified flags to config.mk
307 echo "# project specific flags" >> "$TEMP_DIR/config.mk"
308 if [ -n "${ENV_CFLAGS}" ]; then
309 echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
311 if [ -n "${ENV_CXXFLAGS}" ]; then
312 echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
314 if [ -n "${ENV_LDFLAGS}" ]; then
315 echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
322 #foreach( $dependency in $namedDependencies )
323 dependency_${dependency.name}()
325 printf "checking for ${dependency.name}... "
326 #foreach( $sub in $dependency.getSubdependencies() )
327 # dependency $sub.getFullName()
331 if isnotplatform "${sub.platform}"; then
335 #foreach( $not in $sub.getNotList() )
336 if isplatform "${not}"; then
340 #if( $sub.pkgconfig.size() > 0 )
341 if [ -z "$PKG_CONFIG" ]; then
345 #foreach( $test in $sub.tests )
347 if [ $? -ne 0 ]; then
351 #foreach( $pkg in $sub.pkgconfig )
352 $pkg.getPkgConfigTestQuery()
353 if [ $? -ne 0 ] ; then
356 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags $pkg.name`"
357 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs $pkg.name`"
359 #foreach( $flags in $sub.flags )
361 $flags.value > /dev/null
362 if [ $? -eq 0 ]; then
363 TEMP_$flags.varName="$TEMP_$flags.varName `$flags.value`"
368 TEMP_$flags.varName="$TEMP_$flags.varName $flags.value"
371 #if ( $sub.make.length() > 0 )
372 cat >> $TEMP_DIR/make.mk << __EOF__
373 # Dependency: $dependency.name
389 #if( $dependencies.size() > 0 )
390 # general dependencies
393 #foreach( $dependency in $dependencies )
396 #if( $dependency.platform )
397 if isnotplatform "${dependency.platform}"; then
401 #foreach( $not in $dependency.getNotList() )
402 if isplatform "${not}"; then
408 #if( $dependency.pkgconfig.size() > 0 )
409 if [ -z "$PKG_CONFIG" ]; then
414 #foreach( $pkg in $dependency.pkgconfig )
415 printf "checking for pkg-config package $pkg.name... "
416 $pkg.getPkgConfigTestQuery()
417 if [ $? -ne 0 ]; then
423 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags $pkg.name`"
424 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs $pkg.name`"
427 #foreach( $flags in $dependency.flags )
429 $flags.value > /dev/null
430 if [ $? -ne 0 ]; then
431 TEMP_$flags.varName="$TEMP_$flags.varName `$flags.value`"
437 TEMP_$flags.varName="$TEMP_$flags.varName $flags.value"
440 #if ( $dependency.make.length() > 0 )
441 cat >> "$TEMP_DIR/make.mk" << __EOF__
453 # add general dependency flags to config.mk
454 echo >> "$TEMP_DIR/config.mk"
455 if [ -n "${TEMP_CFLAGS}" ]; then
456 echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
458 if [ -n "${TEMP_CXXFLAGS}" ]; then
459 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
461 if [ -n "${TEMP_LDFLAGS}" ]; then
462 echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
469 #foreach( $opt in $options )
470 #foreach( $val in $opt.values )
474 #foreach( $dep in $val.dependencies )
476 if [ $? -ne 0 ]; then
480 if [ $VERR -ne 0 ]; then
483 #foreach( $def in $val.defines )
484 TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}"
486 #if( $val.hasMake() )
487 cat >> "$TEMP_DIR/make.mk" << __EOF__
503 #foreach( $target in $targets )
505 # Target: $target.name
513 #foreach( $dependency in $target.dependencies )
514 dependency_$dependency
515 if [ $? -ne 0 ]; then
516 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
522 #foreach( $feature in $target.features )
523 if [ -n "$${feature.getVarName()}" ]; then
524 #foreach( $dependency in $feature.dependencies )
526 dependency_$dependency
527 if [ $? -ne 0 ]; then
528 # "auto" features can fail and are just disabled in this case
529 if [ "$${feature.getVarName()}" != "auto" ]; then
530 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
538 #foreach( $opt in $target.options )
539 # Option: --${opt.argument}
540 if [ -z ${D}${opt.getVarName()} ]; then
542 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
546 #foreach( $optdef in $opt.defaults )
547 #if( $optdef.platform )
548 if isplatform "$optdef.platform"; then
551 if [ $? -eq 0 ]; then
552 echo " ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options"
556 #if( $optdef.platform )
562 if [ $ERROR -ne 0 ]; then
566 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
570 #foreach( $optval in $opt.values )
571 elif [ "${D}${opt.getVarName()}" = "${optval.value}" ]; then
572 echo " ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options
574 if [ $? -ne 0 ]; then
582 echo >> "$TEMP_DIR/config.mk"
583 if [ -n "${TEMP_CFLAGS}" ]; then
584 echo "${target.getCFlags()} += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
586 if [ -n "${TEMP_CXXFLAGS}" ]; then
587 echo "${target.getCXXFlags()} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
589 if [ -n "${TEMP_LDFLAGS}" ]; then
590 echo "${target.getLDFlags()} += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
594 if [ $ERROR -ne 0 ]; then
596 echo "Error: Unresolved dependencies"
597 echo "$DEPENDENCIES_FAILED"
602 echo "configure finished"
605 echo " PREFIX: $PREFIX"
606 echo " TOOLCHAIN: $TOOLCHAIN_NAME"
607 #if ( $options.size() > 0 )
609 cat "$TEMP_DIR/options"
612 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk