configure

changeset 802
16e5b9d32754
parent 787
bd96cbb0e205
child 809
8e6d8f0327cf
equal deleted inserted replaced
801:ce97ff16f00e 802:16e5b9d32754
1 #!/bin/sh 1 #!/bin/sh
2 2
3 3 # create temporary directory
4 PREFIX=/usr
5 EPREFIX=$PREFIX
6
7 BINDIR=
8 SBINDIR=
9 LIBDIR=
10 LIBEXECDIR=
11 DATADIR=
12 SYSCONFDIR=
13 SHAREDSTATEDIR=
14 LOCALSTATEDIR=
15 INCLUDEDIR=
16 INFODIR=
17 MANDIR=
18
19 OS=`uname -s`
20 OS_VERSION=`uname -r`
21
22 TEMP_DIR=".tmp-`uname -n`" 4 TEMP_DIR=".tmp-`uname -n`"
23 mkdir -p "$TEMP_DIR" 5 rm -Rf "$TEMP_DIR"
24 if [ $? -ne 0 ]; then 6 if mkdir -p "$TEMP_DIR"; then
25 echo "Cannot create tmp dir" 7 :
8 else
9 echo "Cannot create tmp dir $TEMP_DIR"
26 echo "Abort" 10 echo "Abort"
11 exit 1
27 fi 12 fi
28 touch "$TEMP_DIR/options" 13 touch "$TEMP_DIR/options"
29 touch "$TEMP_DIR/features" 14 touch "$TEMP_DIR/features"
30 15
16 # define standard variables
17 # also define standard prefix (this is where we will search for config.site)
18 prefix=/usr
19 exec_prefix=
20 bindir=
21 sbindir=
22 libdir=
23 libexecdir=
24 datarootdir=
25 datadir=
26 sysconfdir=
27 sharedstatedir=
28 localstatedir=
29 runstatedir=
30 includedir=
31 infodir=
32 localedir=
33 mandir=
34
35 # custom variables
36
31 # features 37 # features
38
39 # clean abort
40 abort_configure()
41 {
42 rm -Rf "$TEMP_DIR"
43 exit 1
44 }
32 45
33 # help text 46 # help text
34 printhelp() 47 printhelp()
35 { 48 {
36 echo "Usage: $0 [OPTIONS]..." 49 echo "Usage: $0 [OPTIONS]..."
45 --sbindir=DIR system admin executables [EPREFIX/sbin] 58 --sbindir=DIR system admin executables [EPREFIX/sbin]
46 --libexecdir=DIR program executables [EPREFIX/libexec] 59 --libexecdir=DIR program executables [EPREFIX/libexec]
47 --sysconfdir=DIR system configuration files [PREFIX/etc] 60 --sysconfdir=DIR system configuration files [PREFIX/etc]
48 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] 61 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
49 --localstatedir=DIR modifiable single-machine data [PREFIX/var] 62 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
63 --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run]
50 --libdir=DIR object code libraries [EPREFIX/lib] 64 --libdir=DIR object code libraries [EPREFIX/lib]
51 --includedir=DIR C header files [PREFIX/include] 65 --includedir=DIR C header files [PREFIX/include]
52 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] 66 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
53 --datadir=DIR read-only architecture-independent data [DATAROOTDIR] 67 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
54 --infodir=DIR info documentation [DATAROOTDIR/info] 68 --infodir=DIR info documentation [DATAROOTDIR/info]
55 --mandir=DIR man documentation [DATAROOTDIR/man] 69 --mandir=DIR man documentation [DATAROOTDIR/man]
70 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
56 71
57 __EOF__ 72 __EOF__
58 } 73 }
59 74
60 # 75 #
61 # parse arguments 76 # parse arguments
62 # 77 #
78 BUILD_TYPE="default"
63 for ARG in "$@" 79 for ARG in "$@"
64 do 80 do
65 case "$ARG" in 81 case "$ARG" in
66 "--prefix="*) PREFIX=${ARG#--prefix=} ;; 82 "--prefix="*) prefix=${ARG#--prefix=} ;;
67 "--exec-prefix="*) EPREFIX=${ARG#--exec-prefix=} ;; 83 "--exec-prefix="*) exec_prefix=${ARG#--exec-prefix=} ;;
68 "--bindir="*) BINDIR=${ARG#----bindir=} ;; 84 "--bindir="*) bindir=${ARG#----bindir=} ;;
69 "--sbindir="*) SBINDIR=${ARG#--sbindir=} ;; 85 "--sbindir="*) sbindir=${ARG#--sbindir=} ;;
70 "--libdir="*) LIBDIR=${ARG#--libdir=} ;; 86 "--libdir="*) libdir=${ARG#--libdir=} ;;
71 "--libexecdir="*) LIBEXECDIR=${ARG#--libexecdir=} ;; 87 "--libexecdir="*) libexecdir=${ARG#--libexecdir=} ;;
72 "--datadir="*) DATADIR=${ARG#--datadir=} ;; 88 "--datarootdir="*) datarootdir=${ARG#--datarootdir=} ;;
73 "--sysconfdir="*) SYSCONFDIR=${ARG#--sysconfdir=} ;; 89 "--datadir="*) datadir=${ARG#--datadir=} ;;
74 "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;; 90 "--sysconfdir="*) sysconfdir=${ARG#--sysconfdir=} ;;
75 "--localstatedir="*) LOCALSTATEDIR=${ARG#--localstatedir=} ;; 91 "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;;
76 "--includedir="*) INCLUDEDIR=${ARG#--includedir=} ;; 92 "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;;
77 "--infodir="*) INFODIR=${ARG#--infodir=} ;; 93 "--includedir="*) includedir=${ARG#--includedir=} ;;
78 "--mandir"*) MANDIR=${ARG#--mandir} ;; 94 "--infodir="*) infodir=${ARG#--infodir=} ;;
79 "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;; 95 "--mandir"*) mandir=${ARG#--mandir} ;;
80 "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;; 96 "--localedir"*) localedir=${ARG#--localedir} ;;
97 "--help"*) printhelp; abort_configure ;;
98 "--debug") BUILD_TYPE="debug" ;;
99 "--release") BUILD_TYPE="release" ;;
100 "-"*) echo "unknown option: $ARG"; abort_configure ;;
81 esac 101 esac
82 done 102 done
83 103
84 # set dir variables 104
85 if [ -z "$BINDIR" ]; then 105
86 BINDIR=$EPREFIX/bin 106 # set defaults for dir variables
87 fi 107 : ${exec_prefix:="$prefix"}
88 if [ -z "$SBINDIR" ]; then 108 : ${bindir:='${exec_prefix}/bin'}
89 SBINDIR=$EPREFIX/sbin 109 : ${sbindir:='${exec_prefix}/sbin'}
90 fi 110 : ${libdir:='${exec_prefix}/lib'}
91 if [ -z "$LIBDIR" ]; then 111 : ${libexecdir:='${exec_prefix}/libexec'}
92 LIBDIR=$EPREFIX/lib 112 : ${datarootdir:='${prefix}/share'}
93 fi 113 : ${datadir:='${datarootdir}'}
94 if [ -z "$LIBEXEC" ]; then 114 : ${sysconfdir:='${prefix}/etc'}
95 LIBEXECDIR=$EPREFIX/libexec 115 : ${sharedstatedir:='${prefix}/com'}
96 fi 116 : ${localstatedir:='${prefix}/var'}
97 if [ -z "$DATADIR" ]; then 117 : ${runstatedir:='${localstatedir}/run'}
98 DATADIR=$PREFIX/share 118 : ${includedir:='${prefix}/include'}
99 fi 119 : ${infodir:='${datarootdir}/info'}
100 if [ -z "$SYSCONFDIR" ]; then 120 : ${mandir:='${datarootdir}/man'}
101 SYSCONFDIR=$PREFIX/etc 121 : ${localedir:='${datarootdir}/locale'}
102 fi 122
103 if [ -z "$SHAREDSTATEDIR" ]; then 123 # check if a config.site exists and load it
104 SHAREDSTATEDIR=$PREFIX/com 124 if [ -n "$CONFIG_SITE" ]; then
105 fi 125 # CONFIG_SITE may contain space separated file names
106 if [ -z "$LOCALSTATEDIR" ]; then 126 for cs in $CONFIG_SITE; do
107 LOCALSTATEDIR=$PREFIX/var 127 printf "loading defaults from $cs... "
108 fi 128 . "$cs"
109 if [ -z "$INCLUDEDIR" ]; then 129 echo ok
110 INCLUDEDIR=$PREFIX/include 130 done
111 fi 131 elif [ -f "$prefix/share/config.site" ]; then
112 if [ -z "$INFODIR" ]; then 132 printf "loading site defaults... "
113 INFODIR=$PREFIX/info 133 . "$prefix/share/config.site"
114 fi 134 echo ok
115 if [ -z "$MANDIR" ]; then 135 elif [ -f "$prefix/etc/config.site" ]; then
116 MANDIR=$PREFIX/man 136 printf "loading site defaults... "
117 fi 137 . "$prefix/etc/config.site"
118 138 echo ok
119 which pkg-config > /dev/null 139 fi
120 if [ $? -eq 0 ]; then 140
121 PKG_CONFIG=pkg-config 141 # Test for availability of pkg-config
122 else 142 PKG_CONFIG=`command -v pkg-config`
123 PKG_CONFIG=false 143 : ${PKG_CONFIG:="false"}
124 fi
125 144
126 # Simple uname based platform detection 145 # Simple uname based platform detection
127 # $PLATFORM is used for platform dependent dependency selection 146 # $PLATFORM is used for platform dependent dependency selection
147 OS=`uname -s`
148 OS_VERSION=`uname -r`
128 printf "detect platform... " 149 printf "detect platform... "
129 if [ "$OS" = "SunOS" ]; then 150 if [ "$OS" = "SunOS" ]; then
130 PLATFORM="solaris sunos unix svr4" 151 PLATFORM="solaris sunos unix svr4"
131 fi 152 elif [ "$OS" = "Linux" ]; then
132 if [ "$OS" = "Linux" ]; then
133 PLATFORM="linux unix" 153 PLATFORM="linux unix"
134 fi 154 elif [ "$OS" = "FreeBSD" ]; then
135 if [ "$OS" = "FreeBSD" ]; then
136 PLATFORM="freebsd bsd unix" 155 PLATFORM="freebsd bsd unix"
137 fi 156 elif [ "$OS" = "OpenBSD" ]; then
138 if [ "$OS" = "Darwin" ]; then 157 PLATFORM="openbsd bsd unix"
158 elif [ "$OS" = "NetBSD" ]; then
159 PLATFORM="netbsd bsd unix"
160 elif [ "$OS" = "Darwin" ]; then
139 PLATFORM="macos osx bsd unix" 161 PLATFORM="macos osx bsd unix"
140 fi 162 elif echo "$OS" | grep -i "MINGW" > /dev/null; then
141 echo "$OS" | grep -i "MINGW" > /dev/null
142 if [ $? -eq 0 ]; then
143 PLATFORM="windows mingw" 163 PLATFORM="windows mingw"
144 fi 164 fi
145 165 : ${PLATFORM:="unix"}
146 if [ -z "$PLATFORM" ]; then 166
147 PLATFORM="unix" 167 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
148 fi 168 echo "$PLATFORM_NAME"
149
150 for p in $PLATFORM
151 do
152 PLATFORM_NAME=$p
153 break
154 done
155 echo $PLATFORM_NAME
156 169
157 isplatform() 170 isplatform()
158 { 171 {
159 for p in $PLATFORM 172 for p in $PLATFORM
160 do 173 do
162 return 0 175 return 0
163 fi 176 fi
164 done 177 done
165 return 1 178 return 1
166 } 179 }
167 isnotplatform() 180 notisplatform()
168 { 181 {
169 for p in $PLATFORM 182 for p in $PLATFORM
170 do 183 do
171 if [ "$p" = "$1" ]; then 184 if [ "$p" = "$1" ]; then
172 return 1 185 return 1
173 fi 186 fi
174 done 187 done
175 return 0 188 return 0
176 } 189 }
177 190 istoolchain()
178 # generate config.mk and config.h 191 {
179 cat > "$TEMP_DIR/config.mk" << __EOF__ 192 for t in $TOOLCHAIN
180 # 193 do
181 # config.mk generated by configure 194 if [ "$t" = "$1" ]; then
182 # 195 return 0
183 196 fi
184 # general vars 197 done
185 198 return 1
186 PREFIX=$PREFIX 199 }
187 EPREFIX=$EPREFIX 200 notistoolchain()
188 201 {
189 BINDIR=$BINDIR 202 for t in $TOOLCHAIN
190 SBINDIR=$SBINDIR 203 do
191 LIBDIR=$LIBDIR 204 if [ "$t" = "$1" ]; then
192 LIBEXECDIR=$LIBEXECDIR 205 return 1
193 DATADIR=$DATADIR 206 fi
194 SYSCONFDIR=$SYSCONFDIR 207 done
195 SHAREDSTATEDIR=$SHAREDSTATEDIR 208 return 0
196 LOCALSTATEDIR=$LOCALSTATEDIR 209 }
197 INCLUDEDIR=$INCLUDEDIR 210
198 INFODIR=$INFODIR 211
199 MANDIR=$MANDIR 212 # generate vars.mk
200 213 cat > "$TEMP_DIR/vars.mk" << __EOF__
214 prefix="$prefix"
215 exec_prefix="$exec_prefix"
216 bindir="$bindir"
217 sbindir="$sbindir"
218 libdir="$libdir"
219 libexecdir="$libexecdir"
220 datarootdir="$datarootdir"
221 datadir="$datadir"
222 sysconfdir="$sysconfdir"
223 sharedstatedir="$sharedstatedir"
224 localstatedir="$localstatedir"
225 runstatedir="$runstatedir"
226 includedir="$includedir"
227 infodir="$infodir"
228 mandir="$mandir"
229 localedir="$localedir"
201 __EOF__ 230 __EOF__
202 231
232 # toolchain detection utilities
233 . make/toolchain.sh
234
235 #
236 # DEPENDENCIES
237 #
238
239 # check languages
240 lang_c=
241 lang_cpp=
242 if detect_c_compiler ; then
243 lang_c=1
244 fi
245
246 # create buffer for make variables required by dependencies
203 echo > "$TEMP_DIR/make.mk" 247 echo > "$TEMP_DIR/make.mk"
204 248
205 ENV_CFLAGS=$CFLAGS 249 test_pkg_config()
206 ENV_LDFLAGS=$LDFLAGS 250 {
207 ENV_CXXFLAGS=$CXXFLAGS 251 if "$PKG_CONFIG" --exists "$1" ; then :
208 252 else return 1 ; fi
209 # Toolchain detection 253 if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then :
210 # this will insert make vars to config.mk 254 else return 1 ; fi
211 . make/toolchain.sh 255 if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then :
212 256 else return 1 ; fi
213 # add user specified flags to config.mk 257 if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then :
214 echo "# project specific flags" >> "$TEMP_DIR/config.mk" 258 else return 1 ; fi
215 if [ -n "${ENV_CFLAGS}" ]; then 259 return 0
216 echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk" 260 }
217 fi 261
218 if [ -n "${ENV_CXXFLAGS}" ]; then 262 print_check_msg()
219 echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk" 263 {
220 fi 264 if [ -z "$1" ]; then
221 if [ -n "${ENV_LDFLAGS}" ]; then 265 shift
222 echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk" 266 printf "$@"
223 fi 267 fi
224 268 }
225 # 269
226 # DEPENDENCIES 270 dependency_error_curl()
227 # 271 {
228 272 print_check_msg "$dep_checked_curl" "checking for curl... "
229 dependency_curl()
230 {
231 printf "checking for curl... "
232 # dependency curl platform="windows" 273 # dependency curl platform="windows"
233 while true 274 while true
234 do 275 do
235 if isnotplatform "windows"; then 276 if notisplatform "windows"; then
236 break 277 break
237 fi 278 fi
238 TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include" 279 TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include"
239 TEMP_LDFLAGS="$TEMP_LDFLAGS -lcurl" 280 TEMP_LDFLAGS="$TEMP_LDFLAGS -lcurl"
240 echo yes 281 print_check_msg "$dep_checked_curl" "yes\n"
241 return 0 282 dep_checked_curl=1
283 return 1
242 done 284 done
243 285
244 # dependency curl platform="macos" 286 # dependency curl platform="macos"
245 while true 287 while true
246 do 288 do
247 if isnotplatform "macos"; then 289 if notisplatform "macos"; then
248 break 290 break
249 fi 291 fi
250 curl-config --cflags > /dev/null 292 if tmp_flags=`curl-config --cflags` ; then
251 if [ $? -eq 0 ]; then 293 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
252 TEMP_CFLAGS="$TEMP_CFLAGS `curl-config --cflags`" 294 else
253 else 295 break
254 break 296 fi
255 fi 297 if tmp_flags=`curl-config --ldflags` ; then
256 curl-config --ldflags > /dev/null 298 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
257 if [ $? -eq 0 ]; then 299 else
258 TEMP_LDFLAGS="$TEMP_LDFLAGS `curl-config --ldflags`" 300 break
259 else 301 fi
260 break 302 print_check_msg "$dep_checked_curl" "yes\n"
261 fi 303 dep_checked_curl=1
262 echo yes 304 return 1
263 return 0
264 done 305 done
265 306
266 # dependency curl 307 # dependency curl
267 while true 308 while true
268 do 309 do
269 if [ -z "$PKG_CONFIG" ]; then 310 if [ -z "$PKG_CONFIG" ]; then
270 break 311 break
271 fi 312 fi
272 $PKG_CONFIG libcurl 313 if test_pkg_config "libcurl" "" "" "" ; then
273 if [ $? -ne 0 ] ; then 314 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libcurl`"
274 break 315 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libcurl`"
275 fi 316 else
276 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libcurl`" 317 break
277 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libcurl`" 318 fi
278 echo yes 319 print_check_msg "$dep_checked_curl" "yes\n"
279 return 0 320 dep_checked_curl=1
321 return 1
280 done 322 done
281 323
282 # dependency curl 324 # dependency curl
283 while true 325 while true
284 do 326 do
285 curl-config --cflags > /dev/null 327 if tmp_flags=`curl-config --cflags` ; then
286 if [ $? -eq 0 ]; then 328 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
287 TEMP_CFLAGS="$TEMP_CFLAGS `curl-config --cflags`" 329 else
288 else 330 break
289 break 331 fi
290 fi 332 if tmp_flags=`curl-config --libs` ; then
291 curl-config --libs > /dev/null 333 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
292 if [ $? -eq 0 ]; then 334 else
293 TEMP_LDFLAGS="$TEMP_LDFLAGS `curl-config --libs`" 335 break
294 else 336 fi
295 break 337 print_check_msg "$dep_checked_curl" "yes\n"
296 fi 338 dep_checked_curl=1
297 echo yes 339 return 1
298 return 0 340 done
299 done 341
300 342 print_check_msg "$dep_checked_curl" "no\n"
301 echo no 343 dep_checked_curl=1
302 return 1 344 return 0
303 } 345 }
304 dependency_openssl() 346 dependency_error_openssl()
305 { 347 {
306 printf "checking for openssl... " 348 print_check_msg "$dep_checked_openssl" "checking for openssl... "
307 # dependency openssl platform="windows" 349 # dependency openssl platform="windows"
308 while true 350 while true
309 do 351 do
310 if isnotplatform "windows"; then 352 if notisplatform "windows"; then
311 break 353 break
312 fi 354 fi
313 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" 355 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
314 echo yes 356 print_check_msg "$dep_checked_openssl" "yes\n"
315 return 0 357 dep_checked_openssl=1
358 return 1
316 done 359 done
317 360
318 # dependency openssl platform="macos" 361 # dependency openssl platform="macos"
319 while true 362 while true
320 do 363 do
321 if isnotplatform "macos"; then 364 if notisplatform "macos"; then
322 break 365 break
323 fi 366 fi
324 TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation" 367 TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation"
325 echo yes 368 print_check_msg "$dep_checked_openssl" "yes\n"
326 return 0 369 dep_checked_openssl=1
370 return 1
327 done 371 done
328 372
329 # dependency openssl platform="bsd" 373 # dependency openssl platform="bsd"
330 while true 374 while true
331 do 375 do
332 if isnotplatform "bsd"; then 376 if notisplatform "bsd"; then
333 break 377 break
334 fi 378 fi
335 if isplatform "macos"; then 379 if isplatform "macos" || istoolchain "macos"; then
336 break 380 break
337 fi 381 fi
338 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto" 382 TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
339 echo yes 383 print_check_msg "$dep_checked_openssl" "yes\n"
340 return 0 384 dep_checked_openssl=1
385 return 1
341 done 386 done
342 387
343 # dependency openssl 388 # dependency openssl
344 while true 389 while true
345 do 390 do
346 if [ -z "$PKG_CONFIG" ]; then 391 if [ -z "$PKG_CONFIG" ]; then
347 break 392 break
348 fi 393 fi
349 $PKG_CONFIG openssl 394 if test_pkg_config "openssl" "" "" "" ; then
350 if [ $? -ne 0 ] ; then 395 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
351 break 396 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
352 fi 397 else
353 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags openssl`" 398 break
354 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs openssl`" 399 fi
355 echo yes 400 print_check_msg "$dep_checked_openssl" "yes\n"
356 return 0 401 dep_checked_openssl=1
357 done 402 return 1
358 403 done
359 echo no 404
360 return 1 405 print_check_msg "$dep_checked_openssl" "no\n"
361 } 406 dep_checked_openssl=1
362 dependency_libxml2() 407 return 0
363 { 408 }
364 printf "checking for libxml2... " 409 dependency_error_libxml2()
410 {
411 print_check_msg "$dep_checked_libxml2" "checking for libxml2... "
365 # dependency libxml2 platform="windows" 412 # dependency libxml2 platform="windows"
366 while true 413 while true
367 do 414 do
368 if isnotplatform "windows"; then 415 if notisplatform "windows"; then
369 break 416 break
370 fi 417 fi
371 xml2-config --cflags > /dev/null 418 if tmp_flags=`xml2-config --cflags` ; then
372 if [ $? -eq 0 ]; then 419 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
373 TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`" 420 else
374 else 421 break
375 break 422 fi
376 fi 423 if tmp_flags=`xml2-config --libs` ; then
377 xml2-config --libs > /dev/null 424 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
378 if [ $? -eq 0 ]; then 425 else
379 TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`" 426 break
380 else 427 fi
381 break 428 print_check_msg "$dep_checked_libxml2" "yes\n"
382 fi 429 dep_checked_libxml2=1
383 echo yes 430 return 1
384 return 0
385 done 431 done
386 432
387 # dependency libxml2 platform="macos" 433 # dependency libxml2 platform="macos"
388 while true 434 while true
389 do 435 do
390 if isnotplatform "macos"; then 436 if notisplatform "macos"; then
391 break 437 break
392 fi 438 fi
393 xml2-config --cflags > /dev/null 439 if tmp_flags=`xml2-config --cflags` ; then
394 if [ $? -eq 0 ]; then 440 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
395 TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`" 441 else
396 else 442 break
397 break 443 fi
398 fi 444 if tmp_flags=`xml2-config --libs` ; then
399 xml2-config --libs > /dev/null 445 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
400 if [ $? -eq 0 ]; then 446 else
401 TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`" 447 break
402 else 448 fi
403 break 449 print_check_msg "$dep_checked_libxml2" "yes\n"
404 fi 450 dep_checked_libxml2=1
405 echo yes 451 return 1
406 return 0
407 done 452 done
408 453
409 # dependency libxml2 454 # dependency libxml2
410 while true 455 while true
411 do 456 do
412 if [ -z "$PKG_CONFIG" ]; then 457 if [ -z "$PKG_CONFIG" ]; then
413 break 458 break
414 fi 459 fi
415 $PKG_CONFIG libxml-2.0 460 if test_pkg_config "libxml-2.0" "" "" "" ; then
416 if [ $? -ne 0 ] ; then 461 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`"
417 break 462 TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`"
418 fi 463 else
419 TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libxml-2.0`" 464 break
420 TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libxml-2.0`" 465 fi
421 echo yes 466 print_check_msg "$dep_checked_libxml2" "yes\n"
422 return 0 467 dep_checked_libxml2=1
468 return 1
423 done 469 done
424 470
425 # dependency libxml2 471 # dependency libxml2
426 while true 472 while true
427 do 473 do
428 xml2-config --cflags > /dev/null 474 if tmp_flags=`xml2-config --cflags` ; then
429 if [ $? -eq 0 ]; then 475 TEMP_CFLAGS="$TEMP_CFLAGS $tmp_flags"
430 TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`" 476 else
431 else 477 break
432 break 478 fi
433 fi 479 if tmp_flags=`xml2-config --libs` ; then
434 xml2-config --libs > /dev/null 480 TEMP_LDFLAGS="$TEMP_LDFLAGS $tmp_flags"
435 if [ $? -eq 0 ]; then 481 else
436 TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`" 482 break
437 else 483 fi
438 break 484 print_check_msg "$dep_checked_libxml2" "yes\n"
439 fi 485 dep_checked_libxml2=1
440 echo yes 486 return 1
441 return 0 487 done
442 done 488
443 489 print_check_msg "$dep_checked_libxml2" "no\n"
444 echo no 490 dep_checked_libxml2=1
445 return 1 491 return 0
446 } 492 }
493
494 # start collecting dependency information
495 echo > "$TEMP_DIR/flags.mk"
447 496
448 DEPENDENCIES_FAILED= 497 DEPENDENCIES_FAILED=
449 ERROR=0 498 ERROR=0
450 # general dependencies 499 # unnamed dependencies
451 TEMP_CFLAGS= 500 TEMP_CFLAGS=
501 TEMP_CXXFLAGS=
452 TEMP_LDFLAGS= 502 TEMP_LDFLAGS=
453 while true 503 while true
454 do 504 do
455 while true 505 while true
456 do 506 do
507 if [ -z "$lang_c" ] ; then
508 ERROR=1
509 break
510 fi
457 511
458 TEMP_LDFLAGS="$TEMP_LDFLAGS -lm -lpthread" 512 TEMP_LDFLAGS="$TEMP_LDFLAGS -lm -lpthread"
459 513 break
460 break 514 done
461 done
462
463 break 515 break
464 done 516 done
465 while true 517 while true
466 do 518 do
467 if isnotplatform "bsd"; then 519 if notisplatform "bsd"; then
468 break 520 break
469 fi 521 fi
470 if isplatform "macos"; then 522 if isplatform "macos" || istoolchain "macos"; then
471 break 523 break
472 fi 524 fi
473 while true 525 while true
474 do 526 do
475 527
476 TEMP_CFLAGS="$TEMP_CFLAGS -I/usr/local/include" 528 TEMP_CFLAGS="$TEMP_CFLAGS -I/usr/local/include"
477 TEMP_LDFLAGS="$TEMP_LDFLAGS -L/usr/local/lib" 529 TEMP_LDFLAGS="$TEMP_LDFLAGS -L/usr/local/lib"
478 530 break
479 break 531 done
480 done
481
482 break 532 break
483 done 533 done
484 while true 534 while true
485 do 535 do
486 if isnotplatform "macos"; then 536 if notisplatform "macos"; then
487 break 537 break
488 fi 538 fi
489 while true 539 while true
490 do 540 do
491 541
492 cat >> "$TEMP_DIR/make.mk" << __EOF__ 542 cat >> "$TEMP_DIR/make.mk" << __EOF__
493 OBJ_EXT = .o 543 OBJ_EXT = .o
494 LIB_EXT = .a 544 LIB_EXT = .a
495 545
496 __EOF__ 546 __EOF__
497 547 break
498 break 548 done
499 done
500
501 break 549 break
502 done 550 done
503 while true 551 while true
504 do 552 do
505 if isnotplatform "unix"; then 553 if notisplatform "unix"; then
506 break 554 break
507 fi 555 fi
508 if isplatform "macos"; then 556 if isplatform "macos" || istoolchain "macos"; then
509 break 557 break
510 fi 558 fi
511 while true 559 while true
512 do 560 do
513 561
514 cat >> "$TEMP_DIR/make.mk" << __EOF__ 562 cat >> "$TEMP_DIR/make.mk" << __EOF__
515 OBJ_EXT = .o 563 OBJ_EXT = .o
516 LIB_EXT = .a 564 LIB_EXT = .a
517 565
518 __EOF__ 566 __EOF__
519 567 break
520 break 568 done
521 done
522
523 break 569 break
524 done 570 done
525 571
526 # add general dependency flags to config.mk 572 # add general dependency flags to flags.mk
527 echo >> "$TEMP_DIR/config.mk" 573 echo "# general flags" >> "$TEMP_DIR/flags.mk"
528 if [ -n "${TEMP_CFLAGS}" ]; then 574 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
529 echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk 575 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
530 fi 576 fi
531 if [ -n "${TEMP_CXXFLAGS}" ]; then 577 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
532 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk 578 echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
533 fi 579 fi
534 if [ -n "${TEMP_LDFLAGS}" ]; then 580 if [ -n "${TEMP_LDFLAGS}" ]; then
535 echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk 581 echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
536 fi 582 fi
537 583
538 # 584 #
539 # OPTION VALUES 585 # OPTION VALUES
540 # 586 #
541 587
542 # 588 #
543 # TARGETS 589 # TARGETS
544 # 590 #
591
592 echo >> "$TEMP_DIR/flags.mk"
593 echo "configuring target: dav"
594 echo "# flags for target dav" >> "$TEMP_DIR/flags.mk"
545 TEMP_CFLAGS= 595 TEMP_CFLAGS=
546 TEMP_CXXFLAGS= 596 TEMP_CXXFLAGS=
547 TEMP_LDFLAGS= 597 TEMP_LDFLAGS=
548 598
549 # Target: dav 599 if dependency_error_curl; then
550 TEMP_CFLAGS=
551 TEMP_LDFLAGS=
552 TEMP_CXXFLAGS=
553
554 dependency_curl
555 if [ $? -ne 0 ]; then
556 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl " 600 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
557 ERROR=1 601 ERROR=1
558 fi 602 fi
559 dependency_libxml2 603 if dependency_error_libxml2; then
560 if [ $? -ne 0 ]; then
561 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 " 604 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
562 ERROR=1 605 ERROR=1
563 fi 606 fi
564 dependency_openssl 607 if dependency_error_openssl; then
565 if [ $? -ne 0 ]; then
566 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl " 608 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
567 ERROR=1 609 ERROR=1
568 fi 610 fi
569 611
570 # Features 612 # Features
571 613
572 614
573 echo >> "$TEMP_DIR/config.mk" 615 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then
574 if [ -n "${TEMP_CFLAGS}" ]; then 616 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
575 echo "DAV_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk" 617 fi
576 fi 618 if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then
577 if [ -n "${TEMP_CXXFLAGS}" ]; then 619 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
578 echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk" 620 fi
621 if [ "$BUILD_TYPE" = "debug" ]; then
622 if [ -n "$lang_c" ]; then
623 echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
624 fi
625 if [ -n "$lang_cpp" ]; then
626 echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
627 fi
628 fi
629 if [ "$BUILD_TYPE" = "release" ]; then
630 if [ -n "$lang_c" ]; then
631 echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
632 fi
633 if [ -n "$lang_cpp" ]; then
634 echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
635 fi
579 fi 636 fi
580 if [ -n "${TEMP_LDFLAGS}" ]; then 637 if [ -n "${TEMP_LDFLAGS}" ]; then
581 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk" 638 echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
582 fi 639 fi
583 640
641
642 # final result
584 if [ $ERROR -ne 0 ]; then 643 if [ $ERROR -ne 0 ]; then
585 echo 644 echo
586 echo "Error: Unresolved dependencies" 645 echo "Error: Unresolved dependencies"
587 echo "$DEPENDENCIES_FAILED" 646 echo "$DEPENDENCIES_FAILED"
588 rm -Rf "$TEMP_DIR" 647 abort_configure
589 exit 1
590 fi 648 fi
591 649
592 echo "configure finished" 650 echo "configure finished"
593 echo 651 echo
594 echo "Build Config:" 652 echo "Build Config:"
595 echo " PREFIX: $PREFIX" 653 echo " PREFIX: $prefix"
596 echo " TOOLCHAIN: $TOOLCHAIN_NAME" 654 echo " TOOLCHAIN: $TOOLCHAIN_NAME"
597 echo 655 echo
598 cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk 656
657 # generate the config.mk file
658 cat > "$TEMP_DIR/config.mk" << __EOF__
659 #
660 # config.mk generated by configure
661 #
662
663 __EOF__
664 write_toolchain_defaults "$TEMP_DIR/toolchain.mk"
665 cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk
599 rm -Rf "$TEMP_DIR" 666 rm -Rf "$TEMP_DIR"
600
601

mercurial