VirtualBox

source: vbox/trunk/configure@ 838

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

configure: also check for newer libpam

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