VirtualBox

source: vbox/trunk/configure@ 4743

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

moved PATH more to the beginning of the file

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