VirtualBox

source: vbox/trunk/configure@ 23291

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

configure: depend on Qt >= 4.4.0

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