VirtualBox

source: vbox/trunk/configure@ 8018

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

configure: added --disable-alsa switch

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 42.6 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 which_wrapper sdl-config > /dev/null; then
912 FLGSDL=`sdl-config --cflags`
913 INCSDL=`strip_I "$FLGSDL"`
914 LIBSDL=`sdl-config --libs`
915 LIBSDLMAIN="-lSDLmain"
916 [ "$OS" = "linux" -o "$OS" = "darwin" -o "$OS" = "solaris" ] && LIBSDLMAIN=""
917 cat > .tmp_src.cc << EOF
918#include <cstdio>
919#include <SDL.h>
920#include <SDL_main.h>
921extern "C" int main(int argc, char** argv)
922{
923 printf("found version %d.%d.%d",
924 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
925#if SDL_VERSION_ATLEAST(1,2,7)
926 printf(", OK.\n");
927 return 0;
928#else
929 printf(", expected version 1.2.7 or higher\n");
930 return 1;
931#endif
932}
933EOF
934 [ -n "$INCSDL" ] && I_INCSDL=`prefix_I "$INCSDL"`
935 if test_compile "$LIBSDL $LIBSDLMAIN $I_INCSDL" SDL SDL; then
936 if test_execute; then
937 cnf_append "LIB_SDK_LIBSDL_SDL" "`strip_l "$LIBSDL"`"
938 cnf_append "SDK_LIBSDL_LIBPATH" "`strip_L "$LIBSDL"`"
939 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
940 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
941 fi
942 fi
943 else
944 log_failure "not found"
945 fail
946 fi
947}
948
949#
950# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
951#
952check_sdl_ttf()
953{
954 test_header SDL_ttf
955 cat > .tmp_src.cc << EOF
956#include <cstdio>
957#include <SDL_ttf.h>
958#ifndef SDL_TTF_MAJOR_VERSION
959#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
960#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
961#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
962#endif
963extern "C" int main(void)
964{
965 printf("found version %d.%d.%d",
966 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
967#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
968 printf(", OK.\n");
969 return 0;
970#else
971 printf(", expected version 2.0.6 or higher\n");
972 return 1;
973#endif
974}
975EOF
976 if test_compile "-lSDL_ttf $I_INCSDL" SDL_ttf SDL_ttf; then
977 test_execute
978 fi
979}
980
981#
982# Check for libasound, needed by the ALSA audio backend
983#
984check_alsa()
985{
986 test_header ALSA
987 cat > .tmp_src.cc << EOF
988#include <cstdio>
989#include <alsa/asoundlib.h>
990extern "C" int main(void)
991{
992 printf("found version %d.%d.%d",
993 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
994#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
995 printf(", OK.\n");
996 return 0;
997#else
998 printf(", expected version 1.0.6 or higher\n");
999 return 1;
1000#endif
1001}
1002EOF
1003 if test_compile "-lasound" asound asound; then
1004 test_execute
1005 fi
1006}
1007
1008#
1009# Check for PulseAudio
1010#
1011check_pulse()
1012{
1013 test_header "PulseAudio"
1014 cat > .tmp_src.cc << EOF
1015#include <cstdio>
1016#include <pulse/version.h>
1017extern "C" int main(void)
1018{
1019 printf("found version %s API version %d", pa_get_headers_version(), PA_API_VERSION);
1020#if PA_API_VERSION >= 9
1021 printf(", OK.\n");
1022 return 0;
1023#else
1024 printf(", expected version 0.9.0 (API version 9) or higher\n");
1025 return 1;
1026#endif
1027}
1028EOF
1029 if test_compile "-lpulse" pulse pulse; then
1030 test_execute
1031 fi
1032}
1033
1034#
1035# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
1036#
1037check_xcursor()
1038{
1039 test_header Xcursor
1040 cat > .tmp_src.cc << EOF
1041#include <cstdio>
1042#include <X11/Xlib.h>
1043#include <X11/Xcursor/Xcursor.h>
1044extern "C" int main(void)
1045{
1046 XcursorImage *cursor = XcursorImageCreate (10, 10);
1047 XcursorImageDestroy(cursor);
1048 return 0;
1049}
1050EOF
1051 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1052 if test_compile "$LIBX11 $LIBXCURSOR $I_INCX11" Xcursor Xcursor; then
1053 log_success "found"
1054 cnf_append "VBOX_XCURSOR_LIBS" "`strip_l "$LIBXCURSOR"`"
1055 fi
1056}
1057
1058#
1059# Check for the X libraries (Xext, X11)
1060#
1061check_x()
1062{
1063 test_header "X libraries"
1064 cat > .tmp_src.cc << EOF
1065#include <cstdio>
1066#include <X11/Xlib.h>
1067extern "C" int main(void)
1068{
1069 Display *dpy;
1070 int scrn_num;
1071 Screen *scrn;
1072 Window win;
1073
1074 dpy = XOpenDisplay(NULL);
1075 scrn_num = DefaultScreen(dpy);
1076 scrn = ScreenOfDisplay(dpy, scrn_num);
1077 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
1078 0, 16, InputOutput, CopyFromParent, 0, NULL);
1079 XDestroyWindow(dpy, win);
1080}
1081EOF
1082 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1083 if test_compile "$LIBX11 $I_INCX11" Xlibs Xlibs; then
1084 log_success "found"
1085 fi
1086}
1087
1088#
1089# Check for the Qt3 library, needed by VirtualBox
1090#
1091check_qt3()
1092{
1093 test_header Qt3
1094 cat > .tmp_src.cc << EOF
1095#include <cstdio>
1096#include <qglobal.h>
1097extern "C" int main(void)
1098{
1099 printf("found version %s", QT_VERSION_STR);
1100#if QT_VERSION >= 0x030305
1101 printf(", OK.\n");
1102 return 0;
1103#elif QT_VERSION >= 0x030300
1104 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
1105#else
1106 printf(", expected version 3.3.0 or higher\n");
1107 return 1;
1108#endif
1109}
1110EOF
1111 found_qt=0
1112 libs="lib"
1113 [ "$LIB" = "lib64" ] && libs="$libs lib64"
1114 for q in $QT3DIR; do
1115 for l in $libs; do
1116 echo "compiling the following source file:" >> $LOG
1117 cat .tmp_src.cc >> $LOG
1118 echo "using the following command line:" >> $LOG
1119 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt $LIBPTHREAD" >> $LOG
1120 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt $LIBPTHREAD >> $LOG 2>&1
1121 if [ $? -eq 0 ]; then
1122 if test_execute; then
1123 cnf_append "QTDIR" "`cd $q ; pwd`"
1124 found_qt=1
1125 break
1126 fi
1127 fi
1128 done
1129 if [ $found_qt -eq 1 ]; then
1130 break
1131 fi
1132 done
1133 if [ $found_qt -ne 1 ]; then
1134 echo
1135 echo " Qt3 not found at \"$QT3DIR\" or Qt3 headers not found"
1136 echo " Check the file $LOG for detailed error information."
1137 fail
1138 return 1
1139 fi
1140 test_header "Qt3 devtools"
1141 if check_avail "$q/bin/moc" QT3DIR/bin; then
1142 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
1143 if [ $? -ne 0 ]; then
1144 log_failure "not found"
1145 fail
1146 else
1147 log_success "found version $moc_ver"
1148 fi
1149 fi
1150}
1151
1152#
1153# Check for the Qt4 library, needed by VirtualBox4
1154#
1155# Currently not fatal.
1156#
1157check_qt4()
1158{
1159 test_header Qt4
1160 if which_wrapper pkg-config > /dev/null; then
1161 qt4_ver=`pkg-config QtGui --modversion 2>> $LOG`
1162 if [ $? -ne 0 ]; then
1163 log_failure "not found"
1164# fail
1165 else
1166 FLGQT4=`pkg-config QtGui --cflags`
1167 INCQT4=`strip_I "$FLGQT4"`
1168 LIBQT4=`pkg-config QtGui --libs`
1169 cat > .tmp_src.cc << EOF
1170#include <cstdio>
1171#include <Qt/qglobal.h>
1172extern "C" int main(void)
1173{
1174 printf("found version %s", QT_VERSION_STR);
1175#if QT_VERSION >= 0x040200
1176 printf(", OK.\n");
1177 return 0;
1178 printf(", expected version 4.2.0 or higher\n");
1179 return 1;
1180#endif
1181}
1182EOF
1183 [ -n "$INCQT4" ] && I_INCQT4=`prefix_I "$INCQT4"`
1184 if test_compile "$LIBQT4 $LIBPTHREAD $I_INCQT4" qt4 qt4 nofatal; then
1185 if test_execute; then
1186# cnf_append "SDK_VBOX_LIBQT4_INCS" "$INCQT4"
1187# cnf_append "SDK_VBOX_LIBQT4_LIBS" "`strip_l "$LIBQT4"`"
1188 test_header "Qt4 devtools"
1189 for q in $QT4DIR; do
1190 if which_wrapper "$q/bin/moc" > /dev/null; then
1191 moc_ver=`$q/bin/moc -v 2>&1|sed 's+^.*(Qt \(.*\))+\1+'`
1192 if [ $? -ne 0 ]; then
1193 log_failure "not found"
1194 fail
1195 else
1196 log_success "found version $moc_ver"
1197 cnf_append "VBOX_PATH_QT4" "$q"
1198 test_header "Qt4 uic3"
1199 for r in $q/bin $QT4UIC3DIR; do
1200 if which_wrapper "$r/uic3" > /dev/null; then
1201 uic3_ver=`$r/uic3 -version 2>&1|sed 's+^.*version \(.*\)+\1+'`
1202 if [ $? -ne 0 ]; then
1203 log_failure "not found"
1204 fail
1205 else
1206 log_success "found version $uic3_ver"
1207 cnf_append "VBOX_UIC3" "$r/uic3"
1208 return
1209 fi
1210 fi
1211 done
1212 log_failure "not found"
1213 fail
1214 fi
1215 fi
1216 done
1217 fi
1218 log_failure "not found"
1219 fail
1220 fi
1221 fi
1222 else
1223 log_failure "pkg-config not found"
1224# not yet
1225# fail
1226 fi
1227}
1228
1229
1230#
1231# Check whether static libstdc++ is installed
1232#
1233check_staticlibstdcxx()
1234{
1235 test_header "static stc++ library"
1236 libstdcxx=`$CXX -print-file-name=libstdc++.a`
1237 cat > .tmp_src.cc << EOF
1238#include <string>
1239
1240extern "C" int main(void)
1241{
1242 std::string s = "test";
1243 return 0;
1244}
1245EOF
1246 if test_compile "$libstdcxx" libstdc++ libstdc++; then
1247 log_success "found"
1248 fi
1249}
1250
1251#
1252# Check for Linux sources
1253#
1254check_linux()
1255{
1256 test_header "Linux kernel sources"
1257 cat > .tmp_src.c << EOF
1258#include <linux/version.h>
1259int printf(const char *format, ...);
1260int main(void)
1261{
1262 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1263 (LINUX_VERSION_CODE % 65536) / 256,
1264 LINUX_VERSION_CODE % 256);
1265#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1266 printf(", OK.\n");
1267 return 0;
1268#else
1269 printf(", expected version 2.4.0 or higher\n");
1270 return 1;
1271#endif
1272}
1273EOF
1274 echo "compiling the following source file:" >> $LOG
1275 cat .tmp_src.c >> $LOG
1276 echo "using the following command line:" >> $LOG
1277 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
1278 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
1279 if [ $? -ne 0 ]; then
1280 echo
1281 echo " Linux kernel headers not found at $LINUX"
1282 echo " Check the file $LOG for detailed error information."
1283 fail
1284 else
1285 if test_execute; then
1286 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1287 fi
1288 fi
1289}
1290
1291#
1292# Check for kchmviewer, needed to display the online help
1293#
1294check_kchmviewer()
1295{
1296 test_header kchmviewer
1297 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1298 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1299 if [ $? -ne 0 ]; then
1300 log_failure "not found"
1301 fail
1302 else
1303 log_success "found version $kchmviewer_ver"
1304 fi
1305 fi
1306}
1307
1308#
1309# Check for the kBuild tools, we don't support GNU make
1310#
1311check_kbuild()
1312{
1313 test_header kBuild
1314 if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
1315 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
1316 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1317 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1318 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1319 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1320 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1321 if [ "$OS" = "solaris" ]; then
1322 # Because of sh being non-default shell in Solaris we need to export PATH again when
1323 # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
1324 echo "PATH=\"$ORGPATH\"" >> $ENV
1325 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1326 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1327 else
1328 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1329 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1330 fi
1331 echo "export PATH" >> $ENV
1332 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1333 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1334 elif check_avail "kmk" KBUILDDIR really; then
1335 # check for installed kBuild
1336 KBUILD_SED="`which_wrapper kmk_sed`"
1337 else
1338 fail
1339 fi
1340 log_success "found"
1341}
1342
1343
1344#
1345# Check for compiler.h
1346# Some Linux distributions include "compiler.h" in their libc linux
1347# headers package, some don't. Most don't need it, building might (!)
1348# not succeed on openSUSE without it.
1349#
1350# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1351#
1352check_compiler_h()
1353{
1354 test_header compiler.h
1355 if ! test -f "/usr/include/linux/compiler.h"; then
1356 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1357 log_success "compiler.h not found"
1358 else
1359 log_success "compiler.h found"
1360 fi
1361}
1362
1363
1364#
1365# Check if we are able to build 32-bit applications (needed for the guest additions)
1366#
1367check_32bit()
1368{
1369 test_header "32-bit support"
1370 cat > .tmp_src.c << EOF
1371#include <stdint.h>
1372int main(void)
1373{
1374 return 0;
1375}
1376EOF
1377 echo "compiling the following source file:" >> $LOG
1378 cat .tmp_src.c >> $LOG
1379 echo "using the following command line:" >> $LOG
1380 echo "$CC -m32 -O -Wall -o .tmp_out .tmp_src.c" >> $LOG
1381 $CC -m32 -O -Wall -o .tmp_out .tmp_src.c >> $LOG 2>&1
1382 if [ $? -ne 0 ]; then
1383 echo
1384 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1385 echo " Check the file $LOG for detailed error information."
1386 fail
1387 fi
1388 log_success ""
1389}
1390
1391#
1392# Setup wine
1393#
1394setup_wine()
1395{
1396 test_header "Wine support"
1397 if ! which_wrapper wine > /dev/null; then
1398 echo " wine binary not found"
1399 fail
1400 fi
1401 if ! which_wrapper wineprefixcreate > /dev/null; then
1402 echo " wineprefixcreate not found"
1403 fail
1404 fi
1405 export WINEPREFIX="${ODIR}wine.$BUILD_MACHINE"
1406 echo "export WINEPREFIX=\"${ODIR}wine.$BUILD_MACHINE\"" >> $ENV
1407 rm -rf $WINEPREFIX
1408 mkdir -p $WINEPREFIX
1409 touch $WINEPREFIX/.no_prelaunch_window_flag
1410 if ! wineprefixcreate -q > /dev/null 2>&1; then
1411 echo " wineprefixcreate failed"
1412 fail
1413 fi
1414 tmp=.tmp.wine.reg
1415 rm -f $tmp
1416 echo 'REGEDIT4' > $tmp
1417 echo '' >> $tmp
1418 echo '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]' >> $tmp
1419 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
1420 echo '' >> $tmp
1421 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhc.exe\DllOverrides]' >> $tmp
1422 echo '"itss"="native"' >> $tmp
1423 echo '' >> $tmp
1424 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhw.exe\DllOverrides]' >> $tmp
1425 echo '"itss"="native"' >> $tmp
1426 echo '' >> $tmp
1427 if ! wine regedit $tmp > /dev/null 2>&1; then
1428 rm -f $tmp
1429 echo " failed to load registry changes (path)."
1430 fail
1431 fi
1432 rm -f $tmp
1433 log_success "found"
1434}
1435
1436
1437#
1438# Show help
1439#
1440show_help()
1441{
1442 cat << EOF
1443Usage: ./configure [OPTIONS]...
1444
1445Configuration:
1446 -h, --help display this help and exit
1447 --nofatal don't abort on errors
1448 --disable-xpcom disable XPCOM and related stuff
1449 --disable-sdl-ttf disable SDL_ttf detection
1450 --disable-alsa disable the ALSA sound backend
1451 --disable-pulse disable the PulseAudio backend
1452 --disable-kmods don't build Linux kernel modules (host and guest)
1453 --build-libxml2 build libxml2 from sources
1454 --build-libxslt build libxslt from sources (not OSE!)
1455 --setup-wine setup a Wine directory and register the hhc hack
1456
1457Paths:
1458 --with-gcc=PATH location of the gcc compiler [$CC]
1459 --with-g++=PATH location of the g++ compiler [$CXX]
1460 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1461 --with-iasl=PATH location of the iasl compiler [$IASL]
1462 --with-linux=DIR Linux kernel source directory [$LINUX]
1463 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1464 --with-qt-dir=DIR directory for Qt3 headers/libraries [$QT3DIR]
1465 --with-qt4-dir=DIR directory for Qt4 headers/libraries [$QT4DIR]
1466
1467Build type:
1468 -d, --build-debug build with debugging symbols and assertions
1469 --build-profile build with profiling support
1470 --build-headless build headless (without any X11 frontend)
1471EOF
1472 exit 0
1473}
1474
1475
1476#
1477# The body.
1478#
1479
1480# scan command line options
1481for option in $*; do
1482 case "$option" in
1483 --help|-help|-h)
1484 show_help
1485 ;;
1486 --nofatal)
1487 nofatal=1
1488 ;;
1489 --with-gcc=*)
1490 CC=`echo $option | cut -d'=' -f2`
1491 ;;
1492 --with-g++=*)
1493 CXX=`echo $option | cut -d'=' -f2`
1494 ;;
1495 --with-kbuild=*)
1496 KBUILDDIR=`echo $option | cut -d'=' -f2`
1497 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1498 echo "Error: KBUILDDIR contains invalid characters!"
1499 exit 1
1500 fi
1501 ;;
1502 --with-qt-dir=*)
1503 QT3DIR=`echo $option | cut -d'=' -f2`
1504 ;;
1505 --with-qt4-dir=*)
1506 QT4DIR=`echo $option | cut -d'=' -f2`
1507 ;;
1508 --with-iasl=*)
1509 IASL=`echo $option | cut -d'=' -f2`
1510 ;;
1511 --with-linux=*)
1512 LINUX=`echo $option | cut -d'=' -f2`
1513 ;;
1514 --with-mkisofs=*)
1515 MKISOFS=`echo $option | cut -d'=' -f2`
1516 ;;
1517 --disable-xpcom)
1518 WITH_XPCOM=0
1519 ;;
1520 --disable-sdl-ttf)
1521 WITH_SDL_TTF=0
1522 ;;
1523 --disable-qt)
1524 WITH_QT=0
1525 ;;
1526 --disable-alsa)
1527 WITH_ALSA=0
1528 ;;
1529 --disable-pulse)
1530 WITH_PULSE=0
1531 ;;
1532 --disable-kmods)
1533 WITH_KMODS=0
1534 ;;
1535 --build-debug|-d)
1536 BUILD_TYPE=debug
1537 ;;
1538 --build-profile)
1539 BUILD_TYPE=profile
1540 ;;
1541 --build-libxml2)
1542 BUILD_LIBXML2=1
1543 ;;
1544 --build-libxslt)
1545 BUILD_LIBXSLT=1
1546 ;;
1547 --build-headless)
1548 HEADLESS=1
1549 WITH_SDL=0
1550 WITH_SDL_TTF=0
1551 WITH_X11=0
1552 WITH_QT=0
1553 ;;
1554 --ose)
1555 OSE=2
1556 ;;
1557 --odir=*)
1558 ODIR="`echo $option | cut -d'=' -f2`/"
1559 ;;
1560 --setup-wine)
1561 SETUP_WINE=1
1562 ;;
1563 *)
1564 echo
1565 echo "Unrecognized option \"$option\""
1566 echo
1567 show_help
1568 ;;
1569 esac
1570done
1571
1572LOG="$ODIR$LOG"
1573ENV="$ODIR$ENV"
1574CNF="$ODIR$CNF"
1575
1576# initialize output files
1577cat > $LOG << EOF
1578# Log file generated by
1579#
1580# '$0 $*'
1581#
1582
1583EOF
1584cat > $CNF << EOF
1585# -*- Makefile -*-
1586#
1587# automatically generated by
1588#
1589# '$0 $*'
1590#
1591# It will be completely overwritten if configure is executed again.
1592#
1593
1594EOF
1595cat > $ENV << EOF
1596#!/bin/bash
1597#
1598# automatically generated by
1599#
1600# '$0 $*'
1601#
1602# It will be completely overwritten if configure is executed again.
1603# Make sure you source this file once before you start to build VBox.
1604#
1605
1606EOF
1607
1608# test if we are OSE
1609if [ $OSE -eq 1 -a -d "`cd \`dirname $0\`; pwd`/src/VBox/Devices/USB" ]; then
1610 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1611 echo >> $LOG
1612 OSE=0
1613fi
1614
1615if [ "$BUILD_TYPE" = "debug" ]; then
1616 echo "Creating DEBUG build!" >> $LOG
1617elif [ "$BUILD_TYPE" = "profile" ]; then
1618 echo "Creating PROFILE build!" >> $LOG
1619fi
1620
1621# first determine our environment
1622check_environment
1623check_kbuild
1624
1625# append the tools directory to the default search path
1626echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1627export PATH
1628
1629# some things are not available in for OSE
1630if [ $OSE -ge 1 ]; then
1631 cnf_append "VBOX_OSE" "1"
1632 cnf_append "VBOX_WITH_TESTSUITE" ""
1633 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1634
1635 if [ "$OS" = "linux" ]; then
1636 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1637 else
1638 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1639 fi
1640 echo >> $CNF
1641fi
1642
1643# headless
1644if [ -n "$HEADLESS" ]; then
1645 cnf_append "VBOX_HEADLESS" "1"
1646fi
1647
1648# emit disable directives corresponding to any --disable-xxx options.
1649[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
1650[ $WITH_QT -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
1651[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
1652
1653# the tools
1654check_gcc
1655[ "$OS" != "darwin" ] && check_as86
1656[ "$OS" != "darwin" ] && check_bcc
1657[ "$OS" != "darwin" ] && check_iasl
1658# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1659# [ "$OS" != "darwin" ] && check_yasm
1660[ "$OS" != "darwin" ] && check_xsltproc
1661[ $OSE -eq 0 -a "$OS" != "darwin" ] && check_mkisofs
1662
1663# the libraries
1664[ "$OS" != "darwin" ] && check_pthread
1665# build libxml2 on Darwin in every case
1666[ "$OS" != "darwin" ] || BUILD_LIBXML2=1
1667[ $WITH_XPCOM -eq 1 ] && check_libxml2
1668# build libxslt on Darwin in every case
1669[ "$OS" != "darwin" ] || BUILD_LIBXSLT=1
1670[ $WITH_XPCOM -eq 1 ] && check_libxslt
1671[ $WITH_LIBIDL -eq 1 ] && check_libidl
1672# build openssl on Darwin in every case
1673[ "$OS" != "darwin" -a $OSE -eq 0 ] && check_ssl
1674[ "$OS" != "darwin" ] && check_z
1675[ "$OS" != "darwin" ] && check_png
1676[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
1677[ $WITH_SDL -eq 1 ] && check_sdl
1678[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
1679[ $WITH_X11 -eq 1 ] && check_x
1680[ $WITH_X11 -eq 1 ] && check_xcursor
1681[ $WITH_QT -eq 1 ] && check_qt3
1682[ $WITH_QT -eq 1 ] && check_qt4
1683
1684# Linux-specific
1685if [ "$OS" = "linux" ]; then
1686 check_staticlibstdcxx
1687 if [ $WITH_KMODS -eq 1 ]; then
1688 check_linux
1689 else
1690 cnf_append "VBOX_LINUX_SRC" ""
1691 cnf_append "VBOX_WITH_VBOXDRV" ""
1692 cnf_append "VBOX_WITH_LINUX_ADDITIONS_32BIT_R0" ""
1693 fi
1694 if [ $WITH_ALSA -eq 1 ]; then
1695 check_alsa
1696 else
1697 cnf_append "VBOX_WITH_ALSA" ""
1698 fi
1699 if [ $WITH_PULSE -eq 1 ]; then
1700 check_pulse
1701 else
1702 cnf_append "VBOX_WITH_PULSE" ""
1703 fi
1704 check_compiler_h
1705 [ "$BUILD_MACHINE" = "amd64" ] && check_32bit
1706fi
1707
1708[ -n "$SETUP_WINE" ] && setup_wine
1709
1710# success!
1711echo
1712echo "Successfully generated '$CNF' and '$ENV'."
1713echo "Source '$ENV' once before you start to build VBox:"
1714echo ""
1715echo " source $ENV"
1716echo " kmk"
1717echo ""
1718if [ "$OS" = "linux" ]; then
1719 echo "To compile the kernel module, do:"
1720 echo ""
1721 echo " cd ./out/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
1722 echo " make"
1723 echo ""
1724fi
1725echo "Enjoy!"
1726cleanup
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