VirtualBox

source: vbox/trunk/configure@ 22817

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

configure-OSX: make it possible to turn some options off; add Cocoa define for the amd64 target

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