VirtualBox

source: vbox/trunk/configure@ 22633

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

configure: removed gcc-4.4 warning

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