VirtualBox

source: vbox/trunk/configure@ 9936

Last change on this file since 9936 was 9936, checked in by vboxsync, 16 years ago

configure: allow to specify a recompiler gcc in general

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 48.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-2007 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#
27# Defaults
28#
29OSE=1
30ODIR="`pwd`/"
31SETUP_WINE=
32TARGET_MACHINE=""
33TARGET_CPU=""
34WITH_XPCOM=1
35WITH_LIBIDL=1
36WITH_QT=1
37WITH_QT4=1
38WITH_SDL=1
39WITH_SDL_TTF=1
40WITH_X11=1
41WITH_ALSA=1
42WITH_PULSE=1
43WITH_KMODS=1
44CC="gcc"
45CC_COMPAT=""
46CC32=""
47CC64=""
48CXX="g++"
49CXX32=""
50CXX64=""
51BCC="bcc"
52YASM="yasm"
53IASL="iasl"
54AS86="as86"
55XSLTPROC="xsltproc"
56GENISOIMAGE="genisoimage"
57MKISOFS="mkisofs"
58BUILD_LIBXML2=
59BUILD_LIBXSLT=
60LIBCRYPTO="-lcrypto"
61LIBPTHREAD="-lpthread"
62LIBX11="-L/usr/X11R6/lib -L/usr/X11R6/lib64 -L/usr/local/lib -lXext -lX11"
63INCX11="/usr/local/include"
64LIBXCURSOR="-lXcursor"
65INCZ=""
66LIBZ="-lz"
67INCPNG=""
68LIBPNG="-lpng"
69QT3DIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3 /usr/lib64/qt-3.3 /usr/X11R6 /usr/lib/qt"
70QT4DIR="/usr/lib/qt4 /usr/share/qt4 /usr"
71QT4DIR_PKGCONFIG=1
72QT4UIC3DIR="/usr/bin"
73KBUILDDIR="`cd \`dirname $0\`; pwd`/kBuild"
74DEVDIR="`cd \`dirname $0\`; pwd`/tools"
75if [ -d "/lib/modules/`uname -r`/build" ]; then
76 LINUX="/lib/modules/`uname -r`/build"
77else
78 LINUX="/usr/src/linux"
79fi
80KCHMVIEWER="kchmviewer"
81LOG="configure.log"
82CNF="AutoConfig.kmk"
83ENV="env.sh"
84BUILD_TYPE="release"
85# the restricting tool is ar (mri mode).
86INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
87
88if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
89 echo "Error: VBox base path contains invalid characters!"
90 exit 1
91fi
92
93# darwin /bin/sh has a builtin echo that doesn't grok -n. gotta love it.
94if [ "`uname`" = "Darwin" ]; then
95 ECHO_N="/bin/echo -n"
96else
97 ECHO_N="echo -n"
98fi
99
100
101cleanup()
102{
103 rm -f .tmp_src.cc .tmp_src.c .tmp_out .test_execute.log
104}
105
106fail()
107{
108 if [ -z "$nofatal" -o "x$1" != "x" ]; then
109 cleanup
110 rm -f $ENV
111 exit 1
112 fi
113}
114
115log()
116{
117 echo "$1"
118 echo "$1" >> $LOG
119}
120
121log_success()
122{
123 if [ -n "$1" ]; then $ECHO_N "$1, "; fi
124 echo "OK."
125 echo "$1" >> $LOG
126 echo >> $LOG
127 echo >> $LOG
128}
129
130log_failure()
131{
132 echo
133 echo " ** $1!"
134 echo "** $1!" >> $LOG
135 echo >> $LOG
136}
137
138cnf_append()
139{
140 printf "%-30s := %s\n" "$1" "$2" >> $CNF
141}
142
143strip_l()
144{
145 echo "$1"|$KBUILD_SED 's|-l\([^ ]\+\)|\1|g; s|-[^l]\([^ ]\+\)||g; s|^ ||; s| *$||g'
146}
147
148strip_L()
149{
150 echo "$1"|$KBUILD_SED 's|-L\([^ ]\+\)|\1|g; s|-[^L]\([^ ]\+\)||g; s|^ ||; s| *$||g'
151}
152
153strip_I()
154{
155 echo "$1"|$KBUILD_SED 's|-I\([^ ]\+\)|\1|g; s|-[^I]\([^ ]\+\)||g; s|^ ||; s| *$||g'
156}
157
158prefix_I()
159{
160 echo "$1"|$KBUILD_SED 's|^\/|-I/|g; s| \/| -I/|g'
161}
162
163# Wrapper for ancient /usr/bin/which on darwin that always returns 0
164which_wrapper()
165{
166 if [ -z "$have_ancient_which" ]; then
167 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
168 have_ancient_which="yes"
169 else
170 have_ancient_which="no"
171 fi
172 fi
173 if [ "$have_ancient_which" = "yes" ]; then
174 retval=`which $* 2>/dev/null`
175 echo "$retval"
176 test -n "$retval" -a -x "$retval"
177 unset retval
178 else
179 which $* 2> /dev/null
180 fi
181}
182
183check_avail()
184{
185 if [ -z "$1" ]; then
186 log_failure "$2 is empty"
187 fail $3
188 return 1
189 elif which_wrapper $1 > /dev/null; then
190 return 0
191 else
192 log_failure "$1 (variable $2) not found"
193 fail $3
194 return 1
195 fi
196}
197
198# Prepare a test
199test_header()
200{
201 echo "***** Checking $1 *****" >> $LOG
202 $ECHO_N "Checking for $1: "
203}
204
205# Compile a test
206test_compile()
207{
208 echo "compiling the following source file:" >> $LOG
209 cat .tmp_src.cc >> $LOG
210 echo "using the following command line:" >> $LOG
211 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
212 $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
213 if [ $? -ne 0 ]; then
214 if [ -z "$4" ]; then
215 echo
216 echo " $2 not found at $1 or $3 headers not found"
217 echo " Check the file $LOG for detailed error information."
218 fail
219 else
220 echo "not found."
221 echo >> $LOG
222 echo >> $LOG
223 fi
224 return 1
225 fi
226 return 0
227}
228
229# Execute a compiled test binary
230test_execute()
231{
232 echo "executing the binary" >> $LOG
233 ./.tmp_out > .test_execute.log
234 rc=$?
235 cat .test_execute.log | tee -a $LOG
236 if [ $rc -ne 0 ]; then
237 fail $1
238 return 1
239 fi
240 echo >> $LOG
241 echo >> $LOG
242 return 0
243}
244
245#
246# Check for OS, MACHINE, CPU
247#
248check_environment()
249{
250 test_header environment
251 OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr [:upper:] [:lower:]`
252 case "$OS" in
253 linux)
254 ;;
255 darwin)
256 ;;
257 freebsd)
258 ;;
259 sunos)
260 OS='solaris'
261 ;;
262 *)
263 log_failure "Cannot determine OS"
264 exit 1
265 ;;
266 esac
267 BUILD_CPU=`uname -m`
268 [ "$OS" = "solaris" ] && BUILD_CPU=`isainfo | cut -f 1 -d ' '`
269 case "$BUILD_CPU" in
270 i[3456789]86|x86|i86pc)
271 BUILD_MACHINE='x86'
272 LIB='lib'
273 ;;
274 x86_64|amd64)
275 BUILD_MACHINE='amd64'
276 BUILD_CPU='k8'
277 if [ "$OS" != "solaris" ]; then
278 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
279 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
280 LIB='lib64'
281 else
282 # Solaris doesn't seem to subscribe to fhs, libs are usually in
283 # a '64' subdirectory of the standard 'lib' dirs while some 64-bit
284 # alternative binaries can be found in 'amd64' subdirs of the 'bin'
285 # ones. So, in order to find the right stuff (esp. sdl-config) we'll
286 # have to make sure the */bin/amd64 dirs are searched before the */bin
287 # ones. (The sed has some sideeffects, but they shouldn't harm us...)
288 echo "64-bit Solaris detected, hacking the PATH" >> $LOG
289 echo "old PATH: $PATH" >> $LOG
290 PATH=`echo ":$PATH:" | sed -e 's,\(:[^:]*/bin\):,\1/amd64:\1:,g' \
291 -e 's/^:*//' -e 's/:*$//g' -e 's/::*/:/g' `
292 export PATH
293 echo "new PATH: $PATH" >> $LOG
294 LIB='lib/64'
295 fi
296 ;;
297 *)
298 log_failure "Cannot determine system"
299 exit 1
300 ;;
301 esac
302 [ -z "$TARGET_MACHINE" ] && TARGET_MACHINE=$BUILD_MACHINE
303 [ -z "$TARGET_CPU" ] && TARGET_CPU=$BUILD_CPU
304 DEVDIR_BIN="$DEVDIR/$OS.$BUILD_MACHINE/bin"
305 log_success "Determined build machine: $OS.$BUILD_MACHINE, target machine: $OS.$TARGET_MACHINE"
306
307 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
308 echo "export BUILD_PLATFORM_ARCH=\"$BUILD_MACHINE\"" >> $ENV
309 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
310 echo "export BUILD_TARGET_ARCH=\"$TARGET_MACHINE\"" >> $ENV
311 echo "export BUILD_TARGET_CPU=\"$TARGET_CPU\"" >> $ENV
312 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
313}
314
315#
316# Check for gcc with version >= 3.2.
317# We depend on a working gcc, if we fail terminate in every case.
318#
319check_gcc()
320{
321 test_header gcc
322 if [ -n "$CC_COMPAT" ]; then
323 if check_avail "$CC_COMPAT" CC_COMPAT really; then
324 cc_compat_ver=`$CC_COMPAT -dumpversion` 2>/dev/null
325 if [ $? -ne 0 ]; then
326 log_failure "cannot execute '$CC_COMPAT -dumpversion'"
327 fail really
328 fi
329 cc_compat_maj=`echo $cc_compat_ver|cut -d. -f1`
330 cc_compat_min=`echo $cc_compat_ver|cut -d. -f2`
331 if [ $cc_compat_maj -lt 3 \
332 -o \( $cc_compat_maj -eq 3 -a $cc_compat_min -lt 2 \) \
333 -o \( $cc_compat_maj -eq 4 -a $cc_compat_min -lt 1 \) \
334 -o \( $cc_compat_maj -eq 4 -a $cc_compat_min -gt 2 \) \
335 -o $cc_compat_maj -gt 4 ]; then
336 log ""
337 log " ** Version $cc_compat_ver of the compatibility gcc found. Expected gcc 3.x with x>1"
338 log " ** or gcc 4.x with 0<x<3"
339 fail really
340 fi
341 cnf_append "VBOX_RECOMPILER_OP_GCC" "$CC_COMPAT"
342 fi
343 fi
344 if check_avail "$CC" CC really; then
345 cc_ver=`$CC -dumpversion` 2>/dev/null
346 if [ $? -ne 0 ]; then
347 log_failure "cannot execute '$CC -dumpversion'"
348 fail really
349 fi
350 if check_avail "$CXX" CXX really; then
351 cxx_ver=`$CXX -dumpversion` 2>/dev/null
352 if [ $? -ne 0 ]; then
353 log_failure "cannot execute '$CXX -dumpversion'"
354 fail really
355 fi
356 cc_maj=`echo $cc_ver|cut -d. -f1`
357 cc_min=`echo $cc_ver|cut -d. -f2`
358 if [ "x$cc_ver" != "x$cxx_ver" ]; then
359 log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
360 fail really
361 elif [ $cc_maj -eq 4 -a $cc_min -eq 0 -a "OS" = "darwin" ]; then
362 log_success "found version $cc_ver"
363 elif [ $cc_maj -eq 4 -a $cc_min -eq 3 ]; then
364 if [ -z "$CC_COMPAT" ]; then
365 log ""
366 log " ** There are known problems with gcc version 4.3 when compiling the recompiler"
367 log " ** stuff. You need to specify a compatibility compiler with version < 4.3. Look"
368 log " ** for a package compat-gcc-34 on Fedora systems or something similar on other"
369 log " ** distributions and call configure with parameter --with-gcc-compat=gcc34."
370 fail really
371 fi
372 # gcc-4.0 is allowed for Darwin only
373 elif [ $cc_maj -lt 3 \
374 -o \( $cc_maj -eq 3 -a $cc_min -lt 2 \) \
375 -o \( $cc_maj -eq 4 -a $cc_min -lt 1 -a "$OS" != "darwin" \) \
376 -o \( $cc_maj -eq 4 -a $cc_min -gt 3 \) \
377 -o $cc_maj -gt 4 ]; then
378 log_failure "gcc version $cc_ver found, expected gcc 3.x with x>1 or gcc 4.x with 0<x<4"
379 fail really
380 else
381 log_success "found version $cc_ver"
382 fi
383 if [ "$BUILD_MACHINE" = "amd64" ]; then
384 [ -z "$CC32" ] && CC32="$CC -m32"
385 [ -z "$CXX32" ] && CXX32="$CXX -m32"
386 else
387 [ -z "$CC32" ] && CC32="$CC"
388 [ -z "$CXX32" ] && CXX32="$CXX"
389 fi
390 if [ "$BUILD_MACHINE" = "x86" -a "$TARGET_MACHINE" = "amd64" ]; then
391 [ -z "$CC64" ] && CC64="$CC -m64"
392 [ -z "$CXX64" ] && CXX64="$CXX -m64"
393 fi
394 if [ "$CC" != "gcc" ]; then
395 cnf_append "TOOL_GCC3_CC" "$CC"
396 cnf_append "TOOL_GCC3_AS" "$CC"
397 cnf_append "TOOL_GCC3_LD" "$CC"
398 cnf_append "TOOL_GXX3_CC" "$CC"
399 cnf_append "TOOL_GXX3_AS" "$CC"
400 fi
401 if [ "$CXX" != "g++" ]; then
402 cnf_append "TOOL_GCC3_CXX" "$CXX"
403 cnf_append "TOOL_GXX3_CXX" "$CXX"
404 cnf_append "TOOL_GXX3_LD" "$CXX"
405 fi
406 if [ "$CC32" != "gcc -m32" ]; then
407 cnf_append "TOOL_GCC32_CC" "$CC32"
408 cnf_append "TOOL_GCC32_AS" "$CC32"
409 cnf_append "TOOL_GCC32_LD" "$CC32"
410 cnf_append "TOOL_GXX32_CC" "$CC32"
411 cnf_append "TOOL_GXX32_AS" "$CC32"
412 fi
413 if [ "$CXX32" != "g++ -m32" ]; then
414 cnf_append "TOOL_GCC32_CXX" "$CXX32"
415 cnf_append "TOOL_GXX32_CXX" "$CXX32"
416 cnf_append "TOOL_GXX32_LD" "$CXX32"
417 fi
418 # this isn't not necessary, there is not such tool.
419 if [ -n "$CC64" ]; then
420 cnf_append "TOOL_GCC64_CC" "$CC64"
421 cnf_append "TOOL_GCC64_AS" "$CC64"
422 cnf_append "TOOL_GCC64_LD" "$CC64"
423 cnf_append "TOOL_GXX64_CC" "$CC64"
424 cnf_append "TOOL_GXX64_AS" "$CC64"
425 fi
426 if [ -n "$CXX64" ]; then
427 cnf_append "TOOL_GCC64_CXX" "$CXX64"
428 cnf_append "TOOL_GXX64_CXX" "$CXX64"
429 cnf_append "TOOL_GXX64_LD" "$CXX64"
430 fi
431 # Solaris sports a 32-bit gcc/g++.
432 if [ "$OS" = "solaris" -a "$BUILD_MACHINE" = "amd64" ]; then
433 [ "$CC" = "gcc" ] && CC="gcc -m64"
434 [ "$CXX" = "g++" ] && CXX="g++ -m64"
435 fi
436 fi
437 fi
438}
439
440#
441# Check for the bcc compiler, needed for compiling the BIOS
442#
443check_bcc()
444{
445 test_header bcc
446 if check_avail "$BCC" BCC; then
447 bcc_ver=`$BCC -v 2>&1|grep version|sed 's+^bcc: version \(.*\)+\1+'`
448 if [ $? -ne 0 ]; then
449 log_failure "not found"
450 fail
451 else
452 echo "compiling the following source file:" >> $LOG
453 cat > .tmp_src.c << EOF
454int foo(a)
455 int a;
456{
457 return 0;
458}
459EOF
460 cat .tmp_src.c >> $LOG
461 bcc_path=`which_wrapper $BCC`
462 bcc_dir="`dirname $bcc_path`/"
463 echo "using the following command line:" >> $LOG
464 echo "$BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c" >> $LOG
465 $BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c >> $LOG 2>&1
466 if [ $? -ne 0 ]; then
467 log_failure "not found"
468 fail
469 else
470 log_success "found version $bcc_ver"
471 cnf_append "VBOX_BCC" "$bcc_path -B $bcc_dir"
472 fi
473 unset bcc_path
474 unset bcc_dir
475 fi
476 fi
477}
478
479#
480# Check for the as86 assembler, needed for compiling the BIOS
481#
482check_as86()
483{
484 test_header as86
485 if check_avail "$AS86" AS86; then
486 as86_ver=`$AS86 -v 2>&1|grep version|sed 's+^as86 version: \(.*\)+\1+'`
487 if [ $? -ne 0 ]; then
488 log_failure "not found"
489 fail
490 else
491 log_success "found version $as86_ver"
492 cnf_append "VBOX_AS86" "`which_wrapper $AS86`"
493 fi
494 fi
495}
496
497#
498# Check for yasm, needed to compile assembler files
499#
500check_yasm()
501{
502 test_header yasm
503 if check_avail "$YASM" YASM; then
504 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
505 if [ $? -ne 0 ]; then
506 log_failure "not found"
507 fail
508 else
509 yasm_maj=`echo $yasm_ver|cut -d. -f1`
510 yasm_min=`echo $yasm_ver|cut -d. -f2`
511 yasm_rev=`echo $yasm_ver|cut -d. -f3`
512 yasm_ver_mul=`expr $yasm_maj \* 10000 + $yasm_min \* 100 + $yasm_rev`
513 if [ $yasm_ver_mul -lt 501 ]; then
514 log_failure "found version $yasm_ver, expected at least 0.5.1"
515 fail
516 else
517 log_success "found version $yasm_ver"
518 fi
519 fi
520 fi
521}
522
523#
524# Check for the iasl ACPI compiler, needed to compile vbox.dsl
525#
526check_iasl()
527{
528 test_header iasl
529 if check_avail "$IASL" IASL; then
530 iasl_ver=`$IASL|grep version|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
531 if [ $? -ne 0 ]; then
532 log_failure "not found"
533 fail
534 else
535 log_success "found version $iasl_ver"
536 cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
537 fi
538 fi
539}
540
541#
542# Check for xsltproc, needed by Main
543#
544check_xsltproc()
545{
546 test_header xslt
547 if check_avail "$XSLTPROC" XSLTPROC; then
548 xsltproc_ver=`$XSLTPROC --version`
549 if [ $? -ne 0 ]; then
550 log_failure "not found"
551 fail
552 else
553 log_success "found"
554 cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
555 fi
556 fi
557}
558
559#
560# Check for mkisofs, needed to build the CDROM image containing the additions
561#
562check_mkisofs()
563{
564 test_header mkisofs
565 if which_wrapper $GENISOIMAGE > /dev/null; then
566 mkisofs_ver=`$GENISOIMAGE --version`
567 if [ $? -ne 0 ]; then
568 log_failure "not found"
569 fail
570 else
571 log_success "found $mkisofs_ver"
572 cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
573 fi
574 elif check_avail "$MKISOFS" MKISOFS; then
575 mkisofs_ver=`$MKISOFS --version`
576 if [ $? -ne 0 ]; then
577 log_failure "not found"
578 fail
579 else
580 log_success "found $mkisofs_ver"
581 cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
582 fi
583 fi
584}
585
586#
587# Check for libxml2, needed by VBoxSettings
588# 2.6.24 is known to NOT work, 2.6.26 is known to work (there is no 2.6.25 release)
589#
590check_libxml2()
591{
592 if [ -z "$BUILD_LIBXML2" ]; then
593 test_header libxml2
594 if which_wrapper pkg-config > /dev/null; then
595 libxml2_ver=`pkg-config libxml-2.0 --modversion 2>> $LOG`
596 if [ $? -ne 0 ]; then
597 log_failure "not found"
598 fail
599 else
600 FLGXML2=`pkg-config libxml-2.0 --cflags`
601 INCXML2=`strip_I "$FLGXML2"`
602 LIBXML2=`pkg-config libxml-2.0 --libs`
603 cat > .tmp_src.cc << EOF
604#include <cstdio>
605#include <libxml/xmlversion.h>
606extern "C" int main(void)
607{
608 printf("found version %s", LIBXML_DOTTED_VERSION);
609#if LIBXML_VERSION >= 20626
610 printf(", OK.\n");
611 return 0;
612#else
613 printf(", expected version 2.6.26 or higher\n");
614 return 1;
615#endif
616}
617EOF
618 [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
619 if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
620 if test_execute; then
621 cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
622 cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
623 fi
624 fi
625 fi
626 elif which_wrapper xml2-config; then
627 libxml2_ver=`xml2-config --version`
628 if [ $? -ne 0 ]; then
629 log_failure "not found"
630 fail
631 else
632 log_success "found version $libxml2_ver"
633 FLGXML2=`xml2-config --cflags`
634 INCXML2=`strip_I "$FLGXML2"`
635 LIBXML2=`xml2-config --libs`
636 cat > .tmp_src.cc << EOF
637#include <cstdio>
638#include <libxml/xmlversion.h>
639extern "C" int main(void)
640{
641 printf("found version %s", LIBXML_DOTTED_VERSION);
642#if LIBXML_VERSION >= 20626
643 printf(", OK.\n");
644 return 0;
645#else
646 printf(", expected version 2.6.26 or higher\n");
647 return 1;
648#endif
649}
650EOF
651 [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
652 if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
653 if test_execute; then
654 cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
655 cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
656 fi
657 fi
658 fi
659 else
660 log_failure "neither pkg-config nor xml2-config found"
661 fail
662 fi
663 fi
664}
665
666#
667# Check for libxslt, needed by VBoxSettings. For now we depend on 1.1.17.
668# This library is available on Ubuntu Edgy which fulfils the minimal libxml2
669# requirement (2.6.26).
670#
671check_libxslt()
672{
673 if [ -z "$BUILD_LIBXSLT" ]; then
674 test_header libxslt
675 if which_wrapper pkg-config > /dev/null; then
676 libxslt_ver=`pkg-config libxslt --modversion 2>> $LOG`
677 if [ $? -ne 0 ]; then
678 log_failure "not found"
679 fail
680 else
681 FLGXSLT=`pkg-config libxslt --cflags`
682 INCXSLT=`strip_I "$FLGXSLT"`
683 LIBXSLT=`pkg-config libxslt --libs`
684 cat > .tmp_src.cc << EOF
685#include <cstdio>
686#include <libxslt/xsltconfig.h>
687extern "C" int main(void)
688{
689 printf("found version %s", LIBXSLT_DOTTED_VERSION);
690#if LIBXSLT_VERSION >= 10117
691 printf(", OK.\n");
692 return 0;
693#else
694 printf(", expected version 1.1.17 or higher\n");
695 return 1;
696#endif
697}
698EOF
699 [ -n "$INCXSLT" ] && I_INCXSLT=`prefix_I "$INCXSLT"`
700 if test_compile "$LIBXSLT $LIBPTHREAD $I_INCXSLT" xslt xslt; then
701 if test_execute; then
702 cnf_append "SDK_VBOX_LIBXSLT_INCS" "$INCXSLT"
703 cnf_append "SDK_VBOX_LIBXSLT_LIBS" "`strip_l "$LIBXSLT"`"
704 fi
705 fi
706 fi
707 elif which_wrapper xslt-config; then
708 libxslt_ver=`xslt-config --version`
709 if [ $? -ne 0 ]; then
710 log_failure "not found"
711 fail
712 else
713 log_success "found version $libxslt_ver"
714 FLGXSLT=`xslt-config --cflags`
715 INCXSLT=`strip_I "$FLGXSLT"`
716 LIBXSLT=`xslt-config --libs`
717 cat > .tmp_src.cc << EOF
718#include <cstdio>
719#include <libxslt/xsltconfig.h>
720extern "C" int main(void)
721{
722 printf("found version %s", LIBXSLT_DOTTED_VERSION);
723#if LIBXSLT_VERSION >= 10117
724 printf(", OK.\n");
725 return 0;
726#else
727 printf(", expected version 1.1.17 or higher\n");
728 return 1;
729#endif
730}
731EOF
732 [ -n "$INCXSLT" ] && I_INCXSLT=`prefix_I "$INCXSLT"`
733 if test_compile "$LIBXSLT $LIBPTHREAD $I_INCXSLT" xslt xslt; then
734 if test_execute; then
735 cnf_append "SDK_VBOX_LIBXSLT_INCS" "$INCXSLT"
736 cnf_append "SDK_VBOX_LIBXSLT_LIBS" "`strip_l "$LIBXSLT"`"
737 fi
738 fi
739 fi
740 else
741 log_failure "neither pkg-config nor xslt-config found"
742 fail
743 fi
744 fi
745}
746
747#
748# Check for libIDL, needed by xpcom
749#
750check_libidl()
751{
752 test_header libIDL
753
754 if which_wrapper libIDL-config-2 > /dev/null; then
755 libidl_ver=`libIDL-config-2 --version`
756 if [ $? -ne 0 ]; then
757 log_failure "not found"
758 fail
759 else
760 log_success "found version $libidl_ver"
761 cnf_append "VBOX_LIBIDL_CONFIG" \
762 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
763 fi
764 elif check_avail "libIDL-config" libIDL-config; then
765 libidl_ver=`libIDL-config --version`
766 if [ $? -ne 0 ]; then
767 log_failure "not found"
768 fail
769 else
770 log_success "found version $libidl_ver"
771 cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
772 fi
773 fi
774}
775
776#
777# Check for openssl, needed for RDP
778#
779check_ssl()
780{
781 test_header ssl
782 cat > .tmp_src.cc << EOF
783#include <cstdio>
784#include <openssl/opensslv.h>
785extern "C" int main(void)
786{
787 printf("found version %s", OPENSSL_VERSION_TEXT);
788#if OPENSSL_VERSION_NUMBER >= 0x0090700
789 printf(", OK.\n");
790 return 0;
791#else
792 printf(", expected version 0.9.7 or higher\n");
793 return 1;
794#endif
795}
796EOF
797 if test_compile $LIBCRYPTO libcrypto openssl; then
798 if test_execute nofatal; then
799 cnf_append "SDK_VBOX_OPENSSL_INCS" ""
800 cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
801 fi
802 fi
803}
804
805#
806# Check for pthread, needed by VBoxSVC, frontends, ...
807#
808check_pthread()
809{
810 test_header pthread
811 cat > .tmp_src.cc << EOF
812#include <cstdio>
813#include <pthread.h>
814extern "C" int main(void)
815{
816 pthread_mutex_t mutex;
817 if (pthread_mutex_init(&mutex, NULL)) {
818 printf("pthread_mutex_init() failed\n");
819 return 1;
820 }
821 if (pthread_mutex_lock(&mutex)) {
822 printf("pthread_mutex_lock() failed\n");
823 return 1;
824 }
825 if (pthread_mutex_unlock(&mutex)) {
826 printf("pthread_mutex_unlock() failed\n");
827 return 1;
828 }
829 printf("found, OK.\n");
830}
831EOF
832 if test_compile $LIBPTHREAD pthread pthread; then
833 if test_execute; then
834 cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
835 fi
836 fi
837}
838
839#
840# Check for zlib, needed by VBoxSVC, Runtime, ...
841#
842check_z()
843{
844 test_header zlib
845 cat > .tmp_src.cc << EOF
846#include <cstdio>
847#include <zlib.h>
848extern "C" int main(void)
849{
850 printf("found version %s", ZLIB_VERSION);
851#if ZLIB_VERNUM >= 0x1210
852 printf(", OK.\n");
853 return 0;
854#else
855 printf(", expected version 1.2.1 or higher\n");
856 return 1;
857#endif
858}
859EOF
860 [ -n "$INCZ" ] && I_INCZ=`prefix_I "$INCZ"`
861 if test_compile "$LIBZ $I_INCZ" zlib zlib; then
862 if test_execute; then
863 cnf_append "SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
864 cnf_append "SDK_VBOX_ZLIB_INCS" "$INCZ"
865 fi
866 fi
867}
868
869#
870# Check for libpng, needed by kchmviewer
871#
872check_png()
873{
874 test_header libpng
875 cat > .tmp_src.cc << EOF
876#include <cstdio>
877#include <png.h>
878extern "C" int main(void)
879{
880 printf("found version %s", PNG_LIBPNG_VER_STRING);
881#if PNG_LIBPNG_VER >= 10205
882 printf(", OK.\n");
883 return 0;
884#else
885 printf(", expected version 1.2.5 or higher\n");
886 return 1;
887#endif
888}
889EOF
890 [ -n "$INCPNG" ] && I_INCPNG=`prefix_I "$INCPNG"`
891# if test_compile "$LIBPNG $I_INCPNG" libpng libpng nofatal; then
892 if test_compile "$LIBPNG $I_INCPNG" libpng libpng; then
893# if test_execute nofatal; then
894 if test_execute; then
895 cnf_append "SDK_VBOX_LIBPNG_LIBS" "`strip_l "$LIBPNG"`"
896 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
897 fi
898 fi
899}
900
901#
902# Check for pam, needed by VRDPAuth
903# Version 79 was introduced in 9/2005, do we support older versions?
904# Debian/sarge uses 76
905# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
906#
907check_pam()
908{
909 test_header pam
910 cat > .tmp_src.cc << EOF
911#include <cstdio>
912#include <security/pam_appl.h>
913extern "C" int main(void)
914{
915 printf("found version %d", __LIBPAM_VERSION);
916 if (__LIBPAM_VERSION >= 76)
917 {
918 printf(", OK.\n");
919 return 0;
920 }
921 else
922 {
923 printf(", expected version 76 or higher\n");
924 return 1;
925 }
926}
927EOF
928 if test_compile "-lpam" pam pam nofatal; then
929 if test_execute nofatal; then
930 return 0;
931 fi
932 fi
933 test_header linux_pam
934 cat > .tmp_src.cc << EOF
935#include <cstdio>
936#include <security/pam_appl.h>
937extern "C" int main(void)
938{
939 printf("found version %d.%d", __LINUX_PAM__, __LINUX_PAM_MINOR__);
940 if (__LINUX_PAM__ >= 1)
941 {
942 printf(", OK.\n");
943 return 0;
944 }
945 else
946 {
947 printf(", expected version 1.0 or higher\n");
948 return 1;
949 }
950}
951EOF
952 if test_compile "-lpam" pam pam; then
953 test_execute
954 fi
955}
956
957
958#
959# Check for the SDL library, needed by VBoxSDL and VirtualBox
960# We depend at least on version 1.2.7
961#
962check_sdl()
963{
964 test_header SDL
965 if [ "$OS" = "darwin" ]; then
966 if [ -f "/System/Library/Frameworks/SDL.framework/SDL" ]; then
967 PATH_SDK_LIBSDL="/System/Library/Framework/SDL.framework"
968 elif [ -f "/Library/Frameworks/SDL.framework/SDL" ]; then
969 PATH_SDK_LIBSDL="/Library/Frameworks/SDL.framework"
970 fi
971 if [ -n "$PATH_SDK_LIBSDL" ]; then
972 foundsdl=1
973 INCSDL="$PATH_SDK_LIBSDL/Headers"
974 FLDSDL="-framework SDL"
975 else
976 log_failure "SDL framework not found"
977 fail
978 fi
979 else
980 if which_wrapper sdl-config > /dev/null; then
981 FLGSDL=`sdl-config --cflags`
982 INCSDL=`strip_I "$FLGSDL"`
983 LIBSDL=`sdl-config --libs`
984 LIBSDLMAIN="-lSDLmain"
985 FLDSDL=
986 foundsdl=1
987 fi
988 fi
989 [ "$OS" = "linux" -o "$OS" = "darwin" -o "$OS" = "solaris" ] && LIBSDLMAIN=""
990 if [ -n "$foundsdl" ]; then
991 cat > .tmp_src.cc << EOF
992#include <cstdio>
993#include <SDL.h>
994#include <SDL_main.h>
995#undef main
996extern "C" int main(int argc, char** argv)
997{
998 printf("found version %d.%d.%d",
999 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
1000#if SDL_VERSION_ATLEAST(1,2,7)
1001 printf(", OK.\n");
1002 return 0;
1003#else
1004 printf(", expected version 1.2.7 or higher\n");
1005 return 1;
1006#endif
1007}
1008EOF
1009 [ -n "$INCSDL" ] && I_INCSDL=`prefix_I "$INCSDL"`
1010 if test_compile "$LIBSDL $LIBSDLMAIN $I_INCSDL $FLDSDL" SDL SDL; then
1011 if test_execute; then
1012 cnf_append "LIB_SDK_LIBSDL_SDL" "`strip_l "$LIBSDL"`"
1013 cnf_append "SDK_LIBSDL_LIBPATH" "`strip_L "$LIBSDL"`"
1014 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
1015 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
1016 [ -n "$FLDSDL" ] && cnf_append "SDK_LIBSDL_LDFLAGS" "$FLDSDL"
1017 fi
1018 fi
1019 else
1020 log_failure "not found"
1021 fail
1022 fi
1023}
1024
1025#
1026# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
1027#
1028check_sdl_ttf()
1029{
1030 test_header SDL_ttf
1031 cat > .tmp_src.cc << EOF
1032#include <cstdio>
1033#include <SDL_ttf.h>
1034#ifndef SDL_TTF_MAJOR_VERSION
1035#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
1036#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
1037#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
1038#endif
1039extern "C" int main(void)
1040{
1041 printf("found version %d.%d.%d",
1042 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
1043#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
1044 printf(", OK.\n");
1045 return 0;
1046#else
1047 printf(", expected version 2.0.6 or higher\n");
1048 return 1;
1049#endif
1050}
1051EOF
1052 if test_compile "-lSDL_ttf $I_INCSDL" SDL_ttf SDL_ttf nofatal; then
1053 if ! test_execute nofatal; then
1054 cnf_append "VBOX_WITH_SECURELABEL" ""
1055 fi
1056 else
1057 cnf_append "VBOX_WITH_SECURELABEL" ""
1058 fi
1059}
1060
1061#
1062# Check for libasound, needed by the ALSA audio backend
1063#
1064check_alsa()
1065{
1066 test_header ALSA
1067 cat > .tmp_src.cc << EOF
1068#include <cstdio>
1069#include <alsa/asoundlib.h>
1070extern "C" int main(void)
1071{
1072 printf("found version %d.%d.%d",
1073 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
1074#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
1075 printf(", OK.\n");
1076 return 0;
1077#else
1078 printf(", expected version 1.0.6 or higher\n");
1079 return 1;
1080#endif
1081}
1082EOF
1083 if test_compile "-lasound" asound asound; then
1084 test_execute
1085 fi
1086}
1087
1088#
1089# Check for PulseAudio
1090#
1091check_pulse()
1092{
1093 test_header "PulseAudio"
1094 cat > .tmp_src.cc << EOF
1095#include <cstdio>
1096#include <pulse/version.h>
1097extern "C" int main(void)
1098{
1099 printf("found version %s API version %d", pa_get_headers_version(), PA_API_VERSION);
1100#if PA_API_VERSION >= 9
1101 printf(", OK.\n");
1102 return 0;
1103#else
1104 printf(", expected version 0.9.0 (API version 9) or higher\n");
1105 return 1;
1106#endif
1107}
1108EOF
1109 if test_compile "-lpulse" pulse pulse; then
1110 test_execute
1111 fi
1112}
1113
1114#
1115# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
1116#
1117check_xcursor()
1118{
1119 test_header Xcursor
1120 cat > .tmp_src.cc << EOF
1121#include <cstdio>
1122#include <X11/Xlib.h>
1123#include <X11/Xcursor/Xcursor.h>
1124extern "C" int main(void)
1125{
1126 XcursorImage *cursor = XcursorImageCreate (10, 10);
1127 XcursorImageDestroy(cursor);
1128 return 0;
1129}
1130EOF
1131 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1132 if test_compile "$LIBX11 $LIBXCURSOR $I_INCX11" Xcursor Xcursor; then
1133 log_success "found"
1134 cnf_append "VBOX_XCURSOR_LIBS" "`strip_l "$LIBXCURSOR"`"
1135 fi
1136}
1137
1138#
1139# Check for the X libraries (Xext, X11)
1140#
1141check_x()
1142{
1143 test_header "X libraries"
1144 cat > .tmp_src.cc << EOF
1145#include <cstdio>
1146#include <X11/Xlib.h>
1147extern "C" int main(void)
1148{
1149 Display *dpy;
1150 int scrn_num;
1151 Screen *scrn;
1152 Window win;
1153
1154 dpy = XOpenDisplay(NULL);
1155 scrn_num = DefaultScreen(dpy);
1156 scrn = ScreenOfDisplay(dpy, scrn_num);
1157 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
1158 0, 16, InputOutput, CopyFromParent, 0, NULL);
1159 XDestroyWindow(dpy, win);
1160}
1161EOF
1162 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1163 if test_compile "$LIBX11 $I_INCX11" Xlibs Xlibs; then
1164 log_success "found"
1165 fi
1166}
1167
1168#
1169# Check for the Qt3 library, needed by VirtualBox
1170#
1171check_qt3()
1172{
1173 test_header Qt3
1174 cat > .tmp_src.cc << EOF
1175#include <cstdio>
1176#include <qglobal.h>
1177extern "C" int main(void)
1178{
1179 printf("found version %s", QT_VERSION_STR);
1180#if QT_VERSION >= 0x030305
1181 printf(", OK.\n");
1182 return 0;
1183#elif QT_VERSION >= 0x030300
1184 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
1185#else
1186 printf(", expected version 3.3.0 or higher\n");
1187 return 1;
1188#endif
1189}
1190EOF
1191 found_qt=0
1192 libs="lib"
1193 [ "$LIB" = "lib64" ] && libs="$libs lib64"
1194 for q in $QT3DIR; do
1195 for l in $libs; do
1196 echo "compiling the following source file:" >> $LOG
1197 cat .tmp_src.cc >> $LOG
1198 echo "using the following command line:" >> $LOG
1199 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt $LIBPTHREAD" >> $LOG
1200 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt $LIBPTHREAD >> $LOG 2>&1
1201 if [ $? -eq 0 ]; then
1202 if test_execute; then
1203 cnf_append "QTDIR" "`cd $q ; pwd`"
1204 found_qt=1
1205 break
1206 fi
1207 fi
1208 done
1209 if [ $found_qt -eq 1 ]; then
1210 break
1211 fi
1212 done
1213 if [ $found_qt -ne 1 ]; then
1214 echo
1215 echo " Qt3 not found at \"$QT3DIR\" or Qt3 headers not found"
1216 echo " Check the file $LOG for detailed error information."
1217 fail
1218 return 1
1219 fi
1220 test_header "Qt3 devtools"
1221 if check_avail "$q/bin/moc" QT3DIR/bin; then
1222 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
1223 if [ $? -ne 0 ]; then
1224 log_failure "not found"
1225 fail
1226 else
1227 log_success "found version $moc_ver"
1228 fi
1229 fi
1230}
1231
1232#
1233# Check for the Qt4 library, needed by VirtualBox4
1234#
1235# Currently not fatal.
1236#
1237check_qt4()
1238{
1239 test_header Qt4
1240 if [ "$OS" = "darwin" ]; then
1241 if [ -f "/System/Library/Frameworks/QtCore.framework/QtCore" ]; then
1242 PATH_SDK_QT4="/System/Library/Framework/QtCore.framework"
1243 elif [ -f "/Library/Frameworks/QtCore.framework/QtCore" ]; then
1244 PATH_SDK_QT4="/Library/Frameworks/QtCore.framework"
1245 fi
1246 if [ -n "$PATH_SDK_QT4" ]; then
1247 foundqt4=1
1248 INCQT4="$PATH_SDK_QT4/Headers"
1249 LIBQT4=
1250 FLDQT4="-framework QtCore"
1251 else
1252 log_failure "Qt4 framework not found"
1253 fail
1254 fi
1255 else
1256 if [ $QT4DIR_PKGCONFIG -eq 1 ]; then
1257 # default is to use pkg-config
1258 if which_wrapper pkg-config > /dev/null; then
1259 qt4_ver=`pkg-config QtCore --modversion 2>> $LOG`
1260 if [ $? -ne 0 ]; then
1261 log_failure "not found"
1262 # fail
1263 else
1264 FLGQT4=`pkg-config QtCore --cflags`
1265 INCQT4=`strip_I "$FLGQT4"`
1266 LIBQT4=`pkg-config QtCore --libs`
1267 foundqt4=1
1268 fi
1269 else
1270 log_failure "pkg-config not found"
1271# not yet
1272# fail
1273 fi
1274 else
1275 # do it the old way (e.g. user has specified QT4DIR)
1276 for q in $QT4DIR; do
1277 INCQT4="$q/include $q/include/QtCore"
1278 LIBQT4="-L$q/lib -lQtCore"
1279 FLGQT4="-DQT_SHARED"
1280 I_INCQT4=`prefix_I "$INCQT4"`
1281 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLDQT4" qt4 qt4 nofatal; then
1282 foundqt4=1
1283 break;
1284 fi
1285 done
1286 fi
1287 fi
1288 if [ -n "$foundqt4" ]; then
1289 cat > .tmp_src.cc << EOF
1290#include <cstdio>
1291#include <QtGlobal>
1292extern "C" int main(void)
1293{
1294 printf("found version %s", QT_VERSION_STR);
1295#if QT_VERSION >= 0x040200
1296 printf(", OK.\n");
1297 return 0;
1298 printf(", expected version 4.2.0 or higher\n");
1299 return 1;
1300#endif
1301}
1302EOF
1303 [ -n "$INCQT4" ] && I_INCQT4=`prefix_I "$INCQT4"`
1304 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLDQT4" qt4 qt4 nofatal; then
1305 if test_execute; then
1306# cnf_append "SDK_VBOX_LIBQT4_INCS" "$INCQT4"
1307# cnf_append "SDK_VBOX_LIBQT4_LIBS" "`strip_l "$LIBQT4"`"
1308 if [ "$OS" = "darwin" ]; then
1309 cnf_append "VBOX_WITH_QT4GUI" "1"
1310 else
1311 test_header "Qt4 devtools"
1312 for q in $QT4DIR; do
1313 if which_wrapper "$q/bin/moc" > /dev/null; then
1314 moc_ver=`$q/bin/moc -v 2>&1|sed 's+^.*(Qt \(.*\))+\1+'`
1315 if [ $? -ne 0 ]; then
1316 log_failure "not found"
1317 fail
1318 else
1319 log_success "found version $moc_ver"
1320 cnf_append "VBOX_PATH_QT4" "$q"
1321 test_header "Qt4 uic3"
1322 for r in $q/bin $QT4UIC3DIR; do
1323 if which_wrapper "$r/uic3" > /dev/null; then
1324 uic3_ver=`$r/uic3 -version 2>&1|sed 's+^.*version \(.*\)+\1+'`
1325 if [ $? -ne 0 ]; then
1326 log_failure "not found"
1327 fail
1328 else
1329 log_success "found version $uic3_ver"
1330 cnf_append "VBOX_UIC3" "$r/uic3"
1331 return
1332 fi
1333 fi
1334 done
1335 log_failure "not found"
1336 fail
1337 fi
1338 fi
1339 done
1340 fi
1341 fi
1342 else
1343 log_failure "not found"
1344 fail
1345 fi
1346 fi
1347}
1348
1349
1350#
1351# Check whether static libstdc++ is installed
1352#
1353check_staticlibstdcxx()
1354{
1355 test_header "static stc++ library"
1356 libstdcxx=`$CXX -print-file-name=libstdc++.a`
1357 cat > .tmp_src.cc << EOF
1358#include <string>
1359
1360extern "C" int main(void)
1361{
1362 std::string s = "test";
1363 return 0;
1364}
1365EOF
1366 if test_compile "$libstdcxx" libstdc++ libstdc++; then
1367 log_success "found"
1368 fi
1369}
1370
1371#
1372# Check for Linux sources
1373#
1374check_linux()
1375{
1376 test_header "Linux kernel sources"
1377 cat > .tmp_src.c << EOF
1378#include <linux/version.h>
1379int printf(const char *format, ...);
1380int main(void)
1381{
1382 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1383 (LINUX_VERSION_CODE % 65536) / 256,
1384 LINUX_VERSION_CODE % 256);
1385#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1386 printf(", OK.\n");
1387 return 0;
1388#else
1389 printf(", expected version 2.4.0 or higher\n");
1390 return 1;
1391#endif
1392}
1393EOF
1394 echo "compiling the following source file:" >> $LOG
1395 cat .tmp_src.c >> $LOG
1396 echo "using the following command line:" >> $LOG
1397 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
1398 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
1399 if [ $? -ne 0 ]; then
1400 echo
1401 echo " Linux kernel headers not found at $LINUX"
1402 echo " Check the file $LOG for detailed error information."
1403 fail
1404 else
1405 if test_execute; then
1406 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1407 fi
1408 fi
1409}
1410
1411#
1412# Check for kchmviewer, needed to display the online help
1413#
1414check_kchmviewer()
1415{
1416 test_header kchmviewer
1417 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1418 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1419 if [ $? -ne 0 ]; then
1420 log_failure "not found"
1421 fail
1422 else
1423 log_success "found version $kchmviewer_ver"
1424 fi
1425 fi
1426}
1427
1428#
1429# Check for the kBuild tools, we don't support GNU make
1430#
1431check_kbuild()
1432{
1433 test_header kBuild
1434 if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
1435 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
1436 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1437 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1438 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1439 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1440 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1441 if [ "$OS" = "solaris" ]; then
1442 # Because of sh being non-default shell in Solaris we need to export PATH again when
1443 # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
1444 echo "PATH=\"$ORGPATH\"" >> $ENV
1445 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1446 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1447 else
1448 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1449 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1450 fi
1451 echo "export PATH" >> $ENV
1452 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1453 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1454 elif check_avail "kmk" KBUILDDIR really; then
1455 # check for installed kBuild
1456 KBUILD_SED="`which_wrapper kmk_sed`"
1457 else
1458 fail
1459 fi
1460 log_success "found"
1461}
1462
1463
1464#
1465# Check for compiler.h
1466# Some Linux distributions include "compiler.h" in their libc linux
1467# headers package, some don't. Most don't need it, building might (!)
1468# not succeed on openSUSE without it.
1469#
1470# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1471#
1472check_compiler_h()
1473{
1474 test_header compiler.h
1475 if ! test -f "/usr/include/linux/compiler.h"; then
1476 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1477 log_success "compiler.h not found"
1478 else
1479 log_success "compiler.h found"
1480 fi
1481}
1482
1483
1484#
1485# Check if we are able to build 32-bit applications (needed for the guest additions)
1486#
1487check_32bit()
1488{
1489 test_header "32-bit support"
1490 cat > .tmp_src.c << EOF
1491#include <stdint.h>
1492int main(void)
1493{
1494 return 0;
1495}
1496EOF
1497 echo "compiling the following source file:" >> $LOG
1498 cat .tmp_src.c >> $LOG
1499 echo "using the following command line:" >> $LOG
1500 echo "$CC -m32 -O -Wall -o .tmp_out .tmp_src.c" >> $LOG
1501 $CC -m32 -O -Wall -o .tmp_out .tmp_src.c >> $LOG 2>&1
1502 if [ $? -ne 0 ]; then
1503 echo
1504 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1505 echo " Check the file $LOG for detailed error information."
1506 fail
1507 fi
1508 log_success ""
1509}
1510
1511#
1512# Setup wine
1513#
1514setup_wine()
1515{
1516 test_header "Wine support"
1517 if ! which_wrapper wine > /dev/null; then
1518 echo " wine binary not found"
1519 fail
1520 fi
1521 if ! which_wrapper wineprefixcreate > /dev/null; then
1522 echo " wineprefixcreate not found"
1523 fail
1524 fi
1525 export WINEPREFIX="${ODIR}wine.$BUILD_MACHINE"
1526 echo "export WINEPREFIX=\"${ODIR}wine.$BUILD_MACHINE\"" >> $ENV
1527 rm -rf $WINEPREFIX
1528 mkdir -p $WINEPREFIX
1529 touch $WINEPREFIX/.no_prelaunch_window_flag
1530 if ! wineprefixcreate -q > /dev/null 2>&1; then
1531 echo " wineprefixcreate failed"
1532 fail
1533 fi
1534 tmp=.tmp.wine.reg
1535 rm -f $tmp
1536 echo 'REGEDIT4' > $tmp
1537 echo '' >> $tmp
1538 echo '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]' >> $tmp
1539 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
1540 echo '' >> $tmp
1541 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhc.exe\DllOverrides]' >> $tmp
1542 echo '"itss"="native"' >> $tmp
1543 echo '' >> $tmp
1544 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhw.exe\DllOverrides]' >> $tmp
1545 echo '"itss"="native"' >> $tmp
1546 echo '' >> $tmp
1547 if ! wine regedit $tmp > /dev/null 2>&1; then
1548 rm -f $tmp
1549 echo " failed to load registry changes (path)."
1550 fail
1551 fi
1552 rm -f $tmp
1553 log_success "found"
1554}
1555
1556
1557#
1558# Determines the Darwin version.
1559# @todo This should really check the Xcode/SDK version.
1560#
1561check_darwinversion()
1562{
1563 test_header "Darwin version"
1564 darwin_ver=`uname -r`
1565 case "$darwin_ver" in
1566 9\.*)
1567 darwin_ver="10.5"
1568 #cnf_append "VBOX_TARGET_MAC_OS_X_VERSION_10_5" "1"
1569 ;;
1570 8\.*)
1571 darwin_ver="10.4"
1572 ;;
1573 *)
1574 echo " failed to determin darwin version. (uname -r: $darwin_ver)"
1575 fail
1576 darwin_ver="unknown"
1577 ;;
1578 esac
1579 log_success "found version $darwin_ver"
1580}
1581
1582
1583#
1584# Checks that i386-elf-gcc-3.4.6, i386-elf-gcc-3.4.3, i386-elf-gcc-3.4 or i386-elf-gcc
1585# is around to prevent confusion when the build fails in src/recompiler.
1586# Note. Keep the which order in sync with the $(which ) in src/recompiler/Makefile.kmk.
1587#
1588check_i386elfgcc()
1589{
1590 test_header "i386-elf-gcc"
1591 i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.6`
1592 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.3`
1593 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4`
1594 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc`
1595 if test -z "$i386_elf_gcc"; then
1596 echo " failed to find i386-elf-gcc"
1597 fail
1598 fi
1599 log_success "found $i386_elf_gcc"
1600}
1601
1602
1603#
1604# Show help
1605#
1606show_help()
1607{
1608 cat << EOF
1609Usage: ./configure [OPTIONS]...
1610
1611Configuration:
1612 -h, --help display this help and exit
1613 --nofatal don't abort on errors
1614 --disable-xpcom disable XPCOM and related stuff
1615 --disable-sdl-ttf disable SDL_ttf detection
1616 --disable-alsa disable the ALSA sound backend
1617 --disable-pulse disable the PulseAudio backend
1618 --disable-kmods don't build Linux kernel modules (host and guest)
1619 --build-libxml2 build libxml2 from sources
1620 --build-libxslt build libxslt from sources
1621 --setup-wine setup a Wine directory and register the hhc hack
1622
1623Paths:
1624 --with-gcc=PATH location of the gcc compiler [$CC]
1625 --with-g++=PATH location of the g++ compiler [$CXX]
1626 --with-gcc-compat=PATH location of the gcc compiler for recompiler [$CC]
1627 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1628 --with-iasl=PATH location of the iasl compiler [$IASL]
1629 --with-linux=DIR Linux kernel source directory [$LINUX]
1630 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1631 --with-qt-dir=DIR directory for Qt3 headers/libraries [$QT3DIR]
1632 --with-qt4-dir=DIR directory for Qt4 headers/libraries [pkgconfig]
1633
1634Build type:
1635 -d, --build-debug build with debugging symbols and assertions
1636 --build-profile build with profiling support
1637 --build-headless build headless (without any X11 frontend)
1638EOF
1639 exit 0
1640}
1641
1642
1643#
1644# The body.
1645#
1646
1647# scan command line options
1648for option in $*; do
1649 case "$option" in
1650 --help|-help|-h)
1651 show_help
1652 ;;
1653 --nofatal)
1654 nofatal=1
1655 ;;
1656 --with-gcc=*)
1657 CC=`echo $option | cut -d'=' -f2`
1658 ;;
1659 --with-g++=*)
1660 CXX=`echo $option | cut -d'=' -f2`
1661 ;;
1662 --with-gcc-compat=*)
1663 CC_COMPAT=`echo $option | cut -d'=' -f2`
1664 ;;
1665 --with-kbuild=*)
1666 KBUILDDIR=`echo $option | cut -d'=' -f2`
1667 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1668 echo "Error: KBUILDDIR contains invalid characters!"
1669 exit 1
1670 fi
1671 ;;
1672 --with-qt-dir=*)
1673 QT3DIR=`echo $option | cut -d'=' -f2`
1674 ;;
1675 --with-qt4-dir=*)
1676 QT4DIR=`echo $option | cut -d'=' -f2`
1677 QT4DIR_PKGCONFIG=0
1678 ;;
1679 --with-iasl=*)
1680 IASL=`echo $option | cut -d'=' -f2`
1681 ;;
1682 --with-linux=*)
1683 LINUX=`echo $option | cut -d'=' -f2`
1684 ;;
1685 --with-mkisofs=*)
1686 MKISOFS=`echo $option | cut -d'=' -f2`
1687 ;;
1688 --disable-xpcom)
1689 WITH_XPCOM=0
1690 ;;
1691 --disable-sdl-ttf)
1692 WITH_SDL_TTF=0
1693 ;;
1694 --disable-qt)
1695 WITH_QT=0
1696 WITH_QT4=0
1697 ;;
1698 --disable-qt4)
1699 WITH_QT4=0
1700 ;;
1701 --disable-alsa)
1702 WITH_ALSA=0
1703 ;;
1704 --disable-pulse)
1705 WITH_PULSE=0
1706 ;;
1707 --disable-kmods)
1708 WITH_KMODS=0
1709 ;;
1710 --build-debug|-d)
1711 BUILD_TYPE=debug
1712 ;;
1713 --build-profile)
1714 BUILD_TYPE=profile
1715 ;;
1716 --build-libxml2)
1717 BUILD_LIBXML2=1
1718 ;;
1719 --build-libxslt)
1720 BUILD_LIBXSLT=1
1721 ;;
1722 --build-headless)
1723 HEADLESS=1
1724 WITH_SDL=0
1725 WITH_SDL_TTF=0
1726 WITH_X11=0
1727 WITH_QT=0
1728 WITH_QT4=0
1729 ;;
1730 --ose)
1731 OSE=2
1732 ;;
1733 --odir=*)
1734 ODIR="`echo $option | cut -d'=' -f2`/"
1735 ;;
1736 --setup-wine)
1737 SETUP_WINE=1
1738 ;;
1739 *)
1740 echo
1741 echo "Unrecognized option \"$option\""
1742 echo
1743 show_help
1744 ;;
1745 esac
1746done
1747
1748LOG="$ODIR$LOG"
1749ENV="$ODIR$ENV"
1750CNF="$ODIR$CNF"
1751
1752# initialize output files
1753cat > $LOG << EOF
1754# Log file generated by
1755#
1756# '$0 $*'
1757#
1758
1759EOF
1760cat > $CNF << EOF
1761# -*- Makefile -*-
1762#
1763# automatically generated by
1764#
1765# '$0 $*'
1766#
1767# It will be completely overwritten if configure is executed again.
1768#
1769
1770EOF
1771cat > $ENV << EOF
1772#!/bin/bash
1773#
1774# automatically generated by
1775#
1776# '$0 $*'
1777#
1778# It will be completely overwritten if configure is executed again.
1779# Make sure you source this file once before you start to build VBox.
1780#
1781
1782EOF
1783
1784# test if we are OSE
1785if [ $OSE -eq 1 -a -d "`cd \`dirname $0\`; pwd`/src/VBox/Devices/USB" ]; then
1786 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1787 echo >> $LOG
1788 OSE=0
1789fi
1790
1791if [ "$BUILD_TYPE" = "debug" ]; then
1792 echo "Creating DEBUG build!" >> $LOG
1793elif [ "$BUILD_TYPE" = "profile" ]; then
1794 echo "Creating PROFILE build!" >> $LOG
1795fi
1796
1797# first determine our environment
1798check_environment
1799check_kbuild
1800
1801# append the tools directory to the default search path
1802echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1803export PATH
1804
1805# some things are not available in for OSE
1806if [ $OSE -ge 1 ]; then
1807 cnf_append "VBOX_OSE" "1"
1808 cnf_append "VBOX_WITH_TESTSUITE" ""
1809 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1810
1811 if [ "$OS" = "linux" ]; then
1812 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1813 else
1814 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1815 fi
1816 echo >> $CNF
1817fi
1818
1819# headless
1820if [ -n "$HEADLESS" ]; then
1821 cnf_append "VBOX_HEADLESS" "1"
1822fi
1823
1824if [ "$OS" = "darwin" ]; then
1825 # On Darwin we want to build against Qt4 only. WITH_QT4 is enabled by
1826 # default so disable Qt3. --disable-qt disables both Qt3 and Qt4 GUI now,
1827 # --disable-qt4 disables only the Qt4 GUI (which is not appropriate for
1828 # Darwin as we disable the Qt3 here anyway.
1829 # (Qt3 builds for Intel Macs are usually not threaded or for X11. And they
1830 # don't contain our patches, which means the result isn't really usable.)
1831 WITH_QT=0
1832 # No Qt4 for OSE yet.
1833 [ $OSE -ge 1 ] && WITH_QT4=0
1834 BUILD_LIBXSLT=1
1835 BUILD_LIBXML2=1
1836fi
1837
1838# emit disable directives corresponding to any --disable-xxx options.
1839[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
1840[ $WITH_QT -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
1841[ $WITH_QT4 -eq 0 ] && cnf_append "VBOX_WITH_QT4GUI" ""
1842[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
1843
1844# the tools
1845check_gcc
1846[ "$OS" != "darwin" ] && check_as86
1847[ "$OS" != "darwin" ] && check_bcc
1848[ "$OS" != "darwin" ] && check_iasl
1849# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1850# [ "$OS" != "darwin" ] && check_yasm
1851[ "$OS" != "darwin" ] && check_xsltproc
1852[ $OSE -eq 0 -a "$OS" != "darwin" ] && check_mkisofs
1853
1854# the libraries
1855[ "$OS" != "darwin" ] && check_pthread
1856[ $WITH_XPCOM -eq 1 ] && check_libxml2
1857[ $WITH_XPCOM -eq 1 ] && check_libxslt
1858[ $WITH_LIBIDL -eq 1 ] && check_libidl
1859# build openssl on Darwin in every case
1860[ "$OS" != "darwin" -a $OSE -eq 0 ] && check_ssl
1861[ "$OS" != "darwin" ] && check_z
1862[ "$OS" != "darwin" ] && check_png
1863[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
1864[ $WITH_SDL -eq 1 ] && check_sdl
1865[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
1866[ $WITH_X11 -eq 1 ] && check_x
1867[ $WITH_X11 -eq 1 ] && check_xcursor
1868[ $WITH_QT -eq 1 ] && check_qt3
1869[ $WITH_QT4 -eq 1 ] && check_qt4
1870
1871# Linux-specific
1872if [ "$OS" = "linux" ]; then
1873 check_staticlibstdcxx
1874 if [ $WITH_KMODS -eq 1 ]; then
1875 check_linux
1876 else
1877 cnf_append "VBOX_LINUX_SRC" ""
1878 cnf_append "VBOX_WITH_VBOXDRV" ""
1879 cnf_append "VBOX_WITH_ADDITION_DRIVERS" ""
1880 fi
1881 if [ $WITH_ALSA -eq 1 ]; then
1882 check_alsa
1883 else
1884 cnf_append "VBOX_WITH_ALSA" ""
1885 fi
1886 if [ $WITH_PULSE -eq 1 ]; then
1887 check_pulse
1888 else
1889 cnf_append "VBOX_WITH_PULSE" ""
1890 fi
1891 check_compiler_h
1892 [ "$BUILD_MACHINE" = "amd64" ] && check_32bit
1893fi
1894
1895[ -n "$SETUP_WINE" ] && setup_wine
1896
1897# Darwin-specific
1898if [ "$OS" = "darwin" ]; then
1899 check_darwinversion
1900 check_i386elfgcc
1901fi
1902
1903# success!
1904echo
1905echo "Successfully generated '$CNF' and '$ENV'."
1906echo "Source '$ENV' once before you start to build VBox:"
1907echo ""
1908echo " source $ENV"
1909echo " kmk"
1910echo ""
1911if [ "$OS" = "linux" ]; then
1912 echo "To compile the kernel module, do:"
1913 echo ""
1914 echo " cd ./out/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
1915 echo " make"
1916 echo ""
1917fi
1918echo "Enjoy!"
1919cleanup
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