VirtualBox

source: vbox/trunk/configure@ 10196

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

uic3 is not necessary anymore

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 47.8 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 return
1322 fi
1323 fi
1324 done
1325 fi
1326 fi
1327 else
1328 log_failure "not found"
1329 fail
1330 fi
1331 fi
1332}
1333
1334
1335#
1336# Check whether static libstdc++ is installed
1337#
1338check_staticlibstdcxx()
1339{
1340 test_header "static stc++ library"
1341 libstdcxx=`$CXX -print-file-name=libstdc++.a`
1342 cat > .tmp_src.cc << EOF
1343#include <string>
1344
1345extern "C" int main(void)
1346{
1347 std::string s = "test";
1348 return 0;
1349}
1350EOF
1351 if test_compile "$libstdcxx" libstdc++ libstdc++; then
1352 log_success "found"
1353 fi
1354}
1355
1356#
1357# Check for Linux sources
1358#
1359check_linux()
1360{
1361 test_header "Linux kernel sources"
1362 cat > .tmp_src.c << EOF
1363#include <linux/version.h>
1364int printf(const char *format, ...);
1365int main(void)
1366{
1367 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1368 (LINUX_VERSION_CODE % 65536) / 256,
1369 LINUX_VERSION_CODE % 256);
1370#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1371 printf(", OK.\n");
1372 return 0;
1373#else
1374 printf(", expected version 2.4.0 or higher\n");
1375 return 1;
1376#endif
1377}
1378EOF
1379 echo "compiling the following source file:" >> $LOG
1380 cat .tmp_src.c >> $LOG
1381 echo "using the following command line:" >> $LOG
1382 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
1383 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
1384 if [ $? -ne 0 ]; then
1385 echo
1386 echo " Linux kernel headers not found at $LINUX"
1387 echo " Check the file $LOG for detailed error information."
1388 fail
1389 else
1390 if test_execute; then
1391 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1392 fi
1393 fi
1394}
1395
1396#
1397# Check for kchmviewer, needed to display the online help
1398#
1399check_kchmviewer()
1400{
1401 test_header kchmviewer
1402 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1403 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1404 if [ $? -ne 0 ]; then
1405 log_failure "not found"
1406 fail
1407 else
1408 log_success "found version $kchmviewer_ver"
1409 fi
1410 fi
1411}
1412
1413#
1414# Check for the kBuild tools, we don't support GNU make
1415#
1416check_kbuild()
1417{
1418 test_header kBuild
1419 if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
1420 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
1421 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1422 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1423 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1424 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1425 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1426 if [ "$OS" = "solaris" ]; then
1427 # Because of sh being non-default shell in Solaris we need to export PATH again when
1428 # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
1429 echo "PATH=\"$ORGPATH\"" >> $ENV
1430 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1431 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1432 else
1433 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1434 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1435 fi
1436 echo "export PATH" >> $ENV
1437 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1438 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1439 elif check_avail "kmk" KBUILDDIR really; then
1440 # check for installed kBuild
1441 KBUILD_SED="`which_wrapper kmk_sed`"
1442 else
1443 fail
1444 fi
1445 log_success "found"
1446}
1447
1448
1449#
1450# Check for compiler.h
1451# Some Linux distributions include "compiler.h" in their libc linux
1452# headers package, some don't. Most don't need it, building might (!)
1453# not succeed on openSUSE without it.
1454#
1455# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1456#
1457check_compiler_h()
1458{
1459 test_header compiler.h
1460 if ! test -f "/usr/include/linux/compiler.h"; then
1461 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1462 log_success "compiler.h not found"
1463 else
1464 log_success "compiler.h found"
1465 fi
1466}
1467
1468
1469#
1470# Check if we are able to build 32-bit applications (needed for the guest additions)
1471#
1472check_32bit()
1473{
1474 test_header "32-bit support"
1475 cat > .tmp_src.c << EOF
1476#include <stdint.h>
1477int main(void)
1478{
1479 return 0;
1480}
1481EOF
1482 echo "compiling the following source file:" >> $LOG
1483 cat .tmp_src.c >> $LOG
1484 echo "using the following command line:" >> $LOG
1485 echo "$CC -m32 -O -Wall -o .tmp_out .tmp_src.c" >> $LOG
1486 $CC -m32 -O -Wall -o .tmp_out .tmp_src.c >> $LOG 2>&1
1487 if [ $? -ne 0 ]; then
1488 echo
1489 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1490 echo " Check the file $LOG for detailed error information."
1491 fail
1492 fi
1493 log_success ""
1494}
1495
1496#
1497# Setup wine
1498#
1499setup_wine()
1500{
1501 test_header "Wine support"
1502 if ! which_wrapper wine > /dev/null; then
1503 echo " wine binary not found"
1504 fail
1505 fi
1506 if ! which_wrapper wineprefixcreate > /dev/null; then
1507 echo " wineprefixcreate not found"
1508 fail
1509 fi
1510 export WINEPREFIX="${ODIR}wine.$BUILD_MACHINE"
1511 echo "export WINEPREFIX=\"${ODIR}wine.$BUILD_MACHINE\"" >> $ENV
1512 rm -rf $WINEPREFIX
1513 mkdir -p $WINEPREFIX
1514 touch $WINEPREFIX/.no_prelaunch_window_flag
1515 if ! wineprefixcreate -q > /dev/null 2>&1; then
1516 echo " wineprefixcreate failed"
1517 fail
1518 fi
1519 tmp=.tmp.wine.reg
1520 rm -f $tmp
1521 echo 'REGEDIT4' > $tmp
1522 echo '' >> $tmp
1523 echo '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]' >> $tmp
1524 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
1525 echo '' >> $tmp
1526 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhc.exe\DllOverrides]' >> $tmp
1527 echo '"itss"="native"' >> $tmp
1528 echo '' >> $tmp
1529 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhw.exe\DllOverrides]' >> $tmp
1530 echo '"itss"="native"' >> $tmp
1531 echo '' >> $tmp
1532 if ! wine regedit $tmp > /dev/null 2>&1; then
1533 rm -f $tmp
1534 echo " failed to load registry changes (path)."
1535 fail
1536 fi
1537 rm -f $tmp
1538 log_success "found"
1539}
1540
1541
1542#
1543# Determines the Darwin version.
1544# @todo This should really check the Xcode/SDK version.
1545#
1546check_darwinversion()
1547{
1548 test_header "Darwin version"
1549 darwin_ver=`uname -r`
1550 case "$darwin_ver" in
1551 9\.*)
1552 darwin_ver="10.5"
1553 #cnf_append "VBOX_TARGET_MAC_OS_X_VERSION_10_5" "1"
1554 ;;
1555 8\.*)
1556 darwin_ver="10.4"
1557 ;;
1558 *)
1559 echo " failed to determin darwin version. (uname -r: $darwin_ver)"
1560 fail
1561 darwin_ver="unknown"
1562 ;;
1563 esac
1564 log_success "found version $darwin_ver"
1565}
1566
1567
1568#
1569# Checks that i386-elf-gcc-3.4.6, i386-elf-gcc-3.4.3, i386-elf-gcc-3.4 or i386-elf-gcc
1570# is around to prevent confusion when the build fails in src/recompiler.
1571# Note. Keep the which order in sync with the $(which ) in src/recompiler/Makefile.kmk.
1572#
1573check_i386elfgcc()
1574{
1575 test_header "i386-elf-gcc"
1576 i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.6`
1577 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.3`
1578 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4`
1579 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc`
1580 if test -z "$i386_elf_gcc"; then
1581 echo " failed to find i386-elf-gcc"
1582 fail
1583 fi
1584 log_success "found $i386_elf_gcc"
1585}
1586
1587
1588#
1589# Show help
1590#
1591show_help()
1592{
1593 cat << EOF
1594Usage: ./configure [OPTIONS]...
1595
1596Configuration:
1597 -h, --help display this help and exit
1598 --nofatal don't abort on errors
1599 --disable-xpcom disable XPCOM and related stuff
1600 --disable-sdl-ttf disable SDL_ttf detection
1601 --disable-alsa disable the ALSA sound backend
1602 --disable-pulse disable the PulseAudio backend
1603 --disable-kmods don't build Linux kernel modules (host and guest)
1604 --build-libxml2 build libxml2 from sources
1605 --build-libxslt build libxslt from sources
1606 --setup-wine setup a Wine directory and register the hhc hack
1607
1608Paths:
1609 --with-gcc=PATH location of the gcc compiler [$CC]
1610 --with-g++=PATH location of the g++ compiler [$CXX]
1611 --with-gcc-compat=PATH location of the gcc compiler for recompiler [$CC]
1612 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1613 --with-iasl=PATH location of the iasl compiler [$IASL]
1614 --with-linux=DIR Linux kernel source directory [$LINUX]
1615 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1616 --with-qt-dir=DIR directory for Qt3 headers/libraries [$QT3DIR]
1617 --with-qt4-dir=DIR directory for Qt4 headers/libraries [pkgconfig]
1618
1619Build type:
1620 -d, --build-debug build with debugging symbols and assertions
1621 --build-profile build with profiling support
1622 --build-headless build headless (without any X11 frontend)
1623EOF
1624 exit 0
1625}
1626
1627
1628#
1629# The body.
1630#
1631
1632# scan command line options
1633for option in $*; do
1634 case "$option" in
1635 --help|-help|-h)
1636 show_help
1637 ;;
1638 --nofatal)
1639 nofatal=1
1640 ;;
1641 --with-gcc=*)
1642 CC=`echo $option | cut -d'=' -f2`
1643 ;;
1644 --with-g++=*)
1645 CXX=`echo $option | cut -d'=' -f2`
1646 ;;
1647 --with-gcc-compat=*)
1648 CC_COMPAT=`echo $option | cut -d'=' -f2`
1649 ;;
1650 --with-kbuild=*)
1651 KBUILDDIR=`echo $option | cut -d'=' -f2`
1652 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1653 echo "Error: KBUILDDIR contains invalid characters!"
1654 exit 1
1655 fi
1656 ;;
1657 --with-qt-dir=*)
1658 QT3DIR=`echo $option | cut -d'=' -f2`
1659 ;;
1660 --with-qt4-dir=*)
1661 QT4DIR=`echo $option | cut -d'=' -f2`
1662 QT4DIR_PKGCONFIG=0
1663 ;;
1664 --with-iasl=*)
1665 IASL=`echo $option | cut -d'=' -f2`
1666 ;;
1667 --with-linux=*)
1668 LINUX=`echo $option | cut -d'=' -f2`
1669 ;;
1670 --with-mkisofs=*)
1671 MKISOFS=`echo $option | cut -d'=' -f2`
1672 ;;
1673 --disable-xpcom)
1674 WITH_XPCOM=0
1675 ;;
1676 --disable-sdl-ttf)
1677 WITH_SDL_TTF=0
1678 ;;
1679 --disable-qt)
1680 WITH_QT=0
1681 WITH_QT4=0
1682 ;;
1683 --disable-qt4)
1684 WITH_QT4=0
1685 ;;
1686 --disable-alsa)
1687 WITH_ALSA=0
1688 ;;
1689 --disable-pulse)
1690 WITH_PULSE=0
1691 ;;
1692 --disable-kmods)
1693 WITH_KMODS=0
1694 ;;
1695 --build-debug|-d)
1696 BUILD_TYPE=debug
1697 ;;
1698 --build-profile)
1699 BUILD_TYPE=profile
1700 ;;
1701 --build-libxml2)
1702 BUILD_LIBXML2=1
1703 ;;
1704 --build-libxslt)
1705 BUILD_LIBXSLT=1
1706 ;;
1707 --build-headless)
1708 HEADLESS=1
1709 WITH_SDL=0
1710 WITH_SDL_TTF=0
1711 WITH_X11=0
1712 WITH_QT=0
1713 WITH_QT4=0
1714 ;;
1715 --ose)
1716 OSE=2
1717 ;;
1718 --odir=*)
1719 ODIR="`echo $option | cut -d'=' -f2`/"
1720 ;;
1721 --setup-wine)
1722 SETUP_WINE=1
1723 ;;
1724 *)
1725 echo
1726 echo "Unrecognized option \"$option\""
1727 echo
1728 show_help
1729 ;;
1730 esac
1731done
1732
1733LOG="$ODIR$LOG"
1734ENV="$ODIR$ENV"
1735CNF="$ODIR$CNF"
1736
1737# initialize output files
1738cat > $LOG << EOF
1739# Log file generated by
1740#
1741# '$0 $*'
1742#
1743
1744EOF
1745cat > $CNF << EOF
1746# -*- Makefile -*-
1747#
1748# automatically generated by
1749#
1750# '$0 $*'
1751#
1752# It will be completely overwritten if configure is executed again.
1753#
1754
1755EOF
1756cat > $ENV << EOF
1757#!/bin/bash
1758#
1759# automatically generated by
1760#
1761# '$0 $*'
1762#
1763# It will be completely overwritten if configure is executed again.
1764# Make sure you source this file once before you start to build VBox.
1765#
1766
1767EOF
1768
1769# test if we are OSE
1770if [ $OSE -eq 1 -a -d "`cd \`dirname $0\`; pwd`/src/VBox/Devices/USB" ]; then
1771 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1772 echo >> $LOG
1773 OSE=0
1774fi
1775
1776if [ "$BUILD_TYPE" = "debug" ]; then
1777 echo "Creating DEBUG build!" >> $LOG
1778elif [ "$BUILD_TYPE" = "profile" ]; then
1779 echo "Creating PROFILE build!" >> $LOG
1780fi
1781
1782# first determine our environment
1783check_environment
1784check_kbuild
1785
1786# append the tools directory to the default search path
1787echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1788export PATH
1789
1790# some things are not available in for OSE
1791if [ $OSE -ge 1 ]; then
1792 cnf_append "VBOX_OSE" "1"
1793 cnf_append "VBOX_WITH_TESTSUITE" ""
1794 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1795
1796 if [ "$OS" = "linux" ]; then
1797 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1798 else
1799 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1800 fi
1801 echo >> $CNF
1802fi
1803
1804# headless
1805if [ -n "$HEADLESS" ]; then
1806 cnf_append "VBOX_HEADLESS" "1"
1807fi
1808
1809if [ "$OS" = "darwin" ]; then
1810 # On Darwin we want to build against Qt4 only. WITH_QT4 is enabled by
1811 # default so disable Qt3. --disable-qt disables both Qt3 and Qt4 GUI now,
1812 # --disable-qt4 disables only the Qt4 GUI (which is not appropriate for
1813 # Darwin as we disable the Qt3 here anyway.
1814 # (Qt3 builds for Intel Macs are usually not threaded or for X11. And they
1815 # don't contain our patches, which means the result isn't really usable.)
1816 WITH_QT=0
1817 # No Qt4 for OSE yet.
1818 [ $OSE -ge 1 ] && WITH_QT4=0
1819 BUILD_LIBXSLT=1
1820 BUILD_LIBXML2=1
1821fi
1822
1823# emit disable directives corresponding to any --disable-xxx options.
1824[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
1825[ $WITH_QT -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
1826[ $WITH_QT4 -eq 0 ] && cnf_append "VBOX_WITH_QT4GUI" ""
1827[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
1828
1829# the tools
1830check_gcc
1831[ "$OS" != "darwin" ] && check_as86
1832[ "$OS" != "darwin" ] && check_bcc
1833[ "$OS" != "darwin" ] && check_iasl
1834# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1835# [ "$OS" != "darwin" ] && check_yasm
1836[ "$OS" != "darwin" ] && check_xsltproc
1837[ $OSE -eq 0 -a "$OS" != "darwin" ] && check_mkisofs
1838
1839# the libraries
1840[ "$OS" != "darwin" ] && check_pthread
1841[ $WITH_XPCOM -eq 1 ] && check_libxml2
1842[ $WITH_XPCOM -eq 1 ] && check_libxslt
1843[ $WITH_LIBIDL -eq 1 ] && check_libidl
1844# build openssl on Darwin in every case
1845[ "$OS" != "darwin" -a $OSE -eq 0 ] && check_ssl
1846[ "$OS" != "darwin" ] && check_z
1847[ "$OS" != "darwin" ] && check_png
1848[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
1849[ $WITH_SDL -eq 1 ] && check_sdl
1850[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
1851[ $WITH_X11 -eq 1 ] && check_x
1852[ $WITH_X11 -eq 1 ] && check_xcursor
1853[ $WITH_QT -eq 1 ] && check_qt3
1854[ $WITH_QT4 -eq 1 ] && check_qt4
1855
1856# Linux-specific
1857if [ "$OS" = "linux" ]; then
1858 check_staticlibstdcxx
1859 if [ $WITH_KMODS -eq 1 ]; then
1860 check_linux
1861 else
1862 cnf_append "VBOX_LINUX_SRC" ""
1863 cnf_append "VBOX_WITH_VBOXDRV" ""
1864 cnf_append "VBOX_WITH_ADDITION_DRIVERS" ""
1865 fi
1866 if [ $WITH_ALSA -eq 1 ]; then
1867 check_alsa
1868 else
1869 cnf_append "VBOX_WITH_ALSA" ""
1870 fi
1871 if [ $WITH_PULSE -eq 1 ]; then
1872 check_pulse
1873 else
1874 cnf_append "VBOX_WITH_PULSE" ""
1875 fi
1876 check_compiler_h
1877 [ "$BUILD_MACHINE" = "amd64" ] && check_32bit
1878fi
1879
1880[ -n "$SETUP_WINE" ] && setup_wine
1881
1882# Darwin-specific
1883if [ "$OS" = "darwin" ]; then
1884 check_darwinversion
1885 check_i386elfgcc
1886fi
1887
1888# success!
1889echo
1890echo "Successfully generated '$CNF' and '$ENV'."
1891echo "Source '$ENV' once before you start to build VBox:"
1892echo ""
1893echo " source $ENV"
1894echo " kmk"
1895echo ""
1896if [ "$OS" = "linux" ]; then
1897 echo "To compile the kernel module, do:"
1898 echo ""
1899 echo " cd ./out/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
1900 echo " make"
1901 echo ""
1902fi
1903echo "Enjoy!"
1904cleanup
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