VirtualBox

root/trunk/configure

Revision 11735, 51.4 kB (checked in by vboxsync, 21 hours ago)

configure: detect python

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
Line 
1 #!/bin/sh
2 # The purpose of this script is to check for all external tools, headers, and
3 # libraries VBox OSE depends on.
4
5 #
6 # Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 #
8 # This file is part of VirtualBox Open Source Edition (OSE), as
9 # available from http://www.virtualbox.org. This file is free software;
10 # you can redistribute it and/or modify it under the terms of the GNU
11 # General Public License as published by the Free Software Foundation,
12 # in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 # distribution. VirtualBox OSE is distributed in the hope that it will
14 # be useful, but WITHOUT ANY WARRANTY of any kind.
15 #
16
17 LC_ALL=C
18 export LC_ALL
19
20 # append some extra paths
21 PATH="$PATH:/opt/gnome/bin"
22 # Solaris (order of paths important for tr, echo, grep, sed to work)
23 PATH="/usr/xpg4/bin:/usr/ucb:$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin"
24 ORGPATH=$PATH
25
26 #
27 # Defaults
28 #
29 OSE=1
30 ODIR="`pwd`/"
31 SETUP_WINE=
32 TARGET_MACHINE=""
33 TARGET_CPU=""
34 WITH_XPCOM=1
35 WITH_PYTHON=1
36 WITH_LIBIDL=1
37 WITH_QT3=1
38 WITH_QT4=1
39 WITH_SDL=1
40 WITH_SDL_TTF=1
41 WITH_X11=1
42 WITH_ALSA=1
43 WITH_PULSE=1
44 WITH_KMODS=1
45 CC="gcc"
46 CC_COMPAT=""
47 CC32=""
48 CC64=""
49 CXX="g++"
50 CXX32=""
51 CXX64=""
52 BCC="bcc"
53 YASM="yasm"
54 IASL="iasl"
55 AS86="as86"
56 XSLTPROC="xsltproc"
57 GENISOIMAGE="genisoimage"
58 MKISOFS="mkisofs"
59 BUILD_LIBXML2=
60 BUILD_LIBXSLT=
61 LIBCRYPTO="-lcrypto"
62 LIBPTHREAD="-lpthread"
63 LIBX11="-L/usr/X11R6/lib -L/usr/X11R6/lib64 -L/usr/local/lib -lXext -lX11"
64 INCX11="/usr/local/include"
65 LIBXCURSOR="-lXcursor"
66 INCZ=""
67 LIBZ="-lz"
68 INCPNG=""
69 LIBPNG="-lpng"
70 PYTHONDIR="/usr /usr/local"
71 QT3DIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3"
72 QT3DIR="$QT3DIR /usr/lib64/qt-3.3 /usr/X11R6 /usr/lib/qt"
73 QT4DIR="/usr/lib/qt4 /usr/share/qt4 /usr/lib64/qt4 /usr"
74 QT4DIR_PKGCONFIG=1
75 QT4UIC3DIR="/usr/bin"
76 KBUILDDIR="`cd \`dirname $0\`; pwd`/kBuild"
77 DEVDIR="`cd \`dirname $0\`; pwd`/tools"
78 if [ -d "/lib/modules/`uname -r`/build" ]; then
79  LINUX="/lib/modules/`uname -r`/build"
80 else
81  LINUX="/usr/src/linux"
82 fi
83 KCHMVIEWER="kchmviewer"
84 LOG="configure.log"
85 CNF="AutoConfig.kmk"
86 ENV="env.sh"
87 BUILD_TYPE="release"
88 # the restricting tool is ar (mri mode).
89 INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
90
91 if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
92   echo "Error: VBox base path contains invalid characters!"
93   exit 1
94 fi
95
96 # darwin /bin/sh has a builtin echo that doesn't grok -n. gotta love it.
97 if [ "`uname`" = "Darwin" ]; then
98   ECHO_N="/bin/echo -n"
99 else
100   ECHO_N="echo -n"
101 fi
102
103
104 cleanup()
105 {
106   rm -f .tmp_src.cc .tmp_src.c .tmp_out .test_execute.log
107 }
108
109 fail()
110 {
111   if [ -z "$nofatal" -o "x$1" != "x" ]; then
112     cleanup
113     rm -f $ENV
114     exit 1
115   fi
116 }
117
118 log()
119 {
120   echo "$1"
121   echo "$1" >> $LOG
122 }
123
124 log_success()
125 {
126   if [ -n "$1" ]; then $ECHO_N "$1, "; fi
127   echo "OK."
128   echo "$1" >> $LOG
129   echo >> $LOG
130   echo >> $LOG
131 }
132
133 log_failure()
134 {
135   echo
136   echo "  ** $1!"
137   echo "** $1!" >> $LOG
138   echo >> $LOG
139 }
140
141 cnf_append()
142 {
143   printf "%-30s := %s\n" "$1" "$2" >> $CNF
144 }
145
146 strip_l()
147 {
148   echo "$1"|$KBUILD_SED 's|-l\([^ ]\+\)|\1|g; s|^-[^l][^ ]*||g; s| -[^l][^ ]*||g; s|^ ||; s| *$||g'
149 }
150
151 strip_L()
152 {
153   echo "$1"|$KBUILD_SED 's|-L\([^ ]\+\)|\1|g; s|^-[^L][^ ]*||g; s| -[^L][^ ]*||g; s|^ ||; s| *$||g'
154 }
155
156 strip_I()
157 {
158   echo "$1"|$KBUILD_SED 's|-I\([^ ]\+\)|\1|g; s|^-[^I][^ ]*||g; s| -[^I][^ ]*||g; s|^ ||; s| *$||g'
159 }
160
161 prefix_I()
162 {
163   echo "$1"|$KBUILD_SED 's|^\/|-I/|g; s| \/| -I/|g'
164 }
165
166 # Wrapper for ancient /usr/bin/which on darwin that always returns 0
167 which_wrapper()
168 {
169   if [ -z "$have_ancient_which" ]; then
170     if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
171       have_ancient_which="yes"
172     else
173       have_ancient_which="no"
174     fi
175   fi
176   if [ "$have_ancient_which" = "yes" ]; then
177     retval=`which $* 2>/dev/null`
178     echo "$retval"
179     test -n "$retval" -a -x "$retval"
180     unset retval
181   else
182     which $* 2> /dev/null
183   fi
184 }
185
186
187 check_avail()
188 {
189    if [ -z "$1" ]; then
190      log_failure "$2 is empty"
191      fail $3
192      return 1
193    elif which_wrapper $1 > /dev/null; then
194      return 0
195    else
196      log_failure "$1 (variable $2) not found"
197      fail $3
198      return 1
199    fi
200 }
201
202
203 # Prepare a test
204 test_header()
205 {
206   echo "***** Checking $1 *****" >> $LOG
207   $ECHO_N "Checking for $1: "
208 }
209
210
211 # Compile a test
212 test_compile()
213 {
214   echo "compiling the following source file:" >> $LOG
215   cat .tmp_src.cc >> $LOG
216   echo "using the following command line:" >> $LOG
217   echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
218   $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
219   if [ $? -ne 0 ]; then
220     if [ -z "$4" ]; then
221       echo
222       echo "  $2 not found at $1 or $3 headers not found"
223       echo "  Check the file $LOG for detailed error information."
224       fail
225     else
226       echo "not found."
227       echo >> $LOG
228       echo >> $LOG
229     fi
230     return 1
231   fi
232   return 0
233 }
234
235
236 # Execute a compiled test binary
237 test_execute()
238 {
239   echo "executing the binary" >> $LOG
240   ./.tmp_out > .test_execute.log
241   rc=$?
242   cat .test_execute.log | tee -a $LOG
243   if [ $rc -ne 0 ]; then
244     fail $1
245     return 1
246   fi
247   echo >> $LOG
248   echo >> $LOG
249   return 0
250 }
251
252
253 # Execute a compiled test binary
254 test_execute_path()
255 {
256   echo "executing the binary (LD_LIBRARY_PATH=$1)" >> $LOG
257   LD_LIBRARY_PATH=$1 ./.tmp_out > .test_execute.log
258   rc=$?
259   cat .test_execute.log | tee -a $LOG
260   if [ $rc -ne 0 ]; then
261     fail
262     return 1
263   fi
264   echo >> $LOG
265   echo >> $LOG
266   return 0
267 }
268
269
270 #
271 # Check for OS, MACHINE, CPU
272 #
273 check_environment()
274 {
275   test_header environment
276   OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr [:upper:] [:lower:]`
277   case "$OS" in
278     linux)
279       ;;
280     darwin)
281       ;;
282     freebsd)
283       ;;
284     sunos)
285       OS='solaris'
286       ;;
287     *)
288       log_failure "Cannot determine OS"
289       exit 1
290       ;;
291   esac
292   BUILD_CPU=`uname -m`
293   [ "$OS" = "solaris" ] && BUILD_CPU=`isainfo | cut -f 1 -d ' '`
294   case "$BUILD_CPU" in
295     i[3456789]86|x86|i86pc)
296       BUILD_MACHINE='x86'
297       LIB='lib'
298       ;;
299     x86_64|amd64)
300       BUILD_MACHINE='amd64'
301       BUILD_CPU='k8'
302       if [ "$OS" != "solaris" ]; then
303         # on AMD64 systems, 64bit libs are usually located in /usr/lib64
304         # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
305         LIB='lib64'
306       else
307         # Solaris doesn't seem to subscribe to fhs, libs are usually in
308         # a '64' subdirectory of the standard 'lib' dirs while some 64-bit
309         # alternative binaries can be found in 'amd64' subdirs of the 'bin'
310         # ones. So, in order to find the right stuff (esp. sdl-config) we'll
311         # have to make sure the */bin/amd64 dirs are searched before the */bin
312         # ones. (The sed has some sideeffects, but they shouldn't harm us...)
313         echo "64-bit Solaris detected, hacking the PATH" >> $LOG
314         echo "old PATH: $PATH" >> $LOG
315         PATH=`echo ":$PATH:" | sed -e 's,\(:[^:]*/bin\):,\1/amd64:\1:,g' \
316                                    -e 's/^:*//' -e 's/:*$//g' -e 's/::*/:/g' `
317         export PATH
318         echo "new PATH: $PATH" >> $LOG
319         LIB='lib/64'
320       fi
321       ;;
322     *)
323       log_failure "Cannot determine system"
324       exit 1
325       ;;
326   esac
327   [ -z "$TARGET_MACHINE" ] && TARGET_MACHINE=$BUILD_MACHINE
328   [ -z "$TARGET_CPU"     ] && TARGET_CPU=$BUILD_CPU
329   DEVDIR_BIN="$DEVDIR/$OS.$BUILD_MACHINE/bin"
330   log_success "Determined build machine: $OS.$BUILD_MACHINE, target machine: $OS.$TARGET_MACHINE"
331
332   echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
333   echo "export BUILD_PLATFORM_ARCH=\"$BUILD_MACHINE\"" >> $ENV
334   echo "export BUILD_TARGET=\"$OS\"" >> $ENV
335   echo "export BUILD_TARGET_ARCH=\"$TARGET_MACHINE\"" >> $ENV
336   echo "export BUILD_TARGET_CPU=\"$TARGET_CPU\"" >> $ENV
337   echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
338 }
339
340 #
341 # Check for gcc with version >= 3.2.
342 # We depend on a working gcc, if we fail terminate in every case.
343 #
344 check_gcc()
345 {
346   test_header gcc
347   if [ -n "$CC_COMPAT" ]; then
348     if check_avail "$CC_COMPAT" CC_COMPAT really; then
349       cc_compat_ver=`$CC_COMPAT -dumpversion` 2>/dev/null
350       if [ $? -ne 0 ]; then
351         log_failure "cannot execute '$CC_COMPAT -dumpversion'"
352         fail really
353       fi
354       cc_compat_maj=`echo $cc_compat_ver|cut -d. -f1`
355       cc_compat_min=`echo $cc_compat_ver|cut -d. -f2`
356       if [ $cc_compat_maj -lt 3 \
357          -o \( $cc_compat_maj -eq 3 -a $cc_compat_min -lt 2 \) \
358          -o \( $cc_compat_maj -eq 4 -a $cc_compat_min -lt 1 \) \
359          -o \( $cc_compat_maj -eq 4 -a $cc_compat_min -gt 2 \) \
360          -o $cc_compat_maj -gt 4 ]; then
361         log ""
362         log "  ** Version $cc_compat_ver of the compatibility gcc found. Expected gcc 3.x with x>1"
363         log "  ** or gcc 4.x with 0<x<3"
364         fail really
365       fi
366       cnf_append "VBOX_RECOMPILER_OP_GCC" "$CC_COMPAT"
367     fi
368   fi
369   if check_avail "$CC" CC really; then
370     cc_ver=`$CC -dumpversion` 2>/dev/null
371     if [ $? -ne 0 ]; then
372       log_failure "cannot execute '$CC -dumpversion'"
373       fail really
374     fi
375     if check_avail "$CXX" CXX really; then
376       cxx_ver=`$CXX -dumpversion` 2>/dev/null
377       if [ $? -ne 0 ]; then
378         log_failure "cannot execute '$CXX -dumpversion'"
379         fail really
380       fi
381       cc_maj=`echo $cc_ver|cut -d. -f1`
382       cc_min=`echo $cc_ver|cut -d. -f2`
383       if [ "x$cc_ver" != "x$cxx_ver" ]; then
384         log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
385         fail really
386       elif [ $cc_maj -eq 4 -a $cc_min -eq 0 -a "OS" = "darwin" ]; then
387         log_success "found version $cc_ver"
388       elif [ $cc_maj -eq 4 -a $cc_min -eq 3 ]; then
389         if [ -z "$CC_COMPAT" ]; then
390           log ""
391           log "  ** There are known problems with gcc version 4.3 when compiling the recompiler"
392           log "  ** stuff. You need to specify a compatibility compiler with version < 4.3. Look"
393           log "  ** for a package compat-gcc-34 on Fedora systems or something similar on other"
394           log "  ** distributions and call configure with parameter --with-gcc-compat=gcc34."
395           fail really
396         fi
397         log_success "found version $cc_ver + compat version $cc_compat_ver"
398       # gcc-4.0 is allowed for Darwin only
399       elif [ $cc_maj -lt 3 \
400              -o \( $cc_maj -eq 3 -a $cc_min -lt 2 \) \
401              -o \( $cc_maj -eq 4 -a $cc_min -lt 1 -a "$OS" != "darwin" \) \
402              -o \( $cc_maj -eq 4 -a $cc_min -gt 3 \) \
403              -o $cc_maj -gt 4 ]; then
404         log_failure "gcc version $cc_ver found, expected gcc 3.x with x>1 or gcc 4.x with 0<x<4"
405         fail really
406       else
407         log_success "found version $cc_ver"
408       fi
409       if [ "$BUILD_MACHINE" = "amd64" ]; then
410         [ -z "$CC32"  ] && CC32="$CC -m32"
411         [ -z "$CXX32" ] && CXX32="$CXX -m32"
412       else
413         [ -z "$CC32"  ] && CC32="$CC"
414         [ -z "$CXX32" ] && CXX32="$CXX"
415       fi
416       if [ "$BUILD_MACHINE" = "x86" -a "$TARGET_MACHINE" = "amd64" ]; then
417         [ -z "$CC64"  ] && CC64="$CC -m64"
418         [ -z "$CXX64" ] && CXX64="$CXX -m64"
419       fi
420       if [ "$CC" != "gcc" ]; then
421         cnf_append "TOOL_GCC3_CC"   "$CC"
422         cnf_append "TOOL_GCC3_AS"   "$CC"
423         cnf_append "TOOL_GCC3_LD"   "$CC"
424         cnf_append "TOOL_GXX3_CC"   "$CC"
425         cnf_append "TOOL_GXX3_AS"   "$CC"
426       fi
427       if [ "$CXX" != "g++" ]; then
428         cnf_append "TOOL_GCC3_CXX"  "$CXX"
429         cnf_append "TOOL_GXX3_CXX"  "$CXX"
430         cnf_append "TOOL_GXX3_LD"   "$CXX"
431       fi
432       if [ "$CC32" != "gcc -m32" ]; then
433         cnf_append "TOOL_GCC32_CC"  "$CC32"
434         cnf_append "TOOL_GCC32_AS"  "$CC32"
435         cnf_append "TOOL_GCC32_LD"  "$CC32"
436         cnf_append "TOOL_GXX32_CC"  "$CC32"
437         cnf_append "TOOL_GXX32_AS"  "$CC32"
438       fi
439       if [ "$CXX32" != "g++ -m32" ]; then
440         cnf_append "TOOL_GCC32_CXX" "$CXX32"
441         cnf_append "TOOL_GXX32_CXX" "$CXX32"
442         cnf_append "TOOL_GXX32_LD"  "$CXX32"
443       fi
444       # this isn't not necessary, there is not such tool.
445       if [ -n "$CC64" ]; then
446         cnf_append "TOOL_GCC64_CC"  "$CC64"
447         cnf_append "TOOL_GCC64_AS"  "$CC64"
448         cnf_append "TOOL_GCC64_LD"  "$CC64"
449         cnf_append "TOOL_GXX64_CC"  "$CC64"
450         cnf_append "TOOL_GXX64_AS"  "$CC64"
451       fi
452       if [ -n "$CXX64" ]; then
453         cnf_append "TOOL_GCC64_CXX" "$CXX64"
454         cnf_append "TOOL_GXX64_CXX" "$CXX64"
455         cnf_append "TOOL_GXX64_LD"  "$CXX64"
456       fi
457       # Solaris sports a 32-bit gcc/g++.
458       if [ "$OS" = "solaris" -a "$BUILD_MACHINE" = "amd64" ]; then
459         [ "$CC" = "gcc" ] && CC="gcc -m64"
460         [ "$CXX" = "g++" ] && CXX="g++ -m64"
461       fi
462     fi
463   fi
464 }
465
466
467 #
468 # Check for the bcc compiler, needed for compiling the BIOS
469 #
470 check_bcc()
471 {
472   test_header bcc
473   if check_avail "$BCC" BCC; then
474     bcc_ver=`$BCC -v 2>&1|grep version|sed 's+^bcc: version \(.*\)+\1+'`
475     if [ $? -ne 0 ]; then
476       log_failure "not found"
477       fail
478     else
479       echo "compiling the following source file:" >> $LOG
480       cat > .tmp_src.c << EOF
481 int foo(a)
482   int a;
483 {
484   return 0;
485 }
486 EOF
487       cat .tmp_src.c >> $LOG
488       bcc_path=`which_wrapper $BCC`
489       bcc_dir="`dirname $bcc_path`/"
490       echo "using the following command line:" >> $LOG
491       echo "$BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c" >> $LOG
492       $BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c >> $LOG 2>&1
493       if [ $? -ne 0 ]; then
494         log_failure "not found"
495         fail
496       else
497         log_success "found version $bcc_ver"
498         cnf_append "VBOX_BCC" "$bcc_path -B $bcc_dir"
499       fi
500       unset bcc_path
501       unset bcc_dir
502     fi
503   fi
504 }
505
506
507 #
508 # Check for the as86 assembler, needed for compiling the BIOS
509 #
510 check_as86()
511 {
512   test_header as86
513   if check_avail "$AS86" AS86; then
514     as86_ver=`$AS86 -v 2>&1|grep version|sed 's+^as86 version: \(.*\)+\1+'`
515     if [ $? -ne 0 ]; then
516       log_failure "not found"
517       fail
518     else
519       log_success "found version $as86_ver"
520       cnf_append "VBOX_AS86" "`which_wrapper $AS86`"
521     fi
522   fi
523 }
524
525
526 #
527 # Check for yasm, needed to compile assembler files
528 #
529 check_yasm()
530 {
531   test_header yasm
532   if check_avail "$YASM" YASM; then
533     yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
534     if [ $? -ne 0 ]; then
535       log_failure "not found"
536       fail
537     else
538       yasm_maj=`echo $yasm_ver|cut -d. -f1`
539       yasm_min=`echo $yasm_ver|cut -d. -f2`
540       yasm_rev=`echo $yasm_ver|cut -d. -f3`
541       yasm_ver_mul=`expr $yasm_maj \* 10000 + $yasm_min \* 100 + $yasm_rev`
542       if [ $yasm_ver_mul -lt 501 ]; then
543         log_failure "found version $yasm_ver, expected at least 0.5.1"
544         fail
545       else
546         log_success "found version $yasm_ver"
547       fi
548     fi
549   fi
550 }
551
552
553 #
554 # Check for the iasl ACPI compiler, needed to compile vbox.dsl
555 #
556 check_iasl()
557 {
558   test_header iasl
559   if check_avail "$IASL" IASL; then
560     iasl_ver=`$IASL|grep version|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
561     if [ $? -ne 0 ]; then
562       log_failure "not found"
563       fail
564     else
565       log_success "found version $iasl_ver"
566       cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
567     fi
568   fi
569 }
570
571
572 #
573 # Check for xsltproc, needed by Main
574 #
575 check_xsltproc()
576 {
577   test_header xslt
578   if check_avail "$XSLTPROC" XSLTPROC; then
579     xsltproc_ver=`$XSLTPROC --version`
580     if [ $? -ne 0 ]; then
581       log_failure "not found"
582       fail
583     else
584       log_success "found"
585       cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
586     fi
587   fi
588 }
589
590
591 #
592 # Check for mkisofs, needed to build the CDROM image containing the additions
593 #
594 check_mkisofs()
595 {
596   test_header mkisofs
597   if which_wrapper $GENISOIMAGE > /dev/null; then
598     mkisofs_ver=`$GENISOIMAGE --version`
599     if [ $? -ne 0 ]; then
600       log_failure "not found"
601       fail
602     else
603       log_success "found $mkisofs_ver"
604       cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
605     fi
606   elif check_avail "$MKISOFS" MKISOFS; then
607     mkisofs_ver=`$MKISOFS --version`
608     if [ $? -ne 0 ]; then
609       log_failure "not found"
610       fail
611     else
612       log_success "found $mkisofs_ver"
613       cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
614     fi
615   fi
616 }
617
618
619 #
620 # Check for libxml2, needed by VBoxSettings
621 # 2.6.24 is known to NOT work, 2.6.26 is known to work (there is no 2.6.25 release)
622 #
623 check_libxml2()
624 {
625   if [ -z "$BUILD_LIBXML2" ]; then
626     test_header libxml2
627     if which_wrapper pkg-config > /dev/null; then
628       libxml2_ver=`pkg-config libxml-2.0 --modversion 2>> $LOG`
629       if [ $? -ne 0 ]; then
630         log_failure "not found"
631         fail
632       else
633         FLGXML2=`pkg-config libxml-2.0 --cflags`
634         INCXML2=`strip_I "$FLGXML2"`
635         LIBXML2=`pkg-config libxml-2.0 --libs`
636         cat > .tmp_src.cc << EOF
637 #include <cstdio>
638 #include <libxml/xmlversion.h>
639 extern "C" int main(void)
640 {
641   printf("found version %s", LIBXML_DOTTED_VERSION);
642 #if LIBXML_VERSION >= 20626
643   printf(", OK.\n");
644   return 0;
645 #else
646   printf(", expected version 2.6.26 or higher\n");
647   return 1;
648 #endif
649 }
650 EOF
651         [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
652         if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
653           if test_execute; then
654             cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
655             cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
656           fi
657         fi
658       fi
659     elif which_wrapper xml2-config; then
660       libxml2_ver=`xml2-config --version`
661       if [ $? -ne 0 ]; then
662         log_failure "not found"
663         fail
664       else
665         log_success "found version $libxml2_ver"
666         FLGXML2=`xml2-config --cflags`
667         INCXML2=`strip_I "$FLGXML2"`
668         LIBXML2=`xml2-config --libs`
669         cat > .tmp_src.cc << EOF
670 #include <cstdio>
671 #include <libxml/xmlversion.h>
672 extern "C" int main(void)
673 {
674   printf("found version %s", LIBXML_DOTTED_VERSION);
675 #if LIBXML_VERSION >= 20626
676   printf(", OK.\n");
677   return 0;
678 #else
679   printf(", expected version 2.6.26 or higher\n");
680   return 1;
681 #endif
682 }
683 EOF
684         [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
685         if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
686           if test_execute; then
687             cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
688             cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
689           fi
690         fi
691       fi
692     else
693       log_failure "neither pkg-config nor xml2-config found"
694       fail
695     fi
696   fi
697 }
698
699
700 #
701 # Check for libxslt, needed by VBoxSettings. For now we depend on 1.1.17.
702 # This library is available on Ubuntu Edgy which fulfils the minimal libxml2
703 # requirement (2.6.26).
704 #
705 check_libxslt()
706 {
707   if [ -z "$BUILD_LIBXSLT" ]; then
708     test_header libxslt
709     if which_wrapper pkg-config > /dev/null; then
710       libxslt_ver=`pkg-config libxslt --modversion 2>> $LOG`
711       if [ $? -ne 0 ]; then
712         log_failure "not found"
713         fail
714       else
715         FLGXSLT=`pkg-config libxslt --cflags`
716         INCXSLT=`strip_I "$FLGXSLT"`
717         LIBXSLT=`pkg-config libxslt --libs`
718         cat > .tmp_src.cc << EOF
719 #include <cstdio>
720 #include <libxslt/xsltconfig.h>
721 extern "C" int main(void)
722 {
723   printf("found version %s", LIBXSLT_DOTTED_VERSION);
724 #if LIBXSLT_VERSION >= 10117
725   printf(", OK.\n");
726   return 0;
727 #else
728   printf(", expected version 1.1.17 or higher\n");
729   return 1;
730 #endif
731 }
732 EOF
733         [ -n "$INCXSLT" ] && I_INCXSLT=`prefix_I "$INCXSLT"`
734         if test_compile "$LIBXSLT $LIBPTHREAD $I_INCXSLT" xslt xslt; then
735           if test_execute; then
736             cnf_append "SDK_VBOX_LIBXSLT_INCS" "$INCXSLT"
737             cnf_append "SDK_VBOX_LIBXSLT_LIBS" "`strip_l "$LIBXSLT"`"
738           fi
739         fi
740       fi
741     elif which_wrapper xslt-config; then
742       libxslt_ver=`xslt-config --version`
743       if [ $? -ne 0 ]; then
744         log_failure "not found"
745         fail
746       else
747         log_success "found version $libxslt_ver"
748         FLGXSLT=`xslt-config --cflags`
749         INCXSLT=`strip_I "$FLGXSLT"`
750         LIBXSLT=`xslt-config --libs`
751         cat > .tmp_src.cc << EOF
752 #include <cstdio>
753 #include <libxslt/xsltconfig.h>
754 extern "C" int main(void)
755 {
756   printf("found version %s", LIBXSLT_DOTTED_VERSION);
757 #if LIBXSLT_VERSION >= 10117
758   printf(", OK.\n");
759   return 0;
760 #else
761   printf(", expected version 1.1.17 or higher\n");
762   return 1;
763 #endif
764 }
765 EOF
766         [ -n "$INCXSLT" ] && I_INCXSLT=`prefix_I "$INCXSLT"`
767         if test_compile "$LIBXSLT $LIBPTHREAD $I_INCXSLT" xslt xslt; then
768           if test_execute; then
769             cnf_append "SDK_VBOX_LIBXSLT_INCS" "$INCXSLT"
770             cnf_append "SDK_VBOX_LIBXSLT_LIBS" "`strip_l "$LIBXSLT"`"
771           fi
772         fi
773       fi
774     else
775       log_failure "neither pkg-config nor xslt-config found"
776       fail
777     fi
778   fi
779 }
780
781
782 #
783 # Check for libIDL, needed by xpcom
784 #
785 check_libidl()
786 {
787   test_header libIDL
788
789   if which_wrapper libIDL-config-2 > /dev/null; then
790     libidl_ver=`libIDL-config-2 --version`
791     if [ $? -ne 0 ]; then
792       log_failure "not found"
793       fail
794     else
795       log_success "found version $libidl_ver"
796       cnf_append "VBOX_LIBIDL_CONFIG" \
797         "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
798     fi
799   elif check_avail "libIDL-config" libIDL-config; then
800     libidl_ver=`libIDL-config --version`
801     if [ $? -ne 0 ]; then
802       log_failure "not found"
803       fail
804     else
805       log_success "found version $libidl_ver"
806       cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
807     fi
808   fi
809 }
810
811
812 #
813 # Check for openssl, needed for RDP
814 #
815 check_ssl()
816 {
817   test_header ssl
818   cat > .tmp_src.cc << EOF
819 #include <cstdio>
820 #include <openssl/opensslv.h>
821 extern "C" int main(void)
822 {
823   printf("found version %s", OPENSSL_VERSION_TEXT);
824 #if OPENSSL_VERSION_NUMBER >= 0x0090700
825   printf(", OK.\n");
826   return 0;
827 #else
828   printf(", expected version 0.9.7 or higher\n");
829   return 1;
830 #endif
831 }
832 EOF
833   if test_compile $LIBCRYPTO libcrypto openssl; then
834     if test_execute nofatal; then
835       cnf_append "SDK_VBOX_OPENSSL_INCS" ""
836       cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
837     fi
838   fi
839 }
840
841
842 #
843 # Check for pthread, needed by VBoxSVC, frontends, ...
844 #
845 check_pthread()
846 {
847   test_header pthread
848   cat > .tmp_src.cc << EOF
849 #include <cstdio>
850 #include <pthread.h>
851 extern "C" int main(void)
852 {
853   pthread_mutex_t mutex;
854   if (pthread_mutex_init(&mutex, NULL)) {
855     printf("pthread_mutex_init() failed\n");
856     return 1;
857   }
858   if (pthread_mutex_lock(&mutex)) {
859     printf("pthread_mutex_lock() failed\n");
860     return 1;
861   }
862   if (pthread_mutex_unlock(&mutex)) {
863     printf("pthread_mutex_unlock() failed\n");
864     return 1;
865   }
866   printf("found, OK.\n");
867 }
868 EOF
869   if test_compile $LIBPTHREAD pthread pthread; then
870     if test_execute; then
871       cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
872     fi
873   fi
874 }
875
876
877 #
878 # Check for zlib, needed by VBoxSVC, Runtime, ...
879 #
880 check_z()
881 {
882   test_header zlib
883   cat > .tmp_src.cc << EOF
884 #include <cstdio>
885 #include <zlib.h>
886 extern "C" int main(void)
887 {
888   printf("found version %s", ZLIB_VERSION);
889 #if ZLIB_VERNUM >= 0x1210
890   printf(", OK.\n");
891   return 0;
<