VirtualBox

source: vbox/trunk/configure@ 788

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

support Debian/sarge

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