VirtualBox

source: vbox/trunk/configure@ 27476

Last change on this file since 27476 was 27449, checked in by vboxsync, 15 years ago

configure: added Xinerama check

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 64.4 KB
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-2009 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 (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
17# Clara, CA 95054 USA or visit http://www.sun.com if you need
18# additional information or have any questions.
19#
20
21LC_ALL=C
22export LC_ALL
23
24# append some extra paths
25PATH="$PATH:/opt/gnome/bin"
26# Solaris (order of paths important for tr, echo, grep, sed to work)
27PATH="/usr/xpg4/bin:/usr/ucb:$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin"
28ORGPATH=$PATH
29
30# Wrapper for ancient /usr/bin/which on darwin that always returns 0
31which_wrapper()
32{
33 if [ -z "$have_ancient_which" ]; then
34 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
35 have_ancient_which="yes"
36 else
37 have_ancient_which="no"
38 fi
39 fi
40 if [ "$have_ancient_which" = "yes" ]; then
41 retval=`which $* 2>/dev/null`
42 echo "$retval"
43 test -n "$retval" -a -x "$retval"
44 unset retval
45 else
46 which $* 2> /dev/null
47 fi
48}
49
50OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr [:upper:] [:lower:]`
51case "$OS" in
52 linux)
53 ;;
54 darwin)
55 ;;
56 freebsd)
57 ;;
58 sunos)
59 OS='solaris'
60 ;;
61 *)
62 echo "Cannot determine OS!"
63 exit 1
64 ;;
65esac
66
67#
68# Defaults
69#
70OSE=1
71ODIR="`pwd`/"
72ODIR_OVERRIDE=0
73OUT_PATH=""
74OUT_PATH_OVERRIDE=0
75SETUP_WINE=
76TARGET_MACHINE=""
77TARGET_CPU=""
78WITH_XPCOM=1
79WITH_PYTHON=1
80WITH_VMMRAW=1
81WITH_LIBIDL=1
82WITH_GSOAP=0
83WITH_QT4=1
84WITH_SDL=1
85WITH_SDL_TTF=1
86WITH_X11=1
87WITH_ALSA=1
88WITH_PULSE=1
89WITH_DBUS=1
90WITH_KMODS=1
91WITH_OPENGL=1
92WITH_HARDENING=1
93BUILD_LIBXML2=
94BUILD_LIBXSLT=
95BUILD_LIBCURL=
96BUILD_LIBSSL=
97PASSIVE_MESA=0
98CC="gcc"
99CC32=""
100CC64=""
101CXX="g++"
102CXX32=""
103CXX64=""
104BCC="bcc"
105YASM="yasm"
106IASL="iasl"
107AS86="as86"
108XSLTPROC="xsltproc"
109GENISOIMAGE="genisoimage"
110MKISOFS="mkisofs"
111INCCRYPTO=""
112LIBCRYPTO="-lcrypto"
113LIBPTHREAD="-lpthread"
114LIBCAP="-lcap"
115GSOAP=""
116GSOAP_IMPORT=""
117INCX11="/usr/local/include"
118LIBX11="-L/usr/X11R6/lib -L/usr/X11R6/lib64 -L/usr/local/lib -lXext -lX11"
119LIBXCURSOR="-lXcursor"
120LIBXMU="-lXmu"
121LIBXINERAMA="-lXinerama"
122MESA="-lGL"
123INCZ=""
124LIBZ="-lz"
125INCPNG=""
126LIBPNG="-lpng"
127CXX_FLAGS=""
128if [ "$OS" = "freebsd" ]; then
129 INCCURL="-I/usr/local/include"
130 LIBCURL="-L/usr/local/lib -lcurl"
131 INCPULSE="-I/usr/local/include"
132 LIBPULSE="-L/usr/local/lib"
133else
134 INCCURL=""
135 LIBCURL="-lcurl"
136fi
137PKGCONFIG="`which_wrapper pkg-config`"
138PYTHONDIR="/usr /usr/local"
139QT4DIR="/usr/lib/qt4 /usr/share/qt4 /usr/lib64/qt4 /usr /usr/local"
140QT4DIR_PKGCONFIG=1
141QT4UIC3DIR="/usr/bin"
142KBUILDDIR="`cd \`dirname $0\`; pwd`/kBuild"
143DEVDIR="`cd \`dirname $0\`; pwd`/tools"
144if [ -d "/lib/modules/`uname -r`/build" ]; then
145 LINUX="/lib/modules/`uname -r`/build"
146else
147 LINUX="/usr/src/linux"
148fi
149KCHMVIEWER="kchmviewer"
150LOG="configure.log"
151CNF="AutoConfig.kmk"
152ENV="env.sh"
153BUILD_TYPE="release"
154# the restricting tool is ar (mri mode).
155INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
156
157if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
158 echo "Error: VBox base path contains invalid characters!"
159 exit 1
160fi
161
162# darwin /bin/sh has a builtin echo that doesn't grok -n. gotta love it.
163if [ "$OS" = "darwin" ]; then
164 ECHO_N="/bin/echo -n"
165else
166 ECHO_N="echo -n"
167fi
168
169
170cleanup()
171{
172 rm -f $ODIR.tmp_src.cc $ODIR.tmp_src.c $ODIR.tmp_out $ODIR.test_execute.log
173}
174
175fail()
176{
177 if [ -z "$nofatal" -o "x$1" != "x" ]; then
178 cleanup
179 rm -f $ENV
180 exit 1
181 fi
182}
183
184log()
185{
186 echo "$1"
187 echo "$1" >> $LOG
188}
189
190log_success()
191{
192 if [ -n "$1" ]; then $ECHO_N "$1, "; fi
193 echo "OK."
194 echo "$1" >> $LOG
195 echo >> $LOG
196 echo >> $LOG
197}
198
199log_failure()
200{
201 echo
202 echo " ** $1!"
203 echo "** $1!" >> $LOG
204 echo >> $LOG
205}
206
207cnf_append()
208{
209 printf "%-30s := %s\n" "$1" "$2" >> $CNF
210}
211
212strip_l()
213{
214 echo "$1"|$KBUILD_SED 's|-l\([^ ]\+\)|\1|g; s|^-[^l][^ ]*||g; s| -[^l][^ ]*||g; s|^ ||; s| *$||g'
215}
216
217strip_L()
218{
219 echo "$1"|$KBUILD_SED 's|-L\([^ ]\+\)|\1|g; s|^-[^L][^ ]*||g; s| -[^L][^ ]*||g; s|^ ||; s| *$||g'
220}
221
222strip_I()
223{
224 echo "$1"|$KBUILD_SED 's|-I\([^ ]\+\)|\1|g; s|^-[^I][^ ]*||g; s| -[^I][^ ]*||g; s|^ ||; s| *$||g'
225}
226
227prefix_I()
228{
229 echo "$1"|$KBUILD_SED 's|^\/|-I/|g; s| \/| -I/|g'
230}
231
232check_avail()
233{
234 if [ -z "$1" ]; then
235 log_failure "$2 is empty"
236 fail $3
237 return 1
238 elif which_wrapper $1 > /dev/null; then
239 return 0
240 else
241 log_failure "$1 (variable $2) not found"
242 fail $3
243 return 1
244 fi
245}
246
247
248# Prepare a test
249test_header()
250{
251 echo "***** Checking $1 *****" >> $LOG
252 $ECHO_N "Checking for $1: "
253}
254
255
256# Compile a test
257# $1 compile flags/libs
258# $2 library name
259# $3 package name
260# $4 if this argument is 'nofatal', don't abort
261test_compile()
262{
263 echo "compiling the following source file:" >> $LOG
264 cat $ODIR.tmp_src.cc >> $LOG
265 echo "using the following command line:" >> $LOG
266 echo "$CXX $CXX_FLAGS -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc \"$1\"" >> $LOG
267 $CXX $CXX_FLAGS -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $1 >> $LOG 2>&1
268 if [ $? -ne 0 ]; then
269 if [ -z "$4" ]; then
270 echo
271 echo " $2 not found at $1 or $3 headers not found"
272 echo " Check the file $LOG for detailed error information."
273 fail
274 else
275 echo >> $LOG
276 echo >> $LOG
277 fi
278 return 1
279 fi
280 return 0
281}
282
283
284# Execute a compiled test binary
285test_execute()
286{
287 echo "executing the binary" >> $LOG
288 $ODIR.tmp_out > $ODIR.test_execute.log
289 rc=$?
290 cat $ODIR.test_execute.log | tee -a $LOG
291 if [ $rc -ne 0 ]; then
292 fail $1
293 return 1
294 fi
295 echo >> $LOG
296 echo >> $LOG
297 return 0
298}
299
300
301# Execute a compiled test binary
302test_execute_path()
303{
304 echo "executing the binary (LD_LIBRARY_PATH=$1)" >> $LOG
305 LD_LIBRARY_PATH=$1 $ODIR.tmp_out > $ODIR.test_execute.log
306 rc=$?
307 cat $ODIR.test_execute.log | tee -a $LOG
308 if [ $rc -ne 0 ]; then
309 fail
310 return 1
311 fi
312 echo >> $LOG
313 echo >> $LOG
314 return 0
315}
316
317
318#
319# Check for OS, MACHINE, CPU
320#
321check_environment()
322{
323 test_header environment
324 BUILD_CPU=`uname -m`
325 [ "$OS" = "solaris" ] && BUILD_CPU=`isainfo | cut -f 1 -d ' '`
326 case "$BUILD_CPU" in
327 i[3456789]86|x86|i86pc)
328 BUILD_MACHINE='x86'
329 LIB='lib'
330 ;;
331 x86_64|amd64)
332 BUILD_MACHINE='amd64'
333 BUILD_CPU='k8'
334 if [ "$OS" != "solaris" ]; then
335 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
336 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
337 LIB='lib64'
338 else
339 # Solaris doesn't seem to subscribe to fhs, libs are usually in
340 # a '64' subdirectory of the standard 'lib' dirs while some 64-bit
341 # alternative binaries can be found in 'amd64' subdirs of the 'bin'
342 # ones. So, in order to find the right stuff (esp. sdl-config) we'll
343 # have to make sure the */bin/amd64 dirs are searched before the */bin
344 # ones. (The sed has some sideeffects, but they shouldn't harm us...)
345 echo "64-bit Solaris detected, hacking the PATH" >> $LOG
346 echo "old PATH: $PATH" >> $LOG
347 PATH=`echo ":$PATH:" | sed -e 's,\(:[^:]*/bin\):,\1/amd64:\1:,g' \
348 -e 's/^:*//' -e 's/:*$//g' -e 's/::*/:/g' `
349 export PATH
350 echo "new PATH: $PATH" >> $LOG
351 LIB='lib/64'
352 fi
353 ;;
354 *)
355 log_failure "Cannot determine system"
356 exit 1
357 ;;
358 esac
359 [ -z "$TARGET_MACHINE" ] && TARGET_MACHINE=$BUILD_MACHINE
360 [ -z "$TARGET_CPU" ] && TARGET_CPU=$BUILD_CPU
361 DEVDIR_BIN="$DEVDIR/$OS.$BUILD_MACHINE/bin"
362 log_success "Determined build machine: $OS.$BUILD_MACHINE, target machine: $OS.$TARGET_MACHINE"
363
364 echo "BUILD_PLATFORM=\"$OS\"" >> $ENV
365 echo "export BUILD_PLATFORM" >> $ENV
366 echo "BUILD_PLATFORM_ARCH=\"$BUILD_MACHINE\"" >> $ENV
367 echo "export BUILD_PLATFORM_ARCH" >> $ENV
368 echo "BUILD_TARGET=\"$OS\"" >> $ENV
369 echo "export BUILD_TARGET" >> $ENV
370 echo "BUILD_TARGET_ARCH=\"$TARGET_MACHINE\"" >> $ENV
371 echo "export BUILD_TARGET_ARCH" >> $ENV
372 echo "BUILD_TARGET_CPU=\"$TARGET_CPU\"" >> $ENV
373 echo "export BUILD_TARGET_CPU" >> $ENV
374 echo "BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
375 echo "export BUILD_TYPE" >> $ENV
376}
377
378#
379# Check for gcc with version >= 3.2.
380# We depend on a working gcc, if we fail terminate in every case.
381#
382check_gcc()
383{
384 test_header gcc
385 if check_avail "$CC" CC really; then
386 cc_ver=`$CC -dumpversion` 2>/dev/null
387 if [ $? -ne 0 ]; then
388 log_failure "cannot execute '$CC -dumpversion'"
389 fail really
390 fi
391 if check_avail "$CXX" CXX really; then
392 cxx_ver=`$CXX -dumpversion` 2>/dev/null
393 if [ $? -ne 0 ]; then
394 log_failure "cannot execute '$CXX -dumpversion'"
395 fail really
396 fi
397 cc_maj=`echo $cc_ver|cut -d. -f1`
398 cc_min=`echo $cc_ver|cut -d. -f2`
399 if [ "x$cc_ver" != "x$cxx_ver" ]; then
400 log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
401 fail really
402 elif [ $cc_maj -eq 4 -a $cc_min -eq 0 -a "$OS" = "darwin" ]; then
403 log_success "found version $cc_ver"
404 # gcc-4.0 is allowed for Darwin only
405 elif [ $cc_maj -lt 3 \
406 -o \( $cc_maj -eq 3 -a $cc_min -lt 2 \) \
407 -o \( $cc_maj -eq 4 -a $cc_min -lt 1 -a "$OS" != "darwin" \) \
408 -o \( $cc_maj -eq 4 -a $cc_min -gt 4 \) \
409 -o $cc_maj -gt 4 ]; then
410 log_failure "gcc version $cc_ver found, expected gcc 3.x with x>1 or gcc 4.x with 0<x<4"
411 fail really
412 else
413 log_success "found version $cc_ver"
414 fi
415 if [ "$BUILD_MACHINE" = "amd64" ]; then
416 [ -z "$CC32" ] && CC32="$CC -m32"
417 [ -z "$CXX32" ] && CXX32="$CXX -m32"
418 else
419 [ -z "$CC32" ] && CC32="$CC"
420 [ -z "$CXX32" ] && CXX32="$CXX"
421 fi
422 if [ "$BUILD_MACHINE" = "x86" -a "$TARGET_MACHINE" = "amd64" ]; then
423 [ -z "$CC64" ] && CC64="$CC -m64"
424 [ -z "$CXX64" ] && CXX64="$CXX -m64"
425 fi
426 if [ "$TARGET_MACHINE" = "amd64" -a $WITH_VMMRAW -eq 0 ]; then
427 CC32="undefined"
428 CXX32="undefined"
429 fi
430 if [ "$CC" != "gcc" ]; then
431 cnf_append "TOOL_GCC3_CC" "$CC"
432 cnf_append "TOOL_GCC3_AS" "$CC"
433 cnf_append "TOOL_GCC3_LD" "$CC"
434 cnf_append "TOOL_GXX3_CC" "$CC"
435 cnf_append "TOOL_GXX3_AS" "$CC"
436 fi
437 if [ "$CXX" != "g++" ]; then
438 cnf_append "TOOL_GCC3_CXX" "$CXX"
439 cnf_append "TOOL_GXX3_CXX" "$CXX"
440 cnf_append "TOOL_GXX3_LD" "$CXX"
441 fi
442 if [ "$CC32" != "gcc -m32" -a "$CC32" != "undefined" ]; then
443 cnf_append "TOOL_GCC32_CC" "$CC32"
444 cnf_append "TOOL_GCC32_AS" "$CC32"
445 cnf_append "TOOL_GCC32_LD" "$CC32"
446 cnf_append "TOOL_GXX32_CC" "$CC32"
447 cnf_append "TOOL_GXX32_AS" "$CC32"
448 fi
449 if [ "$CXX32" != "g++ -m32" -a "$CXX32" != "undefined" ]; then
450 cnf_append "TOOL_GCC32_CXX" "$CXX32"
451 cnf_append "TOOL_GXX32_CXX" "$CXX32"
452 cnf_append "TOOL_GXX32_LD" "$CXX32"
453 fi
454 # this isn't not necessary, there is not such tool.
455 if [ -n "$CC64" ]; then
456 cnf_append "TOOL_GCC64_CC" "$CC64"
457 cnf_append "TOOL_GCC64_AS" "$CC64"
458 cnf_append "TOOL_GCC64_LD" "$CC64"
459 cnf_append "TOOL_GXX64_CC" "$CC64"
460 cnf_append "TOOL_GXX64_AS" "$CC64"
461 fi
462 if [ -n "$CXX64" ]; then
463 cnf_append "TOOL_GCC64_CXX" "$CXX64"
464 cnf_append "TOOL_GXX64_CXX" "$CXX64"
465 cnf_append "TOOL_GXX64_LD" "$CXX64"
466 fi
467 # Solaris sports a 32-bit gcc/g++.
468 if [ "$OS" = "solaris" -a "$BUILD_MACHINE" = "amd64" ]; then
469 [ "$CC" = "gcc" ] && CC="gcc -m64"
470 [ "$CXX" = "g++" ] && CXX="g++ -m64"
471 fi
472 fi
473 fi
474}
475
476
477#
478# Check for the bcc compiler, needed for compiling the BIOS
479#
480check_bcc()
481{
482 test_header bcc
483 if check_avail "$BCC" BCC; then
484 bcc_ver=`$BCC -v 2>&1|grep version|sed 's+^bcc: version \(.*\)+\1+'`
485 if [ $? -ne 0 ]; then
486 log_failure "not found"
487 fail
488 else
489 echo "compiling the following source file:" >> $LOG
490 cat > $ODIR.tmp_src.c << EOF
491int foo(a)
492 int a;
493{
494 return 0;
495}
496EOF
497 cat $ODIR.tmp_src.c >> $LOG
498 bcc_path=`which_wrapper $BCC`
499 bcc_dir="`dirname $bcc_path`/"
500 echo "using the following command line:" >> $LOG
501 echo "$BCC -B $bcc_dir -C-c -3 -S -o $ODIR.tmp_out $ODIR.tmp_src.c" >> $LOG
502 $BCC -B $bcc_dir -C-c -3 -S -o $ODIR.tmp_out $ODIR.tmp_src.c >> $LOG 2>&1
503 if [ $? -ne 0 ]; then
504 log_failure "not found"
505 fail
506 else
507 log_success "found version $bcc_ver"
508 cnf_append "VBOX_BCC" "$bcc_path -B $bcc_dir"
509 fi
510 unset bcc_path
511 unset bcc_dir
512 fi
513 fi
514}
515
516
517#
518# Check for the as86 assembler, needed for compiling the BIOS
519#
520check_as86()
521{
522 test_header as86
523 if check_avail "$AS86" AS86; then
524 as86_ver=`$AS86 -v 2>&1|grep version|sed 's+^as86 version: \(.*\)+\1+'`
525 if [ $? -ne 0 ]; then
526 log_failure "not found"
527 fail
528 else
529 log_success "found version $as86_ver"
530 cnf_append "VBOX_AS86" "`which_wrapper $AS86`"
531 fi
532 fi
533}
534
535
536#
537# Check for yasm, needed to compile assembler files
538#
539check_yasm()
540{
541 test_header yasm
542 if check_avail "$YASM" YASM; then
543 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
544 if [ $? -ne 0 ]; then
545 log_failure "not found"
546 fail
547 else
548 yasm_maj=`echo $yasm_ver|cut -d. -f1`
549 yasm_min=`echo $yasm_ver|cut -d. -f2`
550 yasm_rev=`echo $yasm_ver|cut -d. -f3`
551 yasm_ver_mul=`expr $yasm_maj \* 10000 + $yasm_min \* 100 + $yasm_rev`
552 if [ $yasm_ver_mul -lt 501 ]; then
553 log_failure "found version $yasm_ver, expected at least 0.5.1"
554 fail
555 else
556 log_success "found version $yasm_ver"
557 fi
558 fi
559 fi
560}
561
562
563#
564# Check for the iasl ACPI compiler, needed to compile vbox.dsl
565#
566check_iasl()
567{
568 test_header iasl
569 if check_avail "$IASL" IASL; then
570 iasl_ver=`$IASL|grep version|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
571 if [ $? -ne 0 ]; then
572 log_failure "not found"
573 fail
574 else
575 log_success "found version $iasl_ver"
576 cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
577 fi
578 fi
579}
580
581
582#
583# Check for xsltproc, needed by Main
584#
585check_xsltproc()
586{
587 test_header xslt
588 if check_avail "$XSLTPROC" XSLTPROC; then
589 xsltproc_ver=`$XSLTPROC --version`
590 if [ $? -ne 0 ]; then
591 log_failure "not found"
592 fail
593 else
594 log_success "found"
595 cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
596 fi
597 fi
598}
599
600
601#
602# Check for mkisofs, needed to build the CDROM image containing the additions
603#
604check_mkisofs()
605{
606 test_header mkisofs
607 if which_wrapper $GENISOIMAGE > /dev/null; then
608 mkisofs_ver=`$GENISOIMAGE --version`
609 if [ $? -ne 0 ]; then
610 log_failure "not found"
611 fail
612 else
613 log_success "found $mkisofs_ver"
614 cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
615 fi
616 elif check_avail "$MKISOFS" MKISOFS; then
617 mkisofs_ver=`$MKISOFS --version`
618 if [ $? -ne 0 ]; then
619 log_failure "not found"
620 fail
621 else
622 log_success "found $mkisofs_ver"
623 cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
624 fi
625 fi
626}
627
628
629#
630# Check for libxml2, needed by VBoxSettings and Runtime.
631# 2.6.24 is known to NOT work, 2.6.26 is known to work (there is no 2.6.25 release)
632#
633check_libxml2()
634{
635 if [ -z "$BUILD_LIBXML2" ]; then
636 test_header libxml2
637 if which_wrapper pkg-config > /dev/null; then
638 libxml2_ver=`pkg-config libxml-2.0 --modversion 2>> $LOG`
639 if [ $? -ne 0 ]; then
640 log_failure "not found"
641 fail
642 else
643 FLGXML2=`pkg-config libxml-2.0 --cflags`
644 INCXML2=`strip_I "$FLGXML2"`
645 LIBXML2=`pkg-config libxml-2.0 --libs`
646 cat > $ODIR.tmp_src.cc << EOF
647#include <cstdio>
648#include <libxml/xmlversion.h>
649extern "C" int main(void)
650{
651 printf("found version %s", LIBXML_DOTTED_VERSION);
652#if LIBXML_VERSION >= 20626
653 printf(", OK.\n");
654 return 0;
655#else
656 printf(", expected version 2.6.26 or higher\n");
657 return 1;
658#endif
659}
660EOF
661 [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
662 if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
663 if test_execute; then
664 cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
665 cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
666 fi
667 fi
668 fi
669 elif which_wrapper xml2-config; then
670 libxml2_ver=`xml2-config --version`
671 if [ $? -ne 0 ]; then
672 log_failure "not found"
673 fail
674 else
675 log_success "found version $libxml2_ver"
676 FLGXML2=`xml2-config --cflags`
677 INCXML2=`strip_I "$FLGXML2"`
678 LIBXML2=`xml2-config --libs`
679 cat > $ODIR.tmp_src.cc << EOF
680#include <cstdio>
681#include <libxml/xmlversion.h>
682extern "C" int main(void)
683{
684 printf("found version %s", LIBXML_DOTTED_VERSION);
685#if LIBXML_VERSION >= 20626
686 printf(", OK.\n");
687 return 0;
688#else
689 printf(", expected version 2.6.26 or higher\n");
690 return 1;
691#endif
692}
693EOF
694 [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
695 if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
696 if test_execute; then
697 cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
698 cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
699 fi
700 fi
701 fi
702 else
703 log_failure "neither pkg-config nor xml2-config found"
704 fail
705 fi
706 fi
707}
708
709
710#
711# Check for libxslt, needed by VBoxSettings. For now we depend on 1.1.15,
712# as Solaris right now has no newer version and it definitely works.
713# 1.1.17 is available on Ubuntu Edgy which fulfils the minimal libxml2
714# requirement (2.6.26).
715#
716check_libxslt()
717{
718 if [ -z "$BUILD_LIBXSLT" ]; then
719 test_header libxslt
720 if which_wrapper pkg-config > /dev/null; then
721 libxslt_ver=`pkg-config libxslt --modversion 2>> $LOG`
722 if [ $? -ne 0 ]; then
723 log_failure "not found"
724 fail
725 else
726 FLGXSLT=`pkg-config libxslt --cflags`
727 INCXSLT=`strip_I "$FLGXSLT"`
728 LIBXSLT=`pkg-config libxslt --libs`
729 cat > $ODIR.tmp_src.cc << EOF
730#include <cstdio>
731#include <libxslt/xsltconfig.h>
732extern "C" int main(void)
733{
734 printf("found version %s", LIBXSLT_DOTTED_VERSION);
735#if LIBXSLT_VERSION >= 10117
736 printf(", OK.\n");
737 return 0;
738#else
739 printf(", expected version 1.1.17 or higher\n");
740 return 1;
741#endif
742}
743EOF
744 [ -n "$INCXSLT" ] && I_INCXSLT=`prefix_I "$INCXSLT"`
745 if test_compile "$LIBXSLT $LIBPTHREAD $I_INCXSLT" xslt xslt; then
746 if test_execute; then
747 cnf_append "SDK_VBOX_LIBXSLT_INCS" "$INCXSLT"
748 cnf_append "SDK_VBOX_LIBXSLT_LIBS" "`strip_l "$LIBXSLT"`"
749 fi
750 fi
751 fi
752 elif which_wrapper xslt-config; then
753 libxslt_ver=`xslt-config --version`
754 if [ $? -ne 0 ]; then
755 log_failure "not found"
756 fail
757 else
758 log_success "found version $libxslt_ver"
759 FLGXSLT=`xslt-config --cflags`
760 INCXSLT=`strip_I "$FLGXSLT"`
761 LIBXSLT=`xslt-config --libs`
762 cat > $ODIR.tmp_src.cc << EOF
763#include <cstdio>
764#include <libxslt/xsltconfig.h>
765extern "C" int main(void)
766{
767 printf("found version %s", LIBXSLT_DOTTED_VERSION);
768#if LIBXSLT_VERSION >= 10117
769 printf(", OK.\n");
770 return 0;
771#else
772 printf(", expected version 1.1.17 or higher\n");
773 return 1;
774#endif
775}
776EOF
777 [ -n "$INCXSLT" ] && I_INCXSLT=`prefix_I "$INCXSLT"`
778 if test_compile "$LIBXSLT $LIBPTHREAD $I_INCXSLT" xslt xslt; then
779 if test_execute; then
780 cnf_append "SDK_VBOX_LIBXSLT_INCS" "$INCXSLT"
781 cnf_append "SDK_VBOX_LIBXSLT_LIBS" "`strip_l "$LIBXSLT"`"
782 fi
783 fi
784 fi
785 else
786 log_failure "neither pkg-config nor xslt-config found"
787 fail
788 fi
789 fi
790}
791
792
793#
794# Check for libIDL, needed by xpcom
795#
796check_libidl()
797{
798 test_header libIDL
799
800 if which_wrapper libIDL-config-2 > /dev/null; then
801 libidl_ver=`libIDL-config-2 --version`
802 if [ $? -ne 0 ]; then
803 log_failure "not found"
804 fail
805 else
806 log_success "found version $libidl_ver"
807 cnf_append "VBOX_LIBIDL_CONFIG" \
808 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
809 fi
810 elif check_avail "libIDL-config" libIDL-config; then
811 libidl_ver=`libIDL-config --version`
812 if [ $? -ne 0 ]; then
813 log_failure "not found"
814 fail
815 else
816 log_success "found version $libidl_ver"
817 cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
818 fi
819 fi
820}
821
822
823#
824# Check for openssl, needed for RDP and S3
825#
826check_ssl()
827{
828 if [ -z "$BUILD_LIBSSL" ]; then
829 test_header ssl
830 cat > $ODIR.tmp_src.cc << EOF
831#include <cstdio>
832#include <openssl/opensslv.h>
833extern "C" int main(void)
834{
835 printf("found version %s", OPENSSL_VERSION_TEXT);
836#if OPENSSL_VERSION_NUMBER >= 0x00908000
837 printf(", OK.\n");
838 return 0;
839#else
840 printf(", expected version 0.9.8 or higher\n");
841 return 1;
842#endif
843}
844EOF
845 if test_compile "$INCCRYPTO $LIBCRYPTO" libcrypto openssl; then
846 if test_execute nofatal; then
847 cnf_append "SDK_VBOX_OPENSSL_INCS" "`strip_I "$INCCRYPTO"`"
848 cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
849 fi
850 fi
851 fi
852}
853
854
855#
856# Check for pthread, needed by VBoxSVC, frontends, ...
857#
858check_pthread()
859{
860 test_header pthread
861 cat > $ODIR.tmp_src.cc << EOF
862#include <cstdio>
863#include <pthread.h>
864extern "C" int main(void)
865{
866 pthread_mutex_t mutex;
867 if (pthread_mutex_init(&mutex, NULL)) {
868 printf("pthread_mutex_init() failed\n");
869 return 1;
870 }
871 if (pthread_mutex_lock(&mutex)) {
872 printf("pthread_mutex_lock() failed\n");
873 return 1;
874 }
875 if (pthread_mutex_unlock(&mutex)) {
876 printf("pthread_mutex_unlock() failed\n");
877 return 1;
878 }
879 printf("found, OK.\n");
880}
881EOF
882 if test_compile $LIBPTHREAD pthread pthread; then
883 if test_execute; then
884 cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
885 fi
886 fi
887}
888
889
890#
891# Check for zlib, needed by VBoxSVC, Runtime, ...
892#
893check_z()
894{
895 test_header zlib
896 cat > $ODIR.tmp_src.cc << EOF
897#include <cstdio>
898#include <zlib.h>
899extern "C" int main(void)
900{
901 printf("found version %s", ZLIB_VERSION);
902#if ZLIB_VERNUM >= 0x1210
903 printf(", OK.\n");
904 return 0;
905#else
906 printf(", expected version 1.2.1 or higher\n");
907 return 1;
908#endif
909}
910EOF
911 [ -n "$INCZ" ] && I_INCZ=`prefix_I "$INCZ"`
912 if test_compile "$LIBZ $I_INCZ" zlib zlib; then
913 if test_execute; then
914 echo "if1of (\$(KBUILD_TARGET),darwin freebsd linux solaris)" >> $CNF
915 cnf_append " SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
916 cnf_append " SDK_VBOX_ZLIB_INCS" "$INCZ"
917 echo "endif" >> $CNF
918 fi
919 fi
920}
921
922
923#
924# Check for libpng, needed by kchmviewer
925#
926check_png()
927{
928 test_header libpng
929 cat > $ODIR.tmp_src.cc << EOF
930#include <cstdio>
931#include <png.h>
932extern "C" int main(void)
933{
934 printf("found version %s", PNG_LIBPNG_VER_STRING);
935#if PNG_LIBPNG_VER >= 10205
936 printf(", OK.\n");
937 return 0;
938#else
939 printf(", expected version 1.2.5 or higher\n");
940 return 1;
941#endif
942}
943EOF
944 [ -n "$INCPNG" ] && I_INCPNG=`prefix_I "$INCPNG"`
945 if test_compile "$LIBPNG $I_INCPNG" libpng libpng; then
946 if test_execute; then
947 cnf_append "SDK_VBOX_LIBPNG_LIBS" "`strip_l "$LIBPNG"`"
948 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
949 fi
950 fi
951}
952
953#
954# Check for libcurl, needed by S3
955#
956check_curl()
957{
958 if [ -z "$BUILD_LIBCURL" ]; then
959 test_header libcurl
960 cat > $ODIR.tmp_src.cc << EOF
961#include <cstdio>
962#include <curl/curl.h>
963extern "C" int main(void)
964{
965 printf("found version %s", LIBCURL_VERSION);
966#if 10000*LIBCURL_VERSION_MAJOR + 100*LIBCURL_VERSION_MINOR + LIBCURL_VERSION_PATCH >= 71601
967 printf(", OK.\n");
968 return 0;
969#else
970 printf(", expected version 7.16.1 or higher\n");
971 return 1;
972#endif
973}
974EOF
975 [ -n "$INCCURL" ] && I_INCCURL=`prefix_I "$INCCURL"`
976 if test_compile "$LIBCURL $I_INCCURL" libcurl libcurl; then
977 if test_execute; then
978 cnf_append "SDK_VBOX_LIBCURL_LIBS" "`strip_l "$LIBCURL"`"
979 cnf_append "SDK_VBOX_LIBCURL_INCS" "$INCCURL"
980 fi
981 fi
982 fi
983}
984
985
986#
987# Check for pam, needed by VRDPAuth
988# Version 79 was introduced in 9/2005, do we support older versions?
989# Debian/sarge uses 76
990# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
991#
992check_pam()
993{
994 test_header pam
995 cat > $ODIR.tmp_src.cc << EOF
996#include <cstdio>
997#include <security/pam_appl.h>
998extern "C" int main(void)
999{
1000 printf("found version %d", __LIBPAM_VERSION);
1001 if (__LIBPAM_VERSION >= 76)
1002 {
1003 printf(", OK.\n");
1004 return 0;
1005 }
1006 else
1007 {
1008 printf(", expected version 76 or higher\n");
1009 return 1;
1010 }
1011}
1012EOF
1013 if test_compile "-lpam" pam pam nofatal; then
1014 if test_execute nofatal; then
1015 return 0;
1016 fi
1017 fi
1018 echo "not found."
1019 test_header linux_pam
1020 cat > $ODIR.tmp_src.cc << EOF
1021#include <cstdio>
1022#include <security/pam_appl.h>
1023extern "C" int main(void)
1024{
1025 printf("found version %d.%d", __LINUX_PAM__, __LINUX_PAM_MINOR__);
1026 if (__LINUX_PAM__ >= 1)
1027 {
1028 printf(", OK.\n");
1029 return 0;
1030 }
1031 else
1032 {
1033 printf(", expected version 1.0 or higher\n");
1034 return 1;
1035 }
1036}
1037EOF
1038 if test_compile "-lpam" pam pam; then
1039 test_execute
1040 fi
1041}
1042
1043
1044#
1045# Check for the SDL library, needed by VBoxSDL and VirtualBox
1046# We depend at least on version 1.2.7
1047#
1048check_sdl()
1049{
1050 test_header SDL
1051 if [ "$OS" = "darwin" ]; then
1052 if [ -f "/System/Library/Frameworks/SDL.framework/SDL" ]; then
1053 PATH_SDK_LIBSDL="/System/Library/Frameworks/SDL.framework"
1054 elif [ -f "/Library/Frameworks/SDL.framework/SDL" ]; then
1055 PATH_SDK_LIBSDL="/Library/Frameworks/SDL.framework"
1056 fi
1057 if [ -n "$PATH_SDK_LIBSDL" ]; then
1058 foundsdl=1
1059 INCSDL="$PATH_SDK_LIBSDL/Headers"
1060 FLDSDL="-framework SDL"
1061 else
1062 log_failure "SDL framework not found"
1063 fail
1064 fi
1065 else
1066 if which_wrapper sdl-config > /dev/null; then
1067 FLGSDL=`sdl-config --cflags`
1068 INCSDL=`strip_I "$FLGSDL"`
1069 LIBSDL=`sdl-config --libs`
1070 LIBSDLMAIN="-lSDLmain"
1071 FLDSDL=
1072 foundsdl=1
1073 fi
1074 fi
1075 [ "$OS" = "linux" -o "$OS" = "darwin" -o "$OS" = "solaris" ] && LIBSDLMAIN=""
1076 if [ -n "$foundsdl" ]; then
1077 cat > $ODIR.tmp_src.cc << EOF
1078#include <cstdio>
1079#include <SDL.h>
1080#include <SDL_main.h>
1081#undef main
1082extern "C" int main(int argc, char** argv)
1083{
1084 printf("found version %d.%d.%d",
1085 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
1086#if SDL_VERSION_ATLEAST(1,2,7)
1087 printf(", OK.\n");
1088 return 0;
1089#else
1090 printf(", expected version 1.2.7 or higher\n");
1091 return 1;
1092#endif
1093}
1094EOF
1095 [ -n "$INCSDL" ] && I_INCSDL=`prefix_I "$INCSDL"`
1096 if test_compile "$LIBSDL $LIBSDLMAIN $I_INCSDL $FLDSDL" SDL SDL; then
1097 if test_execute; then
1098 cnf_append "LIB_SDK_LIBSDL_SDL" "`strip_l "$LIBSDL"`"
1099 cnf_append "SDK_LIBSDL_LIBPATH" "`strip_L "$LIBSDL"`"
1100 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
1101 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
1102 [ -n "$FLDSDL" ] && cnf_append "SDK_LIBSDL_LDFLAGS" "$FLDSDL"
1103 fi
1104 fi
1105 else
1106 log_failure "not found"
1107 fail
1108 fi
1109}
1110
1111
1112#
1113# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
1114#
1115check_sdl_ttf()
1116{
1117 test_header SDL_ttf
1118 cat > $ODIR.tmp_src.cc << EOF
1119#include <cstdio>
1120#include <SDL_ttf.h>
1121#ifndef SDL_TTF_MAJOR_VERSION
1122#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
1123#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
1124#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
1125#endif
1126extern "C" int main(void)
1127{
1128 printf("found version %d.%d.%d",
1129 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
1130#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
1131 printf(", OK.\n");
1132 return 0;
1133#else
1134 printf(", expected version 2.0.6 or higher\n");
1135 return 1;
1136#endif
1137}
1138EOF
1139 if test_compile "-lSDL_ttf $I_INCSDL" SDL_ttf SDL_ttf nofatal; then
1140 if ! test_execute nofatal; then
1141 cnf_append "VBOX_WITH_SECURELABEL" ""
1142 fi
1143 else
1144 echo "not found -- disabling VBoxSDL secure label."
1145 cnf_append "VBOX_WITH_SECURELABEL" ""
1146 fi
1147}
1148
1149
1150#
1151# Check for libasound, needed by the ALSA audio backend
1152#
1153check_alsa()
1154{
1155 test_header ALSA
1156 cat > $ODIR.tmp_src.cc << EOF
1157#include <cstdio>
1158#include <alsa/asoundlib.h>
1159extern "C" int main(void)
1160{
1161 printf("found version %d.%d.%d",
1162 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
1163#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
1164 printf(", OK.\n");
1165 return 0;
1166#else
1167 printf(", expected version 1.0.6 or higher\n");
1168 return 1;
1169#endif
1170}
1171EOF
1172 if test_compile "-lasound" asound asound; then
1173 test_execute
1174 fi
1175}
1176
1177
1178#
1179# Check for PulseAudio
1180#
1181check_pulse()
1182{
1183 test_header "PulseAudio"
1184 cat > $ODIR.tmp_src.cc << EOF
1185#include <cstdio>
1186#include <pulse/version.h>
1187extern "C" int main(void)
1188{
1189 printf("found version %s API version %d", pa_get_headers_version(), PA_API_VERSION);
1190#if PA_API_VERSION >= 9
1191 printf(", OK.\n");
1192 return 0;
1193#else
1194 printf(", expected version 0.9.0 (API version 9) or higher\n");
1195 return 1;
1196#endif
1197}
1198EOF
1199 if test_compile "$INCPULSE $LIBPULSE -lpulse" pulse pulse; then
1200 test_execute
1201 fi
1202}
1203
1204
1205#
1206# Check for the X libraries (Xext, X11)
1207#
1208check_x()
1209{
1210 test_header "X libraries"
1211 cat > $ODIR.tmp_src.cc << EOF
1212#include <cstdio>
1213#include <X11/Xlib.h>
1214extern "C" int main(void)
1215{
1216 Display *dpy;
1217 int scrn_num;
1218 Screen *scrn;
1219 Window win;
1220
1221 dpy = XOpenDisplay(NULL);
1222 scrn_num = DefaultScreen(dpy);
1223 scrn = ScreenOfDisplay(dpy, scrn_num);
1224 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
1225 0, 16, InputOutput, CopyFromParent, 0, NULL);
1226 XDestroyWindow(dpy, win);
1227 XCloseDisplay(dpy);
1228}
1229EOF
1230 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1231 if test_compile "$LIBX11 $I_INCX11" Xlibs Xlibs; then
1232 log_success "found"
1233 fi
1234}
1235
1236
1237#
1238# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
1239#
1240check_xcursor()
1241{
1242 test_header Xcursor
1243 cat > $ODIR.tmp_src.cc << EOF
1244#include <cstdio>
1245#include <X11/Xlib.h>
1246#include <X11/Xcursor/Xcursor.h>
1247extern "C" int main(void)
1248{
1249 XcursorImage *cursor = XcursorImageCreate (10, 10);
1250 XcursorImageDestroy(cursor);
1251 return 0;
1252}
1253EOF
1254 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1255 if test_compile "$LIBX11 $LIBXCURSOR $I_INCX11" Xcursor Xcursor; then
1256 log_success "found"
1257 cnf_append "VBOX_XCURSOR_LIBS" "`strip_l "$LIBXCURSOR"`"
1258 fi
1259}
1260
1261
1262#
1263# Check for the Xinerama library, needed by the Qt GUI
1264#
1265check_xinerama()
1266{
1267 test_header Xinerama
1268 cat > $ODIR.tmp_src.cc << EOF
1269#include <X11/Xlib.h>
1270#include <X11/extensions/Xinerama.h>
1271extern "C" int main(void)
1272{
1273 Display *dpy;
1274 Bool flag;
1275 dpy = XOpenDisplay(NULL);
1276 if (dpy)
1277 {
1278 flag = XineramaIsActive(dpy);
1279 XCloseDisplay(dpy);
1280 }
1281}
1282EOF
1283 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1284 if test_compile "$LIBX11 $LIBXINERAMA $I_INCX11" Xinerama Xinerama; then
1285 log_success "found"
1286 fi
1287}
1288
1289
1290#
1291# Check for OpenGL
1292#
1293check_opengl()
1294{
1295 # On darwin this is a on/off decision only
1296 if [ "$OS" = "darwin" ]; then
1297 test_header "OpenGL support"
1298 echo "enabled"
1299 cnf_append "VBOX_WITH_CROGL" "1"
1300 else
1301 check_xmu
1302 check_mesa
1303 fi
1304}
1305
1306
1307#
1308# Check for the Xmu library, needed by OpenGL
1309#
1310check_xmu()
1311{
1312 test_header Xmu
1313 cat > $ODIR.tmp_src.cc << EOF
1314#include <cstdio>
1315#include <X11/Xatom.h>
1316#include <X11/Xlib.h>
1317#include <X11/Xutil.h>
1318#include <X11/Xmu/StdCmap.h>
1319extern "C" int main(void)
1320{
1321 Display *dpy;
1322 int scrn_num;
1323 Screen *scrn;
1324
1325 dpy = XOpenDisplay(NULL);
1326 if (dpy)
1327 {
1328 scrn_num = DefaultScreen(dpy);
1329 scrn = ScreenOfDisplay(dpy, scrn_num);
1330 Status status = XmuLookupStandardColormap(dpy, RootWindowOfScreen(scrn), 0,
1331 24, XA_RGB_DEFAULT_MAP, False, True);
1332 printf("Status = %x\n", status);
1333 XCloseDisplay(dpy);
1334 }
1335 return 0;
1336}
1337EOF
1338 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1339 if test_compile "$LIBX11 $LIBXMU $I_INCX11" Xmu Xmu; then
1340 log_success "found"
1341 cnf_append "VBOX_XMU_LIBS" "`strip_l "$LIBXMU"`"
1342 fi
1343}
1344
1345#
1346# Check for Mesa, needed by OpenGL
1347#
1348check_mesa()
1349{
1350 test_header "Mesa / GLU"
1351 cat > $ODIR.tmp_src.cc << EOF
1352#include <cstdio>
1353#include <X11/Xlib.h>
1354#include <GL/glx.h>
1355#include <GL/glu.h>
1356extern "C" int main(void)
1357{
1358 Display *dpy;
1359 int major, minor;
1360
1361 dpy = XOpenDisplay(NULL);
1362 if (dpy)
1363 {
1364 if (glXQueryVersion(dpy, &major, &minor))
1365 {
1366 printf("found version %u.%u, OK.\n", major, minor);
1367 return 0;
1368 }
1369 XCloseDisplay(dpy);
1370 }
1371 printf("found (inactive), OK.\n");
1372 return 0;
1373}
1374EOF
1375 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1376 if test_compile "$LIBX11 $MESA $I_INCX11" Mesa Mesa; then
1377 [ $PASSIVE_MESA -eq 1 ] && unset DISPLAY
1378 test_execute
1379 fi
1380}
1381
1382
1383#
1384# Check for the Qt4 library, needed by the VirtualBox frontend
1385#
1386# Currently not fatal.
1387#
1388check_qt4()
1389{
1390 foundqt4=
1391 test_header Qt4
1392 if [ "$OS" = "darwin" ]; then
1393 # First check if there is the internal version of Qt. If yes nothing else
1394 # has to be done.
1395 QT_INTERNAL=`/bin/ls -rd1 $PWD/tools/$BUILD_TARGET.$BUILD_PLATFORM_ARCH/qt/* 2> /dev/null`
1396 for t in $QT_INTERNAL; do
1397 if [ -f "$t/Frameworks/QtCoreVBox.framework/QtCoreVBox" ]; then
1398 cnf_append "VBOX_WITH_QT4_SUN" "1"
1399 log_success "use internal version"
1400 return
1401 fi
1402 done
1403 # Now try the user provided directory and some of the standard directories.
1404 QT_TRIES="$QT4DIR /System/Library /Library"
1405 for t in $QT_TRIES; do
1406 if [ -f "$t/Frameworks/QtCore.framework/QtCore" ]; then
1407 PATH_SDK_QT4="$t"
1408 break
1409 fi
1410 done
1411 # Add the necessary params for building the test application
1412 if [ -n "$PATH_SDK_QT4" ]; then
1413 foundqt4=1
1414 INCQT4=-I$PATH_SDK_QT4/Frameworks/QtCore.framework/Headers
1415 LIBQT4=-F$PATH_SDK_QT4/Frameworks
1416 FLGQT4="-framework QtCore"
1417 else
1418 log_failure "Qt4 framework not found (can be disabled using --disable-qt4)"
1419 fail
1420 fi
1421 else
1422 if [ $QT4DIR_PKGCONFIG -eq 1 ]; then
1423 # default is to use pkg-config
1424 if which_wrapper pkg-config > /dev/null; then
1425 # this braindead path is necessary for mdv2008.1
1426 qt4_ver=`\
1427 PKG_CONFIG_PATH=/usr/lib/qt4/lib/pkgconfig \
1428 pkg-config QtCore --modversion 2>> $LOG`
1429 if [ $? -ne 0 ]; then
1430 log_failure "not found"
1431 fail
1432 else
1433 FLGQT4=`\
1434 PKG_CONFIG_PATH=/usr/lib/qt4/lib/pkgconfig \
1435 pkg-config QtCore --cflags`
1436 INCQT4=`strip_I "$FLGQT4"`
1437 LIBQT4=`\
1438 PKG_CONFIG_PATH=/usr/lib/qt4/lib/pkgconfig \
1439 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
1440 pkg-config QtCore --libs`
1441 foundqt4=1
1442 fi
1443 else
1444 log_failure "pkg-config not found"
1445 fail
1446 fi
1447 else
1448 # do it the old way (e.g. user has specified QT4DIR)
1449 cat > $ODIR.tmp_src.cc << EOF
1450#include <cstdio>
1451#include <QtGlobal>
1452extern "C" int main(void)
1453{
1454 printf("found version %s", QT_VERSION_STR);
1455#if QT_VERSION >= 0x040400
1456 printf(", OK.\n");
1457 return 0;
1458#else
1459 printf(", expected version 4.4.0 or higher\n");
1460 return 1;
1461#endif
1462}
1463EOF
1464 for q in $QT4DIR; do
1465 INCQT4="$q/include $q/include/QtCore"
1466 FLGQT4="-DQT_SHARED"
1467 I_INCQT4=`prefix_I "$INCQT4"`
1468 LIBQT4="-L$q/lib -lQtCoreVBox"
1469 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLGQT4" qt4 qt4 nofatal; then
1470 foundqt4=2
1471 break;
1472 fi
1473 LIBQT4="-L$q/lib -lQtCore"
1474 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLGQT4" qt4 qt4 nofatal; then
1475 foundqt4=1
1476 break;
1477 fi
1478 done
1479 fi
1480 fi
1481 if [ -n "$foundqt4" ]; then
1482 cat > $ODIR.tmp_src.cc << EOF
1483#include <cstdio>
1484#include <QtGlobal>
1485extern "C" int main(void)
1486{
1487 printf("found version %s", QT_VERSION_STR);
1488#if QT_VERSION >= 0x040400
1489 printf(", OK.\n");
1490 return 0;
1491#else
1492 printf(", expected version 4.4.0 or higher\n");
1493 return 1;
1494#endif
1495}
1496EOF
1497 [ -n "$INCQT4" ] && I_INCQT4=`prefix_I "$INCQT4"`
1498 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLGQT4" qt4 qt4 nofatal; then
1499 if test_execute_path "`strip_L "$LIBQT4"`"; then
1500 if [ "$OS" = "darwin" ]; then
1501 # Successful build & run the test application so add the necessary
1502 # params to AutoConfig.kmk
1503 cnf_append "PATH_SDK_QT4_INC" "$PATH_SDK_QT4/Frameworks"
1504 cnf_append "PATH_SDK_QT4_LIB" "$PATH_SDK_QT4/Frameworks"
1505 cnf_append "PATH_SDK_QT4" "$PATH_SDK_QT4/Frameworks"
1506 # Check for the moc tool in the Qt directory found & some standard
1507 # directories.
1508 for q in $PATH_SDK_QT4 /usr /Developer/Tools/Qt; do
1509 if which_wrapper "$q/bin/moc" > /dev/null; then
1510 cnf_append "PATH_TOOL_QT4" "$q"
1511 cnf_append "PATH_TOOL_QT4_BIN" "$q/bin"
1512 fi
1513 done
1514 else
1515 # strip .../QtCore as we add components ourself
1516 INCQT4=`echo "$INCQT4"|$KBUILD_SED 's|\([^ ]*\)/QtCore|\1|g; s| $||g'`
1517 # store only the first path, remove all other pathes
1518 # most likely pkg-config gave us -I/usr/include/qt4 -I/usr/include/qt4/QtCore
1519 INCQT4=`echo "$INCQT4"|$KBUILD_SED 's|\([^ ]*\) .*|\1|'`
1520 cnf_append "VBOX_PATH_QT4_LIB" "`strip_L "$LIBQT4"`"
1521 cnf_append "SDK_QT4_LIBPATH" "`strip_L "$LIBQT4"`"
1522 cnf_append "PATH_SDK_QT4_INC" "$INCQT4"
1523 # this is not quite right since the qt libpath does not have to be first...
1524 cnf_append "PATH_SDK_QT4_LIB" '$'"(firstword `strip_L "$LIBQT4"`)"
1525 if [ "$foundqt4" = "2" ]; then
1526 cnf_append "VBOX_WITH_QT4_SUN" "1"
1527 fi
1528 test_header "Qt4 devtools"
1529 for q in $QT4DIR; do
1530 # first try it with a suffix, some platforms use that
1531 if which_wrapper "$q/bin/moc-qt4" > /dev/null; then
1532 moc_ver=`$q/bin/moc-qt4 -v 2>&1|sed 's+^.*(Qt \(.*\))+\1+'`
1533 if [ $? -ne 0 ]; then
1534 log_failure "not found"
1535 fail
1536 else
1537 log_success "found version $moc_ver"
1538 cnf_append "VBOX_PATH_QT4" "$q"
1539 cnf_append "PATH_SDK_QT4" "$q"
1540 cnf_append "PATH_TOOL_QT4" "$q"
1541 cnf_append "PATH_TOOL_QT4_BIN" "$q/bin"
1542 cnf_append "TOOL_QT4_BIN_SUFF" "-qt4"
1543 return
1544 fi
1545 elif which_wrapper "$q/bin/moc" > /dev/null; then
1546 moc_ver=`$q/bin/moc -v 2>&1|sed 's+^.*(Qt \(.*\))+\1+'`
1547 if [ $? -ne 0 ]; then
1548 log_failure "not found"
1549 fail
1550 else
1551 log_success "found version $moc_ver"
1552 cnf_append "VBOX_PATH_QT4" "$q"
1553 cnf_append "PATH_SDK_QT4" "$q"
1554 cnf_append "PATH_TOOL_QT4" "$q"
1555 cnf_append "PATH_TOOL_QT4_BIN" "$q/bin"
1556 return
1557 fi
1558 fi
1559 done
1560 fi
1561 fi
1562 else
1563 log_failure "not found"
1564 fail
1565 fi
1566 else
1567 log_failure "not found"
1568 fail
1569 fi
1570}
1571
1572
1573#
1574# Check whether static libstdc++ is installed. This library is required
1575# for the Linux guest additions.
1576#
1577check_staticlibstdcxx()
1578{
1579 test_header "static stc++ library"
1580 libstdcxx=`$CXX -print-file-name=libstdc++.a`
1581 cat > $ODIR.tmp_src.cc << EOF
1582#include <string>
1583
1584extern "C" int main(void)
1585{
1586 std::string s = "test";
1587 return 0;
1588}
1589EOF
1590 if test_compile "$libstdcxx" libstdc++ libstdc++; then
1591 log_success "found"
1592 fi
1593}
1594
1595
1596#
1597# Check for Linux sources
1598#
1599check_linux()
1600{
1601 test_header "Linux kernel sources"
1602 cat > $ODIR.tmp_src.c << EOF
1603#include <linux/version.h>
1604int printf(const char *format, ...);
1605int main(void)
1606{
1607 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1608 (LINUX_VERSION_CODE % 65536) / 256,
1609 LINUX_VERSION_CODE % 256);
1610#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1611 printf(", OK.\n");
1612 return 0;
1613#else
1614 printf(", expected version 2.4.0 or higher\n");
1615 return 1;
1616#endif
1617}
1618EOF
1619 echo "compiling the following source file:" >> $LOG
1620 cat $ODIR.tmp_src.c >> $LOG
1621 echo "using the following command line:" >> $LOG
1622 echo "$CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
1623 $CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
1624 if [ $? -ne 0 ]; then
1625 echo
1626 echo " Linux kernel headers not found at $LINUX"
1627 echo " Check the file $LOG for detailed error information."
1628 fail
1629 else
1630 if test_execute; then
1631 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1632 fi
1633 fi
1634}
1635
1636
1637#
1638# Check for kchmviewer, needed to display the online help
1639# (unused as we ship kchmviewer)
1640#
1641check_kchmviewer()
1642{
1643 test_header kchmviewer
1644 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1645 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1646 if [ $? -ne 0 ]; then
1647 log_failure "not found"
1648 fail
1649 else
1650 log_success "found version $kchmviewer_ver"
1651 fi
1652 fi
1653}
1654
1655
1656#
1657# Check for the kBuild tools, we don't support GNU make
1658#
1659check_kbuild()
1660{
1661 test_header kBuild
1662 if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
1663 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
1664 echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1665 echo "export PATH_KBUILD" >> $ENV
1666 echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1667 echo "export PATH_DEVTOOLS" >> $ENV
1668 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1669 echo "export PATH_KBUILD_BIN" >> $ENV
1670 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1671 if [ "$OS" = "solaris" ]; then
1672 # Because of sh being non-default shell in Solaris we need to export PATH again when
1673 # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
1674 echo "PATH=\"$ORGPATH\"" >> $ENV
1675 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1676 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1677 else
1678 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1679 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1680 fi
1681 echo "export PATH" >> $ENV
1682 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1683 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1684 elif [ "$OS.$BUILD_MACHINE" = "darwin.amd64" ]; then
1685 # Currently there are no amd64 kBuild bins. So use the x86 variant in any case.
1686 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.x86"
1687 echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1688 echo "export PATH_KBUILD" >> $ENV
1689 echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1690 echo "export PATH_DEVTOOLS" >> $ENV
1691 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.x86\"" >> $ENV
1692 echo "PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1693 echo "export PATH_KBUILD_BIN" >> $ENV
1694 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1695 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1696 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1697 echo "export PATH" >> $ENV
1698 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1699 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1700 elif check_avail "kmk" KBUILDDIR really; then
1701 # check for installed kBuild
1702 KBUILD_SED="`which_wrapper kmk_sed`"
1703 else
1704 fail
1705 fi
1706 log_success "found"
1707}
1708
1709
1710#
1711# Check for compiler.h
1712# Some Linux distributions include "compiler.h" in their libc linux
1713# headers package, some don't. Most don't need it, building might (!)
1714# not succeed on openSUSE without it.
1715#
1716# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1717#
1718check_compiler_h()
1719{
1720 test_header compiler.h
1721 if ! test -f "/usr/include/linux/compiler.h"; then
1722 log_success "compiler.h not found"
1723 else
1724 cnf_append "VBOX_WITH_LINUX_COMPILER_H" "1"
1725 log_success "compiler.h found"
1726 fi
1727}
1728
1729#
1730# Check for libcap.
1731# Required to pass CAP_NET_RAW to our binaries to allow to open SOCK_RAW
1732# sockets for doing ICMP requests.
1733#
1734check_libcap()
1735{
1736 test_header "libcap library"
1737 cat > $ODIR.tmp_src.cc << EOF
1738#include <cstdio>
1739#include <sys/types.h>
1740#include <sys/capability.h>
1741
1742extern "C" int main(void)
1743{
1744 char buf[1024];
1745 cap_t caps = cap_get_proc();
1746 snprintf(buf, sizeof(buf), "Current caps are '%s'\n", cap_to_text(caps, NULL));
1747 return 0;
1748}
1749EOF
1750 if test_compile $LIBCAP libcap libcap; then
1751 if test_execute; then
1752 log_success "found"
1753 fi
1754 fi
1755}
1756
1757#
1758# Check if we are able to build 32-bit applications (needed for the guest additions)
1759#
1760check_32bit()
1761{
1762 test_header "32-bit support"
1763 cat > $ODIR.tmp_src.c << EOF
1764#include <stdint.h>
1765int main(void)
1766{
1767 return 0;
1768}
1769EOF
1770 echo "compiling the following source file:" >> $LOG
1771 cat $ODIR.tmp_src.c >> $LOG
1772 echo "using the following command line:" >> $LOG
1773 echo "$CC -m32 -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c" >> $LOG
1774 $CC -m32 -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c >> $LOG 2>&1
1775 if [ $? -ne 0 ]; then
1776 echo
1777 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1778 echo " Check the file $LOG for detailed error information."
1779 fail
1780 fi
1781 log_success ""
1782}
1783
1784
1785#
1786# Check for Python
1787#
1788check_python()
1789{
1790 test_header "python support"
1791
1792 # On darwin this is a on/off decision only
1793 if [ "$OS" = "darwin" ]; then
1794 echo "enabled"
1795 cnf_append "VBOX_WITH_PYTHON" "1"
1796 return
1797 fi
1798
1799 cat > $ODIR.tmp_src.cc << EOF
1800#include <cstdio>
1801#include <Python.h>
1802extern "C" int main(void)
1803{
1804 Py_Initialize();
1805 printf("found version %s", PY_VERSION);
1806#if PY_VERSION_HEX >= 0x02030000
1807 printf(", OK.\n");
1808 return 0;
1809#else
1810 printf(", expected version 2.3 or higher\n");
1811 return 1;
1812#endif
1813}
1814EOF
1815 found=
1816# For Solaris we use libpython2.4 for compatibility with Solaris 10 and passing IPS pkg audit
1817 if [ "$OS" != "solaris" ]; then
1818 SUPPYTHONLIBS="python2.6 python2.5 python2.4 python2.3"
1819 else
1820 SUPPYTHONLIBS="python2.4"
1821 fi
1822 for p in $PYTHONDIR; do
1823 for d in $SUPPYTHONLIBS; do
1824 for b in lib64 lib/64 lib; do
1825 echo "compiling the following source file:" >> $LOG
1826 cat $ODIR.tmp_src.cc >> $LOG
1827 echo "using the following command line:" >> $LOG
1828 echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so" >> $LOG
1829 $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
1830 if [ $? -eq 0 ]; then
1831 found=1
1832 break
1833 fi
1834 done
1835 if [ -n "$found" ]; then break; fi
1836 done
1837 if [ -n "$found" ]; then break; fi
1838 done
1839 if [ -n "$found" ]; then
1840 if test_execute; then
1841 cnf_append "VBOX_WITH_PYTHON" "1"
1842 cnf_append "VBOX_PATH_PYTHON_INC" "$p/include/$d"
1843 cnf_append "VBOX_LIB_PYTHON" "$p/$b/lib$d.so"
1844 else
1845 log_failure "not found"
1846 fail
1847 fi
1848 else
1849 log_failure "not found"
1850 fail
1851 fi
1852}
1853
1854
1855#
1856# Setup wine
1857#
1858setup_wine()
1859{
1860 test_header "Wine support"
1861 if ! which_wrapper wine > /dev/null; then
1862 echo " wine binary not found"
1863 fail
1864 fi
1865 if ! which_wrapper wineprefixcreate > /dev/null; then
1866 echo " wineprefixcreate not found"
1867 fail
1868 fi
1869 export WINEPREFIX="${ODIR}wine.$BUILD_MACHINE"
1870 echo "WINEPREFIX=\"${ODIR}wine.$BUILD_MACHINE\"" >> $ENV
1871 echo "export WINEPREFIX" >> $ENV
1872 rm -rf $WINEPREFIX
1873 mkdir -p $WINEPREFIX
1874 touch $WINEPREFIX/.no_prelaunch_window_flag
1875 if ! wineprefixcreate -q > /dev/null 2>&1; then
1876 echo " wineprefixcreate failed"
1877 fail
1878 fi
1879 tmp=.tmp.wine.reg
1880 rm -f $tmp
1881 echo 'REGEDIT4' > $tmp
1882 echo '' >> $tmp
1883 echo '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]' >> $tmp
1884 echo "\"PATH\"=\"c:\\\\\\\\windows\\\\\\\\system32;c:\\\\\\\\windows;z:$DEVDIR/win.x86/vcc/v8/bin/Microsoft.VC80.CRT;z:$DEVDIR/win.x86/HTML_Help_Workshop/v1.3\"" >> $tmp
1885 echo '' >> $tmp
1886 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhc.exe\DllOverrides]' >> $tmp
1887 echo '"itss"="native"' >> $tmp
1888 echo '' >> $tmp
1889 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhw.exe\DllOverrides]' >> $tmp
1890 echo '"itss"="native"' >> $tmp
1891 echo '' >> $tmp
1892 if ! wine regedit $tmp > /dev/null 2>&1; then
1893 rm -f $tmp
1894 echo " failed to load registry changes (path)."
1895 fail
1896 fi
1897 rm -f $tmp
1898 log_success "found"
1899}
1900
1901#
1902# Check for gSOAP.
1903#
1904check_gsoap()
1905{
1906 test_header "GSOAP compiler"
1907 if [ -z "$GSOAP" ]; then
1908 GSOAP="/usr"
1909 fi
1910 if which_wrapper "$GSOAP/bin/soapcpp2" > /dev/null; then
1911 if which_wrapper "$GSOAP/bin/wsdl2h" > /dev/null; then
1912 if [ -f "$GSOAP/include/stdsoap2.h" ]; then
1913 # TODO: Check for libgsoap++.a/so
1914
1915 if [ -z "$GSOAP_IMPORT" ]; then
1916 GSOAP_IMPORT="$GSOAP/share/gsoap/import"
1917 if [ ! -d "$GSOAP_IMPORT" -a -d "$GSOAP/include/gsoap" ]; then
1918 GSOAP_IMPORT="$GSOAP/include/gsoap"
1919 fi
1920 fi
1921 if [ -f "$GSOAP_IMPORT/stlvector.h" ]; then
1922 cnf_append "VBOX_GSOAP_INSTALLED" "1"
1923 cnf_append "VBOX_PATH_GSOAP" "$GSOAP"
1924 cnf_append "VBOX_PATH_GSOAP_IMPORT" "$GSOAP_IMPORT"
1925 if [ -f "$GSOAP/share/gsoap/stdsoap2.cpp" ]; then
1926 cnf_append "VBOX_GSOAP_CXX_SOURCES" "$GSOAP/share/gsoap/stdsoap2.cpp"
1927 else
1928 cnf_append "VBOX_GSOAP_CXX_SOURCES" ""
1929 fi
1930 cnf_append "VBOX_GSOAP_CXX_LIBS" "libgsoap++"
1931 log_success "found"
1932 else
1933 log_failure "stlvector.h not found -- disabling webservice"
1934 cnf_append "VBOX_WITH_WEBSERVICES" ""
1935 fi
1936 else
1937 log_failure "stdsoap2.h not found -- disabling webservice"
1938 cnf_append "VBOX_WITH_WEBSERVICES" ""
1939 fi
1940 else
1941 log_failure "wsdl2h not found -- disabling webservice"
1942 cnf_append "VBOX_WITH_WEBSERVICES" ""
1943 fi
1944 else
1945 log_failure "soapcpp2 not found -- disabling webservice"
1946 cnf_append "VBOX_WITH_WEBSERVICES" ""
1947 fi
1948}
1949
1950
1951#
1952# Determines the Darwin version.
1953# @todo This should really check the Xcode/SDK version.
1954#
1955check_darwinversion()
1956{
1957 test_header "Darwin version"
1958 darwin_ver=`uname -r`
1959 case "$darwin_ver" in
1960 10\.*)
1961 darwin_ver="10.6"
1962 sdk=/Developer/SDKs/MacOSX10.5.sdk
1963 CXX_FLAGS="-mmacosx-version-min=10.5 -isysroot $sdk -Wl,-syslibroot,$sdk"
1964# test "$CC" = "gcc" && CC="gcc-4.0"
1965# test "$CXX" = "g++" && CXX="g++-4.0"
1966 cnf_append "VBOX_MACOS_10_5_WORKAROUND" "1"
1967 ;;
1968 9\.*)
1969 darwin_ver="10.5"
1970 sdk=/Developer/SDKs/MacOSX10.5.sdk
1971 CXX_FLAGS="-mmacosx-version-min=10.5 -isysroot $sdk -Wl,-syslibroot,$sdk"
1972# test "$CC" = "gcc" && CC="gcc-4.0"
1973# test "$CXX" = "g++" && CXX="g++-4.0"
1974 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6" "1"
1975 cnf_append "VBOX_MACOS_10_5_WORKAROUND" "1"
1976 ;;
1977 8\.*)
1978 darwin_ver="10.4"
1979 sdk=/Developer/SDKs/MacOSX10.4u.sdk
1980 CXX_FLAGS="-mmacosx-version-min=10.4 -isysroot $sdk -Wl,-syslibroot,$sdk"
1981# test "$CC" = "gcc" && CC="gcc-4.0"
1982# test "$CXX" = "g++" && CXX="g++-4.0"
1983 cnf_append "VBOX_WITH_COCOA_QT" ""
1984 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6" "1"
1985 ;;
1986 *)
1987 echo " failed to determine Darwin version. (uname -r: $darwin_ver)"
1988 fail
1989 darwin_ver="unknown"
1990 ;;
1991 esac
1992 log_success "found version $darwin_ver (SDK: $sdk)"
1993}
1994
1995
1996#
1997# Checks that i386-elf-gcc-3.4.6, i386-elf-gcc-3.4.3, i386-elf-gcc-3.4 or i386-elf-gcc
1998# is around to prevent confusion when the build fails in src/recompiler.
1999# Note. Keep the which order in sync with the $(which ) in src/recompiler/Makefile.kmk.
2000#
2001check_i386elfgcc()
2002{
2003 test_header "i386-elf-gcc"
2004 i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.6`
2005 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.3`
2006 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4`
2007 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc`
2008 if test -z "$i386_elf_gcc"; then
2009 echo " failed to find i386-elf-gcc"
2010 fail
2011 fi
2012 log_success "found $i386_elf_gcc"
2013}
2014
2015
2016#
2017# Show help
2018#
2019show_help()
2020{
2021cat << EOF
2022Usage: ./configure [OPTIONS]...
2023
2024Configuration:
2025 -h, --help display this help and exit
2026 --nofatal don't abort on errors
2027EOF
2028[ $WITH_XPCOM -eq 1 ] && echo " --disable-xpcom disable XPCOM and related stuff"
2029[ $WITH_PYTHON -eq 1 ] && echo " --disable-python disable python bindings"
2030[ $WITH_VMMRAW -eq 1 ] && echo " --disable-vmmraw disable VMM raw mode (VT-x/AMD-V mandatory!)"
2031[ $WITH_SDL_TTF -eq 1 ] && echo " --disable-sdl-ttf disable SDL_ttf detection"
2032[ $WITH_ALSA -eq 1 ] && echo " --disable-alsa disable the ALSA sound backend"
2033[ $WITH_PULSE -eq 1 ] && echo " --disable-pulse disable the PulseAudio backend"
2034[ $WITH_DBUS -eq 1 ] && echo " --disable-dbus don't use DBus and hal for hardware detection"
2035[ $WITH_KMODS -eq 1 ] && echo " --disable-kmods don't build Linux kernel modules (host and guest)"
2036[ $WITH_OPENGL -eq 1 ] && echo " --disable-opengl disable OpenGL support"
2037[ $WITH_GSOAP -eq 0 ] && echo " --enable-webservice enable the webservice stuff"
2038cat << EOF
2039 --disable-hardening don't be strict about /dev/vboxdrv access
2040 --build-libxml2 build libxml2 from sources
2041 --build-libxslt build libxslt from sources
2042 --build-libssl build openssl from sources (PUEL only)
2043 --build-libcurl build libcurl from sources (PUEL only)
2044EOF
2045[ "$OS" != "darwin" ] && echo " --setup-wine setup a Wine directory and register the hhc hack"
2046cat << EOF
2047
2048Paths:
2049 --with-gcc=PATH location of the gcc compiler [$CC]
2050 --with-g++=PATH location of the g++ compiler [$CXX]
2051 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
2052 --with-iasl=PATH location of the iasl compiler [$IASL]
2053 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
2054EOF
2055[ "$OS" = "linux" ] && echo " --with-linux=DIR Linux kernel source directory [$LINUX]"
2056[ $WITH_QT4 -eq 1 ] && echo " --with-qt-dir=DIR directory for Qt4 headers/libraries [pkgconfig]"
2057[ $WITH_GSOAP -eq 1 ] && echo " --with-gsoap-dir=PATH directory for gSOAP compiler/headers/libraries"
2058[ $WITH_GSOAP -eq 1 ] && echo " (soapcpp2 and wsdl2h, soapstd2.h, libgsoap++.a/so)"
2059[ $WITH_GSOAP -eq 1 ] && echo " --with-gsoap-import=PATH directory for gSOAP import files (stlvector.h)"
2060cat << EOF
2061 --with-openssl-dir=DIR directory for OpenSSL headers/libraries
2062 --out-path=PATH the folder to which configuration and build output
2063 should go
2064
2065Build type:
2066 -d, --build-debug build with debugging symbols and assertions
2067 --build-profile build with profiling support
2068 --build-headless build headless (without any GUI frontend)
2069EOF
2070 exit 0
2071}
2072
2073
2074#
2075# The body.
2076#
2077
2078# test if we are OSE
2079if [ $OSE -eq 1 -a -r "`cd \`dirname $0\`; pwd`/src/VBox/Devices/USB/USBProxyDevice.cpp" ]; then
2080 OSE=0
2081 # Set this as a reminder to print a log message once we know the path of the
2082 # log file
2083 NOT_OSE=1
2084fi
2085
2086# Change OS specific defaults; must be before all other stuff
2087if [ "$OS" = "darwin" ]; then
2088 WITH_SDL=0
2089 WITH_SDL_TTF=0
2090 WITH_X11=0
2091 WITH_ALSA=0
2092 WITH_PULSE=0
2093 WITH_DBUS=0
2094 WITH_KMODS=0
2095 BUILD_LIBXSLT=1
2096 BUILD_LIBXML2=1
2097 [ $OSE -eq 1 ] || BUILD_LIBCURL=1
2098 [ $OSE -eq 1 ] || BUILD_LIBSSL=1
2099fi
2100
2101
2102# scan command line options
2103for option in $*; do
2104 case "$option" in
2105 --help|-help|-h)
2106 show_help
2107 ;;
2108 --nofatal)
2109 nofatal=1
2110 ;;
2111 --env-only)
2112 ENV_ONLY=1
2113 ;;
2114 --with-gcc=*)
2115 CC=`echo $option | cut -d'=' -f2`
2116 ;;
2117 --with-g++=*)
2118 CXX=`echo $option | cut -d'=' -f2`
2119 ;;
2120 --with-kbuild=*)
2121 KBUILDDIR=`echo $option | cut -d'=' -f2`
2122 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
2123 echo "Error: KBUILDDIR contains invalid characters!"
2124 exit 1
2125 fi
2126 ;;
2127 --with-qt-dir=*|--with-qt4-dir=*)
2128 QT4DIR=`echo $option | cut -d'=' -f2`
2129 QT4DIR_PKGCONFIG=0
2130 ;;
2131 --with-openssl-dir=*)
2132 OPENSSLDIR=`echo $option | cut -d'=' -f2`
2133 INCCRYPTO="-I${OPENSSLDIR}/include"
2134 LIBCRYPTO="${OPENSSLDIR}/lib/libcrypto.a"
2135 ;;
2136 --with-gsoap-dir=*)
2137 GSOAP=`echo $option | cut -d'=' -f2`
2138 ;;
2139 --with-gsoap-import=*)
2140 GSOAP_IMPORT=`echo $option | cut -d'=' -f2`
2141 ;;
2142 --with-iasl=*)
2143 IASL=`echo $option | cut -d'=' -f2`
2144 ;;
2145 --with-linux=*)
2146 LINUX=`echo $option | cut -d'=' -f2`
2147 ;;
2148 --with-mkisofs=*)
2149 MKISOFS=`echo $option | cut -d'=' -f2`
2150 ;;
2151 --target-arch=*)
2152 TARGET_MACHINE=`echo $option | cut -d'=' -f2`
2153 ;;
2154 --disable-xpcom)
2155 [ $WITH_XPCOM -eq 1 ] && WITH_XPCOM=0
2156 ;;
2157 --disable-python)
2158 [ $WITH_PYTHON -eq 1 ] && WITH_PYTHON=0
2159 ;;
2160 --disable-vmmraw)
2161 [ $WITH_VMMRAW -eq 1 ] && WITH_VMMRAW=0
2162 ;;
2163 --disable-sdl-ttf)
2164 [ $WITH_SDL_TTF -eq 1 ] && WITH_SDL_TTF=0
2165 ;;
2166 --disable-qt)
2167 [ $WITH_QT4 -eq 1 ] && WITH_QT4=0
2168 ;;
2169 --disable-qt4)
2170 [ $WITH_QT4 -eq 1 ] && WITH_QT4=0
2171 ;;
2172 --passive-mesa)
2173 PASSIVE_MESA=1
2174 ;;
2175 --disable-alsa)
2176 [ $WITH_ALSA -eq 1 ] && WITH_ALSA=0
2177 ;;
2178 --disable-pulse)
2179 [ $WITH_PULSE -eq 1 ] && WITH_PULSE=0
2180 ;;
2181 --enable-pulse)
2182 WITH_PULSE=2
2183 ;;
2184 --disable-dbus)
2185 [ $WITH_DBUS -eq 1 ] && WITH_DBUS=0
2186 ;;
2187 --disable-kmods)
2188 [ $WITH_KMODS -eq 1 ] && WITH_KMODS=0
2189 ;;
2190 --disable-opengl)
2191 [ $WITH_OPENGL -eq 1 ] && WITH_OPENGL=0
2192 ;;
2193 --enable-webservice)
2194 [ $WITH_GSOAP -eq 0 ] && WITH_GSOAP=1
2195 ;;
2196 --disable-hardening)
2197 WITH_HARDENING=0
2198 ;;
2199 --enable-hardening)
2200 WITH_HARDENING=2
2201 ;;
2202 --build-debug|-d)
2203 BUILD_TYPE=debug
2204 ;;
2205 --build-profile)
2206 BUILD_TYPE=profile
2207 ;;
2208 --build-libxml2)
2209 BUILD_LIBXML2=1
2210 ;;
2211 --build-libxslt)
2212 BUILD_LIBXSLT=1
2213 ;;
2214 --build-libssl)
2215 BUILD_LIBSSL=1
2216 ;;
2217 --build-libcurl)
2218 BUILD_LIBCURL=1
2219 ;;
2220 --build-headless)
2221 HEADLESS=1
2222 WITH_SDL=0
2223 WITH_SDL_TTF=0
2224 WITH_X11=0
2225 WITH_OPENGL=0
2226 WITH_QT4=0
2227 ;;
2228 --ose)
2229 OSE=2
2230 ;;
2231 --odir=*)
2232 ODIR="`echo $option | cut -d'=' -f2`/"
2233 ODIR_OVERRIDE=1
2234 ;;
2235 --out-path=*)
2236 out_path="`echo $option | cut -d'=' -f2`/"
2237 if [ -d $out_path ]; then
2238 saved_path="`pwd`"
2239 cd $out_path
2240 OUT_PATH="`pwd`"
2241 cd $saved_path
2242 OUT_PATH_OVERRIDE=1
2243 if [ $ODIR_OVERRIDE -eq 0 ]; then
2244 # This variable has not *yet* been overridden. That can still happen.
2245 ODIR=$OUT_PATH/
2246 fi
2247 else
2248 echo "Error: invalid folder \"$out_path\" in option \"$option\""
2249 exit 1
2250 fi
2251 ;;
2252 --setup-wine)
2253 [ "$OS" != "darwin" ] && SETUP_WINE=1
2254 ;;
2255 *)
2256 echo
2257 echo "Unrecognized option \"$option\""
2258 echo
2259 show_help
2260 ;;
2261 esac
2262done
2263
2264LOG="$ODIR$LOG"
2265ENV="$ODIR$ENV"
2266CNF="$ODIR$CNF"
2267
2268# Print log warning about OSE if necessary
2269if [ -n "$NOT_OSE" ]; then
2270 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
2271 echo >> $LOG
2272fi
2273
2274# initialize output files
2275cat > $LOG << EOF
2276# Log file generated by
2277#
2278# '$0 $*'
2279#
2280
2281EOF
2282cat > $CNF << EOF
2283# -*- Makefile -*-
2284#
2285# automatically generated by
2286#
2287# '$0 $*'
2288#
2289# It will be completely overwritten if configure is executed again.
2290#
2291
2292EOF
2293cat > $ENV << EOF
2294#!/bin/bash
2295#
2296# automatically generated by
2297#
2298# '$0 $*'
2299#
2300# It will be completely overwritten if configure is executed again.
2301# Make sure you source this file once before you start to build VBox.
2302#
2303
2304EOF
2305
2306if [ "$BUILD_TYPE" = "debug" ]; then
2307 echo "Creating DEBUG build!" >> $LOG
2308elif [ "$BUILD_TYPE" = "profile" ]; then
2309 echo "Creating PROFILE build!" >> $LOG
2310fi
2311
2312# first determine our environment
2313check_environment
2314check_kbuild
2315
2316[ -n "$ENV_ONLY" ] && exit 0
2317
2318# append the tools directory to the default search path
2319echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
2320export PATH
2321
2322# if we will be writing to a different out directory then set this up now
2323if [ $OUT_PATH_OVERRIDE -eq 1 ]; then
2324 echo "AUTOCFG=$OUT_PATH/AutoConfig.kmk" >> $ENV
2325 echo "export AUTOCFG" >> $ENV
2326 echo "LOCALCFG=$OUT_PATH/LocalConfig.kmk" >> $ENV
2327 echo "export LOCALCFG" >> $ENV
2328 echo "PATH_OUT_BASE=$OUT_PATH" >> $ENV
2329 echo "export PATH_OUT_BASE" >> $ENV
2330fi
2331
2332# some things are not available in for OSE
2333if [ $OSE -ge 1 ]; then
2334 cnf_append "VBOX_OSE" "1"
2335 cnf_append "VBOX_WITH_TESTSUITE" ""
2336 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
2337
2338 if [ "$OS" = "linux" ]; then
2339 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
2340 else
2341 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
2342 fi
2343 echo >> $CNF
2344fi
2345
2346# headless
2347if [ -n "$HEADLESS" ]; then
2348 cnf_append "VBOX_HEADLESS" "1"
2349fi
2350
2351# emit disable directives corresponding to any --disable-xxx options.
2352[ $WITH_OPENGL -eq 0 ] && cnf_append "VBOX_WITH_CROGL" ""
2353[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
2354[ $WITH_QT4 -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
2355[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
2356[ $WITH_PYTHON -eq 0 ] && cnf_append "VBOX_WITH_PYTHON" ""
2357[ $WITH_HARDENING -eq 0 ] && cnf_append "VBOX_WITHOUT_HARDENING" "1"
2358[ $WITH_HARDENING -eq 2 ] && cnf_append "VBOX_WITH_HARDENING" "2"
2359[ $WITH_VMMRAW -eq 0 ] && cnf_append "VBOX_WITH_RAW_MODE" ""
2360
2361# Darwin-specific
2362if [ "$OS" = "darwin" ]; then
2363 check_darwinversion
2364fi
2365# the tools
2366check_gcc
2367[ "$OS" != "darwin" ] && check_as86
2368[ "$OS" != "darwin" ] && check_bcc
2369[ "$OS" != "darwin" ] && check_iasl
2370# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
2371# [ "$OS" != "darwin" ] && check_yasm
2372[ "$OS" != "darwin" ] && check_xsltproc
2373[ $OSE -eq 0 -a "$OS" != "darwin" ] && check_mkisofs
2374
2375# the libraries
2376[ "$OS" != "darwin" ] && check_pthread
2377check_libxml2
2378[ $WITH_XPCOM -eq 1 ] && check_libxslt
2379[ $WITH_LIBIDL -eq 1 ] && check_libidl
2380check_ssl
2381check_curl
2382[ "$OS" != "darwin" ] && check_z
2383[ "$OS" != "darwin" -a "$OS" != "freebsd" ] && check_png
2384[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
2385[ $WITH_SDL -eq 1 ] && check_sdl
2386[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
2387[ $WITH_X11 -eq 1 ] && check_x
2388# TODO check for xcomposite-dev (X11/extensions/Xcomposite.h, additions only)
2389# TODO check for libxdamange-dev (X11/extensions/Xdamage.h, additions only)
2390[ $WITH_X11 -eq 1 ] && check_xcursor
2391[ $WITH_X11 -eq 1 ] && check_xinerama
2392[ $WITH_OPENGL -eq 1 ] && check_opengl
2393[ $WITH_QT4 -eq 1 ] && check_qt4
2394[ $WITH_PYTHON -eq 1 ] && check_python
2395
2396# PulseAudio
2397if [ "$OS" = "linux" -o "$OS" = "freebsd" ]; then
2398 if [ $WITH_PULSE -eq 1 ]; then
2399 check_pulse
2400 elif [ $WITH_PULSE -eq 0 ]; then
2401 cnf_append "VBOX_WITH_PULSE" ""
2402 fi
2403fi
2404
2405# Linux-specific
2406if [ "$OS" = "linux" ]; then
2407 # don't check for the static libstdc++ in the PUEL version as we build the
2408 # additions at a dedicated box
2409 [ $OSE -ge 1 ] && check_staticlibstdcxx
2410 if [ $WITH_KMODS -eq 1 ]; then
2411 check_linux
2412 else
2413 cnf_append "VBOX_LINUX_SRC" ""
2414 cnf_append "VBOX_WITH_VBOXDRV" ""
2415 cnf_append "VBOX_WITH_ADDITION_DRIVERS" ""
2416 fi
2417 if [ $WITH_ALSA -eq 1 ]; then
2418 check_alsa
2419 else
2420 cnf_append "VBOX_WITH_ALSA" ""
2421 fi
2422 if [ $WITH_DBUS -eq 0 ]; then
2423 cnf_append "VBOX_WITH_DBUS" ""
2424 fi
2425 check_libcap
2426 check_compiler_h
2427 [ "$BUILD_MACHINE" = "amd64" -a $WITH_VMMRAW -eq 1 ] && check_32bit
2428fi
2429
2430[ -n "$SETUP_WINE" ] && setup_wine
2431
2432if [ $OSE -ge 1 ]; then
2433 if [ $WITH_GSOAP -eq 1 ]; then
2434 check_gsoap
2435 else
2436 cnf_append "VBOX_WITH_WEBSERVICES" ""
2437 fi
2438fi
2439
2440# success!
2441echo
2442echo "Successfully generated '$CNF' and '$ENV'."
2443echo "Source '$ENV' once before you start to build VBox:"
2444echo ""
2445echo " source $ENV"
2446echo " kmk"
2447echo ""
2448if [ "$OS" = "linux" ]; then
2449 if [ $OUT_PATH_OVERRIDE -eq 1 ]; then
2450 vbox_out_path=$OUT_PATH
2451 else
2452 vbox_out_path=./out
2453 fi
2454 echo "To compile the kernel modules, do:"
2455 echo ""
2456 echo " cd $vbox_out_path/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
2457 echo " make"
2458 echo ""
2459fi
2460if [ $WITH_HARDENING -gt 0 ]; then
2461 echo ""
2462 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2463 echo " Hardening is enabled which means that the VBox binaries will not run from"
2464 echo " the binary directory. The binaries have to be installed suid root and some"
2465 echo " more prerequisites have to be fulfilled which is normally done by installing"
2466 echo " the final package. For development, the hardening feature can be disabled"
2467 echo " by specifying the --disable-hardening parameter. Please never disable that"
2468 echo " feature for the final distribution!"
2469 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2470 echo ""
2471else
2472 echo ""
2473 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2474 echo " Hardening is disabled. Please do NOT build packages for distribution with"
2475 echo " disabled hardening!"
2476 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2477 echo ""
2478fi
2479echo "Enjoy!"
2480cleanup
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette