1 #!/bin/sh |
1 #!/bin/sh |
|
2 |
|
3 |
|
4 # some utility functions |
|
5 isplatform() |
|
6 { |
|
7 for p in $PLATFORM |
|
8 do |
|
9 if [ "$p" = "$1" ]; then |
|
10 return 0 |
|
11 fi |
|
12 done |
|
13 return 1 |
|
14 } |
|
15 notisplatform() |
|
16 { |
|
17 for p in $PLATFORM |
|
18 do |
|
19 if [ "$p" = "$1" ]; then |
|
20 return 1 |
|
21 fi |
|
22 done |
|
23 return 0 |
|
24 } |
|
25 istoolchain() |
|
26 { |
|
27 for t in $TOOLCHAIN |
|
28 do |
|
29 if [ "$t" = "$1" ]; then |
|
30 return 0 |
|
31 fi |
|
32 done |
|
33 return 1 |
|
34 } |
|
35 notistoolchain() |
|
36 { |
|
37 for t in $TOOLCHAIN |
|
38 do |
|
39 if [ "$t" = "$1" ]; then |
|
40 return 1 |
|
41 fi |
|
42 done |
|
43 return 0 |
|
44 } |
|
45 |
|
46 # clean abort |
|
47 abort_configure() |
|
48 { |
|
49 rm -Rf "$TEMP_DIR" |
|
50 exit 1 |
|
51 } |
|
52 |
|
53 # Test for availability of pkg-config |
|
54 PKG_CONFIG=`command -v pkg-config` |
|
55 : ${PKG_CONFIG:="false"} |
|
56 |
|
57 # Simple uname based platform detection |
|
58 # $PLATFORM is used for platform dependent dependency selection |
|
59 OS=`uname -s` |
|
60 OS_VERSION=`uname -r` |
|
61 printf "detect platform... " |
|
62 if [ "$OS" = "SunOS" ]; then |
|
63 PLATFORM="solaris sunos unix svr4" |
|
64 elif [ "$OS" = "Linux" ]; then |
|
65 PLATFORM="linux unix" |
|
66 elif [ "$OS" = "FreeBSD" ]; then |
|
67 PLATFORM="freebsd bsd unix" |
|
68 elif [ "$OS" = "OpenBSD" ]; then |
|
69 PLATFORM="openbsd bsd unix" |
|
70 elif [ "$OS" = "NetBSD" ]; then |
|
71 PLATFORM="netbsd bsd unix" |
|
72 elif [ "$OS" = "Darwin" ]; then |
|
73 PLATFORM="macos osx bsd unix" |
|
74 elif echo "$OS" | grep -i "MINGW" > /dev/null; then |
|
75 PLATFORM="windows mingw" |
|
76 fi |
|
77 : ${PLATFORM:="unix"} |
|
78 |
|
79 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
|
80 echo "$PLATFORM_NAME" |
|
81 |
|
82 |
|
83 # help text |
|
84 printhelp() |
|
85 { |
|
86 echo "Usage: $0 [OPTIONS]..." |
|
87 cat << __EOF__ |
|
88 Installation directories: |
|
89 --prefix=PREFIX path prefix for architecture-independent files |
|
90 [$prefix] |
|
91 --exec-prefix=EPREFIX path prefix for architecture-dependent files |
|
92 [PREFIX] |
|
93 |
|
94 --bindir=DIR user executables [EPREFIX/bin] |
|
95 --sbindir=DIR system admin executables [EPREFIX/sbin] |
|
96 --libexecdir=DIR program executables [EPREFIX/libexec] |
|
97 --sysconfdir=DIR system configuration files [PREFIX/etc] |
|
98 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
|
99 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
|
100 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] |
|
101 --libdir=DIR object code libraries [EPREFIX/lib] |
|
102 --includedir=DIR C header files [PREFIX/include] |
|
103 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
|
104 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
|
105 --infodir=DIR info documentation [DATAROOTDIR/info] |
|
106 --mandir=DIR man documentation [DATAROOTDIR/man] |
|
107 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] |
|
108 |
|
109 Build Types: |
|
110 --debug add extra compile flags for debug builds |
|
111 --release add extra compile flags for release builds |
|
112 |
|
113 __EOF__ |
|
114 } |
2 |
115 |
3 # create temporary directory |
116 # create temporary directory |
4 TEMP_DIR=".tmp-`uname -n`" |
117 TEMP_DIR=".tmp-`uname -n`" |
5 rm -Rf "$TEMP_DIR" |
118 rm -Rf "$TEMP_DIR" |
6 if mkdir -p "$TEMP_DIR"; then |
119 if mkdir -p "$TEMP_DIR"; then |
33 mandir= |
146 mandir= |
34 |
147 |
35 # custom variables |
148 # custom variables |
36 |
149 |
37 # features |
150 # features |
38 |
|
39 # clean abort |
|
40 abort_configure() |
|
41 { |
|
42 rm -Rf "$TEMP_DIR" |
|
43 exit 1 |
|
44 } |
|
45 |
|
46 # help text |
|
47 printhelp() |
|
48 { |
|
49 echo "Usage: $0 [OPTIONS]..." |
|
50 cat << __EOF__ |
|
51 Installation directories: |
|
52 --prefix=PREFIX path prefix for architecture-independent files |
|
53 [/usr] |
|
54 --exec-prefix=EPREFIX path prefix for architecture-dependent files |
|
55 [PREFIX] |
|
56 |
|
57 --bindir=DIR user executables [EPREFIX/bin] |
|
58 --sbindir=DIR system admin executables [EPREFIX/sbin] |
|
59 --libexecdir=DIR program executables [EPREFIX/libexec] |
|
60 --sysconfdir=DIR system configuration files [PREFIX/etc] |
|
61 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
|
62 --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
|
63 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] |
|
64 --libdir=DIR object code libraries [EPREFIX/lib] |
|
65 --includedir=DIR C header files [PREFIX/include] |
|
66 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
|
67 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
|
68 --infodir=DIR info documentation [DATAROOTDIR/info] |
|
69 --mandir=DIR man documentation [DATAROOTDIR/man] |
|
70 --localedir=DIR locale-dependent data [DATAROOTDIR/locale] |
|
71 |
|
72 __EOF__ |
|
73 } |
|
74 |
151 |
75 # |
152 # |
76 # parse arguments |
153 # parse arguments |
77 # |
154 # |
78 BUILD_TYPE="default" |
155 BUILD_TYPE="default" |
92 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; |
169 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; |
93 "--includedir="*) includedir=${ARG#--includedir=} ;; |
170 "--includedir="*) includedir=${ARG#--includedir=} ;; |
94 "--infodir="*) infodir=${ARG#--infodir=} ;; |
171 "--infodir="*) infodir=${ARG#--infodir=} ;; |
95 "--mandir"*) mandir=${ARG#--mandir} ;; |
172 "--mandir"*) mandir=${ARG#--mandir} ;; |
96 "--localedir"*) localedir=${ARG#--localedir} ;; |
173 "--localedir"*) localedir=${ARG#--localedir} ;; |
97 "--help"*) printhelp; abort_configure ;; |
174 "--help"*) printhelp; abort_configure ;; |
98 "--debug") BUILD_TYPE="debug" ;; |
175 "--debug") BUILD_TYPE="debug" ;; |
99 "--release") BUILD_TYPE="release" ;; |
176 "--release") BUILD_TYPE="release" ;; |
100 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
177 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
101 esac |
178 esac |
102 done |
179 done |
103 |
180 |
104 |
181 |
118 : ${includedir:='${prefix}/include'} |
195 : ${includedir:='${prefix}/include'} |
119 : ${infodir:='${datarootdir}/info'} |
196 : ${infodir:='${datarootdir}/info'} |
120 : ${mandir:='${datarootdir}/man'} |
197 : ${mandir:='${datarootdir}/man'} |
121 : ${localedir:='${datarootdir}/locale'} |
198 : ${localedir:='${datarootdir}/locale'} |
122 |
199 |
|
200 # remember the above values and compare them later |
|
201 orig_bindir="$bindir" |
|
202 orig_sbindir="$sbindir" |
|
203 orig_libdir="$libdir" |
|
204 orig_libexecdir="$libexecdir" |
|
205 orig_datarootdir="$datarootdir" |
|
206 orig_datadir="$datadir" |
|
207 orig_sysconfdir="$sysconfdir" |
|
208 orig_sharedstatedir="$sharedstatedir" |
|
209 orig_localstatedir="$localstatedir" |
|
210 orig_runstatedir="$runstatedir" |
|
211 orig_includedir="$includedir" |
|
212 orig_infodir="$infodir" |
|
213 orig_mandir="$mandir" |
|
214 orig_localedir="$localedir" |
|
215 |
123 # check if a config.site exists and load it |
216 # check if a config.site exists and load it |
124 if [ -n "$CONFIG_SITE" ]; then |
217 if [ -n "$CONFIG_SITE" ]; then |
125 # CONFIG_SITE may contain space separated file names |
218 # CONFIG_SITE may contain space separated file names |
126 for cs in $CONFIG_SITE; do |
219 for cs in $CONFIG_SITE; do |
127 printf "loading defaults from $cs... " |
220 printf "loading defaults from $cs... " |
136 printf "loading site defaults... " |
229 printf "loading site defaults... " |
137 . "$prefix/etc/config.site" |
230 . "$prefix/etc/config.site" |
138 echo ok |
231 echo ok |
139 fi |
232 fi |
140 |
233 |
141 # Test for availability of pkg-config |
|
142 PKG_CONFIG=`command -v pkg-config` |
|
143 : ${PKG_CONFIG:="false"} |
|
144 |
|
145 # Simple uname based platform detection |
|
146 # $PLATFORM is used for platform dependent dependency selection |
|
147 OS=`uname -s` |
|
148 OS_VERSION=`uname -r` |
|
149 printf "detect platform... " |
|
150 if [ "$OS" = "SunOS" ]; then |
|
151 PLATFORM="solaris sunos unix svr4" |
|
152 fi |
|
153 if [ "$OS" = "Linux" ]; then |
|
154 PLATFORM="linux unix" |
|
155 fi |
|
156 if [ "$OS" = "FreeBSD" ]; then |
|
157 PLATFORM="freebsd bsd unix" |
|
158 fi |
|
159 if [ "$OS" = "Darwin" ]; then |
|
160 PLATFORM="macos osx bsd unix" |
|
161 fi |
|
162 if echo "$OS" | grep -i "MINGW" > /dev/null; then |
|
163 PLATFORM="windows mingw" |
|
164 fi |
|
165 : ${PLATFORM:="unix"} |
|
166 |
|
167 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
|
168 echo "$PLATFORM_NAME" |
|
169 |
|
170 isplatform() |
|
171 { |
|
172 for p in $PLATFORM |
|
173 do |
|
174 if [ "$p" = "$1" ]; then |
|
175 return 0 |
|
176 fi |
|
177 done |
|
178 return 1 |
|
179 } |
|
180 notisplatform() |
|
181 { |
|
182 for p in $PLATFORM |
|
183 do |
|
184 if [ "$p" = "$1" ]; then |
|
185 return 1 |
|
186 fi |
|
187 done |
|
188 return 0 |
|
189 } |
|
190 |
|
191 |
234 |
192 # generate vars.mk |
235 # generate vars.mk |
193 cat > "$TEMP_DIR/vars.mk" << __EOF__ |
236 cat > "$TEMP_DIR/vars.mk" << __EOF__ |
194 prefix="$prefix" |
237 prefix=$prefix |
195 exec_prefix="$exec_prefix" |
238 exec_prefix=$exec_prefix |
196 bindir="$bindir" |
239 bindir=$bindir |
197 sbindir="$sbindir" |
240 sbindir=$sbindir |
198 libdir="$libdir" |
241 libdir=$libdir |
199 libexecdir="$libexecdir" |
242 libexecdir=$libexecdir |
200 datarootdir="$datarootdir" |
243 datarootdir=$datarootdir |
201 datadir="$datadir" |
244 datadir=$datadir |
202 sysconfdir="$sysconfdir" |
245 sysconfdir=$sysconfdir |
203 sharedstatedir="$sharedstatedir" |
246 sharedstatedir=$sharedstatedir |
204 localstatedir="$localstatedir" |
247 localstatedir=$localstatedir |
205 runstatedir="$runstatedir" |
248 runstatedir=$runstatedir |
206 includedir="$includedir" |
249 includedir=$includedir |
207 infodir="$infodir" |
250 infodir=$infodir |
208 mandir="$mandir" |
251 mandir=$mandir |
209 localedir="$localedir" |
252 localedir=$localedir |
210 __EOF__ |
253 __EOF__ |
211 |
254 |
212 # toolchain detection utilities |
255 # toolchain detection utilities |
213 . make/toolchain.sh |
256 . make/toolchain.sh |
214 |
257 |
237 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : |
280 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : |
238 else return 1 ; fi |
281 else return 1 ; fi |
239 return 0 |
282 return 0 |
240 } |
283 } |
241 |
284 |
242 |
285 print_check_msg() |
243 |
286 { |
|
287 if [ -z "$1" ]; then |
|
288 shift |
|
289 printf "$@" |
|
290 fi |
|
291 } |
244 |
292 |
245 |
293 |
246 # start collecting dependency information |
294 # start collecting dependency information |
247 echo > "$TEMP_DIR/flags.mk" |
295 echo > "$TEMP_DIR/flags.mk" |
248 |
296 |
249 DEPENDENCIES_FAILED= |
297 DEPENDENCIES_FAILED= |
250 ERROR=0 |
298 ERROR=0 |
251 # unnamed dependencies |
299 # unnamed dependencies |
252 TEMP_CFLAGS= |
300 TEMP_CFLAGS="$CFLAGS" |
253 TEMP_CXXFLAGS= |
301 TEMP_CXXFLAGS="$CXXFLAGS" |
254 TEMP_LDFLAGS= |
302 TEMP_LDFLAGS="$LDFLAGS" |
255 while true |
303 while true |
256 do |
304 do |
257 while true |
305 while true |
258 do |
306 do |
259 if [ -z "$lang_c" ] ; then |
307 if [ -z "$lang_c" ] ; then |
264 break |
312 break |
265 done |
313 done |
266 break |
314 break |
267 done |
315 done |
268 |
316 |
|
317 # build type |
|
318 if [ "$BUILD_TYPE" = "debug" ]; then |
|
319 TEMP_CFLAGS="\${DEBUG_CFLAGS}$TEMP_CFLAGS" |
|
320 TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS}$TEMP_CXXFLAGS" |
|
321 fi |
|
322 if [ "$BUILD_TYPE" = "release" ]; then |
|
323 TEMP_CFLAGS="\${RELEASE_CFLAGS}$TEMP_CFLAGS" |
|
324 TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS}$TEMP_CXXFLAGS" |
|
325 fi |
|
326 |
269 # add general dependency flags to flags.mk |
327 # add general dependency flags to flags.mk |
270 echo "# general flags" >> "$TEMP_DIR/flags.mk" |
328 echo "# general flags" >> "$TEMP_DIR/flags.mk" |
271 if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then |
329 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
272 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
330 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
273 fi |
331 fi |
274 if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then |
332 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
275 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
333 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
276 fi |
334 fi |
277 if [ -n "${TEMP_LDFLAGS}" ]; then |
335 if [ -n "${TEMP_LDFLAGS}" ]; then |
278 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
336 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
279 fi |
337 fi |
295 |
353 |
296 |
354 |
297 # Features |
355 # Features |
298 |
356 |
299 |
357 |
300 if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then |
358 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
301 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
359 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
302 fi |
360 fi |
303 if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then |
361 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
304 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
362 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
305 fi |
|
306 if [ "$BUILD_TYPE" = "debug" ]; then |
|
307 if [ -n "$lang_c" ]; then |
|
308 echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
309 fi |
|
310 if [ -n "$lang_cpp" ]; then |
|
311 echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
312 fi |
|
313 fi |
|
314 if [ "$BUILD_TYPE" = "release" ]; then |
|
315 if [ -n "$lang_c" ]; then |
|
316 echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
317 fi |
|
318 if [ -n "$lang_cpp" ]; then |
|
319 echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
|
320 fi |
|
321 fi |
363 fi |
322 if [ -n "${TEMP_LDFLAGS}" ]; then |
364 if [ -n "${TEMP_LDFLAGS}" ]; then |
323 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
365 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
324 fi |
366 fi |
325 |
367 |
332 abort_configure |
374 abort_configure |
333 fi |
375 fi |
334 |
376 |
335 echo "configure finished" |
377 echo "configure finished" |
336 echo |
378 echo |
|
379 echo "Toolchain" |
|
380 echo " name: $TOOLCHAIN_NAME" |
|
381 if [ -n "$TOOLCHAIN_CC" ]; then |
|
382 echo " cc: $TOOLCHAIN_CC" |
|
383 fi |
|
384 if [ -n "$TOOLCHAIN_CXX" ]; then |
|
385 echo " cxx: $TOOLCHAIN_CXX" |
|
386 fi |
|
387 if [ -n "$TOOLCHAIN_WSIZE" ]; then |
|
388 echo " word size: $TOOLCHAIN_WSIZE bit" |
|
389 fi |
|
390 if [ -n "$TOOLCHAIN_CSTD" ]; then |
|
391 echo " default C std: $TOOLCHAIN_CSTD" |
|
392 fi |
|
393 echo |
337 echo "Build Config:" |
394 echo "Build Config:" |
338 echo " PREFIX: $prefix" |
395 echo " prefix: $prefix" |
339 echo " TOOLCHAIN: $TOOLCHAIN_NAME" |
396 echo " exec_prefix: $exec_prefix" |
|
397 if [ "$orig_bindir" != "$bindir" ]; then |
|
398 echo " bindir: $bindir" |
|
399 fi |
|
400 if [ "$orig_sbindir" != "$sbindir" ]; then |
|
401 echo " sbindir: $sbindir" |
|
402 fi |
|
403 if [ "$orig_libdir" != "$libdir" ]; then |
|
404 echo " libdir: $libdir" |
|
405 fi |
|
406 if [ "$orig_libexecdir" != "$libexecdir" ]; then |
|
407 echo " libexecdir: $libexecdir" |
|
408 fi |
|
409 if [ "$orig_datarootdir" != "$datarootdir" ]; then |
|
410 echo " datarootdir: $datarootdir" |
|
411 fi |
|
412 if [ "$orig_datadir" != "$datadir" ]; then |
|
413 echo " datadir: $datadir" |
|
414 fi |
|
415 if [ "$orig_sysconfdir" != "$sysconfdir" ]; then |
|
416 echo " sysconfdir: $sysconfdir" |
|
417 fi |
|
418 if [ "$orig_sharedstatedir" != "$sharedstatedir" ]; then |
|
419 echo " sharedstatedir: $sharedstatedir" |
|
420 fi |
|
421 if [ "$orig_localstatedir" != "$localstatedir" ]; then |
|
422 echo " localstatedir: $localstatedir" |
|
423 fi |
|
424 if [ "$orig_runstatedir" != "$runstatedir" ]; then |
|
425 echo " runstatedir: $runstatedir" |
|
426 fi |
|
427 if [ "$orig_includedir" != "$includedir" ]; then |
|
428 echo " includedir: $includedir" |
|
429 fi |
|
430 if [ "$orig_infodir" != "$infodir" ]; then |
|
431 echo " infodir: $infodir" |
|
432 fi |
|
433 if [ "$orig_mandir" != "$mandir" ]; then |
|
434 echo " mandir: $mandir" |
|
435 fi |
|
436 if [ "$orig_localedir" != "$localedir" ]; then |
|
437 echo " localedir: $localedir" |
|
438 fi |
340 echo |
439 echo |
341 |
440 |
342 # generate the config.mk file |
441 # generate the config.mk file |
|
442 pwd=`pwd` |
343 cat > "$TEMP_DIR/config.mk" << __EOF__ |
443 cat > "$TEMP_DIR/config.mk" << __EOF__ |
344 # |
444 # |
345 # config.mk generated by configure |
445 # config.mk generated by: |
|
446 # pwd: $pwd |
|
447 # $0 $@ |
346 # |
448 # |
347 |
449 |
348 __EOF__ |
450 __EOF__ |
349 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" |
451 write_toolchain_defaults "$TEMP_DIR/toolchain.mk" |
350 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
452 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
351 rm -Rf "$TEMP_DIR" |
453 rm -Rf "$TEMP_DIR" |
352 |
|
353 |
|