VirtualBox

source: vbox/trunk/configure@ 8564

Last change on this file since 8564 was 8551, checked in by vboxsync, 17 years ago

configure: fixed --disable-kmods

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 47.7 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 test_execute nofatal
1050 fi
1051}
1052
1053#
1054# Check for libasound, needed by the ALSA audio backend
1055#
1056check_alsa()
1057{
1058 test_header ALSA
1059 cat > .tmp_src.cc << EOF
1060#include <cstdio>
1061#include <alsa/asoundlib.h>
1062extern "C" int main(void)
1063{
1064 printf("found version %d.%d.%d",
1065 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
1066#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
1067 printf(", OK.\n");
1068 return 0;
1069#else
1070 printf(", expected version 1.0.6 or higher\n");
1071 return 1;
1072#endif
1073}
1074EOF
1075 if test_compile "-lasound" asound asound; then
1076 test_execute
1077 fi
1078}
1079
1080#
1081# Check for PulseAudio
1082#
1083check_pulse()
1084{
1085 test_header "PulseAudio"
1086 cat > .tmp_src.cc << EOF
1087#include <cstdio>
1088#include <pulse/version.h>
1089extern "C" int main(void)
1090{
1091 printf("found version %s API version %d", pa_get_headers_version(), PA_API_VERSION);
1092#if PA_API_VERSION >= 9
1093 printf(", OK.\n");
1094 return 0;
1095#else
1096 printf(", expected version 0.9.0 (API version 9) or higher\n");
1097 return 1;
1098#endif
1099}
1100EOF
1101 if test_compile "-lpulse" pulse pulse; then
1102 test_execute
1103 fi
1104}
1105
1106#
1107# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
1108#
1109check_xcursor()
1110{
1111 test_header Xcursor
1112 cat > .tmp_src.cc << EOF
1113#include <cstdio>
1114#include <X11/Xlib.h>
1115#include <X11/Xcursor/Xcursor.h>
1116extern "C" int main(void)
1117{
1118 XcursorImage *cursor = XcursorImageCreate (10, 10);
1119 XcursorImageDestroy(cursor);
1120 return 0;
1121}
1122EOF
1123 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1124 if test_compile "$LIBX11 $LIBXCURSOR $I_INCX11" Xcursor Xcursor; then
1125 log_success "found"
1126 cnf_append "VBOX_XCURSOR_LIBS" "`strip_l "$LIBXCURSOR"`"
1127 fi
1128}
1129
1130#
1131# Check for the X libraries (Xext, X11)
1132#
1133check_x()
1134{
1135 test_header "X libraries"
1136 cat > .tmp_src.cc << EOF
1137#include <cstdio>
1138#include <X11/Xlib.h>
1139extern "C" int main(void)
1140{
1141 Display *dpy;
1142 int scrn_num;
1143 Screen *scrn;
1144 Window win;
1145
1146 dpy = XOpenDisplay(NULL);
1147 scrn_num = DefaultScreen(dpy);
1148 scrn = ScreenOfDisplay(dpy, scrn_num);
1149 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
1150 0, 16, InputOutput, CopyFromParent, 0, NULL);
1151 XDestroyWindow(dpy, win);
1152}
1153EOF
1154 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1155 if test_compile "$LIBX11 $I_INCX11" Xlibs Xlibs; then
1156 log_success "found"
1157 fi
1158}
1159
1160#
1161# Check for the Qt3 library, needed by VirtualBox
1162#
1163check_qt3()
1164{
1165 test_header Qt3
1166 cat > .tmp_src.cc << EOF
1167#include <cstdio>
1168#include <qglobal.h>
1169extern "C" int main(void)
1170{
1171 printf("found version %s", QT_VERSION_STR);
1172#if QT_VERSION >= 0x030305
1173 printf(", OK.\n");
1174 return 0;
1175#elif QT_VERSION >= 0x030300
1176 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
1177#else
1178 printf(", expected version 3.3.0 or higher\n");
1179 return 1;
1180#endif
1181}
1182EOF
1183 found_qt=0
1184 libs="lib"
1185 [ "$LIB" = "lib64" ] && libs="$libs lib64"
1186 for q in $QT3DIR; do
1187 for l in $libs; do
1188 echo "compiling the following source file:" >> $LOG
1189 cat .tmp_src.cc >> $LOG
1190 echo "using the following command line:" >> $LOG
1191 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt $LIBPTHREAD" >> $LOG
1192 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt $LIBPTHREAD >> $LOG 2>&1
1193 if [ $? -eq 0 ]; then
1194 if test_execute; then
1195 cnf_append "QTDIR" "`cd $q ; pwd`"
1196 found_qt=1
1197 break
1198 fi
1199 fi
1200 done
1201 if [ $found_qt -eq 1 ]; then
1202 break
1203 fi
1204 done
1205 if [ $found_qt -ne 1 ]; then
1206 echo
1207 echo " Qt3 not found at \"$QT3DIR\" or Qt3 headers not found"
1208 echo " Check the file $LOG for detailed error information."
1209 fail
1210 return 1
1211 fi
1212 test_header "Qt3 devtools"
1213 if check_avail "$q/bin/moc" QT3DIR/bin; then
1214 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
1215 if [ $? -ne 0 ]; then
1216 log_failure "not found"
1217 fail
1218 else
1219 log_success "found version $moc_ver"
1220 fi
1221 fi
1222}
1223
1224#
1225# Check for the Qt4 library, needed by VirtualBox4
1226#
1227# Currently not fatal.
1228#
1229check_qt4()
1230{
1231 test_header Qt4
1232 if [ "$OS" = "darwin" ]; then
1233 if [ -f "/System/Library/Frameworks/QtCore.framework/QtCore" ]; then
1234 PATH_SDK_QT4="/System/Library/Framework/QtCore.framework"
1235 elif [ -f "/Library/Frameworks/QtCore.framework/QtCore" ]; then
1236 PATH_SDK_QT4="/Library/Frameworks/QtCore.framework"
1237 fi
1238 if [ -n "$PATH_SDK_QT4" ]; then
1239 foundqt4=1
1240 INCQT4="$PATH_SDK_QT4/Headers"
1241 LIBQT4=
1242 FLDQT4="-framework QtCore"
1243 else
1244 log_failure "Qt4 framework not found"
1245 fail
1246 fi
1247 else
1248 if which_wrapper pkg-config > /dev/null; then
1249 qt4_ver=`pkg-config QtCore --modversion 2>> $LOG`
1250 if [ $? -ne 0 ]; then
1251 log_failure "not found"
1252 # fail
1253 else
1254 FLGQT4=`pkg-config QtCore --cflags`
1255 INCQT4=`strip_I "$FLGQT4"`
1256 LIBQT4=`pkg-config QtCore --libs`
1257 foundqt4=1
1258 fi
1259 else
1260 log_failure "pkg-config not found"
1261# not yet
1262# fail
1263 fi
1264 fi
1265 if [ -n "$foundqt4" ]; then
1266 cat > .tmp_src.cc << EOF
1267#include <cstdio>
1268#include <QtGlobal>
1269extern "C" int main(void)
1270{
1271 printf("found version %s", QT_VERSION_STR);
1272#if QT_VERSION >= 0x040200
1273 printf(", OK.\n");
1274 return 0;
1275 printf(", expected version 4.2.0 or higher\n");
1276 return 1;
1277#endif
1278}
1279EOF
1280 [ -n "$INCQT4" ] && I_INCQT4=`prefix_I "$INCQT4"`
1281 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4 $FLDQT4" qt4 qt4 nofatal; then
1282 if test_execute; then
1283# cnf_append "SDK_VBOX_LIBQT4_INCS" "$INCQT4"
1284# cnf_append "SDK_VBOX_LIBQT4_LIBS" "`strip_l "$LIBQT4"`"
1285 if [ "$OS" = "darwin" ]; then
1286 cnf_append "VBOX_WITH_QT4GUI" "1"
1287 else
1288 test_header "Qt4 devtools"
1289 for q in $QT4DIR; do
1290 if which_wrapper "$q/bin/moc" > /dev/null; then
1291 moc_ver=`$q/bin/moc -v 2>&1|sed 's+^.*(Qt \(.*\))+\1+'`
1292 if [ $? -ne 0 ]; then
1293 log_failure "not found"
1294 fail
1295 else
1296 log_success "found version $moc_ver"
1297 cnf_append "VBOX_PATH_QT4" "$q"
1298 test_header "Qt4 uic3"
1299 for r in $q/bin $QT4UIC3DIR; do
1300 if which_wrapper "$r/uic3" > /dev/null; then
1301 uic3_ver=`$r/uic3 -version 2>&1|sed 's+^.*version \(.*\)+\1+'`
1302 if [ $? -ne 0 ]; then
1303 log_failure "not found"
1304 fail
1305 else
1306 log_success "found version $uic3_ver"
1307 cnf_append "VBOX_UIC3" "$r/uic3"
1308 return
1309 fi
1310 fi
1311 done
1312 log_failure "not found"
1313 fail
1314 fi
1315 fi
1316 done
1317 fi
1318 fi
1319 else
1320 log_failure "not found"
1321 fail
1322 fi
1323 fi
1324}
1325
1326
1327#
1328# Check whether static libstdc++ is installed
1329#
1330check_staticlibstdcxx()
1331{
1332 test_header "static stc++ library"
1333 libstdcxx=`$CXX -print-file-name=libstdc++.a`
1334 cat > .tmp_src.cc << EOF
1335#include <string>
1336
1337extern "C" int main(void)
1338{
1339 std::string s = "test";
1340 return 0;
1341}
1342EOF
1343 if test_compile "$libstdcxx" libstdc++ libstdc++; then
1344 log_success "found"
1345 fi
1346}
1347
1348#
1349# Check for Linux sources
1350#
1351check_linux()
1352{
1353 test_header "Linux kernel sources"
1354 cat > .tmp_src.c << EOF
1355#include <linux/version.h>
1356int printf(const char *format, ...);
1357int main(void)
1358{
1359 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1360 (LINUX_VERSION_CODE % 65536) / 256,
1361 LINUX_VERSION_CODE % 256);
1362#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1363 printf(", OK.\n");
1364 return 0;
1365#else
1366 printf(", expected version 2.4.0 or higher\n");
1367 return 1;
1368#endif
1369}
1370EOF
1371 echo "compiling the following source file:" >> $LOG
1372 cat .tmp_src.c >> $LOG
1373 echo "using the following command line:" >> $LOG
1374 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
1375 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
1376 if [ $? -ne 0 ]; then
1377 echo
1378 echo " Linux kernel headers not found at $LINUX"
1379 echo " Check the file $LOG for detailed error information."
1380 fail
1381 else
1382 if test_execute; then
1383 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1384 fi
1385 fi
1386}
1387
1388#
1389# Check for kchmviewer, needed to display the online help
1390#
1391check_kchmviewer()
1392{
1393 test_header kchmviewer
1394 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1395 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1396 if [ $? -ne 0 ]; then
1397 log_failure "not found"
1398 fail
1399 else
1400 log_success "found version $kchmviewer_ver"
1401 fi
1402 fi
1403}
1404
1405#
1406# Check for the kBuild tools, we don't support GNU make
1407#
1408check_kbuild()
1409{
1410 test_header kBuild
1411 if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
1412 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
1413 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1414 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1415 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1416 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1417 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1418 if [ "$OS" = "solaris" ]; then
1419 # Because of sh being non-default shell in Solaris we need to export PATH again when
1420 # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
1421 echo "PATH=\"$ORGPATH\"" >> $ENV
1422 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1423 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1424 else
1425 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1426 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1427 fi
1428 echo "export PATH" >> $ENV
1429 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1430 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1431 elif check_avail "kmk" KBUILDDIR really; then
1432 # check for installed kBuild
1433 KBUILD_SED="`which_wrapper kmk_sed`"
1434 else
1435 fail
1436 fi
1437 log_success "found"
1438}
1439
1440
1441#
1442# Check for compiler.h
1443# Some Linux distributions include "compiler.h" in their libc linux
1444# headers package, some don't. Most don't need it, building might (!)
1445# not succeed on openSUSE without it.
1446#
1447# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1448#
1449check_compiler_h()
1450{
1451 test_header compiler.h
1452 if ! test -f "/usr/include/linux/compiler.h"; then
1453 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1454 log_success "compiler.h not found"
1455 else
1456 log_success "compiler.h found"
1457 fi
1458}
1459
1460
1461#
1462# Check if we are able to build 32-bit applications (needed for the guest additions)
1463#
1464check_32bit()
1465{
1466 test_header "32-bit support"
1467 cat > .tmp_src.c << EOF
1468#include <stdint.h>
1469int main(void)
1470{
1471 return 0;
1472}
1473EOF
1474 echo "compiling the following source file:" >> $LOG
1475 cat .tmp_src.c >> $LOG
1476 echo "using the following command line:" >> $LOG
1477 echo "$CC -m32 -O -Wall -o .tmp_out .tmp_src.c" >> $LOG
1478 $CC -m32 -O -Wall -o .tmp_out .tmp_src.c >> $LOG 2>&1
1479 if [ $? -ne 0 ]; then
1480 echo
1481 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1482 echo " Check the file $LOG for detailed error information."
1483 fail
1484 fi
1485 log_success ""
1486}
1487
1488#
1489# Setup wine
1490#
1491setup_wine()
1492{
1493 test_header "Wine support"
1494 if ! which_wrapper wine > /dev/null; then
1495 echo " wine binary not found"
1496 fail
1497 fi
1498 if ! which_wrapper wineprefixcreate > /dev/null; then
1499 echo " wineprefixcreate not found"
1500 fail
1501 fi
1502 export WINEPREFIX="${ODIR}wine.$BUILD_MACHINE"
1503 echo "export WINEPREFIX=\"${ODIR}wine.$BUILD_MACHINE\"" >> $ENV
1504 rm -rf $WINEPREFIX
1505 mkdir -p $WINEPREFIX
1506 touch $WINEPREFIX/.no_prelaunch_window_flag
1507 if ! wineprefixcreate -q > /dev/null 2>&1; then
1508 echo " wineprefixcreate failed"
1509 fail
1510 fi
1511 tmp=.tmp.wine.reg
1512 rm -f $tmp
1513 echo 'REGEDIT4' > $tmp
1514 echo '' >> $tmp
1515 echo '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]' >> $tmp
1516 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
1517 echo '' >> $tmp
1518 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhc.exe\DllOverrides]' >> $tmp
1519 echo '"itss"="native"' >> $tmp
1520 echo '' >> $tmp
1521 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhw.exe\DllOverrides]' >> $tmp
1522 echo '"itss"="native"' >> $tmp
1523 echo '' >> $tmp
1524 if ! wine regedit $tmp > /dev/null 2>&1; then
1525 rm -f $tmp
1526 echo " failed to load registry changes (path)."
1527 fail
1528 fi
1529 rm -f $tmp
1530 log_success "found"
1531}
1532
1533
1534#
1535# Determines the Darwin version.
1536# @todo This should really check the Xcode/SDK version.
1537#
1538check_darwinversion()
1539{
1540 test_header "Darwin version"
1541 darwin_ver=`uname -r`
1542 case "$darwin_ver" in
1543 9\.*)
1544 darwin_ver="10.5"
1545 cnf_append "VBOX_TARGET_MAC_OS_X_VERSION_10_5" "1"
1546 ;;
1547 8\.*)
1548 darwin_ver="10.5"
1549 ;;
1550 *)
1551 echo " failed to determin darwin version. (uname -r: $darwin_ver)"
1552 fail
1553 darwin_ver="unknown"
1554 ;;
1555 esac
1556 log_success "found version $darwin_ver"
1557}
1558
1559
1560#
1561# Checks that i386-elf-gcc-3.4.6, i386-elf-gcc-3.4.3, i386-elf-gcc-3.4 or i386-elf-gcc
1562# is around to prevent confusion when the build fails in src/recompiler.
1563# Note. Keep the which order in sync with the $(which ) in src/recompiler/Makefile.kmk.
1564#
1565check_i386elfgcc()
1566{
1567 test_header "i386-elf-gcc"
1568 i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.6`
1569 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4.3`
1570 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc-3.4`
1571 test -z "$i386_elf_gcc" && i386_elf_gcc=`which_wrapper i386-elf-gcc`
1572 if test -z "$i386_elf_gcc"; then
1573 echo " failed to find i386-elf-gcc"
1574 fail
1575 fi
1576 log_success "found $i386_elf_gcc"
1577}
1578
1579
1580#
1581# Show help
1582#
1583show_help()
1584{
1585 cat << EOF
1586Usage: ./configure [OPTIONS]...
1587
1588Configuration:
1589 -h, --help display this help and exit
1590 --nofatal don't abort on errors
1591 --disable-xpcom disable XPCOM and related stuff
1592 --disable-sdl-ttf disable SDL_ttf detection
1593 --disable-alsa disable the ALSA sound backend
1594 --disable-pulse disable the PulseAudio backend
1595 --disable-kmods don't build Linux kernel modules (host and guest)
1596 --build-libxml2 build libxml2 from sources
1597 --build-libxslt build libxslt from sources (not OSE!)
1598 --setup-wine setup a Wine directory and register the hhc hack
1599
1600Paths:
1601 --with-gcc=PATH location of the gcc compiler [$CC]
1602 --with-g++=PATH location of the g++ compiler [$CXX]
1603 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1604 --with-iasl=PATH location of the iasl compiler [$IASL]
1605 --with-linux=DIR Linux kernel source directory [$LINUX]
1606 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1607 --with-qt-dir=DIR directory for Qt3 headers/libraries [$QT3DIR]
1608 --with-qt4-dir=DIR directory for Qt4 headers/libraries [$QT4DIR]
1609
1610Build type:
1611 -d, --build-debug build with debugging symbols and assertions
1612 --build-profile build with profiling support
1613 --build-headless build headless (without any X11 frontend)
1614EOF
1615 exit 0
1616}
1617
1618
1619#
1620# The body.
1621#
1622
1623# scan command line options
1624for option in $*; do
1625 case "$option" in
1626 --help|-help|-h)
1627 show_help
1628 ;;
1629 --nofatal)
1630 nofatal=1
1631 ;;
1632 --with-gcc=*)
1633 CC=`echo $option | cut -d'=' -f2`
1634 ;;
1635 --with-g++=*)
1636 CXX=`echo $option | cut -d'=' -f2`
1637 ;;
1638 --with-gcc-compat=*)
1639 CC_COMPAT=`echo $option | cut -d'=' -f2`
1640 ;;
1641 --with-kbuild=*)
1642 KBUILDDIR=`echo $option | cut -d'=' -f2`
1643 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1644 echo "Error: KBUILDDIR contains invalid characters!"
1645 exit 1
1646 fi
1647 ;;
1648 --with-qt-dir=*)
1649 QT3DIR=`echo $option | cut -d'=' -f2`
1650 ;;
1651 --with-qt4-dir=*)
1652 QT4DIR=`echo $option | cut -d'=' -f2`
1653 ;;
1654 --with-iasl=*)
1655 IASL=`echo $option | cut -d'=' -f2`
1656 ;;
1657 --with-linux=*)
1658 LINUX=`echo $option | cut -d'=' -f2`
1659 ;;
1660 --with-mkisofs=*)
1661 MKISOFS=`echo $option | cut -d'=' -f2`
1662 ;;
1663 --disable-xpcom)
1664 WITH_XPCOM=0
1665 ;;
1666 --disable-sdl-ttf)
1667 WITH_SDL_TTF=0
1668 ;;
1669 --disable-qt)
1670 WITH_QT=0
1671 WITH_QT4=0
1672 ;;
1673 --disable-qt4)
1674 WITH_QT4=0
1675 ;;
1676 --disable-alsa)
1677 WITH_ALSA=0
1678 ;;
1679 --disable-pulse)
1680 WITH_PULSE=0
1681 ;;
1682 --disable-kmods)
1683 WITH_KMODS=0
1684 ;;
1685 --build-debug|-d)
1686 BUILD_TYPE=debug
1687 ;;
1688 --build-profile)
1689 BUILD_TYPE=profile
1690 ;;
1691 --build-libxml2)
1692 BUILD_LIBXML2=1
1693 ;;
1694 --build-libxslt)
1695 BUILD_LIBXSLT=1
1696 ;;
1697 --build-headless)
1698 HEADLESS=1
1699 WITH_SDL=0
1700 WITH_SDL_TTF=0
1701 WITH_X11=0
1702 WITH_QT=0
1703 WITH_QT4=0
1704 ;;
1705 --ose)
1706 OSE=2
1707 ;;
1708 --odir=*)
1709 ODIR="`echo $option | cut -d'=' -f2`/"
1710 ;;
1711 --setup-wine)
1712 SETUP_WINE=1
1713 ;;
1714 *)
1715 echo
1716 echo "Unrecognized option \"$option\""
1717 echo
1718 show_help
1719 ;;
1720 esac
1721done
1722
1723LOG="$ODIR$LOG"
1724ENV="$ODIR$ENV"
1725CNF="$ODIR$CNF"
1726
1727# initialize output files
1728cat > $LOG << EOF
1729# Log file generated by
1730#
1731# '$0 $*'
1732#
1733
1734EOF
1735cat > $CNF << EOF
1736# -*- Makefile -*-
1737#
1738# automatically generated by
1739#
1740# '$0 $*'
1741#
1742# It will be completely overwritten if configure is executed again.
1743#
1744
1745EOF
1746cat > $ENV << EOF
1747#!/bin/bash
1748#
1749# automatically generated by
1750#
1751# '$0 $*'
1752#
1753# It will be completely overwritten if configure is executed again.
1754# Make sure you source this file once before you start to build VBox.
1755#
1756
1757EOF
1758
1759# test if we are OSE
1760if [ $OSE -eq 1 -a -d "`cd \`dirname $0\`; pwd`/src/VBox/Devices/USB" ]; then
1761 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1762 echo >> $LOG
1763 OSE=0
1764fi
1765
1766if [ "$BUILD_TYPE" = "debug" ]; then
1767 echo "Creating DEBUG build!" >> $LOG
1768elif [ "$BUILD_TYPE" = "profile" ]; then
1769 echo "Creating PROFILE build!" >> $LOG
1770fi
1771
1772# first determine our environment
1773check_environment
1774check_kbuild
1775
1776# append the tools directory to the default search path
1777echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1778export PATH
1779
1780# some things are not available in for OSE
1781if [ $OSE -ge 1 ]; then
1782 cnf_append "VBOX_OSE" "1"
1783 cnf_append "VBOX_WITH_TESTSUITE" ""
1784 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1785
1786 if [ "$OS" = "linux" ]; then
1787 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1788 else
1789 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1790 fi
1791 echo >> $CNF
1792fi
1793
1794# headless
1795if [ -n "$HEADLESS" ]; then
1796 cnf_append "VBOX_HEADLESS" "1"
1797fi
1798
1799if [ "$OS" = "darwin" ]; then
1800 # On Darwin we want to build against Qt4 only. WITH_QT4 is enabled by
1801 # default so disable Qt3. --disable-qt disables both Qt3 and Qt4 GUI now,
1802 # --disable-qt4 disables only the Qt4 GUI (which is not appropriate for
1803 # Darwin as we disable the Qt3 here anyway.
1804 # (Qt3 builds for Intel Macs are usually not threaded or for X11. And they
1805 # don't contain our patches, which means the result isn't really usable.)
1806 WITH_QT=0
1807 # No Qt4 for OSE yet.
1808 [ $OSE -ge 1 ] && WITH_QT4=0
1809 BUILD_LIBXSLT=1
1810 BUILD_LIBXML2=1
1811fi
1812
1813# emit disable directives corresponding to any --disable-xxx options.
1814[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
1815[ $WITH_QT -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
1816[ $WITH_QT4 -eq 0 ] && cnf_append "VBOX_WITH_QT4GUI" ""
1817[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
1818
1819# the tools
1820check_gcc
1821[ "$OS" != "darwin" ] && check_as86
1822[ "$OS" != "darwin" ] && check_bcc
1823[ "$OS" != "darwin" ] && check_iasl
1824# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1825# [ "$OS" != "darwin" ] && check_yasm
1826[ "$OS" != "darwin" ] && check_xsltproc
1827[ $OSE -eq 0 -a "$OS" != "darwin" ] && check_mkisofs
1828
1829# the libraries
1830[ "$OS" != "darwin" ] && check_pthread
1831[ $WITH_XPCOM -eq 1 ] && check_libxml2
1832[ $WITH_XPCOM -eq 1 ] && check_libxslt
1833[ $WITH_LIBIDL -eq 1 ] && check_libidl
1834# build openssl on Darwin in every case
1835[ "$OS" != "darwin" -a $OSE -eq 0 ] && check_ssl
1836[ "$OS" != "darwin" ] && check_z
1837[ "$OS" != "darwin" ] && check_png
1838[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
1839[ $WITH_SDL -eq 1 ] && check_sdl
1840[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
1841[ $WITH_X11 -eq 1 ] && check_x
1842[ $WITH_X11 -eq 1 ] && check_xcursor
1843[ $WITH_QT -eq 1 ] && check_qt3
1844[ $WITH_QT4 -eq 1 ] && check_qt4
1845
1846# Linux-specific
1847if [ "$OS" = "linux" ]; then
1848 check_staticlibstdcxx
1849 if [ $WITH_KMODS -eq 1 ]; then
1850 check_linux
1851 else
1852 cnf_append "VBOX_LINUX_SRC" ""
1853 cnf_append "VBOX_WITH_VBOXDRV" ""
1854 cnf_append "VBOX_WITH_ADDITION_DRIVERS" ""
1855 fi
1856 if [ $WITH_ALSA -eq 1 ]; then
1857 check_alsa
1858 else
1859 cnf_append "VBOX_WITH_ALSA" ""
1860 fi
1861 if [ $WITH_PULSE -eq 1 ]; then
1862 check_pulse
1863 else
1864 cnf_append "VBOX_WITH_PULSE" ""
1865 fi
1866 check_compiler_h
1867 [ "$BUILD_MACHINE" = "amd64" ] && check_32bit
1868fi
1869
1870[ -n "$SETUP_WINE" ] && setup_wine
1871
1872# Darwin-specific
1873if [ "$OS" = "darwin" ]; then
1874 check_darwinversion
1875 check_i386elfgcc
1876fi
1877
1878# success!
1879echo
1880echo "Successfully generated '$CNF' and '$ENV'."
1881echo "Source '$ENV' once before you start to build VBox:"
1882echo ""
1883echo " source $ENV"
1884echo " kmk"
1885echo ""
1886if [ "$OS" = "linux" ]; then
1887 echo "To compile the kernel module, do:"
1888 echo ""
1889 echo " cd ./out/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
1890 echo " make"
1891 echo ""
1892fi
1893echo "Enjoy!"
1894cleanup
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