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
Line 
1#!/bin/sh
2# The purpose of this script is to check for all external tools, headers, and
3# libraries VBox OSE depends on.
4
5#
6# Copyright (C) 2006-2007 innotek GmbH
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License as published by the Free Software Foundation,
12# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13# distribution. VirtualBox OSE is distributed in the hope that it will
14# be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16# If you received this file as part of a commercial VirtualBox
17# distribution, then only the terms of your commercial VirtualBox
18# license agreement apply instead of the previous paragraph.
19#
20
21LC_ALL=C
22export LC_ALL
23
24#
25# Defaults
26#
27OSE=1
28WITH_XPCOM=1
29WITH_LIBIDL=1
30WITH_QT=1
31WITH_SDL_TTF=1
32WITH_HAL=1
33CC="gcc"
34CXX="g++"
35BCC="bcc"
36YASM="yasm"
37IASL="iasl"
38AS86="as86"
39XSLTPROC="xsltproc"
40GENISOIMAGE="genisoimage"
41MKISOFS="mkisofs"
42INCXALAN=""
43LIBXALAN="-lxalan-c"
44INCXERCES=""
45LIBXERCES="-lxerces-c"
46LIBCRYPTO="-lcrypto"
47LIBPTHREAD="-lpthread"
48LIBX11="-L/usr/X11R6/lib -lXext -lX11"
49LIBXCURSOR="-lXcursor"
50INCZ=""
51LIBZ="-lz"
52INCPNG=""
53LIBPNG="-lpng"
54CFLAGSHAL="-I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include"
55LIBPATHHAL=""
56LIBHAL="-lhal -ldbus-1"
57QTDIR="/usr/qt/3 /usr/lib/qt3 /usr/lib/qt-3.3 /usr/share/qt3 /usr/lib64/qt-3.3 /usr/X11R6"
58KBUILDDIR="`cd $(dirname $0); pwd`/kBuild"
59DEVDIR="`cd $(dirname $0); pwd`/tools"
60if [ -d "/lib/modules/`uname -r`/build" ]; then
61 LINUX="/lib/modules/`uname -r`/build"
62else
63 LINUX="/usr/src/linux"
64fi
65KCHMVIEWER="kchmviewer"
66LOG="configure.log"
67CNF="AutoConfig.kmk"
68ENV="env.sh"
69BUILD_TYPE="release"
70# the restricting tool is ar (mri mode).
71INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
72
73if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
74 echo "Error: VBox base path contains invalid characters!"
75 exit 1
76fi
77
78cleanup()
79{
80 rm -f .tmp_src.cc .tmp_src.c .tmp_out .test_execute.log
81}
82
83fail()
84{
85 if [ -z "$nofatal" -o "x$1" != "x" ]; then
86 cleanup
87 rm -f $ENV
88 exit 1
89 fi
90}
91
92log_success()
93{
94 if [ -n "$1" ]; then echo -n "$1, "; fi
95 echo "OK."
96 echo -e "$1\n\n" >> $LOG
97}
98
99log_failure()
100{
101 echo -e "\n ** $1!"
102 echo -e "** $1!\n" >> $LOG
103}
104
105cnf_append()
106{
107 printf "%-30s := %s\n" "$1" "$2" >> $CNF
108}
109
110strip_l()
111{
112 echo "$1"|sed 's|-l\([^ ]\+\)|\1|g; s|-[^l]\([^ ]\+\)||g; s|^ ||; s| *$||g'
113}
114
115strip_L()
116{
117 echo "$1"|sed 's|-L\([^ ]\+\)|\1|g; s|-[^L]\([^ ]\+\)||g; s|^ ||; s| *$||g'
118}
119
120strip_I()
121{
122 echo "$1"|sed 's|-I\([^ ]\+\)|\1|g; s|-[^I]\([^ ]\+\)||g; s|^ ||; s| *$||g'
123}
124
125# Wrapper for ancient /usr/bin/which on darwin that always returns 0
126which_wrapper()
127{
128 if [ -z "$have_ancient_which" ]; then
129 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
130 have_ancient_which="yes"
131 else
132 have_ancient_which="no"
133 fi
134 fi
135 if [ "$have_ancient_which" = "yes" ]; then
136 local retval=`which $* 2>/dev/null`
137 echo "$retval"
138 test -n "$retval" -a -e "$retval"
139 else
140 which $* 2> /dev/null
141 fi
142}
143
144check_avail()
145{
146 if [ -z "$1" ]; then
147 log_failure "$2 is empty"
148 fail $3
149 return 1
150 elif which_wrapper $1 > /dev/null; then
151 return 0
152 else
153 log_failure "$1 (variable $2) not found"
154 fail $3
155 return 1
156 fi
157}
158
159# Prepare a test
160test_header()
161{
162 echo "***** Checking $1 *****" >> $LOG
163 echo -n "Checking for $1: "
164}
165
166# Compile a test
167test_compile()
168{
169 echo "compiling the following source file:" >> $LOG
170 cat .tmp_src.cc >> $LOG
171 echo "using the following command line:" >> $LOG
172 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
173 $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
174 if [ $? -ne 0 ]; then
175 if [ -z "$4" ]; then
176 echo -e "\n $2 not found at $1 or $3 headers not found"
177 echo " Check the file $LOG for detailed error information."
178 fail
179 else
180 echo "not found."
181 echo -e "\n" >> $LOG
182 fi
183 return 1
184 fi
185 return 0
186}
187
188# Execute a compiled test binary
189test_execute()
190{
191 echo "executing the binary" >> $LOG
192 ./.tmp_out > .test_execute.log
193 rc=$?
194 cat .test_execute.log | tee -a $LOG
195 if [ $rc -ne 0 ]; then
196 fail $1
197 return 1
198 fi
199 echo -e "\n\n" >> $LOG
200 return 0
201}
202
203#
204# Check for OS, MACHINE, CPU
205#
206check_environment()
207{
208 test_header environment
209 CPU=`uname -m`
210 case "$CPU" in
211 i[3456789]86|x86)
212 MACHINE='x86'
213 LIB='lib'
214 ;;
215 x86_64|amd64)
216 MACHINE='amd64'
217 CPU='k8'
218 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
219 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
220 LIB='lib64'
221 ;;
222 *)
223 log_failure "Cannot determine system"
224 exit 1
225 ;;
226 esac
227 OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr 'A-Z' 'a-z'`
228 case "$OS" in
229 linux)
230 ;;
231 darwin)
232 ;;
233 freebsd)
234 ;;
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"
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
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#
257check_gcc()
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
269 elif [ $cc_maj -gt 3 ]; then
270 log_success "found version $cc_ver"
271 elif [ $cc_maj -lt 3 -o $cc_min -lt 2 ]; then
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"
280 cnf_append "TOOL_GXX3_CC" "$CC"
281 cnf_append "TOOL_GXX3_AS" "$CC"
282 fi
283 if [ "$CXX" != "g++" ]; then
284 cnf_append "TOOL_GCC3_CXX" "$CXX"
285 cnf_append "TOOL_GCC3_LD" "$CXX"
286 cnf_append "TOOL_GXX3_CXX" "$CXX"
287 cnf_append "TOOL_GXX3_LD" "$CXX"
288 fi
289 fi
290 fi
291}
292
293#
294# Check for the bcc compiler, needed for compiling the BIOS
295#
296check_bcc()
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+'`
301 if [ $? -ne 0 ]; then
302 log_failure "not found"
303 fail
304 else
305 echo "compiling the following source file:" >> $LOG
306 cat > .tmp_src.c << EOF
307int foo(a)
308 int a;
309{
310 return 0;
311}
312EOF
313 cat .tmp_src.c >> $LOG
314 local bcc_path=`which_wrapper $BCC`
315 local bcc_dir="`dirname $bcc_path`/"
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
319 if [ $? -ne 0 ]; then
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#
333check_as86()
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+'`
338 if [ $? -ne 0 ]; then
339 log_failure "not found"
340 fail
341 else
342 log_success "found version $as86_ver"
343 cnf_append "VBOX_AS86" "`which_wrapper $AS86`"
344 fi
345 fi
346}
347
348#
349# Check for yasm, needed to compile assembler files
350#
351check_yasm()
352{
353 test_header yasm
354 if check_avail "$YASM" YASM; then
355 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
356 if [ $? -ne 0 ]; then
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))
364 if [ $yasm_ver_mul -lt 501 ]; then
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#
377check_iasl()
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+'`
382 if [ $? -ne 0 ]; then
383 log_failure "not found"
384 fail
385 else
386 log_success "found version $iasl_ver"
387 cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
388 fi
389 fi
390}
391
392#
393# Check for xsltproc, needed by Main
394#
395check_xsltproc()
396{
397 test_header xslt
398 if check_avail "$XSLTPROC" XSLTPROC; then
399 xsltproc_ver=`$XSLTPROC --version`
400 if [ $? -ne 0 ]; then
401 log_failure "not found"
402 fail
403 else
404 log_success "found"
405 cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
406 fi
407 fi
408}
409
410#
411# Check for mkisofs, needed to build the CDROM image containing the additions
412#
413check_mkisofs()
414{
415 test_header mkisofs
416 if which_wrapper $GENISOIMAGE > /dev/null; then
417 mkisofs_ver=`$GENISOIMAGE --version`
418 if [ $? -ne 0 ]; then
419 log_failure "not found"
420 fail
421 else
422 log_success "found $mkisofs_ver"
423 cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
424 fi
425 elif check_avail "$MKISOFS" MKISOFS; then
426 mkisofs_ver=`$MKISOFS --version`
427 if [ $? -ne 0 ]; then
428 log_failure "not found"
429 fail
430 else
431 log_success "found $mkisofs_ver"
432 cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
433 fi
434 fi
435}
436
437#
438# Check for xalan, needed by VBoxXML
439#
440check_xalan()
441{
442 if [ -n "$LIBXALAN" ]; then
443 test_header xalan
444 cat > .tmp_src.cc << EOF
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);
451#if _XALAN_VERSION >= 10800
452 printf(", OK.\n");
453 return 0;
454#else
455 printf(", expected version 1.8.0 or higher\n");
456 return 1;
457#endif
458}
459EOF
460 if test_compile "$LIBXALAN $LIBPTHREAD ${INCXALAN:+-I$INCXALAN}" xalan xalanc; then
461 if test_execute; then
462 cnf_append "SDK_VBOX_XALAN_LIBS" "`strip_l "$LIBXALAN"`"
463 cnf_append "SDK_VBOX_XALAN_INCS" "$INCXALAN"
464 fi
465 fi
466 else
467 echo "Building xalan from shipped sources."
468 echo -e "Building xalan from shipped sources.\n\n" >> $LOG
469 fi
470}
471
472#
473# Check for xerces, needed by VBoxXML
474#
475check_xerces()
476{
477 if [ -n "$LIBXERCES" ]; then
478 test_header xerces
479 cat > .tmp_src.cc << EOF
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);
486#if _XERCES_VERSION >= 20500
487 printf(", OK.\n");
488 return 0;
489#else
490 printf(", expected version 2.5.0 or higher");
491 return 1;
492#endif
493}
494EOF
495 if test_compile "$LIBXERCES $LIBPTHREAD ${INCXERCES:+-I$INCXERCES}" xerces xercesc; then
496 if test_execute; then
497 cnf_append "SDK_VBOX_XERCES_LIBS" "`strip_l "$LIBXERCES"`"
498 cnf_append "SDK_VBOX_XERCES_INCS" "$INCXERCES"
499 fi
500 fi
501 else
502 echo "Building xerces from shipped sources."
503 echo -e "Building xerces from shipped sources.\n\n" >> $LOG
504 fi
505}
506
507#
508# Check for libIDL, needed by xpcom
509#
510check_libidl()
511{
512 test_header libIDL
513
514 if which_wrapper libIDL-config-2 > /dev/null; then
515 libidl_ver=`libIDL-config-2 --version`
516 if [ $? -ne 0 ]; then
517 log_failure "not found"
518 fail
519 else
520 log_success "found version $libidl_ver"
521 cnf_append "VBOX_LIBIDL_CONFIG" \
522 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
523 fi
524 elif check_avail "libIDL-config" libIDL-config; then
525 libidl_ver=`libIDL-config --version`
526 if [ $? -ne 0 ]; then
527 log_failure "not found"
528 fail
529 else
530 log_success "found version $libidl_ver"
531 cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
532 fi
533 fi
534}
535
536#
537# Check for openssl, needed for RDP
538#
539check_ssl()
540{
541 test_header ssl
542 cat > .tmp_src.cc << EOF
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}
556EOF
557 if test_compile $LIBCRYPTO libcrypto openssl; then
558 if test_execute nofatal; then
559 cnf_append "SDK_VBOX_OPENSSL_INCS" ""
560 cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
561 fi
562 fi
563}
564
565#
566# Check for pthread, needed by VBoxSVC, frontends, ...
567#
568check_pthread()
569{
570 test_header pthread
571 cat > .tmp_src.cc << EOF
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}
591EOF
592 if test_compile $LIBPTHREAD pthread pthread; then
593 if test_execute; then
594 cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
595 fi
596 fi
597}
598
599#
600# Check for zlib, needed by VBoxSVC, Runtime, ...
601#
602check_z()
603{
604 test_header zlib
605 cat > .tmp_src.cc << EOF
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}
619EOF
620 if test_compile "$LIBZ ${INCZ:+-I$INCZ}" zlib zlib; then
621 if test_execute; then
622 cnf_append "SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
623 cnf_append "SDK_VBOX_ZLIB_INCS" "$INCZ"
624 fi
625 fi
626}
627
628#
629# Check for libpng, needed by kchmviewer
630#
631check_png()
632{
633 test_header libpng
634 cat > .tmp_src.cc << EOF
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}
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"`"
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?
662# Debian/sarge uses 76
663# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
664#
665check_pam()
666{
667 test_header pam
668 cat > .tmp_src.cc << EOF
669#include <cstdio>
670#include <security/pam_appl.h>
671extern "C" int main(void)
672{
673 printf("found version %d", __LIBPAM_VERSION);
674 if (__LIBPAM_VERSION >= 76)
675 {
676 printf(", OK.\n");
677 return 0;
678 }
679 else
680 {
681 printf(", expected version 76 or higher\n");
682 return 1;
683 }
684}
685EOF
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
692 cat > .tmp_src.cc << EOF
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}
709EOF
710 if test_compile "-lpam" pam pam; then
711 test_execute
712 fi
713}
714
715
716#
717# Check for the SDL library, needed by VBoxSDL and VirtualBox
718# We depend at least on version 1.2.7
719#
720check_sdl()
721{
722 test_header SDL
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
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}
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
752 fi
753 else
754 log_failure "not found"
755 fi
756}
757
758#
759# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
760#
761check_sdl_ttf()
762{
763 test_header SDL_ttf
764 cat > .tmp_src.cc << EOF
765#include <cstdio>
766#include <SDL/SDL_ttf.h>
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
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}
784EOF
785 if test_compile "-lSDL_ttf" SDL_ttf SDL_ttf; then
786 test_execute
787 fi
788}
789
790#
791# Check for libasound, needed by the ALSA audio backend
792#
793check_alsa()
794{
795 test_header ALSA
796 cat > .tmp_src.cc << EOF
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);
802#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10006
803 printf(", OK.\n");
804 return 0;
805#else
806 printf(", expected version 1.0.6 or higher\n");
807 return 1;
808#endif
809}
810EOF
811 if test_compile "-lasound" asound asound; then
812 test_execute
813 fi
814}
815
816#
817# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
818#
819check_xcursor()
820{
821 test_header Xcursor
822 cat > .tmp_src.cc << EOF
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}
832EOF
833 if test_compile "$LIBX11 $LIBXCURSOR" Xcursor Xcursor; then
834 log_success "found"
835 cnf_append "LIB_XCURSOR" "`strip_l "$LIBXCURSOR"`"
836 fi
837}
838
839#
840# Check for the X libraries (Xext, X11)
841#
842check_x()
843{
844 test_header "X libraries"
845 cat > .tmp_src.cc << EOF
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}
862EOF
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#
871check_qt()
872{
873 test_header Qt
874 cat > .tmp_src.cc << EOF
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}
890EOF
891 found_qt=0
892 libs="lib"
893 [ "$LIB" = "lib64" ] && libs="$libs lib64"
894 for q in $QTDIR; do
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
900
901 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/$l -lqt-mt >> $LOG 2>&1
902 if [ $? -eq 0 ]; then
903 if test_execute; then
904 cnf_append "QTDIR" "`cd $q ; pwd`"
905 found_qt=1
906 break
907 fi
908 fi
909 done
910 if [ $found_qt -eq 1 ]; then
911 break
912 fi
913 done
914 if [ $found_qt -ne 1 ]; then
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+'`
923 if [ $? -ne 0 ]; then
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#
935check_linux()
936{
937 test_header "Linux kernel sources"
938 cat > .tmp_src.c << EOF
939#include <linux/version.h>
940int printf(const char *format, ...);
941int main(void)
942{
943 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
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}
954EOF
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
960 if [ $? -ne 0 ]; then
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
966 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
967 fi
968 fi
969}
970
971#
972# Check for kchmviewer, needed to display the online help
973#
974check_kchmviewer()
975{
976 test_header kchmviewer
977 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
978 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
979 if [ $? -ne 0 ]; then
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#
991check_kbuild()
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
1005 echo "export PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
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
1014
1015#
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#
1023check_compiler_h()
1024{
1025 test_header compiler.h
1026 if ! test -f "/usr/include/linux/compiler.h"; then
1027 cnf_append "VBOX_WITHOUT_LINUX_COMPILER_H" "1"
1028 log_success "compiler.h not found"
1029 else
1030 log_success "compiler.h found"
1031 fi
1032}
1033
1034
1035#
1036# Check for the libhal library for obtaining hardware information on Linux
1037#
1038check_libhal()
1039{
1040 test_header libhal
1041 pc_cflagshal=`pkg-config hal --cflags 2>/dev/null`
1042 pc_libhal=`pkg-config hal --libs-only-l 2>/dev/null`
1043 pc_libpathhal=`pkg-config hal --libs-only-L 2>/dev/null`
1044 pc_verhal=`pkg-config hal --modversion 2>/dev/null`
1045 if [ ! -z "$pc_cflagshal" ]; then # is this acceptable?
1046 CFLAGSHAL=$pc_cflagshal
1047 LIBPATHHAL=$pc_libpathhal
1048 LIBHAL=$pc_libhal
1049 fi
1050 cat > .tmp_src.cc << EOF
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}
1064EOF
1065 if test_compile "$CFLAGSHAL $LIBPATHHAL $LIBHAL" libhal libhal; then
1066 log_success "found version $pc_verhal"
1067 cnf_append "LIB_HAL_CFLAGS" "$CFLAGSHAL"
1068 cnf_append "LIB_HAL_LIBS" "`strip_l "$LIBHAL"`"
1069 cnf_append "LIB_HAL_LIBPATH" "`strip_L "$LIBPATHHAL"`"
1070 cnf_append "VBOX_WITH_LIBHAL" "1"
1071 fi
1072}
1073
1074
1075#
1076# Show help
1077#
1078show_help()
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
1087 --disable-sdl-ttf disable SDL_ttf detection
1088 --build-xalan build xalan & xerces from shipped sources
1089 --without-hal do not use libhal, even if it is available
1090
1091Paths:
1092 --with-gcc=PATH location of the gcc compiler [$CC]
1093 --with-g++=PATH location of the g++ compiler [$CXX]
1094 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
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]
1098 --with-linux=DIR Linux kernel source directory [$LINUX]
1099 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
1100 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
1101 --with-xalan=LIB location of the xalan library [$LIBXALAN]
1102 --with-xerces=LIB location of the xerces library [$LIBXERCES]
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`
1132 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
1133 echo "Error: KBUILDDIR contains invalid characters!"
1134 exit 1
1135 fi
1136 ;;
1137 --with-qt-dir=*)
1138 QTDIR=`echo $option | cut -d'=' -f2`
1139 ;;
1140 --with-hal-dir=*)
1141 INCHAL=`echo $option | cut -d'=' -f2`
1142 ;;
1143 --with-hal=*)
1144 LIBHAL=`echo $option | cut -d'=' -f2`
1145 ;;
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)
1162 WITH_XPCOM=0
1163 ;;
1164 --disable-sdl-ttf)
1165 WITH_SDL_TTF=0
1166 ;;
1167 --disable-qt)
1168 WITH_QT=0
1169 ;;
1170 --without-hal)
1171 WITH_HAL=0
1172 ;;
1173 --build-debug|-d)
1174 BUILD_TYPE=debug
1175 ;;
1176 --build-xalan)
1177 LIBXERCES=``
1178 LIBXALAN=``
1179 ;;
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
1232if [ $OSE -eq 1 -a -d "`cd $(dirname $0); pwd`/src/VBox/Devices/USB" ]; then
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
1243if [ $OSE -ge 1 ]; then
1244 cnf_append "VBOX_OSE" "1"
1245 cnf_append "VBOX_WITH_TESTSUITE" ""
1246 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1247
1248 if [ "$OS" = "linux" ]; then
1249 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1250 else
1251 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1252 fi
1253 echo >> $CNF
1254fi
1255
1256# emit disable directives corresponding to any --disable-xxx options.
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" ""
1260
1261# append the tools directory to the default search path
1262echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1263
1264# append some extra paths
1265PATH="$PATH:/opt/gnome/bin"
1266
1267# the tools
1268check_gcc
1269[ "$OS" != "darwin" ] && check_as86
1270[ "$OS" != "darwin" ] && check_bcc
1271[ "$OS" != "darwin" ] && check_iasl
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
1274[ "$OS" != "darwin" ] && check_xsltproc
1275[ $OSE -eq 0 ] && check_mkisofs
1276
1277# the libraries
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
1291
1292# Linux-specific
1293if [ "$OS" = "linux" ]; then
1294 check_linux
1295 check_alsa
1296 check_compiler_h
1297 [ "$WITH_HAL" = "1" ] && check_libhal
1298fi
1299
1300# success!
1301echo
1302echo "Successfully generated '$CNF' and '$ENV'."
1303echo "Source '$ENV' once before you start to build VBox:"
1304echo ""
1305echo " source $ENV"
1306echo " kmk"
1307echo ""
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
1315echo "Enjoy!"
1316cleanup
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use