VirtualBox

source: vbox/trunk/configure@ 4750

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

file header and eol-style.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 32.0 KB
Line 
1#!/bin/sh
2# The purpose of this script is to check for all external tools, headers, and
3# libraries VBox OSE depends on.
4
5#
6# Copyright (C) 2006-2007 innotek GmbH
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License as published by the Free Software Foundation,
12# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13# distribution. VirtualBox OSE is distributed in the hope that it will
14# be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16
17LC_ALL=C
18export LC_ALL
19
20# append some extra paths
21PATH="$PATH:/opt/gnome/bin"
22# solaris
23PATH="/usr/ucb:/usr/xpg4/bin:$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin"
24export PATH
25
26#
27# Defaults
28#
29OSE=1
30TARGET_MACHINE=""
31TARGET_CPU=""
32WITH_XPCOM=1
33WITH_LIBIDL=1
34WITH_QT=1
35WITH_SDL_TTF=1
36CC="gcc"
37CC32=""
38CC64=""
39CXX="g++"
40CXX32=""
41CXX64=""
42BCC="bcc"
43YASM="yasm"
44IASL="iasl"
45AS86="as86"
46XSLTPROC="xsltproc"
47GENISOIMAGE="genisoimage"
48MKISOFS="mkisofs"
49INCXALAN=""
50LIBXALAN="-lxalan-c"
51INCXERCES=""
52LIBXERCES="-lxerces-c"
53LIBCRYPTO="-lcrypto"
54LIBPTHREAD="-lpthread"
55LIBX11="-L/usr/X11R6/lib -L/usr/X11R6/lib64 -lXext -lX11"
56LIBXCURSOR="-lXcursor"
57INCZ=""
58LIBZ="-lz"
59INCPNG=""
60LIBPNG="-lpng"
61QTDIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3 /usr/lib64/qt-3.3 /usr/X11R6"
62KBUILDDIR="`cd \`dirname $0\`; pwd`/kBuild"
63DEVDIR="`cd \`dirname $0\`; pwd`/tools"
64if [ -d "/lib/modules/`uname -r`/build" ]; then
65 LINUX="/lib/modules/`uname -r`/build"
66else
67 LINUX="/usr/src/linux"
68fi
69KCHMVIEWER="kchmviewer"
70LOG="configure.log"
71CNF="AutoConfig.kmk"
72ENV="env.sh"
73BUILD_TYPE="release"
74# the restricting tool is ar (mri mode).
75INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
76
77if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
78 echo "Error: VBox base path contains invalid characters!"
79 exit 1
80fi
81
82cleanup()
83{
84 rm -f .tmp_src.cc .tmp_src.c .tmp_out .test_execute.log
85}
86
87fail()
88{
89 if [ -z "$nofatal" -o "x$1" != "x" ]; then
90 cleanup
91 rm -f $ENV
92 exit 1
93 fi
94}
95
96log_success()
97{
98 if [ -n "$1" ]; then echo -n "$1, "; fi
99 echo "OK."
100 echo "$1" >> $LOG
101 echo >> $LOG
102 echo >> $LOG
103}
104
105log_failure()
106{
107 echo
108 echo " ** $1!"
109 echo "** $1!" >> $LOG
110 echo >> $LOG
111}
112
113cnf_append()
114{
115 printf "%-30s := %s\n" "$1" "$2" >> $CNF
116}
117
118strip_l()
119{
120 echo "$1"|sed 's|-l\([^ ]\+\)|\1|g; s|-[^l]\([^ ]\+\)||g; s|^ ||; s| *$||g'
121}
122
123strip_L()
124{
125 echo "$1"|sed 's|-L\([^ ]\+\)|\1|g; s|-[^L]\([^ ]\+\)||g; s|^ ||; s| *$||g'
126}
127
128strip_I()
129{
130 echo "$1"|sed 's|-I\([^ ]\+\)|\1|g; s|-[^I]\([^ ]\+\)||g; s|^ ||; s| *$||g'
131}
132
133# Wrapper for ancient /usr/bin/which on darwin that always returns 0
134which_wrapper()
135{
136 if [ -z "$have_ancient_which" ]; then
137 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
138 have_ancient_which="yes"
139 else
140 have_ancient_which="no"
141 fi
142 fi
143 if [ "$have_ancient_which" = "yes" ]; then
144 local retval=`which $* 2>/dev/null`
145 echo "$retval"
146 test -n "$retval" -a -e "$retval"
147 else
148 which $* 2> /dev/null
149 fi
150}
151
152check_avail()
153{
154 if [ -z "$1" ]; then
155 log_failure "$2 is empty"
156 fail $3
157 return 1
158 elif which_wrapper $1 > /dev/null; then
159 return 0
160 else
161 log_failure "$1 (variable $2) not found"
162 fail $3
163 return 1
164 fi
165}
166
167# Prepare a test
168test_header()
169{
170 echo "***** Checking $1 *****" >> $LOG
171 echo -n "Checking for $1: "
172}
173
174# Compile a test
175test_compile()
176{
177 echo "compiling the following source file:" >> $LOG
178 cat .tmp_src.cc >> $LOG
179 echo "using the following command line:" >> $LOG
180 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
181 $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
182 if [ $? -ne 0 ]; then
183 if [ -z "$4" ]; then
184 echo
185 echo " $2 not found at $1 or $3 headers not found"
186 echo " Check the file $LOG for detailed error information."
187 fail
188 else
189 echo "not found."
190 echo >> $LOG
191 echo >> $LOG
192 fi
193 return 1
194 fi
195 return 0
196}
197
198# Execute a compiled test binary
199test_execute()
200{
201 echo "executing the binary" >> $LOG
202 ./.tmp_out > .test_execute.log
203 rc=$?
204 cat .test_execute.log | tee -a $LOG
205 if [ $rc -ne 0 ]; then
206 fail $1
207 return 1
208 fi
209 echo >> $LOG
210 echo >> $LOG
211 return 0
212}
213
214#
215# Check for OS, MACHINE, CPU
216#
217check_environment()
218{
219 test_header environment
220 BUILD_CPU=`uname -m`
221 case "$BUILD_CPU" in
222 i[3456789]86|x86|i86pc)
223 BUILD_MACHINE='x86'
224 LIB='lib'
225 ;;
226 x86_64|amd64)
227 BUILD_MACHINE='amd64'
228 BUILD_CPU='k8'
229 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
230 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
231 LIB='lib64'
232 ;;
233 *)
234 log_failure "Cannot determine system"
235 exit 1
236 ;;
237 esac
238 [ -z "$TARGET_MACHINE" ] && TARGET_MACHINE=$BUILD_MACHINE
239 [ -z "$TARGET_CPU" ] && TARGET_CPU=$BUILD_CPU
240 OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr [:upper:] [:lower:]`
241 case "$OS" in
242 linux)
243 ;;
244 darwin)
245 ;;
246 freebsd)
247 ;;
248 sunos)
249 OS='solaris'
250 ;;
251 *)
252 log_failure "Cannot determine OS"
253 exit 1
254 ;;
255 esac
256 DEVDIR_BIN="$DEVDIR/$OS.$BUILD_MACHINE/bin"
257 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
258 log_success "Determined build machine: $OS.$BUILD_MACHINE, target machine: $OS.$TARGET_MACHINE"
259
260 # Automatically disable XPCOM on darwin.
261 if [ "$OS" = "darwin" -a $WITH_XPCOM -eq 1 ]; then
262 WITH_XPCOM=0
263 WITH_LIBIDL=0
264 WITH_QT=0
265 echo "Disabling checks for XPCOM related components."
266 fi
267}
268
269#
270# Check for gcc with version >= 3.2.
271# We depend on a working gcc, if we fail terminate in every case.
272#
273check_gcc()
274{
275 test_header gcc
276 if check_avail "$CC" CC really; then
277 cc_ver=`$CC -dumpversion`
278 if check_avail "$CXX" CXX really; then
279 cxx_ver=`$CXX -dumpversion`
280 cc_maj=`echo $cc_ver|cut -d. -f1`
281 cc_min=`echo $cc_ver|cut -d. -f2`
282 if [ "x$cc_ver" != "x$cxx_ver" ]; then
283 log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
284 fail really
285 elif [ $cc_maj -eq 4 -a $cc_min -eq 0 ]; then
286 if [ "$OS" = "darwin" ]; then
287 log_success "found version $cc_ver"
288 else
289 log_failure "gcc version $cc_ver found, expected gcc 3.x with x>1 or gcc 4.x with x>0"
290 fail really
291 fi
292 elif [ $cc_maj -gt 3 ]; then
293 log_success "found version $cc_ver"
294 elif [ $cc_maj -lt 3 -o $cc_min -lt 2 ]; then
295 log_failure "gcc version $cc_ver found, expected gcc 3.x with x>1 or gcc 4.x with x>0"
296 fail really
297 else
298 log_success "found version $cc_ver"
299 fi
300 if [ "$BUILD_MACHINE" = "amd64" ]; then
301 [ -z "$CC32" ] && CC32="$CC -m32"
302 [ -z "$CXX32" ] && CXX32="$CXX -m32"
303 else
304 [ -z "$CC32" ] && CC32="$CC"
305 [ -z "$CXX32" ] && CXX32="$CXX"
306 fi
307 if [ "$BUILD_MACHINE" = "x86" -a "$TARGET_MACHINE" = "amd64" ]; then
308 [ -z "$CC64" ] && CC64="$CC -m64"
309 [ -z "$CXX64" ] && CXX64="$CXX -m64"
310 fi
311 if [ "$CC" != "gcc" ]; then
312 cnf_append "TOOL_GCC3_CC" "$CC"
313 cnf_append "TOOL_GCC3_AS" "$CC"
314 cnf_append "TOOL_GCC3_LD" "$CC"
315 cnf_append "TOOL_GXX3_CC" "$CC"
316 cnf_append "TOOL_GXX3_AS" "$CC"
317 fi
318 if [ "$CXX" != "g++" ]; then
319 cnf_append "TOOL_GCC3_CXX" "$CXX"
320 cnf_append "TOOL_GXX3_CXX" "$CXX"
321 cnf_append "TOOL_GXX3_LD" "$CXX"
322 fi
323 if [ "$CC32" != "gcc -m32" ]; then
324 cnf_append "TOOL_GCC32_CC" "$CC32"
325 cnf_append "TOOL_GCC32_AS" "$CC32"
326 cnf_append "TOOL_GCC32_LD" "$CC32"
327 cnf_append "TOOL_GXX32_CC" "$CC32"
328 cnf_append "TOOL_GXX32_AS" "$CC32"
329 fi
330 if [ "$CXX32" != "g++ -m32" ]; then
331 cnf_append "TOOL_GCC32_CXX" "$CXX32"
332 cnf_append "TOOL_GXX32_CXX" "$CXX32"
333 cnf_append "TOOL_GXX32_LD" "$CXX32"
334 fi
335 if [ -n "$CC64" ]; then
336 cnf_append "TOOL_GCC64_CC" "$CC64"
337 cnf_append "TOOL_GCC64_AS" "$CC64"
338 cnf_append "TOOL_GCC64_LD" "$CC64"
339 cnf_append "TOOL_GXX64_CC" "$CC64"
340 cnf_append "TOOL_GXX64_AS" "$CC64"
341 fi
342 if [ -n "$CXX64" ]; then
343 cnf_append "TOOL_GCC64_CXX" "$CXX64"
344 cnf_append "TOOL_GXX64_CXX" "$CXX64"
345 cnf_append "TOOL_GXX64_LD" "$CXX64"
346 fi
347 fi
348 fi
349}
350
351#
352# Check for the bcc compiler, needed for compiling the BIOS
353#
354check_bcc()
355{
356 test_header bcc
357 if check_avail "$BCC" BCC; then
358 bcc_ver=`$BCC -v 2>&1|grep version|sed 's+^bcc: version \(.*\)+\1+'`
359 if [ $? -ne 0 ]; then
360 log_failure "not found"
361 fail
362 else
363 echo "compiling the following source file:" >> $LOG
364 cat > .tmp_src.c << EOF
365int foo(a)
366 int a;
367{
368 return 0;
369}
370EOF
371 cat .tmp_src.c >> $LOG
372 local bcc_path=`which_wrapper $BCC`
373 local bcc_dir="`dirname $bcc_path`/"
374 echo "using the following command line:" >> $LOG
375 echo "$BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c" >> $LOG
376 $BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c >> $LOG 2>&1
377 if [ $? -ne 0 ]; then
378 log_failure "not found"
379 fail
380 else
381 log_success "found version $bcc_ver"
382 cnf_append "VBOX_BCC" "$bcc_path -B $bcc_dir"
383 fi
384 fi
385 fi
386}
387
388#
389# Check for the as86 assembler, needed for compiling the BIOS
390#
391check_as86()
392{
393 test_header as86
394 if check_avail "$AS86" AS86; then
395 as86_ver=`$AS86 -v 2>&1|grep version|sed 's+^as86 version: \(.*\)+\1+'`
396 if [ $? -ne 0 ]; then
397 log_failure "not found"
398 fail
399 else
400 log_success "found version $as86_ver"
401 cnf_append "VBOX_AS86" "`which_wrapper $AS86`"
402 fi
403 fi
404}
405
406#
407# Check for yasm, needed to compile assembler files
408#
409check_yasm()
410{
411 test_header yasm
412 if check_avail "$YASM" YASM; then
413 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
414 if [ $? -ne 0 ]; then
415 log_failure "not found"
416 fail
417 else
418 yasm_maj=`echo $yasm_ver|cut -d. -f1`
419 yasm_min=`echo $yasm_ver|cut -d. -f2`
420 yasm_rev=`echo $yasm_ver|cut -d. -f3`
421 yasm_ver_mul=`expr $yasm_maj \* 10000 + $yasm_min \* 100 + $yasm_rev`
422 if [ $yasm_ver_mul -lt 501 ]; then
423 log_failure "found version $yasm_ver, expected at least 0.5.1"
424 fail
425 else
426 log_success "found version $yasm_ver"
427 fi
428 fi
429 fi
430}
431
432#
433# Check for the iasl ACPI compiler, needed to compile vbox.dsl
434#
435check_iasl()
436{
437 test_header iasl
438 if check_avail "$IASL" IASL; then
439 iasl_ver=`$IASL|grep version|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
440 if [ $? -ne 0 ]; then
441 log_failure "not found"
442 fail
443 else
444 log_success "found version $iasl_ver"
445 cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
446 fi
447 fi
448}
449
450#
451# Check for xsltproc, needed by Main
452#
453check_xsltproc()
454{
455 test_header xslt
456 if check_avail "$XSLTPROC" XSLTPROC; then
457 xsltproc_ver=`$XSLTPROC --version`
458 if [ $? -ne 0 ]; then
459 log_failure "not found"
460 fail
461 else
462 log_success "found"
463 cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
464 fi
465 fi
466}
467
468#
469# Check for mkisofs, needed to build the CDROM image containing the additions
470#
471check_mkisofs()
472{
473 test_header mkisofs
474 if which_wrapper $GENISOIMAGE > /dev/null; then
475 mkisofs_ver=`$GENISOIMAGE --version`
476 if [ $? -ne 0 ]; then
477 log_failure "not found"
478 fail
479 else
480 log_success "found $mkisofs_ver"
481 cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
482 fi
483 elif check_avail "$MKISOFS" MKISOFS; then
484 mkisofs_ver=`$MKISOFS --version`
485 if [ $? -ne 0 ]; then
486 log_failure "not found"
487 fail
488 else
489 log_success "found $mkisofs_ver"
490 cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
491 fi
492 fi
493}
494
495#
496# Check for xalan, needed by VBoxXML
497#
498check_xalan()
499{
500 if [ -n "$LIBXALAN" ]; then
501 test_header xalan
502 cat > .tmp_src.cc << EOF
503#include <cstdio>
504#include <xalanc/Include/XalanVersion.hpp>
505extern "C" int main(void)
506{
507 printf("found version %d.%d.%d",
508 XALAN_VERSION_MAJOR, XALAN_VERSION_MINOR, XALAN_VERSION_REVISION);
509#if _XALAN_VERSION >= 10800
510 printf(", OK.\n");
511 return 0;
512#else
513 printf(", expected version 1.8.0 or higher\n");
514 return 1;
515#endif
516}
517EOF
518 [ -n "$INCXALAN" ] && I_INCXALAN="-I$INCXALAN"
519 if test_compile "$LIBXALAN $LIBPTHREAD $I_INCXALAN" xalan xalanc; then
520 if test_execute; then
521 cnf_append "SDK_VBOX_XALAN_LIBS" "`strip_l "$LIBXALAN"`"
522 cnf_append "SDK_VBOX_XALAN_INCS" "$INCXALAN"
523 fi
524 fi
525 else
526 echo "Building xalan from shipped sources."
527 echo "Building xalan from shipped sources." >> $LOG
528 echo >> $LOG
529 echo >> $LOG
530 fi
531}
532
533#
534# Check for xerces, needed by VBoxXML
535#
536check_xerces()
537{
538 if [ -n "$LIBXERCES" ]; then
539 test_header xerces
540 cat > .tmp_src.cc << EOF
541#include <cstdio>
542#include <xercesc/util/XercesVersion.hpp>
543extern "C" int main(void)
544{
545 printf("found version %d.%d.%d",
546 XERCES_VERSION_MAJOR, XERCES_VERSION_MINOR, XERCES_VERSION_REVISION);
547#if _XERCES_VERSION >= 20500
548 printf(", OK.\n");
549 return 0;
550#else
551 printf(", expected version 2.5.0 or higher");
552 return 1;
553#endif
554}
555EOF
556 [ -n "$INCXERCES" ] && I_INCXERCES="-I$INCXERCES"
557 if test_compile "$LIBXERCES $LIBPTHREAD $I_INCXERCES" xerces xercesc; then
558 if test_execute; then
559 cnf_append "SDK_VBOX_XERCES_LIBS" "`strip_l "$LIBXERCES"`"
560 cnf_append "SDK_VBOX_XERCES_INCS" "$INCXERCES"
561 fi
562 fi
563 else
564 echo "Building xerces from shipped sources."
565 echo "Building xerces from shipped sources." >> $LOG
566 echo >> $LOG
567 echo >> $LOG
568 fi
569}
570
571#
572# Check for libIDL, needed by xpcom
573#
574check_libidl()
575{
576 test_header libIDL
577
578 if which_wrapper libIDL-config-2 > /dev/null; then
579 libidl_ver=`libIDL-config-2 --version`
580 if [ $? -ne 0 ]; then
581 log_failure "not found"
582 fail
583 else
584 log_success "found version $libidl_ver"
585 cnf_append "VBOX_LIBIDL_CONFIG" \
586 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
587 fi
588 elif check_avail "libIDL-config" libIDL-config; then
589 libidl_ver=`libIDL-config --version`
590 if [ $? -ne 0 ]; then
591 log_failure "not found"
592 fail
593 else
594 log_success "found version $libidl_ver"
595 cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
596 fi
597 fi
598}
599
600#
601# Check for openssl, needed for RDP
602#
603check_ssl()
604{
605 test_header ssl
606 cat > .tmp_src.cc << EOF
607#include <cstdio>
608#include <openssl/opensslv.h>
609extern "C" int main(void)
610{
611 printf("found version %s", OPENSSL_VERSION_TEXT);
612#if OPENSSL_VERSION_NUMBER >= 0x0090700
613 printf(", OK.\n");
614 return 0;
615#else
616 printf(", expected version 0.9.7 or higher\n");
617 return 1;
618#endif
619}
620EOF
621 if test_compile $LIBCRYPTO libcrypto openssl; then
622 if test_execute nofatal; then
623 cnf_append "SDK_VBOX_OPENSSL_INCS" ""
624 cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
625 fi
626 fi
627}
628
629#
630# Check for pthread, needed by VBoxSVC, frontends, ...
631#
632check_pthread()
633{
634 test_header pthread
635 cat > .tmp_src.cc << EOF
636#include <cstdio>
637#include <pthread.h>
638extern "C" int main(void)
639{
640 pthread_mutex_t mutex;
641 if (pthread_mutex_init(&mutex, NULL)) {
642 printf("pthread_mutex_init() failed\n");
643 return 1;
644 }
645 if (pthread_mutex_lock(&mutex)) {
646 printf("pthread_mutex_lock() failed\n");
647 return 1;
648 }
649 if (pthread_mutex_unlock(&mutex)) {
650 printf("pthread_mutex_unlock() failed\n");
651 return 1;
652 }
653 printf("found, OK.\n");
654}
655EOF
656 if test_compile $LIBPTHREAD pthread pthread; then
657 if test_execute; then
658 cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
659 fi
660 fi
661}
662
663#
664# Check for zlib, needed by VBoxSVC, Runtime, ...
665#
666check_z()
667{
668 test_header zlib
669 cat > .tmp_src.cc << EOF
670#include <cstdio>
671#include <zlib.h>
672extern "C" int main(void)
673{
674 printf("found version %s", ZLIB_VERSION);
675#if ZLIB_VERNUM >= 0x1210
676 printf(", OK.\n");
677 return 0;
678#else
679 printf(", expected version 1.2.1 or higher\n");
680 return 1;
681#endif
682}
683EOF
684 [ -n "$INCZ" ] && I_INCZ="-I$INCZ"
685 if test_compile "$LIBZ $I_INCZ" zlib zlib; then
686 if test_execute; then
687 cnf_append "SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
688 cnf_append "SDK_VBOX_ZLIB_INCS" "$INCZ"
689 fi
690 fi
691}
692
693#
694# Check for libpng, needed by kchmviewer
695#
696check_png()
697{
698 test_header libpng
699 cat > .tmp_src.cc << EOF
700#include <cstdio>
701#include <png.h>
702extern "C" int main(void)
703{
704 printf("found version %s", PNG_LIBPNG_VER_STRING);
705#if PNG_LIBPNG_VER >= 10205
706 printf(", OK.\n");
707 return 0;
708#else
709 printf(", expected version 1.2.5 or higher\n");
710 return 1;
711#endif
712}
713EOF
714 [ -n "$INCPNG" ] && I_INCPNG="-I$INCPNG"
715# if test_compile "$LIBPNG $I_INCPNG" libpng libpng nofatal; then
716 if test_compile "$LIBPNG $I_INCPNG" libpng libpng; then
717# if test_execute nofatal; then
718 if test_execute; then
719 cnf_append "SDK_VBOX_LIBPNG_LIBS" "`strip_l "$LIBPNG"`"
720 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
721 fi
722 fi
723}
724
725#
726# Check for pam, needed by VRDPAuth
727# Version 79 was introduced in 9/2005, do we support older versions?
728# Debian/sarge uses 76
729# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
730#
731check_pam()
732{
733 test_header pam
734 cat > .tmp_src.cc << EOF
735#include <cstdio>
736#include <security/pam_appl.h>
737extern "C" int main(void)
738{
739 printf("found version %d", __LIBPAM_VERSION);
740 if (__LIBPAM_VERSION >= 76)
741 {
742 printf(", OK.\n");
743 return 0;
744 }
745 else
746 {
747 printf(", expected version 76 or higher\n");
748 return 1;
749 }
750}
751EOF
752 if test_compile "-lpam" pam pam nofatal; then
753 if test_execute nofatal; then
754 return 0;
755 fi
756 fi
757 test_header linux_pam
758 cat > .tmp_src.cc << EOF
759#include <cstdio>
760#include <security/pam_appl.h>
761extern "C" int main(void)
762{
763 printf("found version %d.%d", __LINUX_PAM__, __LINUX_PAM_MINOR__);
764 if (__LINUX_PAM__ >= 1)
765 {
766 printf(", OK.\n");
767 return 0;
768 }
769 else
770 {
771 printf(", expected version 1.0 or higher\n");
772 return 1;
773 }
774}
775EOF
776 if test_compile "-lpam" pam pam; then
777 test_execute
778 fi
779}
780
781
782#
783# Check for the SDL library, needed by VBoxSDL and VirtualBox
784# We depend at least on version 1.2.7
785#
786check_sdl()
787{
788 test_header SDL
789 if which_wrapper sdl-config > /dev/null; then
790 FLGSDL=`sdl-config --cflags`
791 INCSDL=`strip_I "$FLGSDL"`
792 LIBSDL=`sdl-config --libs`
793 LIBSDLMAIN="-lSDLmain"
794 cat > .tmp_src.cc << EOF
795#include <cstdio>
796#include <SDL/SDL.h>
797#include <SDL/SDL_main.h>
798extern "C" int main(void)
799{
800 printf("found version %d.%d.%d",
801 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
802#if SDL_VERSION_ATLEAST(1,2,7)
803 printf(", OK.\n");
804 return 0;
805#else
806 printf(", expected version 1.2.7 or higher\n");
807 return 1;
808#endif
809}
810EOF
811 [ -n "$INCSDL" ] && I_INCSDL="-I$INCSDL"
812 if test_compile "$LIBSDL $LIBSDLMAIN $I_INCSDL" SDL SDL; then
813 if test_execute; then
814 cnf_append "LIB_SDK_LIBSDL_SDL" "`strip_l "$LIBSDL"`"
815 cnf_append "SDK_LIBSDL_LIBPATH" "`strip_L "$LIBSDL"`"
816 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
817 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
818 fi
819 fi
820 else
821 log_failure "not found"
822 fi
823}
824
825#
826# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
827#
828check_sdl_ttf()
829{
830 test_header SDL_ttf
831 cat > .tmp_src.cc << EOF
832#include <cstdio>
833#include <SDL/SDL_ttf.h>
834#ifndef SDL_TTF_MAJOR_VERSION
835#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
836#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
837#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
838#endif
839extern "C" int main(void)
840{
841 printf("found version %d.%d.%d",
842 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
843#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
844 printf(", OK.\n");
845 return 0;
846#else
847 printf(", expected version 2.0.6 or higher\n");
848 return 1;
849#endif
850}
851EOF
852 if test_compile "-lSDL_ttf" SDL_ttf SDL_ttf; then
853 test_execute
854 fi
855}
856
857#
858# Check for libasound, needed by the ALSA audio backend
859#
860check_alsa()
861{
862 test_header ALSA
863 cat > .tmp_src.cc << EOF
864#include <alsa/asoundlib.h>
865extern "C" int main(void)
866{
867 printf("found version %d.%d.%d",
868 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
869#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
870 printf(", OK.\n");
871 return 0;
872#else
873 printf(", expected version 1.0.6 or higher\n");
874 return 1;
875#endif
876}
877EOF
878 if test_compile "-lasound" asound asound; then
879 test_execute
880 fi
881}
882
883#
884# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
885#
886check_xcursor()
887{
888 test_header Xcursor
889 cat > .tmp_src.cc << EOF
890#include <cstdio>
891#include <X11/Xlib.h>
892#include <X11/Xcursor/Xcursor.h>
893extern "C" int main(void)
894{
895 XcursorImage *cursor = XcursorImageCreate (10, 10);
896 XcursorImageDestroy(cursor);
897 return 0;
898}
899EOF
900 if test_compile "$LIBX11 $LIBXCURSOR" Xcursor Xcursor; then
901 log_success "found"
902 cnf_append "LIB_XCURSOR" "`strip_l "$LIBXCURSOR"`"
903 fi
904}
905
906#
907# Check for the X libraries (Xext, X11)
908#
909check_x()
910{
911 test_header "X libraries"
912 cat > .tmp_src.cc << EOF
913#include <cstdio>
914#include <X11/Xlib.h>
915extern "C" int main(void)
916{
917 Display *dpy;
918 int scrn_num;
919 Screen *scrn;
920 Window win;
921
922 dpy = XOpenDisplay(NULL);
923 scrn_num = DefaultScreen(dpy);
924 scrn = ScreenOfDisplay(dpy, scrn_num);
925 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
926 0, 16, InputOutput, CopyFromParent, 0, NULL);
927 XDestroyWindow(dpy, win);
928}
929EOF
930 if test_compile "$LIBX11" Xlibs Xlibs; then
931 log_success "found"
932 fi
933}
934
935#
936# Check for the QT library, needed by VirtualBox
937#
938check_qt()
939{
940 test_header Qt
941 cat > .tmp_src.cc << EOF
942#include <cstdio>
943#include <qglobal.h>
944extern "C" int main(void)
945{
946 printf("found version %s", QT_VERSION_STR);
947#if QT_VERSION >= 0x030305
948 printf(", OK.\n");
949 return 0;
950#elif QT_VERSION >= 0x030300
951 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
952#else
953 printf(", expected version 3.3.0 or higher\n");
954 return 1;
955#endif
956}
957EOF
958 found_qt=0
959 libs="lib"
960 [ "$LIB" = "lib64" ] && libs="$libs lib64"
961 for q in $QTDIR; do
962 for l in $libs; do
963 echo "compiling the following source file:" >> $LOG
964 cat .tmp_src.cc >> $LOG
965 echo "using the following command line:" >> $LOG
966 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt" >> $LOG
967
968 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt >> $LOG 2>&1
969 if [ $? -eq 0 ]; then
970 if test_execute; then
971 cnf_append "QTDIR" "`cd $q ; pwd`"
972 found_qt=1
973 break
974 fi
975 fi
976 done
977 if [ $found_qt -eq 1 ]; then
978 break
979 fi
980 done
981 if [ $found_qt -ne 1 ]; then
982 echo
983 echo " Qt not found at \"$QTDIR\" or Qt headers not found"
984 echo " Check the file $LOG for detailed error information."
985 fail
986 return 1
987 fi
988 test_header "Qt devtools"
989 if check_avail "$q/bin/moc" QTDIR/bin; then
990 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
991 if [ $? -ne 0 ]; then
992 log_failure "not found"
993 fail
994 else
995 log_success "found version $moc_ver"
996 fi
997 fi
998}
999
1000#
1001# Check for Linux sources
1002#
1003check_linux()
1004{
1005 test_header "Linux kernel sources"
1006 cat > .tmp_src.c << EOF
1007#include <linux/version.h>
1008int printf(const char *format, ...);
1009int main(void)
1010{
1011 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1012 (LINUX_VERSION_CODE % 65536) / 256,
1013 LINUX_VERSION_CODE % 256);
1014#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1015 printf(", OK.\n");
1016 return 0;
1017#else
1018 printf(", expected version 2.4.0 or higher\n");
1019 return 1;
1020#endif
1021}
1022EOF
1023 echo "compiling the following source file:" >> $LOG
1024 cat .tmp_src.c >> $LOG
1025 echo "using the following command line:" >> $LOG
1026 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
1027 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
1028 if [ $? -ne 0 ]; then
1029 echo
1030 echo " Linux kernel headers not found at $LINUX"
1031 echo " Check the file $LOG for detailed error information."
1032 fail
1033 else
1034 if test_execute; then
1035 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1036 fi
1037 fi
1038}
1039
1040#
1041# Check for kchmviewer, needed to display the online help
1042#
1043check_kchmviewer()
1044{
1045 test_header kchmviewer
1046 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1047 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1048 if [ $? -ne 0 ]; then
1049 log_failure "not found"
1050 fail
1051 else
1052 log_success "found version $kchmviewer_ver"
1053 fi
1054 fi
1055}
1056
1057#
1058# Check for the kBuild tools, we don't support GNU make
1059#
1060check_kbuild()
1061{
1062 test_header kBuild
1063 if check_avail "$KBUILDDIR_BIN/kmk" KBUILDDIR really; then
1064 log_success "found"
1065 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
1066 echo "export BUILD_PLATFORM_ARCH=\"$BUILD_MACHINE\"" >> $ENV
1067 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
1068 echo "export BUILD_TARGET_ARCH=\"$TARGET_MACHINE\"" >> $ENV
1069 echo "export BUILD_TARGET_CPU=\"$TARGET_CPU\"" >> $ENV
1070 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
1071 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1072 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1073 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1074 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1075 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1076 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1077 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1078 echo "export PATH" >> $ENV
1079 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1080 fi
1081}
1082
1083
1084#
1085# Check for compiler.h
1086# Some Linux distributions include "compiler.h" in their libc linux
1087# headers package, some don't. Most don't need it, building might (!)
1088# not succeed on openSUSE without it.
1089#
1090# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1091#
1092check_compiler_h()
1093{
1094 test_header compiler.h
1095 if ! test -f "/usr/include/linux/compiler.h"; then
1096 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1097 log_success "compiler.h not found"
1098 else
1099 log_success "compiler.h found"
1100 fi
1101}
1102
1103
1104#
1105# Check if we are able to build 32-bit applications (needed for the guest additions)
1106#
1107check_32bit()
1108{
1109 test_header "32-bit support"
1110 cat > .tmp_src.c << EOF
1111#include <stdint.h>
1112int main(void)
1113{
1114 return 0;
1115}
1116EOF
1117 echo "compiling the following source file:" >> $LOG
1118 cat .tmp_src.c >> $LOG
1119 echo "using the following command line:" >> $LOG
1120 echo "$CC -m32 -O -Wall -o .tmp_out .tmp_src.c" >> $LOG
1121 $CC -m32 -O -Wall -o .tmp_out .tmp_src.c >> $LOG 2>&1
1122 if [ $? -ne 0 ]; then
1123 echo
1124 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1125 echo " Check the file $LOG for detailed error information."
1126 fail
1127 fi
1128 log_success ""
1129}
1130
1131
1132#
1133# Show help
1134#
1135show_help()
1136{
1137 cat << EOF
1138Usage: ./configure [OPTIONS]...
1139
1140Configuration:
1141 -h, --help display this help and exit
1142 --nofatal don't abort on errors
1143 --disable-xpcom disable XPCOM and related stuff
1144 --disable-sdl-ttf disable SDL_ttf detection
1145 --build-xalan build xalan & xerces from shipped sources
1146
1147Paths:
1148 --with-gcc=PATH location of the gcc compiler [$CC]
1149 --with-g++=PATH location of the g++ compiler [$CXX]
1150 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1151 --with-iasl=PATH location of the iasl compiler [$IASL]
1152 --with-linux=DIR Linux kernel source directory [$LINUX]
1153 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1154 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
1155 --with-xalan=LIB location of the xalan library [$LIBXALAN]
1156 --with-xerces=LIB location of the xerces library [$LIBXERCES]
1157
1158Build type:
1159 -d, --build-debug build with debugging symbols and assertions
1160 --build-headless build headless (without any X11 frontend)
1161EOF
1162 exit 0
1163}
1164
1165
1166#
1167# The body.
1168#
1169
1170# scan command line options
1171for option in $*; do
1172 case "$option" in
1173 --help|-help|-h)
1174 show_help
1175 ;;
1176 --nofatal)
1177 nofatal=1
1178 ;;
1179 --with-gcc=*)
1180 CC=`echo $option | cut -d'=' -f2`
1181 ;;
1182 --with-g++=*)
1183 CXX=`echo $option | cut -d'=' -f2`
1184 ;;
1185 --with-kbuild=*)
1186 KBUILDDIR=`echo $option | cut -d'=' -f2`
1187 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1188 echo "Error: KBUILDDIR contains invalid characters!"
1189 exit 1
1190 fi
1191 ;;
1192 --with-qt-dir=*)
1193 QTDIR=`echo $option | cut -d'=' -f2`
1194 ;;
1195 --with-iasl=*)
1196 IASL=`echo $option | cut -d'=' -f2`
1197 ;;
1198 --with-linux=*)
1199 LINUX=`echo $option | cut -d'=' -f2`
1200 ;;
1201 --with-mkisofs=*)
1202 MKISOFS=`echo $option | cut -d'=' -f2`
1203 ;;
1204 --with-xalan=*)
1205 LIBXALAN=`echo $option | cut -d'=' -f2`
1206 ;;
1207 --with-xerces=*)
1208 LIBXERCES=`echo $option | cut -d'=' -f2`
1209 ;;
1210 --disable-xpcom)
1211 WITH_XPCOM=0
1212 ;;
1213 --disable-sdl-ttf)
1214 WITH_SDL_TTF=0
1215 ;;
1216 --disable-qt)
1217 WITH_QT=0
1218 ;;
1219 --build-debug|-d)
1220 BUILD_TYPE=debug
1221 ;;
1222 --build-xalan)
1223 LIBXERCES=``
1224 LIBXALAN=``
1225 ;;
1226 --build-headless)
1227 HEADLESS=1
1228 ;;
1229 --ose)
1230 OSE=2
1231 ;;
1232 --odir=*)
1233 ODIR="`echo $option | cut -d'=' -f2`/"
1234 ;;
1235 *)
1236 echo
1237 echo "Unrecognized option \"$option\""
1238 echo
1239 show_help
1240 ;;
1241 esac
1242done
1243
1244LOG="$ODIR$LOG"
1245ENV="$ODIR$ENV"
1246CNF="$ODIR$CNF"
1247
1248# initialize output files
1249cat > $LOG << EOF
1250# Log file generated by
1251#
1252# '$0 $*'
1253#
1254
1255EOF
1256cat > $CNF << EOF
1257# -*- Makefile -*-
1258#
1259# automatically generated by
1260#
1261# '$0 $*'
1262#
1263# It will be completely overwritten if configure is executed again.
1264#
1265
1266EOF
1267cat > $ENV << EOF
1268#!/bin/bash
1269#
1270# automatically generated by
1271#
1272# '$0 $*'
1273#
1274# It will be completely overwritten if configure is executed again.
1275# Make sure you source this file once before you start to build VBox.
1276#
1277
1278EOF
1279
1280# test if we are OSE
1281if [ $OSE -eq 1 -a -d "`cd \`dirname $0\`; pwd`/src/VBox/Devices/USB" ]; then
1282 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1283 echo >> $LOG
1284 OSE=0
1285fi
1286
1287if [ "$BUILD_TYPE" = "debug" ]; then
1288 echo "Creating DEBUG build!" >> $LOG
1289fi
1290
1291# first determine our environment
1292check_environment
1293check_kbuild
1294
1295# append the tools directory to the default search path
1296echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1297export PATH
1298
1299# some things are not available in for OSE
1300if [ $OSE -ge 1 ]; then
1301 cnf_append "VBOX_OSE" "1"
1302 cnf_append "VBOX_WITH_TESTSUITE" ""
1303 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1304
1305 if [ "$OS" = "linux" ]; then
1306 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1307 else
1308 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1309 fi
1310 echo >> $CNF
1311fi
1312
1313# headless
1314if [ -n "$HEADLESS" ]; then
1315 cnf_append "VBOX_HEADLESS" "1"
1316fi
1317
1318# emit disable directives corresponding to any --disable-xxx options.
1319[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
1320[ $WITH_QT -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
1321[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
1322
1323# the tools
1324check_gcc
1325[ "$OS" != "darwin" ] && check_as86
1326[ "$OS" != "darwin" ] && check_bcc
1327[ "$OS" != "darwin" ] && check_iasl
1328# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1329# [ "$OS" != "darwin" ] && check_yasm
1330[ "$OS" != "darwin" ] && check_xsltproc
1331[ $OSE -eq 0 ] && check_mkisofs
1332
1333# the libraries
1334[ "$OS" != "darwin" ] && check_pthread
1335[ $WITH_XPCOM -eq 1 ] && check_xalan
1336[ $WITH_XPCOM -eq 1 ] && check_xerces
1337[ $WITH_LIBIDL -eq 1 ] && check_libidl
1338[ $OSE -eq 0 ] && check_ssl
1339[ "$OS" != "darwin" ] && check_z
1340[ $OSE -eq 0 ] && check_png
1341[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
1342[ "$OS" != "darwin" ] && check_sdl
1343[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
1344[ "$OS" != "darwin" ] && check_x
1345[ "$OS" != "darwin" ] && check_xcursor
1346[ $WITH_QT -eq 1 ] && check_qt
1347
1348# Linux-specific
1349if [ "$OS" = "linux" ]; then
1350 check_linux
1351 check_alsa
1352 check_compiler_h
1353 [ "$BUILD_MACHINE" = "amd64" ] && check_32bit
1354fi
1355
1356# success!
1357echo
1358echo "Successfully generated '$CNF' and '$ENV'."
1359echo "Source '$ENV' once before you start to build VBox:"
1360echo ""
1361echo " source $ENV"
1362echo " kmk"
1363echo ""
1364if [ "$OS" = "linux" ]; then
1365 echo "To compile the kernel module, do:"
1366 echo ""
1367 echo " cd ./out/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
1368 echo " make"
1369 echo ""
1370fi
1371echo "Enjoy!"
1372cleanup
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