VirtualBox

source: vbox/trunk/configure@ 4324

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

Switched to runtime detection and loading of dbus and libhal on Linux hosts (in Main)

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