VirtualBox

source: vbox/trunk/configure@ 7503

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

configure: better Qt4 uic3 detection

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