VirtualBox

source: vbox/trunk/configure@ 4757

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

Solaris fixes

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