VirtualBox

source: vbox/trunk/configure@ 2923

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

configure: TOOL_GXX3_*; define PATH_KBUILD_BIN since we are sometimes executed in a chroot environment without /proc mounted

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