VirtualBox

source: vbox/trunk/configure@ 4642

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

solaris

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