VirtualBox

source: vbox/trunk/configure@ 2349

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

XPCOM etc. are used on Darwin

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