VirtualBox

source: vbox/trunk/configure@ 3163

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

fixed some issues with FreeBSD, thanks Jason Spiro

  • Property svn:executable set to *
File size: 30.6 KB
Line 
1#!/bin/sh
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-2007 innotek GmbH
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License as published by the Free Software Foundation,
12# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13# distribution. VirtualBox OSE is distributed in the hope that it will
14# be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# If you received this file as part of a commercial VirtualBox
17# distribution, then only the terms of your commercial VirtualBox
18# license agreement apply instead of the previous paragraph.
19#
20
21LC_ALL=C
22export LC_ALL
23
24#
25# Defaults
26#
27OSE=1
28WITH_XPCOM=1
29WITH_LIBIDL=1
30WITH_QT=1
31WITH_SDL_TTF=1
32WITH_HAL=1
33CC="gcc"
34CXX="g++"
35BCC="bcc"
36YASM="yasm"
37IASL="iasl"
38AS86="as86"
39XSLTPROC="xsltproc"
40GENISOIMAGE="genisoimage"
41MKISOFS="mkisofs"
42INCXALAN=""
43LIBXALAN="-lxalan-c"
44INCXERCES=""
45LIBXERCES="-lxerces-c"
46LIBCRYPTO="-lcrypto"
47LIBPTHREAD="-lpthread"
48LIBX11="-L/usr/X11R6/lib -lXext -lX11"
49LIBXCURSOR="-lXcursor"
50INCZ=""
51LIBZ="-lz"
52INCPNG=""
53LIBPNG="-lpng"
54CFLAGSHAL="-I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include"
55LIBPATHHAL=""
56LIBHAL="-lhal -ldbus-1"
57QTDIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3 /usr/lib64/qt-3.3 /usr/X11R6"
58KBUILDDIR="`cd $(dirname $0); pwd`/kBuild"
59DEVDIR="`cd $(dirname $0); pwd`/tools"
60if [ -d "/lib/modules/`uname -r`/build" ]; then
61 LINUX="/lib/modules/`uname -r`/build"
62else
63 LINUX="/usr/src/linux"
64fi
65KCHMVIEWER="kchmviewer"
66LOG="configure.log"
67CNF="AutoConfig.kmk"
68ENV="env.sh"
69BUILD_TYPE="release"
70# the restricting tool is ar (mri mode).
71INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
72
73if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
74 echo "Error: VBox base path contains invalid characters!"
75 exit 1
76fi
77
78cleanup()
79{
80 rm -f .tmp_src.cc .tmp_src.c .tmp_out .test_execute.log
81}
82
83fail()
84{
85 if [ -z "$nofatal" -o "x$1" != "x" ]; then
86 cleanup
87 rm -f $ENV
88 exit 1
89 fi
90}
91
92log_success()
93{
94 if [ -n "$1" ]; then echo -n "$1, "; fi
95 echo "OK."
96 echo -e "$1\n\n" >> $LOG
97}
98
99log_failure()
100{
101 echo -e "\n ** $1!"
102 echo -e "** $1!\n" >> $LOG
103}
104
105cnf_append()
106{
107 printf "%-30s := %s\n" "$1" "$2" >> $CNF
108}
109
110strip_l()
111{
112 echo "$1"|sed 's|-l\([^ ]\+\)|\1|g; s|-[^l]\([^ ]\+\)||g; s|^ ||; s| *$||g'
113}
114
115strip_L()
116{
117 echo "$1"|sed 's|-L\([^ ]\+\)|\1|g; s|-[^L]\([^ ]\+\)||g; s|^ ||; s| *$||g'
118}
119
120strip_I()
121{
122 echo "$1"|sed 's|-I\([^ ]\+\)|\1|g; s|-[^I]\([^ ]\+\)||g; s|^ ||; s| *$||g'
123}
124
125# Wrapper for ancient /usr/bin/which on darwin that always returns 0
126which_wrapper()
127{
128 if [ -z "$have_ancient_which" ]; then
129 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
130 have_ancient_which="yes"
131 else
132 have_ancient_which="no"
133 fi
134 fi
135 if [ "$have_ancient_which" = "yes" ]; then
136 local retval=`which $* 2>/dev/null`
137 echo "$retval"
138 test -n "$retval" -a -e "$retval"
139 else
140 which $* 2> /dev/null
141 fi
142}
143
144check_avail()
145{
146 if [ -z "$1" ]; then
147 log_failure "$2 is empty"
148 fail $3
149 return 1
150 elif which_wrapper $1 > /dev/null; then
151 return 0
152 else
153 log_failure "$1 (variable $2) not found"
154 fail $3
155 return 1
156 fi
157}
158
159# Prepare a test
160test_header()
161{
162 echo "***** Checking $1 *****" >> $LOG
163 echo -n "Checking for $1: "
164}
165
166# Compile a test
167test_compile()
168{
169 echo "compiling the following source file:" >> $LOG
170 cat .tmp_src.cc >> $LOG
171 echo "using the following command line:" >> $LOG
172 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
173 $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
174 if [ $? -ne 0 ]; then
175 if [ -z "$4" ]; then
176 echo -e "\n $2 not found at $1 or $3 headers not found"
177 echo " Check the file $LOG for detailed error information."
178 fail
179 else
180 echo "not found."
181 echo -e "\n" >> $LOG
182 fi
183 return 1
184 fi
185 return 0
186}
187
188# Execute a compiled test binary
189test_execute()
190{
191 echo "executing the binary" >> $LOG
192 ./.tmp_out > .test_execute.log
193 rc=$?
194 cat .test_execute.log | tee -a $LOG
195 if [ $rc -ne 0 ]; then
196 fail $1
197 return 1
198 fi
199 echo -e "\n\n" >> $LOG
200 return 0
201}
202
203#
204# Check for OS, MACHINE, CPU
205#
206check_environment()
207{
208 test_header environment
209 CPU=`uname -m`
210 case "$CPU" in
211 i[3456789]86|x86)
212 MACHINE='x86'
213 LIB='lib'
214 ;;
215 x86_64|amd64)
216 MACHINE='amd64'
217 CPU='k8'
218 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
219 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
220 LIB='lib64'
221 ;;
222 *)
223 log_failure "Cannot determine system"
224 exit 1
225 ;;
226 esac
227 OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr 'A-Z' 'a-z'`
228 case "$OS" in
229 linux)
230 ;;
231 darwin)
232 ;;
233 *)
234 log_failure "Cannot determine OS"
235 exit 1
236 ;;
237 esac
238 DEVDIR_BIN="$DEVDIR/$OS.$MACHINE/bin"
239 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$MACHINE"
240 log_success "Determined $OS.$MACHINE"
241
242 # Automatically disable XPCOM on darwin.
243 if [ "$OS" = "darwin" -a $WITH_XPCOM -eq 1 ]; then
244 WITH_XPCOM=0
245 WITH_LIBIDL=0
246 WITH_QT=0
247 echo "Disabling checks for XPCOM related components."
248 fi
249}
250
251#
252# Check for gcc with version >= 3.2.
253# We depend on a working gcc, if we fail terminate in every case.
254#
255check_gcc()
256{
257 test_header gcc
258 if check_avail "$CC" CC really; then
259 cc_ver=`$CC -dumpversion`
260 if check_avail "$CXX" CXX really; then
261 cxx_ver=`$CXX -dumpversion`
262 cc_maj=`echo $cc_ver|cut -d. -f1`
263 cc_min=`echo $cc_ver|cut -d. -f2`
264 if [ "x$cc_ver" != "x$cxx_ver" ]; then
265 log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
266 fail really
267 elif [ $cc_maj -gt 3 ]; then
268 log_success "found version $cc_ver"
269 elif [ $cc_maj -lt 3 -o $cc_min -lt 2 ]; then
270 log_failure "gcc version $cc_ver found, expected at least gcc version 3.2"
271 fail really
272 else
273 log_success "found version $cc_ver"
274 fi
275 if [ "$CC" != "gcc" ]; then
276 cnf_append "TOOL_GCC3_CC" "$CC"
277 cnf_append "TOOL_GCC3_AS" "$CC"
278 cnf_append "TOOL_GXX3_CC" "$CC"
279 cnf_append "TOOL_GXX3_AS" "$CC"
280 fi
281 if [ "$CXX" != "g++" ]; then
282 cnf_append "TOOL_GCC3_CXX" "$CXX"
283 cnf_append "TOOL_GCC3_LD" "$CXX"
284 cnf_append "TOOL_GXX3_CXX" "$CXX"
285 cnf_append "TOOL_GXX3_LD" "$CXX"
286 fi
287 fi
288 fi
289}
290
291#
292# Check for the bcc compiler, needed for compiling the BIOS
293#
294check_bcc()
295{
296 test_header bcc
297 if check_avail "$BCC" BCC; then
298 bcc_ver=`$BCC -v 2>&1|grep version|sed 's+^bcc: version \(.*\)+\1+'`
299 if [ $? -ne 0 ]; then
300 log_failure "not found"
301 fail
302 else
303 echo "compiling the following source file:" >> $LOG
304 cat > .tmp_src.c << EOF
305int foo(a)
306 int a;
307{
308 return 0;
309}
310EOF
311 cat .tmp_src.c >> $LOG
312 local bcc_path=`which_wrapper $BCC`
313 local bcc_dir="`dirname $bcc_path`/"
314 echo "using the following command line:" >> $LOG
315 echo "$BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c" >> $LOG
316 $BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c >> $LOG 2>&1
317 if [ $? -ne 0 ]; then
318 log_failure "not found"
319 fail
320 else
321 log_success "found version $bcc_ver"
322 cnf_append "VBOX_BCC" "$bcc_path -B $bcc_dir"
323 fi
324 fi
325 fi
326}
327
328#
329# Check for the as86 assembler, needed for compiling the BIOS
330#
331check_as86()
332{
333 test_header as86
334 if check_avail "$AS86" AS86; then
335 as86_ver=`$AS86 -v 2>&1|grep version|sed 's+^as86 version: \(.*\)+\1+'`
336 if [ $? -ne 0 ]; then
337 log_failure "not found"
338 fail
339 else
340 log_success "found version $as86_ver"
341 cnf_append "VBOX_AS86" "`which_wrapper $AS86`"
342 fi
343 fi
344}
345
346#
347# Check for yasm, needed to compile assembler files
348#
349check_yasm()
350{
351 test_header yasm
352 if check_avail "$YASM" YASM; then
353 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
354 if [ $? -ne 0 ]; then
355 log_failure "not found"
356 fail
357 else
358 yasm_maj=`echo $yasm_ver|cut -d. -f1`
359 yasm_min=`echo $yasm_ver|cut -d. -f2`
360 yasm_rev=`echo $yasm_ver|cut -d. -f3`
361 yasm_ver_mul=$(($yasm_maj*10000+$yasm_min*100+$yasm_rev))
362 if [ $yasm_ver_mul -lt 501 ]; then
363 log_failure "found version $yasm_ver, expected at least 0.5.1"
364 fail
365 else
366 log_success "found version $yasm_ver"
367 fi
368 fi
369 fi
370}
371
372#
373# Check for the iasl ACPI compiler, needed to compile vbox.dsl
374#
375check_iasl()
376{
377 test_header iasl
378 if check_avail "$IASL" IASL; then
379 iasl_ver=`$IASL|grep version|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
380 if [ $? -ne 0 ]; then
381 log_failure "not found"
382 fail
383 else
384 log_success "found version $iasl_ver"
385 cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
386 fi
387 fi
388}
389
390#
391# Check for xsltproc, needed by Main
392#
393check_xsltproc()
394{
395 test_header xslt
396 if check_avail "$XSLTPROC" XSLTPROC; then
397 xsltproc_ver=`$XSLTPROC --version`
398 if [ $? -ne 0 ]; then
399 log_failure "not found"
400 fail
401 else
402 log_success "found"
403 cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
404 fi
405 fi
406}
407
408#
409# Check for mkisofs, needed to build the CDROM image containing the additions
410#
411check_mkisofs()
412{
413 test_header mkisofs
414 if which_wrapper $GENISOIMAGE > /dev/null; then
415 mkisofs_ver=`$GENISOIMAGE --version`
416 if [ $? -ne 0 ]; then
417 log_failure "not found"
418 fail
419 else
420 log_success "found $mkisofs_ver"
421 cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
422 fi
423 elif check_avail "$MKISOFS" MKISOFS; then
424 mkisofs_ver=`$MKISOFS --version`
425 if [ $? -ne 0 ]; then
426 log_failure "not found"
427 fail
428 else
429 log_success "found $mkisofs_ver"
430 cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
431 fi
432 fi
433}
434
435#
436# Check for xalan, needed by VBoxXML
437#
438check_xalan()
439{
440 if [ -n "$LIBXALAN" ]; then
441 test_header xalan
442 cat > .tmp_src.cc << EOF
443#include <cstdio>
444#include <xalanc/Include/XalanVersion.hpp>
445extern "C" int main(void)
446{
447 printf("found version %d.%d.%d",
448 XALAN_VERSION_MAJOR, XALAN_VERSION_MINOR, XALAN_VERSION_REVISION);
449#if _XALAN_VERSION >= 10800
450 printf(", OK.\n");
451 return 0;
452#else
453 printf(", expected version 1.8.0 or higher\n");
454 return 1;
455#endif
456}
457EOF
458 if test_compile "$LIBXALAN $LIBPTHREAD ${INCXALAN:+-I$INCXALAN}" xalan xalanc; then
459 if test_execute; then
460 cnf_append "SDK_VBOX_XALAN_LIBS" "`strip_l "$LIBXALAN"`"
461 cnf_append "SDK_VBOX_XALAN_INCS" "$INCXALAN"
462 fi
463 fi
464 else
465 echo "Building xalan from shipped sources."
466 echo -e "Building xalan from shipped sources.\n\n" >> $LOG
467 fi
468}
469
470#
471# Check for xerces, needed by VBoxXML
472#
473check_xerces()
474{
475 if [ -n "$LIBXERCES" ]; then
476 test_header xerces
477 cat > .tmp_src.cc << EOF
478#include <cstdio>
479#include <xercesc/util/XercesVersion.hpp>
480extern "C" int main(void)
481{
482 printf("found version %d.%d.%d",
483 XERCES_VERSION_MAJOR, XERCES_VERSION_MINOR, XERCES_VERSION_REVISION);
484#if _XERCES_VERSION >= 20500
485 printf(", OK.\n");
486 return 0;
487#else
488 printf(", expected version 2.5.0 or higher");
489 return 1;
490#endif
491}
492EOF
493 if test_compile "$LIBXERCES $LIBPTHREAD ${INCXERCES:+-I$INCXERCES}" xerces xercesc; then
494 if test_execute; then
495 cnf_append "SDK_VBOX_XERCES_LIBS" "`strip_l "$LIBXERCES"`"
496 cnf_append "SDK_VBOX_XERCES_INCS" "$INCXERCES"
497 fi
498 fi
499 else
500 echo "Building xerces from shipped sources."
501 echo -e "Building xerces from shipped sources.\n\n" >> $LOG
502 fi
503}
504
505#
506# Check for libIDL, needed by xpcom
507#
508check_libidl()
509{
510 test_header libIDL
511
512 if which_wrapper libIDL-config-2 > /dev/null; then
513 libidl_ver=`libIDL-config-2 --version`
514 if [ $? -ne 0 ]; then
515 log_failure "not found"
516 fail
517 else
518 log_success "found version $libidl_ver"
519 cnf_append "VBOX_LIBIDL_CONFIG" \
520 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
521 fi
522 elif check_avail "libIDL-config" libIDL-config; then
523 libidl_ver=`libIDL-config --version`
524 if [ $? -ne 0 ]; then
525 log_failure "not found"
526 fail
527 else
528 log_success "found version $libidl_ver"
529 cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
530 fi
531 fi
532}
533
534#
535# Check for openssl, needed for RDP
536#
537check_ssl()
538{
539 test_header ssl
540 cat > .tmp_src.cc << EOF
541#include <cstdio>
542#include <openssl/opensslv.h>
543extern "C" int main(void)
544{
545 printf("found version %s", OPENSSL_VERSION_TEXT);
546#if OPENSSL_VERSION_NUMBER >= 0x0090700
547 printf(", OK.\n");
548 return 0;
549#else
550 printf(", expected version 0.9.7 or higher\n");
551 return 1;
552#endif
553}
554EOF
555 if test_compile $LIBCRYPTO libcrypto openssl; then
556 if test_execute nofatal; then
557 cnf_append "SDK_VBOX_OPENSSL_INCS" ""
558 cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
559 fi
560 fi
561}
562
563#
564# Check for pthread, needed by VBoxSVC, frontends, ...
565#
566check_pthread()
567{
568 test_header pthread
569 cat > .tmp_src.cc << EOF
570#include <cstdio>
571#include <pthread.h>
572extern "C" int main(void)
573{
574 pthread_mutex_t mutex;
575 if (pthread_mutex_init(&mutex, NULL)) {
576 printf("pthread_mutex_init() failed\n");
577 return 1;
578 }
579 if (pthread_mutex_lock(&mutex)) {
580 printf("pthread_mutex_lock() failed\n");
581 return 1;
582 }
583 if (pthread_mutex_unlock(&mutex)) {
584 printf("pthread_mutex_unlock() failed\n");
585 return 1;
586 }
587 printf("found, OK.\n");
588}
589EOF
590 if test_compile $LIBPTHREAD pthread pthread; then
591 if test_execute; then
592 cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
593 fi
594 fi
595}
596
597#
598# Check for zlib, needed by VBoxSVC, Runtime, ...
599#
600check_z()
601{
602 test_header zlib
603 cat > .tmp_src.cc << EOF
604#include <cstdio>
605#include <zlib.h>
606extern "C" int main(void)
607{
608 printf("found version %s", ZLIB_VERSION);
609#if ZLIB_VERNUM >= 0x1210
610 printf(", OK.\n");
611 return 0;
612#else
613 printf(", expected version 1.2.1 or higher\n");
614 return 1;
615#endif
616}
617EOF
618 if test_compile "$LIBZ ${INCZ:+-I$INCZ}" zlib zlib; then
619 if test_execute; then
620 cnf_append "SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
621 cnf_append "SDK_VBOX_ZLIB_INCS" "$INCZ"
622 fi
623 fi
624}
625
626#
627# Check for libpng, needed by kchmviewer
628#
629check_png()
630{
631 test_header libpng
632 cat > .tmp_src.cc << EOF
633#include <cstdio>
634#include <png.h>
635extern "C" int main(void)
636{
637 printf("found version %s", PNG_LIBPNG_VER_STRING);
638#if PNG_LIBPNG_VER >= 10205
639 printf(", OK.\n");
640 return 0;
641#else
642 printf(", expected version 1.2.5 or higher\n");
643 return 1;
644#endif
645}
646EOF
647# if test_compile "$LIBPNG ${INCPNG:+-I$INCPNG}" libpng libpng nofatal; then
648 if test_compile "$LIBPNG ${INCPNG:+-I$INCPNG}" libpng libpng; then
649# if test_execute nofatal; then
650 if test_execute; then
651 cnf_append "SDK_VBOX_LIBPNG_LIBS" "`strip_l "$LIBPNG"`"
652 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
653 fi
654 fi
655}
656
657#
658# Check for pam, needed by VRDPAuth
659# Version 79 was introduced in 9/2005, do we support older versions?
660# Debian/sarge uses 76
661# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
662#
663check_pam()
664{
665 test_header pam
666 cat > .tmp_src.cc << EOF
667#include <cstdio>
668#include <security/pam_appl.h>
669extern "C" int main(void)
670{
671 printf("found version %d", __LIBPAM_VERSION);
672 if (__LIBPAM_VERSION >= 76)
673 {
674 printf(", OK.\n");
675 return 0;
676 }
677 else
678 {
679 printf(", expected version 76 or higher\n");
680 return 1;
681 }
682}
683EOF
684 if test_compile "-lpam" pam pam nofatal; then
685 if test_execute nofatal; then
686 return 0;
687 fi
688 fi
689 test_header linux_pam
690 cat > .tmp_src.cc << EOF
691#include <cstdio>
692#include <security/pam_appl.h>
693extern "C" int main(void)
694{
695 printf("found version %d.%d", __LINUX_PAM__, __LINUX_PAM_MINOR__);
696 if (__LINUX_PAM__ >= 1)
697 {
698 printf(", OK.\n");
699 return 0;
700 }
701 else
702 {
703 printf(", expected version 1.0 or higher\n");
704 return 1;
705 }
706}
707EOF
708 if test_compile "-lpam" pam pam; then
709 test_execute
710 fi
711}
712
713
714#
715# Check for the SDL library, needed by VBoxSDL and VirtualBox
716# We depend at least on version 1.2.7
717#
718check_sdl()
719{
720 test_header SDL
721 if which_wrapper sdl-config > /dev/null; then
722 FLGSDL=`sdl-config --cflags`
723 INCSDL=`strip_I "$FLGSDL"`
724 LIBSDL=`sdl-config --libs`
725 LIBSDLMAIN="-lSDLmain"
726 cat > .tmp_src.cc << EOF
727#include <cstdio>
728#include <SDL/SDL.h>
729#include <SDL/SDL_main.h>
730extern "C" int main(void)
731{
732 printf("found version %d.%d.%d",
733 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
734#if SDL_VERSION_ATLEAST(1,2,7)
735 printf(", OK.\n");
736 return 0;
737#else
738 printf(", expected version 1.2.7 or higher\n");
739 return 1;
740#endif
741}
742EOF
743 if test_compile "$LIBSDL $LIBSDLMAIN ${INCSDL:+-I$INCSDL}" SDL SDL; then
744 if test_execute; then
745 cnf_append "LIB_SDK_LIBSDL_SDL" "`strip_l "$LIBSDL"`"
746 cnf_append "SDK_LIBSDL_LIBPATH" "`strip_L "$LIBSDL"`"
747 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
748 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
749 fi
750 fi
751 else
752 log_failure "not found"
753 fi
754}
755
756#
757# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
758#
759check_sdl_ttf()
760{
761 test_header SDL_ttf
762 cat > .tmp_src.cc << EOF
763#include <cstdio>
764#include <SDL/SDL_ttf.h>
765#ifndef SDL_TTF_MAJOR_VERSION
766#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
767#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
768#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
769#endif
770extern "C" int main(void)
771{
772 printf("found version %d.%d.%d",
773 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
774#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
775 printf(", OK.\n");
776 return 0;
777#else
778 printf(", expected version 2.0.6 or higher\n");
779 return 1;
780#endif
781}
782EOF
783 if test_compile "-lSDL_ttf" SDL_ttf SDL_ttf; then
784 test_execute
785 fi
786}
787
788#
789# Check for libasound, needed by the ALSA audio backend
790#
791check_alsa()
792{
793 test_header ALSA
794 cat > .tmp_src.cc << EOF
795#include <alsa/asoundlib.h>
796extern "C" int main(void)
797{
798 printf("found version %d.%d.%d",
799 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
800#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
801 printf(", OK.\n");
802 return 0;
803#else
804 printf(", expected version 1.0.6 or higher\n");
805 return 1;
806#endif
807}
808EOF
809 if test_compile "-lasound" asound asound; then
810 test_execute
811 fi
812}
813
814#
815# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
816#
817check_xcursor()
818{
819 test_header Xcursor
820 cat > .tmp_src.cc << EOF
821#include <cstdio>
822#include <X11/Xlib.h>
823#include <X11/Xcursor/Xcursor.h>
824extern "C" int main(void)
825{
826 XcursorImage *cursor = XcursorImageCreate (10, 10);
827 XcursorImageDestroy(cursor);
828 return 0;
829}
830EOF
831 if test_compile "$LIBX11 $LIBXCURSOR" Xcursor Xcursor; then
832 log_success "found"
833 cnf_append "LIB_XCURSOR" "`strip_l "$LIBXCURSOR"`"
834 fi
835}
836
837#
838# Check for the X libraries (Xext, X11)
839#
840check_x()
841{
842 test_header "X libraries"
843 cat > .tmp_src.cc << EOF
844#include <cstdio>
845#include <X11/Xlib.h>
846extern "C" int main(void)
847{
848 Display *dpy;
849 int scrn_num;
850 Screen *scrn;
851 Window win;
852
853 dpy = XOpenDisplay(NULL);
854 scrn_num = DefaultScreen(dpy);
855 scrn = ScreenOfDisplay(dpy, scrn_num);
856 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
857 0, 16, InputOutput, CopyFromParent, 0, NULL);
858 XDestroyWindow(dpy, win);
859}
860EOF
861 if test_compile "$LIBX11" Xlibs Xlibs; then
862 log_success "found"
863 fi
864}
865
866#
867# Check for the QT library, needed by VirtualBox
868#
869check_qt()
870{
871 test_header Qt
872 cat > .tmp_src.cc << EOF
873#include <cstdio>
874#include <qglobal.h>
875extern "C" int main(void)
876{
877 printf("found version %s", QT_VERSION_STR);
878#if QT_VERSION >= 0x030305
879 printf(", OK.\n");
880 return 0;
881#elif QT_VERSION >= 0x030300
882 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
883#else
884 printf(", expected version 3.3.0 or higher\n");
885 return 1;
886#endif
887}
888EOF
889 found_qt=0
890 libs="lib"
891 [ "$LIB" = "lib64" ] && libs="$libs lib64"
892 for q in $QTDIR; do
893 for l in $libs; do
894 echo "compiling the following source file:" >> $LOG
895 cat .tmp_src.cc >> $LOG
896 echo "using the following command line:" >> $LOG
897 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt" >> $LOG
898
899 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt >> $LOG 2>&1
900 if [ $? -eq 0 ]; then
901 if test_execute; then
902 cnf_append "QTDIR" "`cd $q ; pwd`"
903 found_qt=1
904 break
905 fi
906 fi
907 done
908 if [ $found_qt -eq 1 ]; then
909 break
910 fi
911 done
912 if [ $found_qt -ne 1 ]; then
913 echo -e "\n Qt not found at \"$QTDIR\" or Qt headers not found"
914 echo " Check the file $LOG for detailed error information."
915 fail
916 return 1
917 fi
918 test_header "Qt devtools"
919 if check_avail "$q/bin/moc" QTDIR/bin; then
920 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
921 if [ $? -ne 0 ]; then
922 log_failure "not found"
923 fail
924 else
925 log_success "found version $moc_ver"
926 fi
927 fi
928}
929
930#
931# Check for Linux sources
932#
933check_linux()
934{
935 test_header "Linux kernel sources"
936 cat > .tmp_src.c << EOF
937#include <linux/version.h>
938int printf(const char *format, ...);
939int main(void)
940{
941 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
942 (LINUX_VERSION_CODE % 65536) / 256,
943 LINUX_VERSION_CODE % 256);
944#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
945 printf(", OK.\n");
946 return 0;
947#else
948 printf(", expected version 2.4.0 or higher\n");
949 return 1;
950#endif
951}
952EOF
953 echo "compiling the following source file:" >> $LOG
954 cat .tmp_src.c >> $LOG
955 echo "using the following command line:" >> $LOG
956 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
957 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
958 if [ $? -ne 0 ]; then
959 echo -e "\n Linux kernel headers not found at $LINUX"
960 echo " Check the file $LOG for detailed error information."
961 fail
962 else
963 if test_execute; then
964 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
965 fi
966 fi
967}
968
969#
970# Check for kchmviewer, needed to display the online help
971#
972check_kchmviewer()
973{
974 test_header kchmviewer
975 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
976 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
977 if [ $? -ne 0 ]; then
978 log_failure "not found"
979 fail
980 else
981 log_success "found version $kchmviewer_ver"
982 fi
983 fi
984}
985
986#
987# Check for the kBuild tools, we don't support GNU make
988#
989check_kbuild()
990{
991 test_header kBuild
992 if check_avail "$KBUILDDIR_BIN/kmk" KBUILDDIR really; then
993 log_success "found"
994 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
995 echo "export BUILD_PLATFORM_ARCH=\"$MACHINE\"" >> $ENV
996 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
997 echo "export BUILD_TARGET_ARCH=\"$MACHINE\"" >> $ENV
998 echo "export BUILD_TARGET_CPU=\"$CPU\"" >> $ENV
999 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
1000 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1001 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1002 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1003 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1004 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1005 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1006 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1007 echo "export PATH" >> $ENV
1008 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1009 fi
1010}
1011
1012
1013#
1014# Check for compiler.h
1015# Some Linux distributions include "compiler.h" in their libc linux
1016# headers package, some don't. Most don't need it, building might (!)
1017# not succeed on openSUSE without it.
1018#
1019# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1020#
1021check_compiler_h()
1022{
1023 test_header compiler.h
1024 if ! test -f "/usr/include/linux/compiler.h"; then
1025 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1026 log_success "compiler.h not found"
1027 else
1028 log_success "compiler.h found"
1029 fi
1030}
1031
1032
1033#
1034# Check for the libhal library for obtaining hardware information on Linux
1035#
1036check_libhal()
1037{
1038 test_header libhal
1039 pc_cflagshal=`pkg-config hal --cflags 2>/dev/null`
1040 pc_libhal=`pkg-config hal --libs-only-l 2>/dev/null`
1041 pc_libpathhal=`pkg-config hal --libs-only-L 2>/dev/null`
1042 pc_verhal=`pkg-config hal --modversion 2>/dev/null`
1043 if [ ! -z "$pc_cflagshal" ]; then # is this acceptable?
1044 CFLAGSHAL=$pc_cflagshal
1045 LIBPATHHAL=$pc_libpathhal
1046 LIBHAL=$pc_libhal
1047 fi
1048 cat > .tmp_src.cc << EOF
1049#include <cstdio>
1050#include <libhal.h>
1051extern "C" int main(void)
1052{
1053 DBusError dbusError;
1054 dbus_error_init (&dbusError);
1055 LibHalContext *halContext = libhal_ctx_new();
1056 if (halContext != 0)
1057 {
1058 libhal_ctx_free(halContext);
1059 }
1060 return 0;
1061}
1062EOF
1063 if test_compile "$CFLAGSHAL $LIBPATHHAL $LIBHAL" libhal libhal; then
1064 log_success "found version $pc_verhal"
1065 cnf_append "LIB_HAL_CFLAGS" "$CFLAGSHAL"
1066 cnf_append "LIB_HAL_LIBS" "`strip_l "$LIBHAL"`"
1067 cnf_append "LIB_HAL_LIBPATH" "`strip_L "$LIBPATHHAL"`"
1068 cnf_append "VBOX_WITH_LIBHAL" "1"
1069 fi
1070}
1071
1072
1073#
1074# Show help
1075#
1076show_help()
1077{
1078 cat << EOF
1079Usage: ./configure [OPTIONS]...
1080
1081Configuration:
1082 -h, --help display this help and exit
1083 --nofatal don't abort on errors
1084 --disable-xpcom disable XPCOM and related stuff
1085 --disable-sdl-ttf disable SDL_ttf detection
1086 --build-xalan build xalan & xerces from shipped sources
1087 --without-hal do not use libhal, even if it is available
1088
1089Paths:
1090 --with-gcc=PATH location of the gcc compiler [$CC]
1091 --with-g++=PATH location of the g++ compiler [$CXX]
1092 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
1093 --with-iasl=PATH location of the iasl compiler [$IASL]
1094 --with-hal-cflags=FLAGS cflags for libhal [$CFLAGSHAL]
1095 --with-hal=LIB location of the libhal libraries [$LIBHAL]
1096 --with-linux=DIR Linux kernel source directory [$LINUX]
1097 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1098 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
1099 --with-xalan=LIB location of the xalan library [$LIBXALAN]
1100 --with-xerces=LIB location of the xerces library [$LIBXERCES]
1101
1102Build type:
1103 -d, --build-debug build with debugging symbols and assertions
1104EOF
1105 exit 0
1106}
1107
1108
1109#
1110# The body.
1111#
1112
1113# scan command line options
1114for option; do
1115 case "$option" in
1116 --help|-help|-h)
1117 show_help
1118 ;;
1119 --nofatal)
1120 nofatal=1
1121 ;;
1122 --with-gcc=*)
1123 CC=`echo $option | cut -d'=' -f2`
1124 ;;
1125 --with-g++=*)
1126 CXX=`echo $option | cut -d'=' -f2`
1127 ;;
1128 --with-kbuild=*)
1129 KBUILDDIR=`echo $option | cut -d'=' -f2`
1130 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1131 echo "Error: KBUILDDIR contains invalid characters!"
1132 exit 1
1133 fi
1134 ;;
1135 --with-qt-dir=*)
1136 QTDIR=`echo $option | cut -d'=' -f2`
1137 ;;
1138 --with-hal-dir=*)
1139 INCHAL=`echo $option | cut -d'=' -f2`
1140 ;;
1141 --with-hal=*)
1142 LIBHAL=`echo $option | cut -d'=' -f2`
1143 ;;
1144 --with-iasl=*)
1145 IASL=`echo $option | cut -d'=' -f2`
1146 ;;
1147 --with-linux=*)
1148 LINUX=`echo $option | cut -d'=' -f2`
1149 ;;
1150 --with-mkisofs=*)
1151 MKISOFS=`echo $option | cut -d'=' -f2`
1152 ;;
1153 --with-xalan=*)
1154 LIBXALAN=`echo $option | cut -d'=' -f2`
1155 ;;
1156 --with-xerces=*)
1157 LIBXERCES=`echo $option | cut -d'=' -f2`
1158 ;;
1159 --disable-xpcom)
1160 WITH_XPCOM=0
1161 ;;
1162 --disable-sdl-ttf)
1163 WITH_SDL_TTF=0
1164 ;;
1165 --disable-qt)
1166 WITH_QT=0
1167 ;;
1168 --without-hal)
1169 WITH_HAL=0
1170 ;;
1171 --build-debug|-d)
1172 BUILD_TYPE=debug
1173 ;;
1174 --build-xalan)
1175 LIBXERCES=``
1176 LIBXALAN=``
1177 ;;
1178 --ose)
1179 OSE=2
1180 ;;
1181 --odir=*)
1182 ODIR=`echo $option | cut -d'=' -f2`
1183 ;;
1184 *)
1185 echo
1186 echo "Unrecognized option \"$option\""
1187 echo
1188 show_help
1189 ;;
1190 esac
1191done
1192
1193LOG="${ODIR:+$ODIR/}$LOG"
1194ENV="${ODIR:+$ODIR/}$ENV"
1195CNF="${ODIR:+$ODIR/}$CNF"
1196
1197# initialize output files
1198cat > $LOG << EOF
1199# Log file generated by
1200#
1201# '$0 $*'
1202#
1203
1204EOF
1205cat > $CNF << EOF
1206# -*- Makefile -*-
1207#
1208# automatically generated by
1209#
1210# '$0 $*'
1211#
1212# It will be completely overwritten if configure is executed again.
1213#
1214
1215EOF
1216cat > $ENV << EOF
1217#!/bin/bash
1218#
1219# automatically generated by
1220#
1221# '$0 $*'
1222#
1223# It will be completely overwritten if configure is executed again.
1224# Make sure you source this file once before you start to build VBox.
1225#
1226
1227EOF
1228
1229# test if we are OSE
1230if [ $OSE -eq 1 -a -d "`cd $(dirname $0); pwd`/src/VBox/Devices/USB" ]; then
1231 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1232 echo >> $LOG
1233 OSE=0
1234fi
1235
1236# first determine our environment
1237check_environment
1238check_kbuild
1239
1240# some things are not available in for OSE
1241if [ $OSE -ge 1 ]; then
1242 cnf_append "VBOX_OSE" "1"
1243 cnf_append "VBOX_WITH_TESTSUITE" ""
1244 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1245
1246 if [ "$OS" = "linux" ]; then
1247 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1248 else
1249 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1250 fi
1251 echo >> $CNF
1252fi
1253
1254# emit disable directives corresponding to any --disable-xxx options.
1255[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
1256[ $WITH_QT -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
1257[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
1258
1259# append the tools directory to the default search path
1260echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1261
1262# append some extra paths
1263PATH="$PATH:/opt/gnome/bin"
1264
1265# the tools
1266check_gcc
1267[ "$OS" != "darwin" ] && check_as86
1268[ "$OS" != "darwin" ] && check_bcc
1269[ "$OS" != "darwin" ] && check_iasl
1270# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1271# [ "$OS" != "darwin" ] && check_yasm
1272[ "$OS" != "darwin" ] && check_xsltproc
1273[ $OSE -eq 0 ] && check_mkisofs
1274
1275# the libraries
1276[ "$OS" != "darwin" ] && check_pthread
1277[ $WITH_XPCOM -eq 1 ] && check_xalan
1278[ $WITH_XPCOM -eq 1 ] && check_xerces
1279[ $WITH_LIBIDL -eq 1 ] && check_libidl
1280[ $OSE -eq 0 ] && check_ssl
1281[ "$OS" != "darwin" ] && check_z
1282[ $OSE -eq 0 ] && check_png
1283[ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
1284[ "$OS" != "darwin" ] && check_sdl
1285[ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
1286[ "$OS" != "darwin" ] && check_x
1287[ "$OS" != "darwin" ] && check_xcursor
1288[ $WITH_QT -eq 1 ] && check_qt
1289
1290# Linux-specific
1291if [ "$OS" = "linux" ]; then
1292 check_linux
1293 check_alsa
1294 check_compiler_h
1295 [ "$WITH_HAL" = "1" ] && check_libhal
1296fi
1297
1298# success!
1299echo
1300echo "Successfully generated '$CNF' and '$ENV'."
1301echo "Source '$ENV' once before you start to build VBox:"
1302echo ""
1303echo " source $ENV"
1304echo " kmk"
1305echo ""
1306if [ "$OS" = "linux" ]; then
1307 echo "To compile the kernel module, do:"
1308 echo ""
1309 echo " cd ./out/$OS.$MACHINE/$BUILD_TYPE/bin/src"
1310 echo " make"
1311 echo ""
1312fi
1313echo "Enjoy!"
1314cleanup
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use