VirtualBox

source: vbox/trunk/configure@ 26696

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

configure: typo

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