VirtualBox

source: vbox/trunk/configure@ 1224

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

configure: --disable-sdl-ttf

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