VirtualBox

source: vbox/trunk/configure@ 2597

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

I think we can remove this warning, right?

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