VirtualBox

source: vbox/trunk/configure@ 1032

Last change on this file since 1032 was 1032, checked in by vboxsync, 18 years ago

configure: VBOX_USING_GCC4 not for amd64

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