VirtualBox

source: vbox/trunk/configure@ 3911

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

make .deb headless work

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