VirtualBox

source: vbox/trunk/configure@ 9266

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

gcc-4.0 is allowed for Darwin only

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