VirtualBox

source: vbox/trunk/configure@ 23473

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

OSE header fixes

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