VirtualBox

source: vbox/trunk/configure@ 26687

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

configure: make env.sh sh-compatible

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