configure

changeset 960
a8a5f3dd5c3d
parent 842
b48cbfa109d4
equal deleted inserted replaced
959:0e1bf3c199bf 960:a8a5f3dd5c3d
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 Options:
110 --debug add extra compile flags for debug builds
111 --release add extra compile flags for release builds
112 --with-docs=(all|html|api|none)
113
114 Optional Features:
115 --enable-coverage
116
117 __EOF__
118 }
2 119
3 # create temporary directory 120 # create temporary directory
4 TEMP_DIR=".tmp-`uname -n`" 121 TEMP_DIR=".tmp-`uname -n`"
5 rm -Rf "$TEMP_DIR" 122 rm -Rf "$TEMP_DIR"
6 if mkdir -p "$TEMP_DIR"; then 123 if mkdir -p "$TEMP_DIR"; then
31 infodir= 148 infodir=
32 localedir= 149 localedir=
33 mandir= 150 mandir=
34 151
35 # custom variables 152 # custom variables
36 src_dir=`pwd` 153 if true \
37 DOXYGEN=`command -v doxygen` 154 ; then
38 PANDOC=`command -v pandoc` 155 src_dir=`pwd`
156 DOXYGEN=`command -v doxygen`
157 PANDOC=`command -v pandoc`
158 fi
39 159
40 # features 160 # features
41
42 # clean abort
43 abort_configure()
44 {
45 rm -Rf "$TEMP_DIR"
46 exit 1
47 }
48
49 # help text
50 printhelp()
51 {
52 echo "Usage: $0 [OPTIONS]..."
53 cat << __EOF__
54 Installation directories:
55 --prefix=PREFIX path prefix for architecture-independent files
56 [/usr]
57 --exec-prefix=EPREFIX path prefix for architecture-dependent files
58 [PREFIX]
59
60 --bindir=DIR user executables [EPREFIX/bin]
61 --sbindir=DIR system admin executables [EPREFIX/sbin]
62 --libexecdir=DIR program executables [EPREFIX/libexec]
63 --sysconfdir=DIR system configuration files [PREFIX/etc]
64 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
65 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
66 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run]
67 --libdir=DIR object code libraries [EPREFIX/lib]
68 --includedir=DIR C header files [PREFIX/include]
69 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
70 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
71 --infodir=DIR info documentation [DATAROOTDIR/info]
72 --mandir=DIR man documentation [DATAROOTDIR/man]
73 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
74
75 Options:
76 --debug add extra compile flags for debug builds
77 --release add extra compile flags for release builds
78 --with-docs=(all|html|api|none)
79
80 Optional Features:
81 --enable-coverage
82
83 __EOF__
84 }
85 161
86 # 162 #
87 # parse arguments 163 # parse arguments
88 # 164 #
89 BUILD_TYPE="default" 165 BUILD_TYPE="default"
150 printf "loading site defaults... " 226 printf "loading site defaults... "
151 . "$prefix/etc/config.site" 227 . "$prefix/etc/config.site"
152 echo ok 228 echo ok
153 fi 229 fi
154 230
155 # Test for availability of pkg-config
156 PKG_CONFIG=`command -v pkg-config`
157 : ${PKG_CONFIG:="false"}
158
159 # Simple uname based platform detection
160 # $PLATFORM is used for platform dependent dependency selection
161 OS=`uname -s`
162 OS_VERSION=`uname -r`
163 printf "detect platform... "
164 if [ "$OS" = "SunOS" ]; then
165 PLATFORM="solaris sunos unix svr4"
166 elif [ "$OS" = "Linux" ]; then
167 PLATFORM="linux unix"
168 elif [ "$OS" = "FreeBSD" ]; then
169 PLATFORM="freebsd bsd unix"
170 elif [ "$OS" = "OpenBSD" ]; then
171 PLATFORM="openbsd bsd unix"
172 elif [ "$OS" = "NetBSD" ]; then
173 PLATFORM="netbsd bsd unix"
174 elif [ "$OS" = "Darwin" ]; then
175 PLATFORM="macos osx bsd unix"
176 elif echo "$OS" | grep -i "MINGW" > /dev/null; then
177 PLATFORM="windows mingw"
178 fi
179 : ${PLATFORM:="unix"}
180
181 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
182 echo "$PLATFORM_NAME"
183
184 isplatform()
185 {
186 for p in $PLATFORM
187 do
188 if [ "$p" = "$1" ]; then
189 return 0
190 fi
191 done
192 return 1
193 }
194 notisplatform()
195 {
196 for p in $PLATFORM
197 do
198 if [ "$p" = "$1" ]; then
199 return 1
200 fi
201 done
202 return 0
203 }
204 istoolchain()
205 {
206 for t in $TOOLCHAIN
207 do
208 if [ "$t" = "$1" ]; then
209 return 0
210 fi
211 done
212 return 1
213 }
214 notistoolchain()
215 {
216 for t in $TOOLCHAIN
217 do
218 if [ "$t" = "$1" ]; then
219 return 1
220 fi
221 done
222 return 0
223 }
224
225 231
226 # generate vars.mk 232 # generate vars.mk
227 cat > "$TEMP_DIR/vars.mk" << __EOF__ 233 cat > "$TEMP_DIR/vars.mk" << __EOF__
228 prefix=$prefix 234 prefix=$prefix
229 exec_prefix=$exec_prefix 235 exec_prefix=$exec_prefix
239 runstatedir=$runstatedir 245 runstatedir=$runstatedir
240 includedir=$includedir 246 includedir=$includedir
241 infodir=$infodir 247 infodir=$infodir
242 mandir=$mandir 248 mandir=$mandir
243 localedir=$localedir 249 localedir=$localedir
244 src_dir=$src_dir
245 DOXYGEN=$DOXYGEN
246 PANDOC=$PANDOC
247 __EOF__ 250 __EOF__
248 251
249 # toolchain detection utilities 252 # toolchain detection utilities
250 . make/toolchain.sh 253 . make/toolchain.sh
251 254
285 } 288 }
286 289
287 dependency_error_coverage() 290 dependency_error_coverage()
288 { 291 {
289 print_check_msg "$dep_checked_coverage" "checking for coverage... " 292 print_check_msg "$dep_checked_coverage" "checking for coverage... "
290 # dependency coverage toolchain="gnuc" 293 # dependency coverage toolchain="gcc"
291 while true 294 while true
292 do 295 do
293 if notistoolchain "gnuc"; then 296 if notistoolchain "gcc"; then
294 break 297 break
295 fi 298 fi
296 TEMP_CFLAGS="$TEMP_CFLAGS \${COVERAGE_CFLAGS}" 299 TEMP_CFLAGS="$TEMP_CFLAGS \${COVERAGE_CFLAGS}"
297 TEMP_LDFLAGS="$TEMP_LDFLAGS \${COVERAGE_LDFLAGS}" 300 TEMP_LDFLAGS="$TEMP_LDFLAGS \${COVERAGE_LDFLAGS}"
298 print_check_msg "$dep_checked_coverage" "yes\n" 301 print_check_msg "$dep_checked_coverage" "yes\n"

mercurial