VirtualBox

source: vbox/trunk/configure@ 2676

Last change on this file since 2676 was 2665, checked in by vboxsync, 17 years ago

adapted QTDIR for rhel5-x86_64

  • Property svn:executable set to *
File size: 28.2 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 /usr/lib64/qt-3.3"
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 libs="lib"
859 [ "$LIB" = "lib64" ] && libs="$libs lib64"
860 for q in $QTDIR; do
861 for l in $libs; 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/$l -lqt-mt" >> $LOG
866
867 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt >> $LOG 2>&1
868 if (($?==0)); then
869 if test_execute; then
870 cnf_append "QTDIR" `cd $q ; pwd`
871 found_qt=1
872 break
873 fi
874 fi
875 done
876 done
877 if (($found_qt!=1)); then
878 echo -e "\n Qt not found at \"$QTDIR\" or Qt headers not found"
879 echo " Check the file $LOG for detailed error information."
880 fail
881 return 1
882 fi
883 test_header "Qt devtools"
884 if check_avail "$q/bin/moc" QTDIR/bin; then
885 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
886 if (($?!=0)); then
887 log_failure "not found"
888 fail
889 else
890 log_success "found version $moc_ver"
891 fi
892 fi
893}
894
895#
896# Check for Linux sources
897#
898function check_linux()
899{
900 test_header "Linux kernel sources"
901 echo '
902#include <linux/version.h>
903int printf(const char *format, ...);
904int main(void)
905{
906 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
907 (LINUX_VERSION_CODE % 65536) / 256,
908 LINUX_VERSION_CODE % 256);
909#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
910 printf(", OK.\n");
911 return 0;
912#else
913 printf(", expected version 2.4.0 or higher\n");
914 return 1;
915#endif
916}
917' > .tmp_src.c
918 echo "compiling the following source file:" >> $LOG
919 cat .tmp_src.c >> $LOG
920 echo "using the following command line:" >> $LOG
921 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
922 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
923 if (($?!=0)); then
924 echo -e "\n Linux kernel headers not found at $LINUX"
925 echo " Check the file $LOG for detailed error information."
926 fail
927 else
928 if test_execute; then
929 cnf_append "VBOX_LINUX_SRC" `cd $LINUX ; pwd`
930 fi
931 fi
932}
933
934#
935# Check for kchmviewer, needed to display the online help
936#
937function check_kchmviewer()
938{
939 test_header kchmviewer
940 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
941 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
942 if (($?!=0)); then
943 log_failure "not found"
944 fail
945 else
946 log_success "found version $kchmviewer_ver"
947 fi
948 fi
949}
950
951#
952# Check for the kBuild tools, we don't support GNU make
953#
954function check_kbuild()
955{
956 test_header kBuild
957 if check_avail "$KBUILDDIR_BIN/kmk" KBUILDDIR really; then
958 log_success "found"
959 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
960 echo "export BUILD_PLATFORM_ARCH=\"$MACHINE\"" >> $ENV
961 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
962 echo "export BUILD_TARGET_ARCH=\"$MACHINE\"" >> $ENV
963 echo "export BUILD_TARGET_CPU=\"$CPU\"" >> $ENV
964 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
965 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
966 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
967 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
968 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
969 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
970 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
971 echo "export PATH" >> $ENV
972 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
973 fi
974}
975
976
977#
978# Check for compiler.h
979# Some Linux distributions include "compiler.h" in their libc linux
980# headers package, some don't. Most don't need it, building might (!)
981# not succeed on openSUSE without it.
982#
983# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
984#
985function check_compiler_h
986{
987 test_header compiler.h
988 if ! test -f "/usr/include/linux/compiler.h"; then
989 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
990 log_success "compiler.h not found"
991 else
992 log_success "compiler.h found"
993 fi
994}
995
996
997#
998# Show help
999#
1000function show_help()
1001{
1002 cat << EOF
1003Usage: ./configure [OPTIONS]...
1004
1005Configuration:
1006 -h, --help display this help and exit
1007 --nofatal don't abort on errors
1008 --disable-xpcom disable XPCOM and related stuff
1009 --disable-sdl-ttf disable SDL_ttf detection
1010 --build-xalan build xalan & xerces from shipped sources
1011
1012Paths:
1013 --with-gcc=PATH position of the gcc compiler [$CC]
1014 --with-g++=PATH position of the g++ compiler [$CXX]
1015 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1016 --with-iasl=PATH the position of the iasl compiler [$IASL]
1017 --with-linux=DIR Linux kernel source directory [$LINUX]
1018 --with-mkisofs=PATH position of mkisofs [$MKISOFS]
1019 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
1020 --with-xalan=LIB position of the xalan library [$LIBXALAN]
1021 --with-xerces=LIB position of the xerces library [$LIBXERCES]
1022
1023Build type:
1024 -d, --build-debug build with debugging symbols and assertions
1025EOF
1026 exit 0
1027}
1028
1029
1030#
1031# The body.
1032#
1033
1034# scan command line options
1035for option; do
1036 case "$option" in
1037 --help|-help|-h)
1038 show_help
1039 ;;
1040 --nofatal)
1041 nofatal=1
1042 ;;
1043 --with-gcc=*)
1044 CC=`echo $option | cut -d'=' -f2`
1045 ;;
1046 --with-g++=*)
1047 CXX=`echo $option | cut -d'=' -f2`
1048 ;;
1049 --with-kbuild=*)
1050 KBUILDDIR=`echo $option | cut -d'=' -f2`
1051 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1052 echo "Error: KBUILDDIR contains invalid characters!"
1053 exit 1
1054 fi
1055 ;;
1056 --with-qt-dir=*)
1057 QTDIR=`echo $option | cut -d'=' -f2`
1058 ;;
1059 --with-iasl=*)
1060 IASL=`echo $option | cut -d'=' -f2`
1061 ;;
1062 --with-linux=*)
1063 LINUX=`echo $option | cut -d'=' -f2`
1064 ;;
1065 --with-mkisofs=*)
1066 MKISOFS=`echo $option | cut -d'=' -f2`
1067 ;;
1068 --with-xalan=*)
1069 LIBXALAN=`echo $option | cut -d'=' -f2`
1070 ;;
1071 --with-xerces=*)
1072 LIBXERCES=`echo $option | cut -d'=' -f2`
1073 ;;
1074 --disable-xpcom)
1075 WITH_XPCOM=0
1076 ;;
1077 --disable-sdl-ttf)
1078 WITH_SDL_TTF=0
1079 ;;
1080 --disable-qt)
1081 WITH_QT=0
1082 ;;
1083 --build-debug|-d)
1084 BUILD_TYPE=debug
1085 ;;
1086 --build-xalan)
1087 LIBXERCES=``
1088 LIBXALAN=``
1089 ;;
1090 --ose)
1091 OSE=2
1092 ;;
1093 --odir=*)
1094 ODIR=`echo $option | cut -d'=' -f2`
1095 ;;
1096 *)
1097 echo
1098 echo "Unrecognized option \"$option\""
1099 echo
1100 show_help
1101 ;;
1102 esac
1103done
1104
1105LOG="${ODIR:+$ODIR/}$LOG"
1106ENV="${ODIR:+$ODIR/}$ENV"
1107CNF="${ODIR:+$ODIR/}$CNF"
1108
1109# initialize output files
1110cat > $LOG << EOF
1111# Log file generated by
1112#
1113# '$0 $*'
1114#
1115
1116EOF
1117cat > $CNF << EOF
1118# -*- Makefile -*-
1119#
1120# automatically generated by
1121#
1122# '$0 $*'
1123#
1124# It will be completely overwritten if configure is executed again.
1125#
1126
1127EOF
1128cat > $ENV << EOF
1129#!/bin/bash
1130#
1131# automatically generated by
1132#
1133# '$0 $*'
1134#
1135# It will be completely overwritten if configure is executed again.
1136# Make sure you source this file once before you start to build VBox.
1137#
1138
1139EOF
1140
1141# test if we are OSE
1142if (($OSE==1)) && [ -d "`cd $(dirname $0); pwd`/src/VBox/Devices/USB" ]; then
1143 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1144 echo >> $LOG
1145 OSE=0
1146fi
1147
1148# first determine our environment
1149check_environment
1150check_kbuild
1151
1152# some things are not available in for OSE
1153if (($OSE)); then
1154 cnf_append "VBOX_OSE" "1"
1155 cnf_append "VBOX_WITH_TESTSUITE" ""
1156 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1157
1158 if [ "$OS" = "linux" ]; then
1159 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1160 else
1161 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1162 fi
1163 echo >> $CNF
1164fi
1165
1166# emit disable directives corresponding to any --disable-xxx options.
1167(($WITH_XPCOM==0)) && cnf_append "VBOX_WITH_MAIN" ""
1168(($WITH_QT==0)) && cnf_append "VBOX_WITH_QTGUI" ""
1169(($WITH_SDL_TTF==0)) && cnf_append "VBOX_WITH_SECURELABEL" ""
1170
1171# append the tools directory to the default search path
1172echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1173
1174# append some extra paths
1175PATH="$PATH:/opt/gnome/bin"
1176
1177# the tools
1178check_gcc
1179[ "$OS" != "darwin" ] && check_as86
1180[ "$OS" != "darwin" ] && check_bcc
1181[ "$OS" != "darwin" ] && check_iasl
1182# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1183# [ "$OS" != "darwin" ] && check_yasm
1184[ "$OS" != "darwin" ] && check_xsltproc
1185(($OSE==0)) && check_mkisofs
1186
1187# the libraries
1188(($WITH_XPCOM==1)) && check_xalan
1189(($WITH_XPCOM==1)) && check_xerces
1190(($WITH_LIBIDL==1)) && check_libidl
1191(($OSE==0)) && check_ssl
1192[ "$OS" != "darwin" ] && check_pthread
1193[ "$OS" != "darwin" ] && check_z
1194(($OSE==0)) && check_png
1195(($OSE==0)) && [ "$OS" = "linux" ] && check_pam
1196[ "$OS" != "darwin" ] && check_sdl
1197(($WITH_SDL_TTF==1)) && (($OSE==0)) && check_sdl_ttf
1198[ "$OS" != "darwin" ] && check_alsa
1199[ "$OS" != "darwin" ] && check_x
1200[ "$OS" != "darwin" ] && check_xcursor
1201(($WITH_QT==1)) && check_qt
1202
1203# Linux-specific
1204[ "$OS" = "linux" ] && check_linux
1205[ "$OS" = "linux" ] && check_compiler_h
1206
1207# success!
1208echo
1209echo "Successfully generated '$CNF' and '$ENV'."
1210echo "Source '$ENV' once before you start to build VBox:"
1211echo ""
1212echo " source $ENV"
1213echo " kmk"
1214echo ""
1215if [ "$OS" = "linux" ]; then
1216 echo "To compile the kernel module, do:"
1217 echo ""
1218 echo " cd ./out/$OS.$MACHINE/$BUILD_TYPE/bin/src"
1219 echo " make"
1220 echo ""
1221fi
1222echo "Enjoy!"
1223cleanup
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use