VirtualBox

source: vbox/trunk/configure@ 10624

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

configure: removed superflous make variables

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