VirtualBox

source: vbox/trunk/configure@ 10688

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

configure: write Qt4 include path as well

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