VirtualBox

source: vbox/trunk/configure@ 1572

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

Removed libuuid dependency.

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