VirtualBox

source: vbox/trunk/configure@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 54 years ago

import

  • Property svn:executable set to *
File size: 24.9 KB
Line 
1#!/bin/bash
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 InnoTek Systemberatung 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# Default positions
26#
27OSE=1
28XPCOM=1
29CC="gcc"
30CXX="g++"
31BCC="bcc"
32YASM="yasm"
33IASL="iasl"
34AS86="as86"
35XSLTPROC="xsltproc"
36GENISOIMAGE="genisoimage"
37MKISOFS="mkisofs"
38INCXALAN=""
39LIBXALAN="-lxalan-c"
40INCXERCES=""
41LIBXERCES="-lxerces-c"
42LIBUUID="-luuid"
43INCSDL="/usr/include/SDL"
44LIBSDL="-lSDL"
45LIBSDLMAIN="-lSDLmain"
46LIBCRYPTO="-lcrypto"
47LIBPTHREAD="-lpthread"
48LIBXCURSOR="-lXcursor"
49LIBX11="-lXext -lX11"
50INCZ=""
51LIBZ="-lz"
52INCPNG=""
53LIBPNG="-lpng"
54QTDIR="/usr/qt/3 /usr/share/qt3"
55KBUILDDIR="`cd $(dirname $0); pwd`/kBuild"
56DEVDIR="`cd $(dirname $0); pwd`/tools"
57if [ -d /lib/modules/`uname -r`/build ]; then
58 LINUX="/lib/modules/`uname -r`/build"
59else
60 LINUX="/usr/src/linux"
61fi
62KCHMVIEWER="kchmviewer"
63LOG="configure.log"
64CNF="AutoConfig.kmk"
65ENV="env.sh"
66BUILD_TYPE="release"
67
68function cleanup()
69{
70 rm -f .tmp_src.cc .tmp_src.c .tmp_out
71}
72
73function fail()
74{
75 if [ -z "$nofatal" -o "x$1" != "x" ]; then
76 cleanup
77 rm -f $ENV
78 exit 1
79 fi
80}
81
82function log_success()
83{
84 if [ -n "$1" ]; then echo -n "$1, "; fi
85 echo "OK."
86 echo -e "$1\n\n" >> $LOG
87}
88
89function log_failure()
90{
91 echo -e "\n ** $1!"
92 echo -e "** $1!\n" >> $LOG
93}
94
95function cnf_append()
96{
97 printf "%-26s := %s\n" "$1" "$2" >> $CNF
98}
99
100# Wrapper for ancient /usr/bin/which on darwin that always returns 0.
101function which_wrapper()
102{
103 if [ -z "$have_ancient_which" ]; then
104 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
105 have_ancient_which="yes"
106 else
107 have_ancient_which="no"
108 fi
109 fi
110 if [ "$have_ancient_which" = "yes" ]; then
111 local retval=`which $*`
112 echo "$retval"
113 test -e "$retval"
114 else
115 which $*
116 fi
117}
118
119function check_avail()
120{
121 if [ -z "$1" ]; then
122 log_failure "$2 is empty"
123 fail $3
124 return 1
125 elif which_wrapper $1 > /dev/null; then
126 return 0
127 else
128 log_failure "$1 (variable $2) not found"
129 fail $3
130 return 1
131 fi
132}
133
134#
135# Prepare a test
136#
137function test_header()
138{
139 echo "***** Checking $1 *****" >> $LOG
140 echo -n "Checking for $1: "
141}
142
143#
144# Compile a test
145#
146function test_compile()
147{
148 echo "compiling the following source file:" >> $LOG
149 cat .tmp_src.cc >> $LOG
150 echo "using the following command line:" >> $LOG
151 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"$1\"" >> $LOG
152 $CXX -O -Wall -o .tmp_out .tmp_src.cc $1 >> $LOG 2>&1
153 if (($?!=0)); then
154 if [ -z "$4" ]; then
155 echo -e "\n $2 not found at $1 or $3 headers not found"
156 echo " Check the file $LOG for detailed error information."
157 fail
158 else
159 echo "not found."
160 echo -e "\n" >> $LOG
161 fi
162 return 1
163 fi
164 return 0
165}
166
167# Execute a compiled test binary
168function test_execute()
169{
170 echo "executing the binary" >> $LOG
171 log=`./.tmp_out`
172 rc=$?
173 echo $log | tee -a $LOG
174 if (($rc!=0)); then
175 fail $1
176 return 1
177 fi
178 echo -e "\n\n" >> $LOG
179 return 0
180}
181
182#
183# Check for OS, MACHINE, CPU
184#
185function check_environment()
186{
187 test_header environment
188 CPU=`uname -m`
189 case "$CPU" in
190 i[3456789]86|x86)
191 MACHINE='x86'
192 ;;
193 x86_64|amd64)
194 MACHINE='amd64'
195 CPU='k8'
196 ;;
197 *)
198 log_failure "Cannot determine system"
199 exit 1
200 ;;
201 esac
202 OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr 'A-Z' 'a-z'`
203 case "$OS" in
204 linux)
205 ;;
206 darwin)
207 ;;
208 *)
209 log_failure "Cannot determine OS"
210 exit 1
211 ;;
212 esac
213 DEVDIR_BIN="$DEVDIR/$OS.$MACHINE/bin"
214 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$MACHINE"
215 log_success "Determined $OS.$MACHINE"
216
217 # Automatically disable XPCOM on darwin.
218 if [ "$OS" = "darwin" -a $XPCOM -eq 1 ]; then
219 XPCOM=0
220 echo "Disabling checks for XPCOM related components."
221 fi
222}
223
224#
225# Check for gcc with version >= 3.2.
226# We depend on a working gcc, if we fail terminate in every case.
227#
228function check_gcc()
229{
230 test_header gcc
231 if check_avail "$CC" CC really; then
232 cc_ver=`$CC -dumpversion`
233 if check_avail "$CXX" CXX really; then
234 cxx_ver=`$CXX -dumpversion`
235 cc_maj=`echo $cc_ver|cut -d. -f1`
236 cc_min=`echo $cc_ver|cut -d. -f2`
237 if [ "x$cc_ver" != "x$cxx_ver" ]; then
238 log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
239 fail really
240 elif (($cc_maj>3)); then
241 log_success "found version $cc_ver, using precompiled objects for recompiler"
242 cnf_append "VBOX_USING_GCC4" "1"
243 elif (($cc_maj<3 || $cc_min<2)); then
244 log_failure "gcc version $cc_ver found, expected at least gcc version 3.2"
245 fail really
246 else
247 log_success "found version $cc_ver"
248 fi
249 if [ "$CC" != "gcc" ]; then
250 cnf_append "TOOL_GCC3_CC" "$CC"
251 cnf_append "TOOL_GCC3_AS" "$CC"
252 fi
253 if [ "$CXX" != "g++" ]; then
254 cnf_append "TOOL_GCC3_CXX" "$CXX"
255 cnf_append "TOOL_GCC3_LD" "$CXX"
256 fi
257 fi
258 fi
259}
260
261#
262# Check for the bcc compiler, needed for compiling the BIOS
263#
264function check_bcc()
265{
266 test_header bcc
267 if check_avail "$BCC" BCC; then
268 bcc_ver=`$BCC -v 2>&1|grep version|sed 's+^bcc: version \(.*\)+\1+'`
269 if (($?!=0)); then
270 log_failure "not found"
271 fail
272 else
273 echo "compiling the following source file:" >> $LOG
274 echo '
275int foo(a)
276 int a;
277{
278 return 0;
279}
280' > .tmp_src.c
281 cat .tmp_src.c >> $LOG
282 local bcc_path=`which $BCC`
283 local bcc_dir=`dirname $bcc_path`
284 echo "using the following command line:" >> $LOG
285 echo "$BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c" >> $LOG
286 $BCC -B $bcc_dir -C-c -3 -S -o .tmp_out .tmp_src.c >> $LOG 2>&1
287 if (($?!=0)); then
288 log_failure "not found"
289 fail
290 else
291 log_success "found version $bcc_ver"
292 cnf_append "VBOX_BCC" "$bcc_path -B $bcc_dir"
293 fi
294 fi
295 fi
296}
297
298#
299# Check for the as86 assembler, needed for compiling the BIOS
300#
301function check_as86()
302{
303 test_header as86
304 if check_avail "$AS86" AS86; then
305 as86_ver=`$AS86 -v 2>&1|grep version|sed 's+^as86 version: \(.*\)+\1+'`
306 if (($?!=0)); then
307 log_failure "not found"
308 fail
309 else
310 log_success "found version $as86_ver"
311 cnf_append "VBOX_AS86" "`which $AS86`"
312 fi
313 fi
314}
315
316#
317# Check for yasm, needed to compile assembler files
318#
319function check_yasm()
320{
321 test_header yasm
322 if check_avail "$YASM" YASM; then
323 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
324 if (($?!=0)); then
325 log_failure "not found"
326 fail
327 else
328 yasm_maj=`echo $yasm_ver|cut -d. -f1`
329 yasm_min=`echo $yasm_ver|cut -d. -f2`
330 yasm_rev=`echo $yasm_ver|cut -d. -f3`
331 yasm_ver_mul=$(($yasm_maj*10000+$yasm_min*100+$yasm_rev))
332 if (($yasm_ver_mul<501)); then
333 log_failure "found version $yasm_ver, expected at least 0.5.1"
334 fail
335 else
336 log_success "found version $yasm_ver"
337 fi
338 fi
339 fi
340}
341
342#
343# Check for the iasl ACPI compiler, needed to compile vbox.dsl
344#
345function check_iasl()
346{
347 test_header iasl
348 if check_avail "$IASL" IASL; then
349 iasl_ver=`$IASL|grep version|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
350 if (($?!=0)); then
351 log_failure "not found"
352 fail
353 else
354 log_success "found version $iasl_ver"
355 cnf_append "VBOX_IASLCMD" "`which $IASL`"
356 fi
357 fi
358}
359
360#
361# Check for xsltproc, needed by Main
362#
363function check_xsltproc()
364{
365 test_header xslt
366 if check_avail "$XSLTPROC" XSLTPROC; then
367 xsltproc_ver=`$XSLTPROC --version`
368 if (($?!=0)); then
369 log_failure "not found"
370 fail
371 else
372 log_success "found"
373 cnf_append "VBOX_XSLTPROC" "`which $XSLTPROC`"
374 fi
375 fi
376}
377
378#
379# Check for mkisofs, needed to build the CDROM image containing the additions
380#
381function check_mkisofs()
382{
383 test_header mkisofs
384 if which $GENISOIMAGE > /dev/null; then
385 mkisofs_ver=`$GENISOIMAGE --version`
386 if (($?!=0)); then
387 log_failure "not found"
388 fail
389 else
390 log_success "found $mkisofs_ver"
391 cnf_append "VBOX_MKISOFS" "`which $GENISOIMAGE`"
392 fi
393 elif check_avail "$MKISOFS" MKISOFS; then
394 mkisofs_ver=`$MKISOFS --version`
395 if (($?!=0)); then
396 log_failure "not found"
397 fail
398 else
399 log_success "found $mkisofs_ver"
400 cnf_append "VBOX_MKISOFS" "`which $MKISOFS`"
401 fi
402 fi
403}
404
405#
406# Check for xalan, needed by VBoxXML
407#
408function check_xalan()
409{
410 test_header xalan
411 echo '
412#include <cstdio>
413#include <xalanc/Include/XalanVersion.hpp>
414extern "C" int main(void)
415{
416 printf("found version %d.%d.%d",
417 XALAN_VERSION_MAJOR, XALAN_VERSION_MINOR, XALAN_VERSION_REVISION);
418#if _XALAN_VERSION >= 11000
419 printf(", OK.\n");
420 return 0;
421#else
422 printf(", expected version 1.10.0 or higher\n");
423 return 1;
424#endif
425}
426' > .tmp_src.cc
427 if test_compile "$LIBXALAN ${INCXALAN:+-I$INCXALAN}" xalan xalanc; then
428 if test_execute; then
429 cnf_append "SDK_VBOX_XALAN_LIBS" `echo $LIBXALAN|sed 's+-l++'`
430 cnf_append "SDK_VBOX_XALAN_INCS" "$INCXALAN"
431 fi
432 fi
433}
434
435#
436# Check for xerces, needed by VBoxXML
437#
438function check_xerces()
439{
440 test_header xerces
441 echo '
442#include <cstdio>
443#include <xercesc/util/XercesVersion.hpp>
444extern "C" int main(void)
445{
446 printf("found version %d.%d.%d",
447 XERCES_VERSION_MAJOR, XERCES_VERSION_MINOR, XERCES_VERSION_REVISION);
448#if _XERCES_VERSION >= 20600
449 printf(", OK.\n");
450 return 0;
451#else
452 printf(", expected version 2.6.0 or higher");
453 return 1;
454#endif
455}
456' > .tmp_src.cc
457 if test_compile "$LIBXERCES ${INCXERCES:+-I$INCXERCES}" xerces xercesc; then
458 if test_execute; then
459 cnf_append "SDK_VBOX_XERCES_LIBS" `echo $LIBXERCES|sed 's+-l++'`
460 cnf_append "SDK_VBOX_XERCES_INCS" "$INCXERCES"
461 fi
462 fi
463}
464
465#
466# Check for libIDL, needed by xpcom
467#
468check_libidl()
469{
470 test_header libIDL
471
472 if which "libIDL-config-2" > /dev/null; then
473 libidl_ver=`libIDL-config-2 --version`
474 if (($?!=0)); then
475 log_failure "not found"
476 fail
477 else
478 log_success "found version $libidl_ver"
479 fi
480 elif check_avail "libIDL-config" libIDL-config; then
481 libidl_ver=`libIDL-config --version`
482 if (($?!=0)); then
483 log_failure "not found"
484 fail
485 else
486 log_success "found version $libidl_ver"
487 fi
488 fi
489}
490
491#
492# Check for uuid, needed by Runtime, VBoxSVC, VBoxSDL, and VBoxBFE
493#
494function check_uuid()
495{
496 test_header uuid
497 echo '
498#include <cstdio>
499#include <uuid/uuid.h>
500extern "C" int main(void)
501{
502 uuid_t uu;
503 uuid_clear(uu);
504 if (uuid_is_null(uu)) {
505 printf("found, OK.\n");
506 return 0;
507 } else {
508 printf("uuid found but does not work\n");
509 return 1;
510 }
511}
512' > .tmp_src.cc
513 if test_compile $LIBUUID uuid uuid; then
514 if test_execute; then
515 cnf_append "LIB_UUID" `echo $LIBUUID|sed 's+-l++'`
516 fi
517 fi
518}
519
520#
521# Check for openssl, needed for RDP
522#
523function check_ssl()
524{
525 test_header ssl
526 echo '
527#include <cstdio>
528#include <openssl/opensslv.h>
529extern "C" int main(void)
530{
531 printf("found version %s", OPENSSL_VERSION_TEXT);
532#if OPENSSL_VERSION_NUMBER >= 0x0090700
533 printf(", OK.\n");
534 return 0;
535#else
536 printf(", expected version 0.9.7 or higher\n");
537 return 1;
538#endif
539}
540' > .tmp_src.cc
541 if test_compile $LIBCRYPTO libcrypto openssl; then
542 if test_execute nofatal; then
543 cnf_append "SDK_VBOX_OPENSSL_INCS" ""
544 cnf_append "SDK_VBOX_OPENSSL_LIBS" `echo $LIBCRYPTO|sed 's+-l++'`
545 fi
546 fi
547}
548
549#
550# Check for pthread, needed by VBoxSVC, frontends, ...
551#
552function check_pthread()
553{
554 test_header pthread
555 echo '
556#include <cstdio>
557#include <pthread.h>
558extern "C" int main(void)
559{
560 pthread_mutex_t mutex;
561 if (pthread_mutex_init(&mutex, NULL)) {
562 printf("pthread_mutex_init() failed\n");
563 return 1;
564 }
565 if (pthread_mutex_lock(&mutex)) {
566 printf("pthread_mutex_lock() failed\n");
567 return 1;
568 }
569 if (pthread_mutex_unlock(&mutex)) {
570 printf("pthread_mutex_unlock() failed\n");
571 return 1;
572 }
573 printf("found, OK.\n");
574}
575' > .tmp_src.cc
576 if test_compile $LIBPTHREAD pthread pthread; then
577 if test_execute; then
578 cnf_append "LIB_PTHREAD" `echo $LIBPTHREAD|sed 's+-l++'`
579 fi
580 fi
581}
582
583#
584# Check for zlib, needed by VBoxSVC, Runtime, ...
585#
586function check_z()
587{
588 test_header zlib
589 echo '
590#include <cstdio>
591#include <zlib.h>
592extern "C" int main(void)
593{
594 printf("found version %s", ZLIB_VERSION);
595#if ZLIB_VERNUM >= 0x1210
596 printf(", OK.\n");
597 return 0;
598#else
599 printf(", expected version 1.2.1 or higher\n");
600 return 1;
601#endif
602}
603' > .tmp_src.cc
604 if test_compile "$LIBZ ${INCZ:+-I$INCZ}" zlib zlib; then
605 if test_execute; then
606 cnf_append "SDK_VBOX_ZLIB_LIBS" `echo $LIBZ|sed 's+-l++'`
607 cnf_append "SDK_VBOX_ZLIB_INCS" "$INCZ"
608 fi
609 fi
610}
611
612#
613# Check for libpng, needed by kchmviewer
614#
615function check_png()
616{
617 test_header libpng
618 echo '
619#include <cstdio>
620#include <png.h>
621extern "C" int main(void)
622{
623 printf("found version %s", PNG_LIBPNG_VER_STRING);
624#if PNG_LIBPNG_VER >= 10205
625 printf(", OK.\n");
626 return 0;
627#else
628 printf(", expected version 1.2.5 or higher\n");
629 return 1;
630#endif
631}
632' > .tmp_src.cc
633 if test_compile "$LIBPNG ${INCPNG:+-I$INCPNG}" libpng libpng nofatal; then
634 if test_execute nofatal; then
635 cnf_append "SDK_VBOX_LIBPNG_LIBS" `echo $LIBPNG|sed 's+-l++'`
636 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
637 fi
638 fi
639}
640
641#
642# Check for pam, needed by VRDPAuth
643# Version 79 was introduced in 9/2005, do we support older versions?
644#
645function check_pam()
646{
647 test_header pam
648 echo '
649#include <cstdio>
650#include <security/pam_appl.h>
651extern "C" int main(void)
652{
653 printf("found version %d", __LIBPAM_VERSION);
654 if (__LIBPAM_VERSION >= 79)
655 {
656 printf(", OK.\n");
657 return 0;
658 }
659 else
660 {
661 printf(", expected version 79 or higher\n");
662 return 1;
663 }
664}
665' > .tmp_src.cc
666 if test_compile "-lpam" pam pam; then
667 test_execute
668 fi
669}
670
671#
672# Check for the SDL library, needed by VBoxSDL and VirtualBox
673# We depend at least on version 1.2.7
674#
675function check_sdl()
676{
677 test_header SDL
678 echo '
679#include <cstdio>
680#include <SDL/SDL.h>
681#include <SDL/SDL_main.h>
682extern "C" int main(void)
683{
684 printf("found version %d.%d.%d",
685 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
686#if SDL_VERSION_ATLEAST(1,2,7)
687 printf(", OK.\n");
688 return 0;
689#else
690 printf(", expected version 1.2.7 or higher\n");
691 return 1;
692#endif
693}
694' > .tmp_src.cc
695 if test_compile "$LIBSDL $LIBSDLMAIN ${INCSDL:+-I$INCSDL}" SDL SDL; then
696 if test_execute; then
697 cnf_append "LIB_SDK_LIBSDL_SDL" `echo $LIBSDL|sed 's+-l++'`
698 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" `echo $LIBSDLMAIN|sed 's+-l++'`
699 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
700 fi
701 fi
702}
703
704#
705# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
706#
707function check_sdl_ttf()
708{
709 test_header SDL_ttf
710 echo '
711#include <cstdio>
712#include <SDL/SDL_ttf.h>
713extern "C" int main(void)
714{
715 printf("found version %d.%d.%d",
716 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
717#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
718 printf(", OK.\n");
719 return 0;
720#else
721 printf(", expected version 2.0.6 or higher\n");
722 return 1;
723#endif
724}
725' > .tmp_src.cc
726 if test_compile "-lSDL_ttf" SDL_ttf SDL_ttf; then
727 test_execute
728 fi
729}
730
731#
732# Check for the Xcursor library, needed by VBoxSDL and VBoxBFE
733#
734function check_xcursor()
735{
736 test_header Xcursor
737 echo '
738#include <cstdio>
739#include <X11/Xlib.h>
740#include <X11/Xcursor/Xcursor.h>
741extern "C" int main(void)
742{
743 XcursorImage *cursor = XcursorImageCreate (10, 10);
744 XcursorImageDestroy(cursor);
745 return 0;
746}
747' > .tmp_src.cc
748 if test_compile $LIBXCURSOR Xcursor Xcursor; then
749 log_success "found"
750 cnf_append "LIB_XCURSOR" `echo $LIBXCURSOR|sed 's+-l++'`
751 fi
752}
753
754#
755# Check for the X libraries (Xext, X11)
756#
757function check_x()
758{
759 test_header "X libraries"
760 echo '
761#include <cstdio>
762#include <X11/Xlib.h>
763extern "C" int main(void)
764{
765 Display *dpy;
766 int scrn_num;
767 Screen *scrn;
768 Window win;
769
770 dpy = XOpenDisplay(NULL);
771 scrn_num = DefaultScreen(dpy);
772 scrn = ScreenOfDisplay(dpy, scrn_num);
773 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
774 0, 16, InputOutput, CopyFromParent, 0, NULL);
775 XDestroyWindow(dpy, win);
776}
777' > .tmp_src.cc
778 if test_compile "$LIBX11" Xlibs Xlibs; then
779 log_success "found"
780 fi
781}
782
783#
784# Check for the QT library, needed by VirtualBox
785#
786function check_qt()
787{
788 test_header Qt
789 echo '
790#include <cstdio>
791#include <qglobal.h>
792extern "C" int main(void)
793{
794 printf("found version %s", QT_VERSION_STR);
795#if QT_VERSION >= 0x030305
796 printf(", OK.\n");
797 return 0;
798#elif QT_VERSION >= 0x030300
799 printf("\n ** WARNING: QT < 3.3.5 has known problems!\n");
800#else
801 printf(", expected version 3.3.0 or higher\n");
802 return 1;
803#endif
804}
805' > .tmp_src.cc
806 found_qt=0
807 for q in $QTDIR; do
808 echo "compiling the following source file:" >> $LOG
809 cat .tmp_src.cc >> $LOG
810 echo "using the following command line:" >> $LOG
811 echo "$CXX -O -Wall -o .tmp_out .tmp_src.cc \"-I$q/include -L$q/lib -lqt-mt\"" >> $LOG
812 $CXX -O -Wall -o .tmp_out .tmp_src.cc -I$q/include -L$q/lib -lqt-mt >> $LOG 2>&1
813 if (($?==0)); then
814 if test_execute; then
815 cnf_append "QTDIR" `cd $q ; pwd`
816 found_qt=1
817 break
818 fi
819 fi
820 done
821 if (($found_qt!=1)); then
822 echo -e "\n Qt not found at \"$QTDIR\" or Qt headers not found"
823 echo " Check the file $LOG for detailed error information."
824 fail
825 return 1
826 fi
827 test_header "Qt devtools"
828 if check_avail "$q/bin/moc" QTDIR/bin; then
829 moc_ver=`$q/bin/moc 2>&1 -v|sed 's+^.*(Qt \(.*\))+\1+'`
830 if (($?!=0)); then
831 log_failure "not found"
832 fail
833 else
834 log_success "found version $moc_ver"
835 fi
836 fi
837}
838
839#
840# Check for Linux sources
841#
842function check_linux()
843{
844 test_header "Linux kernel sources"
845 echo '
846#include <linux/version.h>
847int printf(const char *format, ...);
848int main(void)
849{
850 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
851 (LINUX_VERSION_CODE % 65536) / 256,
852 LINUX_VERSION_CODE % 256);
853#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
854 printf(", OK.\n");
855 return 0;
856#else
857 printf(", expected version 2.4.0 or higher\n");
858 return 1;
859#endif
860}
861' > .tmp_src.c
862 echo "compiling the following source file:" >> $LOG
863 cat .tmp_src.c >> $LOG
864 echo "using the following command line:" >> $LOG
865 echo "$CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include" >> $LOG
866 $CC -O -Wall -o .tmp_out .tmp_src.c -nostdinc -I$LINUX/include >> $LOG 2>&1
867 if (($?!=0)); then
868 echo -e "\n Linux kernel headers not found at $LINUX"
869 echo " Check the file $LOG for detailed error information."
870 fail
871 else
872 if test_execute; then
873 cnf_append "VBOX_LINUX_SRC" `cd $LINUX ; pwd`
874 fi
875 fi
876}
877
878#
879# Check for kchmviewer, needed to display the online help
880#
881function check_kchmviewer()
882{
883 test_header kchmviewer
884 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
885 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
886 if (($?!=0)); then
887 log_failure "not found"
888 fail
889 else
890 log_success "found version $kchmviewer_ver"
891 fi
892 fi
893}
894
895#
896# Check for the kBuild tools, we don't support GNU make
897#
898function check_kbuild()
899{
900 test_header kBuild
901 if check_avail "$KBUILDDIR_BIN/kmk" KBUILDDIR really; then
902 log_success "found"
903 echo "export BUILD_PLATFORM=\"$OS\"" >> $ENV
904 echo "export BUILD_PLATFORM_ARCH=\"$MACHINE\"" >> $ENV
905 echo "export BUILD_TARGET=\"$OS\"" >> $ENV
906 echo "export BUILD_TARGET_ARCH=\"$MACHINE\"" >> $ENV
907 echo "export BUILD_TARGET_CPU=\"$CPU\"" >> $ENV
908 echo "export BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
909 echo "export PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
910 echo "export PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
911 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
912 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
913 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
914 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
915 echo "export PATH" >> $ENV
916 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
917 fi
918}
919
920#
921# Show help
922#
923function show_help()
924{
925 cat << EOF
926Usage: ./configure [OPTIONS]...
927
928Configuration:
929 -h, --help display this help and exit
930 --nofatal don't abort on errors
931 --disable-xpcom disable XPCOM and related stuff
932
933Paths:
934 --with-gcc=PATH position of the gcc compiler [$CC]
935 --with-g++=PATH position of the g++ compiler [$CXX]
936 --with-kbuild-dir=DIR kbuild directory [$KBUILDDIR]
937 --with-iasl=PATH the position of the iasl compiler [$IASL]
938 --with-linux=DIR Linux kernel source directory [$LINUX]
939 --with-mkisofs=PATH position of mkisofs [$MKISOFS]
940 --with-qt-dir=DIR directory for QT headers/libraries [$QTDIR]
941 --with-xalan=LIB position of the xalan library [$LIBXALAN]
942 --with-xerces=LIB position of the xerces library [$LIBXERCES]
943
944Build type:
945 -d, --build-debug build with debugging symbols and assertions
946EOF
947 exit 0
948}
949
950
951#
952# The body.
953#
954
955# scan command line options
956for option; do
957 case "$option" in
958 --help|-help|-h)
959 show_help
960 ;;
961 --nofatal)
962 nofatal=1
963 ;;
964 --with-gcc=*)
965 CC=`echo $option | cut -d'=' -f2`
966 ;;
967 --with-g++=*)
968 CXX=`echo $option | cut -d'=' -f2`
969 ;;
970 --with-kbuild=*)
971 KBUILDDIR=`echo $option | cut -d'=' -f2`
972 ;;
973 --with-qt-dir=*)
974 QTDIR=`echo $option | cut -d'=' -f2`
975 ;;
976 --with-iasl=*)
977 IASL=`echo $option | cut -d'=' -f2`
978 ;;
979 --with-linux=*)
980 LINUX=`echo $option | cut -d'=' -f2`
981 ;;
982 --with-mkisofs=*)
983 MKISOFS=`echo $option | cut -d'=' -f2`
984 ;;
985 --with-xalan=*)
986 LIBXALAN=`echo $option | cut -d'=' -f2`
987 ;;
988 --with-xerces=*)
989 LIBXERCES=`echo $option | cut -d'=' -f2`
990 ;;
991 --disable-xpcom)
992 XPCOM=0
993 ;;
994 --disable-qt)
995 WITH_QT=0
996 ;;
997 --build-debug|-d)
998 BUILD_TYPE=debug
999 ;;
1000 --ose)
1001 OSE=2
1002 ;;
1003 --odir=*)
1004 ODIR=`echo $option | cut -d'=' -f2`
1005 ;;
1006 *)
1007 echo
1008 echo "Unrecognized option \"$option\""
1009 echo
1010 show_help
1011 ;;
1012 esac
1013done
1014
1015LOG="${ODIR:+$ODIR/}$LOG"
1016ENV="${ODIR:+$ODIR/}$ENV"
1017CNF="${ODIR:+$ODIR/}$CNF"
1018
1019# initialize output files
1020cat > $LOG << EOF
1021# Log file generated by
1022#
1023# '$0 $*'
1024#
1025
1026EOF
1027cat > $CNF << EOF
1028# -*- Makefile -*-
1029#
1030# automatically generated by
1031#
1032# '$0 $*'
1033#
1034# It will be completely overwritten if configure is executed again.
1035#
1036
1037EOF
1038cat > $ENV << EOF
1039#!/bin/bash
1040#
1041# automatically generated by
1042#
1043# '$0 $*'
1044#
1045# It will be completely overwritten if configure is executed again.
1046# Make sure you source this file once before you start to build VBox.
1047#
1048
1049EOF
1050
1051# test if we are OSE
1052if (($OSE==1)) && [ -d "`cd $(dirname $0); pwd`/src/VBox/Devices/USB" ]; then
1053 echo "Found USB devices, assuming VBOX_OSE = FALSE" >> $LOG
1054 echo >> $LOG
1055 OSE=0
1056fi
1057
1058# first determine our environment
1059check_environment
1060check_kbuild
1061
1062# some things are not available in for OSE
1063if (($OSE)); then
1064 cnf_append "VBOX_OSE" "1"
1065 cnf_append "VBOX_WITH_TESTSUITE" ""
1066 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
1067
1068 if [ "$OS" = "linux" ]; then
1069 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
1070 else
1071 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
1072 fi
1073 echo >> $CNF
1074fi
1075
1076# append the tools directory to the default search path
1077echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
1078
1079# the tools
1080check_gcc
1081[ "$OS" != "darwin" ] && check_as86
1082[ "$OS" != "darwin" ] && check_bcc
1083[ "$OS" != "darwin" ] && check_iasl
1084# don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
1085# [ "$OS" != "darwin" ] && check_yasm
1086[ "$OS" != "darwin" ] && check_xsltproc
1087(($OSE==0)) && check_mkisofs
1088
1089# the libraries
1090(($XPCOM==1)) && check_xalan
1091(($XPCOM==1)) && check_xerces
1092(($XPCOM==1)) && check_libidl
1093[ "$OS" != "darwin" ] && check_uuid
1094(($OSE==0)) && check_ssl
1095[ "$OS" != "darwin" ] && check_pthread
1096[ "$OS" != "darwin" ] && check_z
1097(($OSE==0)) && check_png
1098(($OSE==0)) && check_pam
1099[ "$OS" != "darwin" ] && check_sdl
1100(($OSE==0)) && check_sdl_ttf
1101[ "$OS" != "darwin" ] && check_xcursor
1102[ "$OS" != "darwin" ] && check_x
1103(($XPCOM==1)) && check_qt
1104
1105# Linux-specific
1106[ "$OS" = "linux" ] && check_linux
1107
1108# success!
1109echo
1110echo "Successfully generated '$CNF' and '$ENV'."
1111echo "Source '$ENV' once before you start to build VBox:"
1112echo
1113echo " source $ENV"
1114echo " kmk"
1115echo
1116echo "Enjoy!"
1117cleanup
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use