VirtualBox

source: vbox/trunk/configure@ 8061

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

configure: build the Qt4 GUI but not the Qt3 GUI on Darwin

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