VirtualBox

source: vbox/trunk/configure@ 2917

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

Updated the host DVD code on Linux to use hal for device detection

  • Property svn:executable set to *
File size: 29.7 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
32WITH_HAL=1
33CC="gcc"
34CXX="g++"
35BCC="bcc"
36YASM="yasm"
37IASL="iasl"
38AS86="as86"
39XSLTPROC="xsltproc"
40GENISOIMAGE="genisoimage"
41MKISOFS="mkisofs"
42INCXALAN=""
43LIBXALAN="-lxalan-c"
44INCXERCES=""
45LIBXERCES="-lxerces-c"
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"
57CFLAGSHAL="-I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include"
58LIBHAL="-lhal -ldbus-1"
59QTDIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3 /usr/lib64/qt-3.3"
60KBUILDDIR="`cd $(dirname $0); pwd`/kBuild"
61DEVDIR="`cd $(dirname $0); pwd`/tools"
62if [ -d /lib/modules/`uname -r`/build ]; then
63 LINUX="/lib/modules/`uname -r`/build"
64else
65 LINUX="/usr/src/linux"
66fi
67KCHMVIEWER="kchmviewer"
68LOG="configure.log"
69CNF="AutoConfig.kmk"
70ENV="env.sh"
71BUILD_TYPE="release"
72# the restricting tool is ar (mri mode).
73INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
74
75if (cd $(dirname $0); pwd)|grep -q "$INVALID_CHARS"; then
76 echo "Error: VBox base path contains invalid characters!"
77 exit 1
78fi
79
80function cleanup()
81{
82 rm -f .tmp_src.cc .tmp_src.c .tmp_out .test_execute.log
83}
84
85function fail()
86{
87 if [ -z "$nofatal" -o "x$1" != "x" ]; then
88 cleanup
89 rm -f $ENV
90 exit 1
91 fi
92}
93
94function log_success()
95{
96 if [ -n "$1" ]; then echo -n "$1, "; fi
97 echo "OK."
98 echo -e "$1\n\n" >> $LOG
99}
100
101function log_failure()
102{
103 echo -e "\n ** $1!"
104 echo -e "** $1!\n" >> $LOG
105}
106
107function cnf_append()
108{
109 printf "%-30s := %s\n" "$1" "$2" >> $CNF
110}
111
112# Wrapper for ancient /usr/bin/which on darwin that always returns 0
113function which_wrapper()
114{
115 if [ -z "$have_ancient_which" ]; then
116 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
117 have_ancient_which="yes"
118 else
119 have_ancient_which="no"
120 fi
121 fi
122 if [ "$have_ancient_which" = "yes" ]; then
123 local retval=`which $* 2>/dev/null`
124 echo "$retval"
125 test -n "$retval" -a -e "$retval"
126 else
127 which $* 2> /dev/null
128 fi
129}
130
131function check_avail()
132{
133 if [ -z "$1" ]; then
134 log_failure "$2 is empty"
135 fail $3
136 return 1
137 elif which_wrapper $1 > /dev/null; then
138 return 0
139 else
140 log_failure "$1 (variable $2) not found"
141 fail $3
142 return 1
143 fi
144}
145
146# Prepare a test
147function test_header()
148{
149 echo "***** Checking $1 *****" >> $LOG
150 echo -n "Checking for $1: "
151}
152
153# Compile a test
154function test_compile()
155{
156 echo "compiling the following source file:" >> $LOG
157 cat .tmp_src.cc >> $LOG
158 echo "using the following command line:" >> $LOG
159 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
160 $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
161 if (($?!=0)); then
162 if [ -z "$4" ]; then
163 echo -e "\n $2 not found at $1 or $3 headers not found"
164 echo " Check the file $LOG for detailed error information."
165 fail
166 else
167 echo "not found."
168 echo -e "\n" >> $LOG
169 fi
170 return 1
171 fi
172 return 0
173}
174
175# Execute a compiled test binary
176function test_execute()
177{
178 echo "executing the binary" >> $LOG
179 ./.tmp_out > .test_execute.log
180 rc=$?
181 cat .test_execute.log | tee -a $LOG
182 if (($rc!=0)); then
183 fail $1
184 return 1
185 fi
186 echo -e "\n\n" >> $LOG
187 return 0
188}
189
190#
191# Check for OS, MACHINE, CPU
192#
193function check_environment()
194{
195 test_header environment
196 CPU=`uname -m`
197 case "$CPU" in
198 i[3456789]86|x86)
199 MACHINE='x86'
200 LIB='lib'
201 ;;
202 x86_64|amd64)
203 MACHINE='amd64'
204 CPU='k8'
205 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
206 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
207 LIB='lib64'
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 libs="lib"
862 [ "$LIB" = "lib64" ] && libs="$libs lib64"
863 for q in $QTDIR; do
864 for l in $libs; do
865 echo "compiling the following source file:" >> $LOG
866 cat .tmp_src.cc >> $LOG
867 echo "using the following command line:" >> $LOG
868 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt" >> $LOG
869
870 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt >> $LOG 2>&1
871 if (($?==0)); then
872 if test_execute; then
873 cnf_append "QTDIR" `cd $q ; pwd`
874 found_qt=1
875 break
876 fi
877 fi
878 done
879 if (($found_qt==1)); then
880 break
881 fi
882 done
883 if (($found_qt!=1)); then
884 echo -e "\n Qt not found at \"$QTDIR\" or Qt headers not found"
885 echo " Check the file $LOG for detailed error information."
886 fail
887 return 1
888 fi
889 test_header "Qt devtools"
890 if check_avail "$q/bin/moc" QTDIR/bin; then
891 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
892 if (($?!=0)); then
893 log_failure "not found"
894 fail
895 else
896 log_success "found version $moc_ver"
897 fi
898 fi
899}
900
901#
902# Check for Linux sources
903#
904function check_linux()
905{
906 test_header "Linux kernel sources"
907 echo '
908#include <linux/version.h>
909int printf(const char *format, ...);
910int main(void)
911{
912 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
913 (LINUX_VERSION_CODE % 65536) / 256,
914 LINUX_VERSION_CODE % 256);
915#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
916 printf(", OK.\n");
917 return 0;
918#else
919 printf(", expected version 2.4.0 or higher\n");
920 return 1;
921#endif
922}
923' > .tmp_src.c
924 echo "compiling the following source file:" >> $LOG
925 cat .tmp_src.c >> $LOG
926 echo "using the following command line:" >> $LOG
927 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
928 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
929 if (($?!=0)); then
930 echo -e "\n Linux kernel headers not found at $LINUX"
931 echo " Check the file $LOG for detailed error information."
932 fail
933 else
934 if test_execute; then
935 cnf_append "VBOX_LINUX_SRC" `cd $LINUX ; pwd`
936 fi
937 fi
938}
939
940#
941# Check for kchmviewer, needed to display the online help
942#
943function check_kchmviewer()
944{
945 test_header kchmviewer
946 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
947 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
948 if (($?!=0)); then
949 log_failure "not found"
950 fail
951 else
952 log_success "found version $kchmviewer_ver"
953 fi
954 fi
955}
956
957#
958# Check for the kBuild tools, we don't support GNU make
959#
960function check_kbuild()
961{
962 test_header kBuild
963 if check_avail "$KBUILDDIR_BIN/kmk" KBUILDDIR really; then
964 log_success "found"
965 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
966 echo "export BUILD_PLATFORM_ARCH=\"$MACHINE\"" >> $ENV
967 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
968 echo "export BUILD_TARGET_ARCH=\"$MACHINE\"" >> $ENV
969 echo "export BUILD_TARGET_CPU=\"$CPU\"" >> $ENV
970 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
971 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
972 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
973 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
974 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
975 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
976 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
977 echo "export PATH" >> $ENV
978 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
979 fi
980}
981
982
983#
984# Check for compiler.h
985# Some Linux distributions include "compiler.h" in their libc linux
986# headers package, some don't. Most don't need it, building might (!)
987# not succeed on openSUSE without it.
988#
989# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
990#
991function check_compiler_h
992{
993 test_header compiler.h
994 if ! test -f "/usr/include/linux/compiler.h"; then
995 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
996 log_success "compiler.h not found"
997 else
998 log_success "compiler.h found"
999 fi
1000}
1001
1002
1003#
1004# Check for the libhal library for obtaining hardware information on Linux
1005#
1006function check_libhal()
1007{
1008 test_header libhal
1009 pc_cflagshal=`pkg-config hal --cflags 2>/dev/null`
1010 pc_libhal=`pkg-config hal --libs 2>/dev/null`
1011 if [ ! -z "$pc_cflagshal" ]
1012 then # is this acceptable?
1013 CFLAGSHAL=$pc_cflagshal
1014 LIBHAL=$pc_libhal
1015 fi
1016 echo '
1017#include <cstdio>
1018#include <libhal.h>
1019extern "C" int main(void)
1020{
1021 DBusError dbusError;
1022 dbus_error_init (&dbusError);
1023 LibHalContext *halContext = libhal_ctx_new();
1024 if (halContext != 0)
1025 {
1026 libhal_ctx_free(halContext);
1027 }
1028 return 0;
1029}
1030' > .tmp_src.cc
1031 if test_compile "$CFLAGSHAL $LIBHAL" libhal libhal; then
1032 log_success "found"
1033 cnf_append "LIB_HAL_CFLAGS" "$CFLAGSHAL"
1034 cnf_append "LIB_HAL_LIBS" `echo $LIBHAL | sed 's+-l++g'`
1035 cnf_append "VBOX_WITH_LIBHAL" "1"
1036 fi
1037}
1038
1039
1040#
1041# Show help
1042#
1043function show_help()
1044{
1045 cat << EOF
1046Usage: ./configure [OPTIONS]...
1047
1048Configuration:
1049 -h, --help display this help and exit
1050 --nofatal don't abort on errors
1051 --disable-xpcom disable XPCOM and related stuff
1052 --disable-sdl-ttf disable SDL_ttf detection
1053 --build-xalan build xalan & xerces from shipped sources
1054 --without-hal do not use libhal, even if it is available
1055
1056Paths:
1057 --with-gcc=PATH location of the gcc compiler [$CC]
1058 --with-g++=PATH location of the g++ compiler [$CXX]
1059 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1060 --with-iasl=PATH location of the iasl compiler [$IASL]
1061 --with-hal-cflags=FLAGS cflags for libhal [$CFLAGSHAL]
1062 --with-hal=LIB location of the libhal libraries [$LIBHAL]
1063 --with-linux=DIR Linux kernel source directory [$LINUX]
1064 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1065 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
1066 --with-xalan=LIB location of the xalan library [$LIBXALAN]
1067 --with-xerces=LIB location of the xerces library [$LIBXERCES]
1068
1069Build type:
1070 -d, --build-debug build with debugging symbols and assertions
1071EOF
1072 exit 0
1073}
1074
1075
1076#
1077# The body.
1078#
1079
1080# scan command line options
1081for option; do
1082 case "$option" in
1083 --help|-help|-h)
1084 show_help
1085 ;;
1086 --nofatal)
1087 nofatal=1
1088 ;;
1089 --with-gcc=*)
1090 CC=`echo $option | cut -d'=' -f2`
1091 ;;
1092 --with-g++=*)
1093 CXX=`echo $option | cut -d'=' -f2`
1094 ;;
1095 --with-kbuild=*)
1096 KBUILDDIR=`echo $option | cut -d'=' -f2`
1097 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1098 echo "Error: KBUILDDIR contains invalid characters!"
1099 exit 1
1100 fi
1101 ;;
1102 --with-qt-dir=*)
1103 QTDIR=`echo $option | cut -d'=' -f2`
1104 ;;
1105 --with-hal-dir=*)
1106 INCHAL=`echo $option | cut -d'=' -f2`
1107 ;;
1108 --with-hal=*)
1109 LIBHAL=`echo $option | cut -d'=' -f2`
1110 ;;
1111 --with-iasl=*)
1112 IASL=`echo $option | cut -d'=' -f2`
1113 ;;
1114 --with-linux=*)
1115 LINUX=`echo $option | cut -d'=' -f2`
1116 ;;
1117 --with-mkisofs=*)
1118 MKISOFS=`echo $option | cut -d'=' -f2`
1119 ;;
1120 --with-xalan=*)
1121 LIBXALAN=`echo $option | cut -d'=' -f2`
1122 ;;
1123 --with-xerces=*)
1124 LIBXERCES=`echo $option | cut -d'=' -f2`
1125 ;;
1126 --disable-xpcom)
1127 WITH_XPCOM=0
1128 ;;
1129 --disable-sdl-ttf)
1130 WITH_SDL_TTF=0
1131 ;;
1132 --disable-qt)
1133 WITH_QT=0
1134 ;;
1135 --without-hal)
1136 WITH_HAL=0
1137 ;;
1138 --build-debug|-d)
1139 BUILD_TYPE=debug
1140 ;;
1141 --build-xalan)
1142 LIBXERCES=``
1143 LIBXALAN=``
1144 ;;
1145 --ose)
1146 OSE=2
1147 ;;
1148 --odir=*)
1149 ODIR=`echo $option | cut -d'=' -f2`
1150 ;;
1151 *)
1152 echo
1153 echo "Unrecognized option \"$option\""
1154 echo
1155 show_help
1156 ;;
1157 esac
1158done
1159
1160LOG="${ODIR:+$ODIR/}$LOG"
1161ENV="${ODIR:+$ODIR/}$ENV"
1162CNF="${ODIR:+$ODIR/}$CNF"
1163
1164# initialize output files
1165cat > $LOG << EOF
1166# Log file generated by
1167#
1168# '$0 $*'
1169#
1170
1171EOF
1172cat > $CNF << EOF
1173# -*- Makefile -*-
1174#
1175# automatically generated by
1176#
1177# '$0 $*'
1178#
1179# It will be completely overwritten if configure is executed again.
1180#
1181
1182EOF
1183cat > $ENV << EOF
1184#!/bin/bash
1185#
1186# automatically generated by
1187#
1188# '$0 $*'
1189#
1190# It will be completely overwritten if configure is executed again.
1191# Make sure you source this file once before you start to build VBox.
1192#
1193
1194EOF
1195
1196# test if we are OSE
1197if (($OSE==1)) && [ -d "`cd $(dirname $0); pwd`/src/VBox/Devices/USB" ]; then
1198 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1199 echo >> $LOG
1200 OSE=0
1201fi
1202
1203# first determine our environment
1204check_environment
1205check_kbuild
1206
1207# some things are not available in for OSE
1208if (($OSE)); then
1209 cnf_append "VBOX_OSE" "1"
1210 cnf_append "VBOX_WITH_TESTSUITE" ""
1211 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1212
1213 if [ "$OS" = "linux" ]; then
1214 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1215 else
1216 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1217 fi
1218 echo >> $CNF
1219fi
1220
1221# emit disable directives corresponding to any --disable-xxx options.
1222(($WITH_XPCOM==0)) && cnf_append "VBOX_WITH_MAIN" ""
1223(($WITH_QT==0)) && cnf_append "VBOX_WITH_QTGUI" ""
1224(($WITH_SDL_TTF==0)) && cnf_append "VBOX_WITH_SECURELABEL" ""
1225
1226# append the tools directory to the default search path
1227echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1228
1229# append some extra paths
1230PATH="$PATH:/opt/gnome/bin"
1231
1232# the tools
1233check_gcc
1234[ "$OS" != "darwin" ] && check_as86
1235[ "$OS" != "darwin" ] && check_bcc
1236[ "$OS" != "darwin" ] && check_iasl
1237# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1238# [ "$OS" != "darwin" ] && check_yasm
1239[ "$OS" != "darwin" ] && check_xsltproc
1240(($OSE==0)) && check_mkisofs
1241
1242# the libraries
1243(($WITH_XPCOM==1)) && check_xalan
1244(($WITH_XPCOM==1)) && check_xerces
1245(($WITH_LIBIDL==1)) && check_libidl
1246(($OSE==0)) && check_ssl
1247[ "$OS" != "darwin" ] && check_pthread
1248[ "$OS" != "darwin" ] && check_z
1249(($OSE==0)) && check_png
1250(($OSE==0)) && [ "$OS" = "linux" ] && check_pam
1251[ "$OS" != "darwin" ] && check_sdl
1252(($WITH_SDL_TTF==1)) && (($OSE==0)) && check_sdl_ttf
1253[ "$OS" != "darwin" ] && check_alsa
1254[ "$OS" != "darwin" ] && check_x
1255[ "$OS" != "darwin" ] && check_xcursor
1256(($WITH_QT==1)) && check_qt
1257
1258# Linux-specific
1259[ "$OS" = "linux" ] && check_linux
1260[ "$OS" = "linux" ] && check_compiler_h
1261[ "$OS" = "linux" -a "$WITH_HAL" = "1" ] && check_libhal
1262
1263# success!
1264echo
1265echo "Successfully generated '$CNF' and '$ENV'."
1266echo "Source '$ENV' once before you start to build VBox:"
1267echo ""
1268echo " source $ENV"
1269echo " kmk"
1270echo ""
1271if [ "$OS" = "linux" ]; then
1272 echo "To compile the kernel module, do:"
1273 echo ""
1274 echo " cd ./out/$OS.$MACHINE/$BUILD_TYPE/bin/src"
1275 echo " make"
1276 echo ""
1277fi
1278echo "Enjoy!"
1279cleanup
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