VirtualBox

source: vbox/trunk/configure@ 9771

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

small fix

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