VirtualBox

source: vbox/trunk/configure@ 3164

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

mark freebsd as valid OS

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

© 2023 Oracle
ContactPrivacy policyTerms of Use