VirtualBox

source: vbox/trunk/configure@ 9058

Last change on this file since 9058 was 9035, checked in by vboxsync, 17 years ago

configure: the SDL_ttf check is weak so make sure we don't need it if we don't find it

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