83 --sbindir=DIR system admin executables [EPREFIX/sbin] |
70 --sbindir=DIR system admin executables [EPREFIX/sbin] |
84 --libexecdir=DIR program executables [EPREFIX/libexec] |
71 --libexecdir=DIR program executables [EPREFIX/libexec] |
85 --sysconfdir=DIR system configuration files [PREFIX/etc] |
72 --sysconfdir=DIR system configuration files [PREFIX/etc] |
86 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
73 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
87 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
74 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
|
75 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] |
88 --libdir=DIR object code libraries [EPREFIX/lib] |
76 --libdir=DIR object code libraries [EPREFIX/lib] |
89 --includedir=DIR C header files [PREFIX/include] |
77 --includedir=DIR C header files [PREFIX/include] |
90 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
78 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
91 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
79 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
92 --infodir=DIR info documentation [DATAROOTDIR/info] |
80 --infodir=DIR info documentation [DATAROOTDIR/info] |
93 --mandir=DIR man documentation [DATAROOTDIR/man] |
81 --mandir=DIR man documentation [DATAROOTDIR/man] |
|
82 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] |
94 |
83 |
95 #if( $options.size() > 0 ) |
84 #if( $options.size() > 0 ) |
96 Options: |
85 Options: |
|
86 --debug add extra compile flags for debug builds |
|
87 --release add extra compile flags for release builds |
97 #foreach( $opt in $options ) |
88 #foreach( $opt in $options ) |
98 --${opt.getArgument()}=${opt.getValuesString()} |
89 --${opt.argument}=${opt.valuesString} |
99 #end |
90 #end |
100 |
91 |
101 #end |
92 #end |
102 #if( $features.size() > 0 ) |
93 #if( $features.size() > 0 ) |
103 Optional Features: |
94 Optional Features: |
104 #foreach( $feature in $features ) |
95 #foreach( $feature in $features ) |
105 #if( $feature.default ) |
96 ${feature.helpText} |
106 --disable-${feature.arg} |
|
107 #else |
|
108 --enable-${feature.arg} |
|
109 #end |
|
110 #end |
97 #end |
111 |
98 |
112 #end |
99 #end |
113 __EOF__ |
100 __EOF__ |
114 } |
101 } |
115 |
102 |
116 # |
103 # |
117 # parse arguments |
104 # parse arguments |
118 # |
105 # |
|
106 BUILD_TYPE="default" |
119 #set( $D = '$' ) |
107 #set( $D = '$' ) |
120 for ARG in $@ |
108 for ARG in "$@" |
121 do |
109 do |
122 case "$ARG" in |
110 case "$ARG" in |
123 "--prefix="*) PREFIX=${D}{ARG#--prefix=} ;; |
111 "--prefix="*) prefix=${D}{ARG#--prefix=} ;; |
124 "--exec-prefix="*) EPREFIX=${D}{ARG#--exec-prefix=} ;; |
112 "--exec-prefix="*) exec_prefix=${D}{ARG#--exec-prefix=} ;; |
125 "--bindir="*) BINDIR=${D}{ARG#----bindir=} ;; |
113 "--bindir="*) bindir=${D}{ARG#----bindir=} ;; |
126 "--sbindir="*) SBINDIR=${D}{ARG#--sbindir=} ;; |
114 "--sbindir="*) sbindir=${D}{ARG#--sbindir=} ;; |
127 "--libdir="*) LIBDIR=${D}{ARG#--libdir=} ;; |
115 "--libdir="*) libdir=${D}{ARG#--libdir=} ;; |
128 "--libexecdir="*) LIBEXECDIR=${D}{ARG#--libexecdir=} ;; |
116 "--libexecdir="*) libexecdir=${D}{ARG#--libexecdir=} ;; |
129 "--datadir="*) DATADIR=${D}{ARG#--datadir=} ;; |
117 "--datarootdir="*) datarootdir=${D}{ARG#--datarootdir=} ;; |
130 "--sysconfdir="*) SYSCONFDIR=${D}{ARG#--sysconfdir=} ;; |
118 "--datadir="*) datadir=${D}{ARG#--datadir=} ;; |
131 "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;; |
119 "--sysconfdir="*) sysconfdir=${D}{ARG#--sysconfdir=} ;; |
132 "--localstatedir="*) LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;; |
120 "--sharedstatedir="*) sharedstatedir=${D}{ARG#--sharedstatedir=} ;; |
133 "--includedir="*) INCLUDEDIR=${D}{ARG#--includedir=} ;; |
121 "--localstatedir="*) localstatedir=${D}{ARG#--localstatedir=} ;; |
134 "--infodir="*) INFODIR=${D}{ARG#--infodir=} ;; |
122 "--includedir="*) includedir=${D}{ARG#--includedir=} ;; |
135 "--mandir"*) MANDIR=${D}{ARG#--mandir} ;; |
123 "--infodir="*) infodir=${D}{ARG#--infodir=} ;; |
136 "--help"*) printhelp; exit 1 ;; |
124 "--mandir"*) mandir=${D}{ARG#--mandir} ;; |
137 #foreach( $opt in $options ) |
125 "--localedir"*) localedir=${D}{ARG#--localedir} ;; |
138 "--${opt.getArgument()}="*) ${opt.getVarName()}=${D}{ARG#--${opt.getArgument()}=} ;; |
126 "--help"*) printhelp; abort_configure ;; |
139 #end |
127 "--debug") BUILD_TYPE="debug" ;; |
140 #foreach( $feature in $features ) |
128 "--release") BUILD_TYPE="release" ;; |
141 "--enable-${feature.arg}") ${feature.getVarName()}=on ;; |
129 #foreach( $opt in $options ) |
142 "--disable-${feature.arg}") unset ${feature.getVarName()} ;; |
130 "--${opt.argument}="*) ${opt.varName}=${D}{ARG#--${opt.argument}=} ;; |
143 #end |
131 #end |
144 "-"*) echo "unknown option: $ARG"; exit 1 ;; |
132 #foreach( $feature in $features ) |
145 esac |
133 "--enable-${feature.arg}") ${feature.varName}=on ;; |
|
134 "--disable-${feature.arg}") unset ${feature.varName} ;; |
|
135 #end |
|
136 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
|
137 esac |
146 done |
138 done |
147 |
139 |
148 # set dir variables |
140 ## Begin unparsed content. ** |
149 if [ -z "$BINDIR" ]; then |
141 #[[ |
150 BINDIR=$EPREFIX/bin |
142 |
151 fi |
143 # set defaults for dir variables |
152 if [ -z "$SBINDIR" ]; then |
144 : ${exec_prefix:="$prefix"} |
153 SBINDIR=$EPREFIX/sbin |
145 : ${bindir:='${exec_prefix}/bin'} |
154 fi |
146 : ${sbindir:='${exec_prefix}/sbin'} |
155 if [ -z "$LIBDIR" ]; then |
147 : ${libdir:='${exec_prefix}/lib'} |
156 LIBDIR=$EPREFIX/lib |
148 : ${libexecdir:='${exec_prefix}/libexec'} |
157 fi |
149 : ${datarootdir:='${prefix}/share'} |
158 if [ -z "$LIBEXEC" ]; then |
150 : ${datadir:='${datarootdir}'} |
159 LIBEXECDIR=$EPREFIX/libexec |
151 : ${sysconfdir:='${prefix}/etc'} |
160 fi |
152 : ${sharedstatedir:='${prefix}/com'} |
161 if [ -z "$DATADIR" ]; then |
153 : ${localstatedir:='${prefix}/var'} |
162 DATADIR=$PREFIX/share |
154 : ${runstatedir:='${localstatedir}/run'} |
163 fi |
155 : ${includedir:='${prefix}/include'} |
164 if [ -z "$SYSCONFDIR" ]; then |
156 : ${infodir:='${datarootdir}/info'} |
165 SYSCONFDIR=$PREFIX/etc |
157 : ${mandir:='${datarootdir}/man'} |
166 fi |
158 : ${localedir:='${datarootdir}/locale'} |
167 if [ -z "$SHAREDSTATEDIR" ]; then |
159 |
168 SHAREDSTATEDIR=$PREFIX/com |
160 # check if a config.site exists and load it |
169 fi |
161 if [ -n "$CONFIG_SITE" ]; then |
170 if [ -z "$LOCALSTATEDIR" ]; then |
162 # CONFIG_SITE may contain space separated file names |
171 LOCALSTATEDIR=$PREFIX/var |
163 for cs in $CONFIG_SITE; do |
172 fi |
164 printf "loading defaults from $cs... " |
173 if [ -z "$INCLUDEDIR" ]; then |
165 . "$cs" |
174 INCLUDEDIR=$PREFIX/include |
166 echo ok |
175 fi |
167 done |
176 if [ -z "$INFODIR" ]; then |
168 elif [ -f "$prefix/share/config.site" ]; then |
177 INFODIR=$PREFIX/info |
169 printf "loading site defaults... " |
178 fi |
170 . "$prefix/share/config.site" |
179 if [ -z "$MANDIR" ]; then |
171 echo ok |
180 MANDIR=$PREFIX/man |
172 elif [ -f "$prefix/etc/config.site" ]; then |
181 fi |
173 printf "loading site defaults... " |
182 |
174 . "$prefix/etc/config.site" |
183 which pkg-config > /dev/null |
175 echo ok |
184 if [ $? -eq 0 ]; then |
176 fi |
185 PKG_CONFIG=pkg-config |
177 |
186 else |
178 # Test for availability of pkg-config |
187 PKG_CONFIG=false |
179 PKG_CONFIG=`command -v pkg-config` |
188 fi |
180 : ${PKG_CONFIG:="false"} |
189 |
181 |
190 # Simple uname based platform detection |
182 # Simple uname based platform detection |
191 # $PLATFORM is used for platform dependent dependency selection |
183 # $PLATFORM is used for platform dependent dependency selection |
|
184 OS=`uname -s` |
|
185 OS_VERSION=`uname -r` |
192 printf "detect platform... " |
186 printf "detect platform... " |
193 if [ $OS = SunOS ]; then |
187 if [ "$OS" = "SunOS" ]; then |
194 PLATFORM="solaris sunos unix svr4" |
188 PLATFORM="solaris sunos unix svr4" |
195 fi |
189 elif [ "$OS" = "Linux" ]; then |
196 if [ $OS = Linux ]; then |
|
197 PLATFORM="linux unix" |
190 PLATFORM="linux unix" |
198 fi |
191 elif [ "$OS" = "FreeBSD" ]; then |
199 if [ $OS = FreeBSD ]; then |
|
200 PLATFORM="freebsd bsd unix" |
192 PLATFORM="freebsd bsd unix" |
201 fi |
193 elif [ "$OS" = "OpenBSD" ]; then |
202 if [ $OS = Darwin ]; then |
194 PLATFORM="openbsd bsd unix" |
|
195 elif [ "$OS" = "NetBSD" ]; then |
|
196 PLATFORM="netbsd bsd unix" |
|
197 elif [ "$OS" = "Darwin" ]; then |
203 PLATFORM="macos osx bsd unix" |
198 PLATFORM="macos osx bsd unix" |
204 fi |
199 elif echo "$OS" | grep -i "MINGW" > /dev/null; then |
205 echo $OS | grep "MINGW" > /dev/null |
|
206 if [ $? -eq 0 ]; then |
|
207 PLATFORM="windows mingw" |
200 PLATFORM="windows mingw" |
208 fi |
201 fi |
209 |
202 : ${PLATFORM:="unix"} |
210 if [ -z "$PLATFORM" ]; then |
203 |
211 PLATFORM="unix" |
204 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
212 fi |
205 echo "$PLATFORM_NAME" |
213 |
|
214 for p in $PLATFORM |
|
215 do |
|
216 PLATFORM_NAME=$p |
|
217 break |
|
218 done |
|
219 echo $PLATFORM_NAME |
|
220 |
206 |
221 isplatform() |
207 isplatform() |
222 { |
208 { |
223 for p in $PLATFORM |
209 for p in $PLATFORM |
224 do |
210 do |
225 if [ $p = $1 ]; then |
211 if [ "$p" = "$1" ]; then |
226 return 0 |
212 return 0 |
227 fi |
213 fi |
228 done |
214 done |
229 return 1 |
215 return 1 |
230 } |
216 } |
231 isnotplatform() |
217 notisplatform() |
232 { |
218 { |
233 for p in $PLATFORM |
219 for p in $PLATFORM |
234 do |
220 do |
235 if [ $p = $1 ]; then |
221 if [ "$p" = "$1" ]; then |
236 return 1 |
222 return 1 |
237 fi |
223 fi |
238 done |
224 done |
239 return 0 |
225 return 0 |
240 } |
226 } |
241 |
227 istoolchain() |
242 # generate config.mk and config.h |
228 { |
243 cat > $TEMP_DIR/config.mk << __EOF__ |
229 for t in $TOOLCHAIN |
244 # |
230 do |
245 # config.mk generated by configure |
231 if [ "$t" = "$1" ]; then |
246 # |
232 return 0 |
247 |
233 fi |
248 # general vars |
234 done |
|
235 return 1 |
|
236 } |
|
237 notistoolchain() |
|
238 { |
|
239 for t in $TOOLCHAIN |
|
240 do |
|
241 if [ "$t" = "$1" ]; then |
|
242 return 1 |
|
243 fi |
|
244 done |
|
245 return 0 |
|
246 } |
|
247 ]]# |
|
248 ## End of unparsed content ** |
|
249 |
|
250 # generate vars.mk |
|
251 cat > "$TEMP_DIR/vars.mk" << __EOF__ |
|
252 prefix=$prefix |
|
253 exec_prefix=$exec_prefix |
|
254 bindir=$bindir |
|
255 sbindir=$sbindir |
|
256 libdir=$libdir |
|
257 libexecdir=$libexecdir |
|
258 datarootdir=$datarootdir |
|
259 datadir=$datadir |
|
260 sysconfdir=$sysconfdir |
|
261 sharedstatedir=$sharedstatedir |
|
262 localstatedir=$localstatedir |
|
263 runstatedir=$runstatedir |
|
264 includedir=$includedir |
|
265 infodir=$infodir |
|
266 mandir=$mandir |
|
267 localedir=$localedir |
249 #foreach( $var in $vars ) |
268 #foreach( $var in $vars ) |
250 ${var.name}=$${var.name} |
269 ${var.varName}=${D}${var.varName} |
251 #end |
270 #end |
252 |
|
253 #if ( ! $project.hasVar("PREFIX") ) |
|
254 PREFIX=$PREFIX |
|
255 #end |
|
256 #if ( ! $project.hasVar("EPREFIX") ) |
|
257 EPREFIX=$EPREFIX |
|
258 #end |
|
259 |
|
260 #if ( ! $project.hasVar("BINDIR") ) |
|
261 BINDIR=$BINDIR |
|
262 #end |
|
263 #if ( ! $project.hasVar("SBINDIR") ) |
|
264 SBINDIR=$SBINDIR |
|
265 #end |
|
266 #if ( ! $project.hasVar("LIBDIR") ) |
|
267 LIBDIR=$LIBDIR |
|
268 #end |
|
269 #if ( ! $project.hasVar("LIBEXECDIR") ) |
|
270 LIBEXECDIR=$LIBEXECDIR |
|
271 #end |
|
272 #if ( ! $project.hasVar("DATADIR") ) |
|
273 DATADIR=$DATADIR |
|
274 #end |
|
275 #if ( ! $project.hasVar("SYSCONFDIR") ) |
|
276 SYSCONFDIR=$SYSCONFDIR |
|
277 #end |
|
278 #if ( ! $project.hasVar("SHAREDSTATEDIR") ) |
|
279 SHAREDSTATEDIR=$SHAREDSTATEDIR |
|
280 #end |
|
281 #if ( ! $project.hasVar("LOCALSTATEDIR") ) |
|
282 LOCALSTATEDIR=$LOCALSTATEDIR |
|
283 #end |
|
284 #if ( ! $project.hasVar("INCLUDEDIR") ) |
|
285 INCLUDEDIR=$INCLUDEDIR |
|
286 #end |
|
287 #if ( ! $project.hasVar("INFODIR") ) |
|
288 INFODIR=$INFODIR |
|
289 #end |
|
290 #if ( ! $project.hasVar("MANDIR") ) |
|
291 MANDIR=$MANDIR |
|
292 #end |
|
293 |
|
294 __EOF__ |
271 __EOF__ |
295 |
272 |
296 echo > $TEMP_DIR/make.mk |
273 # toolchain detection utilities |
297 |
|
298 ENV_CFLAGS=$CFLAGS |
|
299 ENV_LDFLAGS=$LDFLAGS |
|
300 ENV_CXXFLAGS=$CXXFLAGS |
|
301 |
|
302 # Toolchain detection |
|
303 # this will insert make vars to config.mk |
|
304 . make/toolchain.sh |
274 . make/toolchain.sh |
305 |
275 |
306 # add user specified flags to config.mk |
|
307 echo >> $TEMP_DIR/config.mk |
|
308 if [ ! -z "${ENV_CFLAGS}" ]; then |
|
309 echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk |
|
310 fi |
|
311 if [ ! -z "${ENV_CXXFLAGS}" ]; then |
|
312 echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk |
|
313 fi |
|
314 if [ ! -z "${ENV_LDFLAGS}" ]; then |
|
315 echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk |
|
316 fi |
|
317 |
|
318 # |
276 # |
319 # DEPENDENCIES |
277 # DEPENDENCIES |
320 # |
278 # |
321 |
279 |
|
280 # check languages |
|
281 lang_c= |
|
282 lang_cpp= |
|
283 #foreach( $lang in $languages ) |
|
284 if detect_${lang}_compiler ; then |
|
285 lang_${lang}=1 |
|
286 fi |
|
287 #end |
|
288 |
|
289 # create buffer for make variables required by dependencies |
|
290 echo > "$TEMP_DIR/make.mk" |
|
291 |
|
292 test_pkg_config() |
|
293 { |
|
294 if "$PKG_CONFIG" --exists "$1" ; then : |
|
295 else return 1 ; fi |
|
296 if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : |
|
297 else return 1 ; fi |
|
298 if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : |
|
299 else return 1 ; fi |
|
300 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : |
|
301 else return 1 ; fi |
|
302 return 0 |
|
303 } |
|
304 |
|
305 print_check_msg() |
|
306 { |
|
307 if [ -z "$1" ]; then |
|
308 shift |
|
309 printf "$@" |
|
310 fi |
|
311 } |
|
312 |
322 #foreach( $dependency in $namedDependencies ) |
313 #foreach( $dependency in $namedDependencies ) |
323 dependency_${dependency.name}() |
314 dependency_error_${dependency.id}() |
324 { |
315 { |
325 printf "checking for ${dependency.name}... " |
316 print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... " |
326 #foreach( $sub in $dependency.getSubdependencies() ) |
317 #foreach( $sub in $dependency.subdependencies ) |
327 # dependency $sub.name $sub.getPlatformString() |
318 # dependency $sub.fullName |
328 while true |
319 while true |
329 do |
320 do |
330 #if( $sub.platform ) |
321 #if( $sub.platform ) |
331 if isnotplatform "${sub.platform}"; then |
322 if notisplatform "${sub.platform}"; then |
332 break |
323 break |
333 fi |
324 fi |
334 #end |
325 #end |
335 #foreach( $not in $sub.getNotList() ) |
326 #if( $sub.toolchain ) |
336 if isplatform "${not}"; then |
327 if notistoolchain "${sub.toolchain}"; then |
337 break |
328 break |
338 fi |
329 fi |
339 #end |
330 #end |
|
331 #foreach( $np in $sub.notList ) |
|
332 if isplatform "${np}" || istoolchain "${np}"; then |
|
333 break |
|
334 fi |
|
335 #end |
|
336 #foreach( $lang in $sub.lang ) |
|
337 if [ -z "$lang_${lang}" ] ; then |
|
338 break |
|
339 fi |
|
340 #end |
340 #if( $sub.pkgconfig.size() > 0 ) |
341 #if( $sub.pkgconfig.size() > 0 ) |
341 if [ -z "$PKG_CONFIG" ]; then |
342 if [ -z "$PKG_CONFIG" ]; then |
342 break |
343 break |
|
344 fi |
|
345 #end |
|
346 #foreach( $test in $sub.tests ) |
|
347 if $test > /dev/null ; then |
|
348 : |
|
349 else |
|
350 break |
343 fi |
351 fi |
344 #end |
352 #end |
345 #foreach( $pkg in $sub.pkgconfig ) |
353 #foreach( $pkg in $sub.pkgconfig ) |
346 $PKG_CONFIG $pkg.getPkgConfigParam() |
354 if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then |
347 if [ $? -ne 0 ] ; then |
355 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" |
348 break |
356 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" |
349 fi |
357 else |
350 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $pkg.getPkgConfigParam()`" |
358 break |
351 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs $pkg.getPkgConfigParam()`" |
359 fi |
352 #end |
360 #end |
353 #foreach( $flags in $sub.flags ) |
361 #foreach( $flags in $sub.flags ) |
354 #if( $flags.exec ) |
362 #if( $flags.exec ) |
355 $flags.value > /dev/null |
363 if tmp_flags=`$flags.value` ; then |
356 if [ $? -eq 0 ]; then |
364 TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" |
357 $flags.varName="$$flags.varName `$flags.value`" |
|
358 else |
365 else |
359 break |
366 break |
360 fi |
367 fi |
361 #else |
368 #else |
362 $flags.varName="$$flags.varName $flags.value" |
369 TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" |
363 #end |
370 #end |
364 #end |
371 #end |
365 #foreach( $test in $sub.tests ) |
372 #if ( $sub.make.length() > 0 ) |
366 $test > /dev/null |
373 cat >> $TEMP_DIR/make.mk << __EOF__ |
367 if [ $? -ne 0 ]; then |
374 # Dependency: $dependency.name |
368 break |
|
369 fi |
|
370 #end |
|
371 #if ( $sub.make.length() > 0 ) |
|
372 cat >> $TEMP_DIR/make.mk << __EOF__ |
|
373 # Dependency: $dependency.name |
|
374 $sub.make |
375 $sub.make |
375 __EOF__ |
376 __EOF__ |
376 #end |
377 #end |
377 echo yes |
378 print_check_msg "${D}dep_checked_${dependency.id}" "yes\n" |
378 return 0 |
379 dep_checked_${dependency.id}=1 |
379 done |
380 return 1 |
380 |
381 done |
381 #end |
382 |
382 echo no |
383 #end |
383 return 1 |
384 print_check_msg "${D}dep_checked_${dependency.id}" "no\n" |
384 } |
385 dep_checked_${dependency.id}=1 |
385 #end |
386 return 0 |
|
387 } |
|
388 #end |
|
389 |
|
390 # start collecting dependency information |
|
391 echo > "$TEMP_DIR/flags.mk" |
386 |
392 |
387 DEPENDENCIES_FAILED= |
393 DEPENDENCIES_FAILED= |
388 ERROR=0 |
394 ERROR=0 |
389 #if( $dependencies.size() > 0 ) |
395 #if( $dependencies.size() > 0 ) |
390 # general dependencies |
396 # unnamed dependencies |
391 CFLAGS= |
397 TEMP_CFLAGS= |
392 LDFLAGS= |
398 TEMP_CXXFLAGS= |
|
399 TEMP_LDFLAGS= |
393 #foreach( $dependency in $dependencies ) |
400 #foreach( $dependency in $dependencies ) |
394 while true |
401 while true |
395 do |
402 do |
396 #if( $dependency.platform ) |
403 #if( $dependency.platform ) |
397 if isnotplatform "${dependency.platform}"; then |
404 if notisplatform "${dependency.platform}"; then |
398 break |
405 break |
399 fi |
406 fi |
400 #end |
407 #end |
401 #foreach( $not in $dependency.getNotList() ) |
408 #if( $dependency.toolchain ) |
402 if isplatform "${not}"; then |
409 if notistoolchain "${dependency.toolchain}"; then |
403 break |
410 break |
404 fi |
411 fi |
405 #end |
412 #end |
|
413 #foreach( $np in $dependency.notList ) |
|
414 if isplatform "${np}" || istoolchain "${np}"; then |
|
415 break |
|
416 fi |
|
417 #end |
406 while true |
418 while true |
407 do |
419 do |
|
420 #foreach( $lang in $dependency.lang ) |
|
421 if [ -z "$lang_${lang}" ] ; then |
|
422 ERROR=1 |
|
423 break |
|
424 fi |
|
425 #end |
408 #if( $dependency.pkgconfig.size() > 0 ) |
426 #if( $dependency.pkgconfig.size() > 0 ) |
409 if [ -z "$PKG_CONFIG" ]; then |
427 if [ -z "$PKG_CONFIG" ]; then |
410 ERROR=1 |
428 ERROR=1 |
411 break |
429 break |
412 fi |
430 fi |
413 #end |
431 #end |
414 #foreach( $pkg in $dependency.pkgconfig ) |
432 #foreach( $pkg in $dependency.pkgconfig ) |
415 printf "checking for pkg-config package $pkg.getPkgConfigParam()... " |
433 print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... " |
416 $PKG_CONFIG $pkg.getPkgConfigParam() |
434 if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then |
417 if [ $? -ne 0 ]; then |
435 print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n" |
418 echo no |
436 dep_pkgconfig_checked_${pkg.id}=1 |
|
437 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" |
|
438 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" |
|
439 else |
|
440 print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n" |
|
441 dep_pkgconfig_checked_${pkg.id}=1 |
419 ERROR=1 |
442 ERROR=1 |
420 break |
443 break |
421 fi |
444 fi |
422 echo yes |
445 #end |
423 CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $pkg.getPkgConfigParam()`" |
446 |
424 LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs $pkg.getPkgConfigParam()`" |
|
425 #end |
|
426 |
|
427 #foreach( $flags in $dependency.flags ) |
447 #foreach( $flags in $dependency.flags ) |
428 #if( $flags.exec ) |
448 #if( $flags.exec ) |
429 $flags.value > /dev/null |
449 $flags.value > /dev/null |
430 if [ $? -ne 0 ]; then |
450 if tmp_flags=`$flags.value` ; then |
431 $flags.varName="$$flags.varName `$flags.value`" |
451 TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" |
432 else |
452 else |
433 ERROR=1 |
453 ERROR=1 |
434 break |
454 break |
435 fi |
455 fi |
436 #else |
456 #else |
437 $flags.varName="$$flags.varName $flags.value" |
457 TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" |
438 #end |
458 #end |
439 #end |
459 #end |
440 #if ( $dependency.make.length() > 0 ) |
460 #if ( $dependency.make.length() > 0 ) |
441 cat >> $TEMP_DIR/make.mk << __EOF__ |
461 cat >> "$TEMP_DIR/make.mk" << __EOF__ |
442 $dependency.make |
462 $dependency.make |
443 __EOF__ |
463 __EOF__ |
444 #end |
464 #end |
445 |
|
446 break |
465 break |
447 done |
466 done |
448 |
|
449 break |
467 break |
450 done |
468 done |
451 #end |
469 #end |
452 |
470 |
453 # add general dependency flags to config.mk |
471 # add general dependency flags to flags.mk |
454 echo >> $TEMP_DIR/config.mk |
472 echo "# general flags" >> "$TEMP_DIR/flags.mk" |
455 if [ ! -z "${CFLAGS}" ]; then |
473 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
456 echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk |
474 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
457 fi |
475 fi |
458 if [ ! -z "${CXXFLAGS}" ]; then |
476 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
459 echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk |
477 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
460 fi |
478 fi |
461 if [ ! -z "${LDFLAGS}" ]; then |
479 if [ -n "${TEMP_LDFLAGS}" ]; then |
462 echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk |
480 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
463 fi |
481 fi |
464 #end |
482 #end |
465 |
483 |
466 # |
484 # |
467 # OPTION VALUES |
485 # OPTION VALUES |
468 # |
486 # |
469 #foreach( $opt in $options ) |
487 #foreach( $opt in $options ) |
470 #foreach( $val in $opt.values ) |
488 #foreach( $val in $opt.values ) |
471 ${val.func}() |
489 ${val.func}() |
472 { |
490 { |
473 VERR=0 |
491 VERR=0 |
474 #foreach( $dep in $val.dependencies ) |
492 #foreach( $dep in $val.dependencies ) |
475 dependency_$dep |
493 if dependency_error_$dep ; then |
476 if [ $? -ne 0 ]; then |
494 VERR=1 |
477 VERR=1 |
495 fi |
478 fi |
496 #end |
479 #end |
497 if [ $VERR -ne 0 ]; then |
480 if [ $VERR -ne 0 ]; then |
498 return 1 |
481 return 1 |
499 fi |
482 fi |
500 #foreach( $def in $val.defines ) |
483 #foreach( $def in $val.defines ) |
501 TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" |
484 CFLAGS="$CFLAGS ${def.toFlags()}" |
502 TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" |
485 #end |
503 #end |
486 #if( $val.hasMake() ) |
504 #if( $val.hasMake() ) |
487 cat >> $TEMP_DIR/make.mk << __EOF__ |
505 cat >> "$TEMP_DIR/make.mk" << __EOF__ |
488 $val.make |
506 $val.make |
489 __EOF__ |
507 __EOF__ |
490 #end |
508 #end |
491 return 0 |
509 return 0 |
492 } |
510 } |
493 #end |
511 #end |
494 #end |
512 #end |
495 |
513 |
496 # |
514 # |
497 # TARGETS |
515 # TARGETS |
498 # |
516 # |
499 CFLAGS= |
|
500 CXXFLAGS= |
|
501 LDFLAGS= |
|
502 |
517 |
503 #foreach( $target in $targets ) |
518 #foreach( $target in $targets ) |
|
519 echo >> "$TEMP_DIR/flags.mk" |
504 #if ( $target.name ) |
520 #if ( $target.name ) |
505 # Target: $target.name |
521 echo "configuring target: $target.name" |
|
522 echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk" |
506 #else |
523 #else |
507 # Target |
524 echo "configuring global target" |
508 #end |
525 echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" |
509 CFLAGS= |
526 #end |
510 LDFLAGS= |
527 TEMP_CFLAGS= |
511 CXXFLAGS= |
528 TEMP_CXXFLAGS= |
|
529 TEMP_LDFLAGS= |
512 |
530 |
513 #foreach( $dependency in $target.dependencies ) |
531 #foreach( $dependency in $target.dependencies ) |
514 dependency_$dependency |
532 if dependency_error_$dependency; then |
515 if [ $? -ne 0 ]; then |
533 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " |
516 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " |
534 ERROR=1 |
517 ERROR=1 |
|
518 fi |
535 fi |
519 #end |
536 #end |
520 |
537 |
521 # Features |
538 # Features |
522 #foreach( $feature in $target.features ) |
539 #foreach( $feature in $target.features ) |
523 if [ ! -z "$${feature.getVarName()}" ]; then |
540 if [ -n "${D}${feature.varName}" ]; then |
524 #foreach( $dependency in $feature.dependencies ) |
541 #foreach( $dependency in $feature.dependencies ) |
525 # check dependency |
542 # check dependency |
526 dependency_$dependency |
543 if dependency_error_$dependency ; then |
527 if [ $? -ne 0 ]; then |
544 # "auto" features can fail and are just disabled in this case |
528 # "auto" features can fail and are just disabled in this case |
545 if [ "${D}${feature.varName}" = "auto" ]; then |
529 if [ $${feature.getVarName()} != "auto" ]; then |
546 DISABLE_${feature.varName}=1 |
530 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " |
547 else |
531 ERROR=1 |
548 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " |
532 fi |
549 ERROR=1 |
533 fi |
550 fi |
534 #end |
551 fi |
|
552 #end |
|
553 if [ -n "$DISABLE_${feature.varName}" ]; then |
|
554 unset ${feature.varName} |
|
555 fi |
535 fi |
556 fi |
536 #end |
557 #end |
537 |
558 |
538 #foreach( $opt in $target.options ) |
559 #foreach( $opt in $target.options ) |
539 # Option: --${opt.argument} |
560 # Option: --${opt.argument} |
540 if [ -z ${D}${opt.getVarName()} ]; then |
561 if [ -z "${D}${opt.varName}" ]; then |
541 SAVED_ERROR=$ERROR |
562 echo "auto-detecting option '${opt.argument}'" |
542 SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED |
563 SAVED_ERROR="$ERROR" |
543 ERROR=0 |
564 SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" |
544 while true |
565 ERROR=1 |
545 do |
566 while true |
546 #foreach( $optdef in $opt.defaults ) |
567 do |
547 #if( $optdef.platform ) |
568 #foreach( $optdef in $opt.defaults ) |
548 if isplatform "$optdef.platform"; then |
569 #if( $optdef.platform ) |
549 #end |
570 if isplatform "$optdef.platform"; then |
550 $optdef.func |
571 #end |
551 if [ $? -eq 0 ]; then |
572 if $optdef.func ; then |
552 echo " ${opt.argument}: ${optdef.valueName}" >> $TEMP_DIR/options |
573 echo " ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options" |
553 ERROR=0 |
574 ERROR=0 |
554 break |
575 break |
555 fi |
576 fi |
556 #if( $optdef.platform ) |
577 #if( $optdef.platform ) |
557 fi |
578 fi |
558 #end |
579 #end |
559 #end |
580 #end |
560 break |
581 break |
561 done |
582 done |
562 if [ $ERROR -ne 0 ]; then |
583 if [ $ERROR -ne 0 ]; then |
563 SAVED_ERROR=1 |
584 SAVED_ERROR=1 |
564 fi |
585 SAVED_DEPENDENCIES_FAILED="option '${opt.argument}' $SAVED_DEPENDENCIES_FAILED" |
565 ERROR=$SAVED_ERROR |
586 fi |
566 DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED= |
587 ERROR="$SAVED_ERROR" |
|
588 DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" |
567 else |
589 else |
568 if false; then |
590 echo "checking option ${opt.argument} = ${D}${opt.varName}" |
569 false |
591 if false; then |
570 #foreach( $optval in $opt.values ) |
592 false |
571 elif [ ${D}${opt.getVarName()} = "${optval.value}" ]; then |
593 #foreach( $optval in $opt.values ) |
572 echo " ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options |
594 elif [ "${D}${opt.varName}" = "${optval.value}" ]; then |
573 $optval.func |
595 echo " ${opt.argument}: ${D}${opt.varName}" >> $TEMP_DIR/options |
574 if [ $? -ne 0 ]; then |
596 if $optval.func ; then |
575 ERROR=1 |
597 : |
576 fi |
598 else |
577 #end |
599 ERROR=1 |
578 fi |
600 DEPENDENCIES_FAILED="option '${opt.argument}' $DEPENDENCIES_FAILED" |
579 fi |
601 fi |
580 #end |
602 #end |
581 |
603 fi |
582 echo >> $TEMP_DIR/config.mk |
604 fi |
583 if [ ! -z "${CFLAGS}" ]; then |
605 #end |
584 echo "${target.getCFlags()} += $CFLAGS" >> $TEMP_DIR/config.mk |
606 |
585 fi |
607 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
586 if [ ! -z "${CXXFLAGS}" ]; then |
608 echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
587 echo "${target.getCXXFlags()} += $CXXFLAGS" >> $TEMP_DIR/config.mk |
609 fi |
588 fi |
610 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
589 if [ ! -z "${LDFLAGS}" ]; then |
611 echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
590 echo "${target.getLDFlags()} += $LDFLAGS" >> $TEMP_DIR/config.mk |
612 fi |
591 fi |
613 if [ "$BUILD_TYPE" = "debug" ]; then |
592 |
614 if [ -n "$lang_c" ]; then |
593 #end |
615 echo '${target.cFlags} += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
616 fi |
|
617 if [ -n "$lang_cpp" ]; then |
|
618 echo '${target.cxxFlags} += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
619 fi |
|
620 fi |
|
621 if [ "$BUILD_TYPE" = "release" ]; then |
|
622 if [ -n "$lang_c" ]; then |
|
623 echo '${target.cFlags} += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
624 fi |
|
625 if [ -n "$lang_cpp" ]; then |
|
626 echo '${target.cxxFlags} += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
627 fi |
|
628 fi |
|
629 if [ -n "${TEMP_LDFLAGS}" ]; then |
|
630 echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
|
631 fi |
|
632 |
|
633 #end |
|
634 |
|
635 # final result |
594 if [ $ERROR -ne 0 ]; then |
636 if [ $ERROR -ne 0 ]; then |
595 echo |
637 echo |
596 echo "Error: Unresolved dependencies" |
638 echo "Error: Unresolved dependencies" |
597 echo $DEPENDENCIES_FAILED |
639 echo "$DEPENDENCIES_FAILED" |
598 rm -Rf $TEMP_DIR |
640 abort_configure |
599 exit 1 |
|
600 fi |
641 fi |
601 |
642 |
602 echo "configure finished" |
643 echo "configure finished" |
603 echo |
644 echo |
604 echo "Build Config:" |
645 echo "Build Config:" |
605 echo " PREFIX: $PREFIX" |
646 echo " PREFIX: $prefix" |
606 echo " TOOLCHAIN: $TOOLCHAIN_NAME" |
647 echo " TOOLCHAIN: $TOOLCHAIN_NAME" |
607 #if ( $options.size() > 0 ) |
648 #if ( $options.size() > 0 ) |
608 echo "Options:" |
649 echo "Options:" |
609 cat $TEMP_DIR/options |
650 cat "$TEMP_DIR/options" |
|
651 #end |
|
652 #if ( $features.size() > 0 ) |
|
653 echo "Features:" |
|
654 #foreach( $feature in $features ) |
|
655 if [ -n "${D}${feature.varName}" ]; then |
|
656 echo " $feature.name: on" |
|
657 else |
|
658 echo " $feature.name: off" |
|
659 fi |
|
660 #end |
610 #end |
661 #end |
611 echo |
662 echo |
612 cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk |
663 |
613 rm -Rf $TEMP_DIR |
664 # generate the config.mk file |
614 |
665 cat > "$TEMP_DIR/config.mk" << __EOF__ |
615 |
666 # |
|
667 # config.mk generated by configure |
|
668 # |
|
669 |
|
670 __EOF__ |
|
671 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" |
|
672 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
|
673 rm -Rf "$TEMP_DIR" |