VirtualBox

source: vbox/trunk/configure@ 2549

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

configure: we are not using precompiled objects anymore; added --build-xalan to force building xalan & xerces from shipped sources; use this new option to fix the rhel4 build

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