VirtualBox

source: vbox/trunk/configure@ 8051

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

configure: attempt to adapt the Qt4 detection to Darwin

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