VirtualBox

source: vbox/trunk/configure@ 818

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

fixed detection of -lXcursor in /usr/X11R6/lib

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