VirtualBox

source: vbox/trunk/configure@ 1025

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

configure: tighten ALSA dependency to 1.0.6 as found on rhel4; added qt path of rhel4; --disable-xpcom now only disables xerces and xalan (old behavior for darwin)

  • Property svn:executable set to *
File size: 27.8 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 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_wrapper $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_wrapper $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_wrapper $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_wrapper $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_wrapper $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_wrapper $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_wrapper $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_wrapper 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 cnf_append "VBOX_LIBIDL_CONFIG" \
494 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/lib/pkgconfig `which_wrapper libIDL-config-2`"
495 fi
496 elif check_avail "libIDL-config" libIDL-config; then
497 libidl_ver=`libIDL-config --version`
498 if (($?!=0)); then
499 log_failure "not found"
500 fail
501 else
502 log_success "found version $libidl_ver"
503 cnf_append "VBOX_LIBIDL_CONFIG" `which_wrapper libIDL-config`
504 fi
505 fi
506}
507
508#
509# Check for uuid, needed by Runtime, VBoxSVC, VBoxSDL, and VBoxBFE
510#
511function check_uuid()
512{
513 test_header uuid
514 echo '
515#include <cstdio>
516#include <uuid/uuid.h>
517extern "C" int main(void)
518{
519 uuid_t uu;
520 uuid_clear(uu);
521 if (uuid_is_null(uu)) {
522 printf("found, OK.\n");
523 return 0;
524 } else {
525 printf("uuid found but does not work\n");
526 return 1;
527 }
528}
529' > .tmp_src.cc
530 if test_compile $LIBUUID uuid uuid; then
531 if test_execute; then
532 cnf_append "LIB_UUID" `echo $LIBUUID|sed 's+-l++'`
533 fi
534 fi
535}
536
537#
538# Check for openssl, needed for RDP
539#
540function check_ssl()
541{
542 test_header ssl
543 echo '
544#include <cstdio>
545#include <openssl/opensslv.h>
546extern "C" int main(void)
547{
548 printf("found version %s", OPENSSL_VERSION_TEXT);
549#if OPENSSL_VERSION_NUMBER >= 0x0090700
550 printf(", OK.\n");
551 return 0;
552#else
553 printf(", expected version 0.9.7 or higher\n");
554 return 1;
555#endif
556}
557' > .tmp_src.cc
558 if test_compile $LIBCRYPTO libcrypto openssl; then
559 if test_execute nofatal; then
560 cnf_append "SDK_VBOX_OPENSSL_INCS" ""
561 cnf_append "SDK_VBOX_OPENSSL_LIBS" `echo $LIBCRYPTO|sed 's+-l++'`
562 fi
563 fi
564}
565
566#
567# Check for pthread, needed by VBoxSVC, frontends, ...
568#
569function check_pthread()
570{
571 test_header pthread
572 echo '
573#include <cstdio>
574#include <pthread.h>
575extern "C" int main(void)
576{
577 pthread_mutex_t mutex;
578 if (pthread_mutex_init(&mutex, NULL)) {
579 printf("pthread_mutex_init() failed\n");
580 return 1;
581 }
582 if (pthread_mutex_lock(&mutex)) {
583 printf("pthread_mutex_lock() failed\n");
584 return 1;
585 }
586 if (pthread_mutex_unlock(&mutex)) {
587 printf("pthread_mutex_unlock() failed\n");
588 return 1;
589 }
590 printf("found, OK.\n");
591}
592' > .tmp_src.cc
593 if test_compile $LIBPTHREAD pthread pthread; then
594 if test_execute; then
595 cnf_append "LIB_PTHREAD" `echo $LIBPTHREAD|sed 's+-l++'`
596 fi
597 fi
598}
599
600#
601# Check for zlib, needed by VBoxSVC, Runtime, ...
602#
603function check_z()
604{
605 test_header zlib
606 echo '
607#include <cstdio>
608#include <zlib.h>
609extern "C" int main(void)
610{
611 printf("found version %s", ZLIB_VERSION);
612#if ZLIB_VERNUM >= 0x1210
613 printf(", OK.\n");
614 return 0;
615#else
616 printf(", expected version 1.2.1 or higher\n");
617 return 1;
618#endif
619}
620' > .tmp_src.cc
621 if test_compile "$LIBZ ${INCZ:+-I$INCZ}" zlib zlib; then
622 if test_execute; then
623 cnf_append "SDK_VBOX_ZLIB_LIBS" `echo $LIBZ|sed 's+-l++'`
624 cnf_append "SDK_VBOX_ZLIB_INCS" "$INCZ"
625 fi
626 fi
627}
628
629#
630# Check for libpng, needed by kchmviewer
631#
632function check_png()
633{
634 test_header libpng
635 echo '
636#include <cstdio>
637#include <png.h>
638extern "C" int main(void)
639{
640 printf("found version %s", PNG_LIBPNG_VER_STRING);
641#if PNG_LIBPNG_VER >= 10205
642 printf(", OK.\n");
643 return 0;
644#else
645 printf(", expected version 1.2.5 or higher\n");
646 return 1;
647#endif
648}
649' > .tmp_src.cc
650 if test_compile "$LIBPNG ${INCPNG:+-I$INCPNG}" libpng libpng nofatal; then
651 if test_execute nofatal; then
652 cnf_append "SDK_VBOX_LIBPNG_LIBS" `echo $LIBPNG|sed 's+-l++'`
653 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
654 fi
655 fi
656}
657
658#
659# Check for pam, needed by VRDPAuth
660# Version 79 was introduced in 9/2005, do we support older versions?
661# Debian/sarge uses 76
662# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
663#
664function check_pam()
665{
666 test_header pam
667 echo '
668#include <cstdio>
669#include <security/pam_appl.h>
670extern "C" int main(void)
671{
672 printf("found version %d", __LIBPAM_VERSION);
673 if (__LIBPAM_VERSION >= 76)
674 {
675 printf(", OK.\n");
676 return 0;
677 }
678 else
679 {
680 printf(", expected version 76 or higher\n");
681 return 1;
682 }
683}
684' > .tmp_src.cc
685 if test_compile "-lpam" pam pam nofatal; then
686 if test_execute nofatal; then
687 return 0;
688 fi
689 fi
690 test_header linux_pam
691 echo '
692#include <cstdio>
693#include <security/pam_appl.h>
694extern "C" int main(void)
695{
696 printf("found version %d.%d", __LINUX_PAM__, __LINUX_PAM_MINOR__);
697 if (__LINUX_PAM__ >= 1)
698 {
699 printf(", OK.\n");
700 return 0;
701 }
702 else
703 {
704 printf(", expected version 1.0 or higher\n");
705 return 1;
706 }
707}
708' > .tmp_src.cc
709 if test_compile "-lpam" pam pam; then
710 test_execute
711 fi
712}
713
714#
715# Check for the SDL library, needed by VBoxSDL and VirtualBox
716# We depend at least on version 1.2.7
717#
718function check_sdl()
719{
720 test_header SDL
721 echo '
722#include <cstdio>
723#include <SDL/SDL.h>
724#include <SDL/SDL_main.h>
725extern "C" int main(void)
726{
727 printf("found version %d.%d.%d",
728 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
729#if SDL_VERSION_ATLEAST(1,2,7)
730 printf(", OK.\n");
731 return 0;
732#else
733 printf(", expected version 1.2.7 or higher\n");
734 return 1;
735#endif
736}
737' > .tmp_src.cc
738 if test_compile "$LIBSDL $LIBSDLMAIN ${INCSDL:+-I$INCSDL}" SDL SDL; then
739 if test_execute; then
740 cnf_append "LIB_SDK_LIBSDL_SDL" `echo $LIBSDL|sed 's+-l++'`
741 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" `echo $LIBSDLMAIN|sed 's+-l++'`
742 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
743 fi
744 fi
745}
746
747#
748# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
749#
750function check_sdl_ttf()
751{
752 test_header SDL_ttf
753 echo '
754#include <cstdio>
755#include <SDL/SDL_ttf.h>
756#ifndef SDL_TTF_MAJOR_VERSION
757#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
758#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
759#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
760#endif
761extern "C" int main(void)
762{
763 printf("found version %d.%d.%d",
764 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
765#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
766 printf(", OK.\n");
767 return 0;
768#else
769 printf(", expected version 2.0.6 or higher\n");
770 return 1;
771#endif
772}
773' > .tmp_src.cc
774 if test_compile "-lSDL_ttf" SDL_ttf SDL_ttf; then
775 test_execute
776 fi
777}
778
779#
780# Check for libasound, needed by the ALSA audio backend
781#
782function check_alsa()
783{
784 test_header ALSA
785 echo '
786#include <alsa/asoundlib.h>
787extern "C" int main(void)
788{
789 printf("found version %d.%d.%d",
790 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
791#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
792 printf(", OK.\n");
793 return 0;
794#else
795 printf(", expected version 1.0.6 or higher\n");
796 return 1;
797#endif
798}
799' > .tmp_src.cc
800 if test_compile "-lasound" asound asound; then
801 test_execute
802 fi
803}
804
805#
806# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
807#
808function check_xcursor()
809{
810 test_header Xcursor
811 echo '
812#include <cstdio>
813#include <X11/Xlib.h>
814#include <X11/Xcursor/Xcursor.h>
815extern "C" int main(void)
816{
817 XcursorImage *cursor = XcursorImageCreate (10, 10);
818 XcursorImageDestroy(cursor);
819 return 0;
820}
821' > .tmp_src.cc
822 if test_compile "$LIBX11 $LIBXCURSOR" Xcursor Xcursor; then
823 log_success "found"
824 cnf_append "LIB_XCURSOR" `echo $LIBXCURSOR|sed 's+-l++'`
825 fi
826}
827
828#
829# Check for the X libraries (Xext, X11)
830#
831function check_x()
832{
833 test_header "X libraries"
834 echo '
835#include <cstdio>
836#include <X11/Xlib.h>
837extern "C" int main(void)
838{
839 Display *dpy;
840 int scrn_num;
841 Screen *scrn;
842 Window win;
843
844 dpy = XOpenDisplay(NULL);
845 scrn_num = DefaultScreen(dpy);
846 scrn = ScreenOfDisplay(dpy, scrn_num);
847 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
848 0, 16, InputOutput, CopyFromParent, 0, NULL);
849 XDestroyWindow(dpy, win);
850}
851' > .tmp_src.cc
852 if test_compile "$LIBX11" Xlibs Xlibs; then
853 log_success "found"
854 fi
855}
856
857#
858# Check for the QT library, needed by VirtualBox
859#
860function check_qt()
861{
862 test_header Qt
863 echo '
864#include <cstdio>
865#include <qglobal.h>
866extern "C" int main(void)
867{
868 printf("found version %s", QT_VERSION_STR);
869#if QT_VERSION >= 0x030305
870 printf(", OK.\n");
871 return 0;
872#elif QT_VERSION >= 0x030300
873 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
874#else
875 printf(", expected version 3.3.0 or higher\n");
876 return 1;
877#endif
878}
879' > .tmp_src.cc
880 found_qt=0
881 for q in $QTDIR; do
882 echo "compiling the following source file:" >> $LOG
883 cat .tmp_src.cc >> $LOG
884 echo "using the following command line:" >> $LOG
885 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/lib -lqt-mt" >> $LOG
886 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/lib -lqt-mt >> $LOG 2>&1
887 if (($?==0)); then
888 if test_execute; then
889 cnf_append "QTDIR" `cd $q ; pwd`
890 found_qt=1
891 break
892 fi
893 fi
894 done
895 if (($found_qt!=1)); then
896 echo -e "\n Qt not found at \"$QTDIR\" or Qt headers not found"
897 echo " Check the file $LOG for detailed error information."
898 fail
899 return 1
900 fi
901 test_header "Qt devtools"
902 if check_avail "$q/bin/moc" QTDIR/bin; then
903 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
904 if (($?!=0)); then
905 log_failure "not found"
906 fail
907 else
908 log_success "found version $moc_ver"
909 fi
910 fi
911}
912
913#
914# Check for Linux sources
915#
916function check_linux()
917{
918 test_header "Linux kernel sources"
919 echo '
920#include <linux/version.h>
921int printf(const char *format, ...);
922int main(void)
923{
924 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
925 (LINUX_VERSION_CODE % 65536) / 256,
926 LINUX_VERSION_CODE % 256);
927#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
928 printf(", OK.\n");
929 return 0;
930#else
931 printf(", expected version 2.4.0 or higher\n");
932 return 1;
933#endif
934}
935' > .tmp_src.c
936 echo "compiling the following source file:" >> $LOG
937 cat .tmp_src.c >> $LOG
938 echo "using the following command line:" >> $LOG
939 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
940 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
941 if (($?!=0)); then
942 echo -e "\n Linux kernel headers not found at $LINUX"
943 echo " Check the file $LOG for detailed error information."
944 fail
945 else
946 if test_execute; then
947 cnf_append "VBOX_LINUX_SRC" `cd $LINUX ; pwd`
948 fi
949 fi
950}
951
952#
953# Check for kchmviewer, needed to display the online help
954#
955function check_kchmviewer()
956{
957 test_header kchmviewer
958 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
959 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
960 if (($?!=0)); then
961 log_failure "not found"
962 fail
963 else
964 log_success "found version $kchmviewer_ver"
965 fi
966 fi
967}
968
969#
970# Check for the kBuild tools, we don't support GNU make
971#
972function check_kbuild()
973{
974 test_header kBuild
975 if check_avail "$KBUILDDIR_BIN/kmk" KBUILDDIR really; then
976 log_success "found"
977 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
978 echo "export BUILD_PLATFORM_ARCH=\"$MACHINE\"" >> $ENV
979 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
980 echo "export BUILD_TARGET_ARCH=\"$MACHINE\"" >> $ENV
981 echo "export BUILD_TARGET_CPU=\"$CPU\"" >> $ENV
982 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
983 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
984 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
985 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
986 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
987 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
988 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
989 echo "export PATH" >> $ENV
990 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
991 fi
992}
993
994
995#
996# Check for compiler.h
997# Some Linux distributions include "compiler.h" in their libc linux
998# headers package, some don't. Most don't need it, building might (!)
999# not succeed on openSUSE without it.
1000#
1001# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1002#
1003function check_compiler_h
1004{
1005 test_header compiler.h
1006 if ! test -f "/usr/include/linux/compiler.h"; then
1007 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1008 log_success "compiler.h not found"
1009 else
1010 log_success "compiler.h found"
1011 fi
1012}
1013
1014
1015#
1016# Show help
1017#
1018function show_help()
1019{
1020 cat << EOF
1021Usage: ./configure [OPTIONS]...
1022
1023Configuration:
1024 -h, --help display this help and exit
1025 --nofatal don't abort on errors
1026 --disable-xpcom disable XPCOM and related stuff
1027
1028Paths:
1029 --with-gcc=PATH position of the gcc compiler [$CC]
1030 --with-g++=PATH position of the g++ compiler [$CXX]
1031 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1032 --with-iasl=PATH the position of the iasl compiler [$IASL]
1033 --with-linux=DIR Linux kernel source directory [$LINUX]
1034 --with-mkisofs=PATH position of mkisofs [$MKISOFS]
1035 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
1036 --with-xalan=LIB position of the xalan library [$LIBXALAN]
1037 --with-xerces=LIB position of the xerces library [$LIBXERCES]
1038
1039Build type:
1040 -d, --build-debug build with debugging symbols and assertions
1041EOF
1042 exit 0
1043}
1044
1045
1046#
1047# The body.
1048#
1049
1050# scan command line options
1051for option; do
1052 case "$option" in
1053 --help|-help|-h)
1054 show_help
1055 ;;
1056 --nofatal)
1057 nofatal=1
1058 ;;
1059 --with-gcc=*)
1060 CC=`echo $option | cut -d'=' -f2`
1061 ;;
1062 --with-g++=*)
1063 CXX=`echo $option | cut -d'=' -f2`
1064 ;;
1065 --with-kbuild=*)
1066 KBUILDDIR=`echo $option | cut -d'=' -f2`
1067 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1068 echo "Error: KBUILDDIR contains invalid characters!"
1069 exit 1
1070 fi
1071 ;;
1072 --with-qt-dir=*)
1073 QTDIR=`echo $option | cut -d'=' -f2`
1074 ;;
1075 --with-iasl=*)
1076 IASL=`echo $option | cut -d'=' -f2`
1077 ;;
1078 --with-linux=*)
1079 LINUX=`echo $option | cut -d'=' -f2`
1080 ;;
1081 --with-mkisofs=*)
1082 MKISOFS=`echo $option | cut -d'=' -f2`
1083 ;;
1084 --with-xalan=*)
1085 LIBXALAN=`echo $option | cut -d'=' -f2`
1086 ;;
1087 --with-xerces=*)
1088 LIBXERCES=`echo $option | cut -d'=' -f2`
1089 ;;
1090 --disable-xpcom)
1091 WITH_XPCOM=0
1092 ;;
1093 --disable-qt)
1094 WITH_QT=0
1095 ;;
1096 --build-debug|-d)
1097 BUILD_TYPE=debug
1098 ;;
1099 --ose)
1100 OSE=2
1101 ;;
1102 --odir=*)
1103 ODIR=`echo $option | cut -d'=' -f2`
1104 ;;
1105 *)
1106 echo
1107 echo "Unrecognized option \"$option\""
1108 echo
1109 show_help
1110 ;;
1111 esac
1112done
1113
1114LOG="${ODIR:+$ODIR/}$LOG"
1115ENV="${ODIR:+$ODIR/}$ENV"
1116CNF="${ODIR:+$ODIR/}$CNF"
1117
1118# initialize output files
1119cat > $LOG << EOF
1120# Log file generated by
1121#
1122# '$0 $*'
1123#
1124
1125EOF
1126cat > $CNF << EOF
1127# -*- Makefile -*-
1128#
1129# automatically generated by
1130#
1131# '$0 $*'
1132#
1133# It will be completely overwritten if configure is executed again.
1134#
1135
1136EOF
1137cat > $ENV << EOF
1138#!/bin/bash
1139#
1140# automatically generated by
1141#
1142# '$0 $*'
1143#
1144# It will be completely overwritten if configure is executed again.
1145# Make sure you source this file once before you start to build VBox.
1146#
1147
1148EOF
1149
1150# test if we are OSE
1151if (($OSE==1)) && [ -d "`cd $(dirname $0); pwd`/src/VBox/Devices/USB" ]; then
1152 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1153 echo >> $LOG
1154 OSE=0
1155fi
1156
1157# first determine our environment
1158check_environment
1159check_kbuild
1160
1161# some things are not available in for OSE
1162if (($OSE)); then
1163 cnf_append "VBOX_OSE" "1"
1164 cnf_append "VBOX_WITH_TESTSUITE" ""
1165 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1166
1167 if [ "$OS" = "linux" ]; then
1168 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1169 else
1170 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1171 fi
1172 echo >> $CNF
1173fi
1174
1175# append the tools directory to the default search path
1176echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1177
1178# append some extra paths
1179PATH="$PATH:/opt/gnome/bin"
1180
1181# the tools
1182check_gcc
1183[ "$OS" != "darwin" ] && check_as86
1184[ "$OS" != "darwin" ] && check_bcc
1185[ "$OS" != "darwin" ] && check_iasl
1186# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1187# [ "$OS" != "darwin" ] && check_yasm
1188[ "$OS" != "darwin" ] && check_xsltproc
1189(($OSE==0)) && check_mkisofs
1190
1191# the libraries
1192(($WITH_XPCOM==1)) && check_xalan
1193(($WITH_XPCOM==1)) && check_xerces
1194(($WITH_LIBIDL==1)) && check_libidl
1195[ "$OS" != "darwin" ] && check_uuid
1196(($OSE==0)) && check_ssl
1197[ "$OS" != "darwin" ] && check_pthread
1198[ "$OS" != "darwin" ] && check_z
1199(($OSE==0)) && check_png
1200(($OSE==0)) && check_pam
1201[ "$OS" != "darwin" ] && check_sdl
1202(($OSE==0)) && check_sdl_ttf
1203[ "$OS" != "darwin" ] && check_alsa
1204[ "$OS" != "darwin" ] && check_x
1205[ "$OS" != "darwin" ] && check_xcursor
1206(($WITH_QT==1)) && check_qt
1207
1208# Linux-specific
1209[ "$OS" = "linux" ] && check_linux
1210[ "$OS" = "linux" ] && check_compiler_h
1211
1212# success!
1213echo
1214echo "Successfully generated '$CNF' and '$ENV'."
1215echo "Source '$ENV' once before you start to build VBox:"
1216echo
1217echo " source $ENV"
1218echo " kmk"
1219echo
1220echo "Enjoy!"
1221cleanup
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