VirtualBox

source: vbox/trunk/configure@ 67954

Last change on this file since 67954 was 67684, checked in by vboxsync, 7 years ago

configure: for internal builds on Linux insist on OpenWatcom

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 77.8 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-2016 Oracle Corporation
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 (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will 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, grep, sed to work)
23PATH="/usr/xpg4/bin:$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin"
24ORGPATH=$PATH
25
26# Wrapper for ancient /usr/bin/which on darwin that always returns 0
27which_wrapper()
28{
29 if [ -z "$have_ancient_which" ]; then
30 if which /bin/___cErTaINly_a_nOn_eXisTing_fIle___ 2> /dev/null > /dev/null; then
31 have_ancient_which="yes"
32 else
33 have_ancient_which="no"
34 fi
35 fi
36 if [ "$have_ancient_which" = "yes" ]; then
37 retval=`which $* 2>/dev/null`
38 echo "$retval"
39 test -n "$retval" -a -x "$retval"
40 unset retval
41 else
42 which $* 2> /dev/null
43 fi
44}
45
46OS=`uname -s | sed -e 's/GNU\/Linux/Linux/g' | tr '[:upper:]' '[:lower:]'`
47case "$OS" in
48 linux)
49 ;;
50 darwin)
51 ;;
52 freebsd)
53 ;;
54 netbsd)
55 ;;
56 sunos)
57 OS='solaris'
58 ;;
59 haiku)
60 ;;
61 *)
62 echo "Cannot determine OS!"
63 exit 1
64 ;;
65esac
66
67#
68# Defaults
69#
70OSE=1
71ODIR="`pwd`/"
72ODIR_OVERRIDE=0
73OUT_PATH=""
74OUT_PATH_OVERRIDE=0
75SETUP_WINE=
76ONLY_ADDITIONS=0
77TARGET_MACHINE=""
78TARGET_CPU=""
79WITH_XPCOM=1
80WITH_PYTHON=1
81WITH_JAVA=1
82WITH_VMMRAW=1
83WITH_LIBIDL=1
84WITH_GSOAP=0
85WITH_QT5=1
86WITH_SDL=1
87WITH_SDL_TTF=1
88WITH_X11=1
89WITH_ALSA=1
90WITH_PULSE=1
91WITH_DBUS=1
92WITH_DEVMAPPER=1
93WITH_KMODS=1
94WITH_OPENGL=1
95WITH_HARDENING=1
96WITH_UDPTUNNEL=1
97WITH_VDE=0
98WITH_VNC=0
99WITH_EXTPACK=1
100WITH_DOCS=1
101WITH_LIBVPX=1
102BUILD_LIBXML2=
103BUILD_LIBCURL=
104BUILD_LIBSSL=
105BUILD_LIBVPX=
106PASSIVE_MESA=0
107CC="gcc"
108CC32=""
109CC64=""
110CXX="g++"
111CXX32=""
112CXX64=""
113YASM="yasm"
114IASL="iasl"
115XSLTPROC="xsltproc"
116GENISOIMAGE="genisoimage"
117MKISOFS="mkisofs"
118INCCRYPTO=""
119LIBCRYPTO="-lssl -lcrypto"
120LIBPTHREAD="-lpthread"
121LIBCAP="-lcap"
122GSOAP=""
123GSOAP_IMPORT=""
124INCX11="/usr/local/include"
125LIBX11="-L/usr/X11R6/lib -L/usr/X11R6/lib64 -L/usr/local/lib -lXext -lX11"
126LIBXCURSOR="-lXcursor"
127LIBXMU="-lXmu"
128LIBXINERAMA="-lXinerama"
129LIBXRANDR="-lXrandr"
130MAKESELF="makeself"
131MESA="-lGL"
132INCZ=""
133LIBZ="-lz"
134INCVNCSERVER=""
135LIBVNCSERVER="-lvncserver"
136INCDEVMAPPER=""
137LIBDEVMAPPER="-ldevmapper"
138CXX_FLAGS=""
139if [ "$OS" = "freebsd" ]; then
140 INCCURL="-I/usr/local/include"
141 LIBCURL="-L/usr/local/lib -lcurl"
142 INCPULSE="-I/usr/local/include"
143 LIBPULSE="-L/usr/local/lib"
144 INCPNG="-I/usr/local/include"
145 LIBPNG="-L/usr/local/lib -lpng"
146else
147 INCCURL=""
148 LIBCURL="-lcurl"
149 INCPNG=""
150 LIBPNG="-lpng"
151fi
152INCVPX=""
153LIBVPX="-lvpx"
154PKGCONFIG="`which_wrapper pkg-config`"
155PYTHONDIR="/usr /usr/local"
156QT5DIR="/usr/lib/qt5 /usr/share/qt5 /usr/lib64/qt5 /usr /usr/local"
157QT5DIR_PKGCONFIG=1
158QT5MAJ=5
159QT5MIN=6
160KBUILDDIR="`cd \`dirname $0\`; pwd`/kBuild"
161DEVDIR="`cd \`dirname $0\`; pwd`/tools"
162if [ -d "/lib/modules/`uname -r`/build" ]; then
163 LINUX="/lib/modules/`uname -r`/build"
164elif [ "`echo /lib/modules/*`" != "/lib/modules/*" ]; then
165 # Get the most recent kernel headers if none match the current kernel.
166 for i in /lib/modules/*; do
167 if [ -r "$i/build" ]; then
168 LINUX="$i/build"
169 fi
170 done
171fi
172if [ -z "$LINUX" ]; then
173 LINUX="/usr/src/linux"
174fi
175KCHMVIEWER="kchmviewer"
176LOG="configure.log"
177CNF="AutoConfig.kmk"
178ENV="env.sh"
179BUILD_TYPE="release"
180# the restricting tool is ar (mri mode).
181INVALID_CHARS="[^A-Za-z0-9/\\$:._-]"
182
183if (cd `dirname $0`; pwd)|grep -q "$INVALID_CHARS"; then
184 echo "Error: VBox base path contains invalid characters!"
185 exit 1
186fi
187
188# darwin /bin/sh has a builtin echo that doesn't grok -n. gotta love it.
189if [ "$OS" = "darwin" ]; then
190 ECHO_N="/bin/echo -n"
191elif [ "$OS" = "solaris" ]; then
192 # Solaris 11 /bin/sh has a builtin echo that could grok -n if there is
193 # /usr/ucb/echo the first echo executable in the path, but the /usr/ucb
194 # tools are no longer installed by default.
195 ECHO_N="/usr/gnu/bin/echo -n"
196else
197 ECHO_N="echo -n"
198fi
199
200
201cleanup()
202{
203 rm -f $ODIR.tmp_src.cc $ODIR.tmp_src.c $ODIR.tmp_out $ODIR.test_execute.log
204}
205
206fail()
207{
208 if [ -z "$nofatal" -o "x$1" != "x" ]; then
209 cleanup
210 rm -f $ENV
211 echo "Check $LOG for details"
212 exit 1
213 fi
214}
215
216log()
217{
218 echo "$1"
219 echo "$1" >> $LOG
220}
221
222log_success()
223{
224 if [ -n "$1" ]; then $ECHO_N "$1, "; fi
225 echo "OK."
226 echo "$1" >> $LOG
227 echo >> $LOG
228 echo >> $LOG
229}
230
231log_failure()
232{
233 echo
234 echo " ** $1!"
235 echo "** $1!" >> $LOG
236 echo >> $LOG
237}
238
239cnf_append()
240{
241 printf "%-30s := %s\n" "$1" "$2" >> $CNF
242}
243
244strip_l()
245{
246 echo "$1"|$KBUILD_SED 's|-l\([^ ]\+\)|\1|g; s|^-[^l][^ ]*||g; s| -[^l][^ ]*||g; s|^ ||; s| *$||g'
247}
248
249strip_L()
250{
251 echo "$1"|$KBUILD_SED 's|-L\([^ ]\+\)|\1|g; s|^-[^L][^ ]*||g; s| -[^L][^ ]*||g; s|^ ||; s| *$||g'
252}
253
254strip_I()
255{
256 echo "$1"|$KBUILD_SED 's|-I\([^ ]\+\)|\1|g; s|^-[^I][^ ]*||g; s| -[^I][^ ]*||g; s|^ ||; s| *$||g'
257}
258
259prefix_I()
260{
261 echo "$1"|$KBUILD_SED 's|^\/|-I/|g; s| \/| -I/|g'
262}
263
264check_avail()
265{
266 if [ -z "$1" ]; then
267 log_failure "$2 is empty"
268 fail $3
269 return 1
270 elif which_wrapper $1 > /dev/null; then
271 return 0
272 else
273 log_failure "$1 (variable $2) not found"
274 fail $3
275 return 1
276 fi
277}
278
279
280# Prepare a test
281test_header()
282{
283 echo "***** Checking $1 *****" >> $LOG
284 $ECHO_N "Checking for $1: "
285}
286
287
288# Compile a test
289# $1 compile flags/libs
290# $2 library name
291# $3 package name
292# $4 if this argument is 'nofatal', don't abort
293test_compile()
294{
295 echo "compiling the following source file:" >> $LOG
296 cat $ODIR.tmp_src.cc >> $LOG
297 echo "using the following command line:" >> $LOG
298 echo "$CXX $CXX_FLAGS -fPIC -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc \"$1\"" >> $LOG
299 $CXX $CXX_FLAGS -fPIC -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $1 >> $LOG 2>&1
300 if [ $? -ne 0 ]; then
301 if [ -z "$4" ]; then
302 echo
303 echo " $2 not found at $1 or $3 headers not found"
304 echo " Check the file $LOG for detailed error information."
305 fail
306 else
307 echo >> $LOG
308 echo >> $LOG
309 fi
310 return 1
311 fi
312 return 0
313}
314
315
316# Execute a compiled test binary
317test_execute()
318{
319 echo "executing the binary" >> $LOG
320 $ODIR.tmp_out > $ODIR.test_execute.log
321 rc=$?
322 cat $ODIR.test_execute.log | tee -a $LOG
323 if [ $rc -ne 0 ]; then
324 fail $1
325 return 1
326 fi
327 echo >> $LOG
328 echo >> $LOG
329 return 0
330}
331
332
333# Execute a compiled test binary
334test_execute_path()
335{
336 ## LD_LIBRARY_PATH to set.
337 local_path="${1}"
338 ## Set this to non-empty to make this test non-fatal.
339 local_nofail="${2}"
340 echo "executing the binary (LD_LIBRARY_PATH=$1)" >> $LOG
341 LD_LIBRARY_PATH="${local_path}" $ODIR.tmp_out > $ODIR.test_execute.log
342 rc=$?
343 cat $ODIR.test_execute.log | tee -a $LOG
344 if [ $rc -ne 0 ]; then
345 test -z "${local_nofail}" && fail
346 echo >> $LOG
347 echo >> $LOG
348 return 1
349 fi
350 echo >> $LOG
351 echo >> $LOG
352 return 0
353}
354
355
356#
357# Check for OS, MACHINE, CPU
358#
359check_environment()
360{
361 test_header environment
362 BUILD_CPU=`uname -m`
363 [ "$OS" = "solaris" ] && BUILD_CPU=`isainfo | cut -f 1 -d ' '`
364 case "$BUILD_CPU" in
365 i[3456789]86|x86|i86pc|BePC)
366 BUILD_MACHINE='x86'
367 LIB='lib'
368 ;;
369 x86_64|amd64)
370 BUILD_MACHINE='amd64'
371 BUILD_CPU='k8'
372 if [ "$OS" != "solaris" ]; then
373 # on AMD64 systems, 64bit libs are usually located in /usr/lib64
374 # see http://www.pathname.com/fhs/pub/fhs-2.3.html#LIB64
375 LIB='lib64'
376 else
377 # Solaris doesn't seem to subscribe to fhs, libs are usually in
378 # a '64' subdirectory of the standard 'lib' dirs while some 64-bit
379 # alternative binaries can be found in 'amd64' subdirs of the 'bin'
380 # ones. So, in order to find the right stuff (esp. sdl-config) we'll
381 # have to make sure the */bin/amd64 dirs are searched before the */bin
382 # ones. (The sed has some sideeffects, but they shouldn't harm us...)
383 echo "64-bit Solaris detected, hacking the PATH" >> $LOG
384 echo "old PATH: $PATH" >> $LOG
385 PATH=`echo ":$PATH:" | sed -e 's,\(:[^:]*/bin\):,\1/amd64:\1:,g' \
386 -e 's/^:*//' -e 's/:*$//g' -e 's/::*/:/g' `
387 export PATH
388 echo "new PATH: $PATH" >> $LOG
389 LIB='lib/64'
390 fi
391 ;;
392 *)
393 log_failure "Cannot determine system"
394 exit 1
395 ;;
396 esac
397 [ -z "$TARGET_MACHINE" ] && TARGET_MACHINE=$BUILD_MACHINE
398 [ -z "$TARGET_CPU" ] && TARGET_CPU=$BUILD_CPU
399 DEVDIR_BIN="$DEVDIR/$OS.$BUILD_MACHINE/bin"
400 log_success "Determined build machine: $OS.$BUILD_MACHINE, target machine: $OS.$TARGET_MACHINE"
401
402 echo "BUILD_PLATFORM=\"$OS\"" >> $ENV
403 echo "export BUILD_PLATFORM" >> $ENV
404 echo "BUILD_PLATFORM_ARCH=\"$BUILD_MACHINE\"" >> $ENV
405 echo "export BUILD_PLATFORM_ARCH" >> $ENV
406 echo "BUILD_TARGET=\"$OS\"" >> $ENV
407 echo "export BUILD_TARGET" >> $ENV
408 echo "BUILD_TARGET_ARCH=\"$TARGET_MACHINE\"" >> $ENV
409 echo "export BUILD_TARGET_ARCH" >> $ENV
410 echo "BUILD_TARGET_CPU=\"$TARGET_CPU\"" >> $ENV
411 echo "export BUILD_TARGET_CPU" >> $ENV
412 echo "BUILD_TYPE=\"$BUILD_TYPE\"" >> $ENV
413 echo "export BUILD_TYPE" >> $ENV
414}
415
416#
417# Check for gcc with version >= 3.2.
418# We depend on a working gcc, if we fail terminate in every case.
419#
420check_gcc()
421{
422 test_header gcc
423 if check_avail "$CC" CC really; then
424 cc_ver=`$CC -dumpfullversion` 2>/dev/null
425 if [ $? -ne 0 ]; then
426 cc_ver=`$CC -dumpversion` 2>/dev/null
427 fi
428 if [ $? -ne 0 ]; then
429 log_failure "cannot execute '$CC -dumpversion'"
430 fail really
431 fi
432 if check_avail "$CXX" CXX really; then
433 cxx_ver=`$CXX -dumpfullversion` 2>/dev/null
434 if [ $? -ne 0 ]; then
435 cxx_ver=`$CXX -dumpversion` 2>/dev/null
436 fi
437 if [ $? -ne 0 ]; then
438 log_failure "cannot execute '$CXX -dumpversion'"
439 fail really
440 fi
441 cc_maj=`echo $cc_ver|cut -d. -f1`
442 cc_min=`echo $cc_ver|cut -d. -f2`
443 if [ "x$cc_ver" != "x$cxx_ver" ]; then
444 log_failure "gcc version $cc_ver does not match g++ version $cxx_ver"
445 fail really
446 elif [ $cc_maj -eq 4 -a $cc_min -eq 0 -a "$OS" = "darwin" ]; then
447 log_success "found version $cc_ver"
448 # gcc-4.0 is allowed for Darwin only
449 elif [ $cc_maj -lt 4 \
450 -o \( $cc_maj -eq 4 -a $cc_min -lt 4 -a "$OS" != "darwin" \) \
451 -o \( $cc_maj -eq 4 -a $cc_min -lt 2 -a "$OS" = "darwin" \) \
452 -o $cc_maj -gt 7 ]; then
453 log_failure "gcc version $cc_maj.$cc_min found, expected gcc 4.x...7.x"
454 fail really
455 else
456 log_success "found version $cc_ver"
457 fi
458 if [ "$BUILD_MACHINE" = "amd64" ]; then
459 [ -z "$CC32" ] && CC32="$CC -m32"
460 [ -z "$CXX32" ] && CXX32="$CXX -m32"
461 else
462 [ -z "$CC32" ] && CC32="$CC"
463 [ -z "$CXX32" ] && CXX32="$CXX"
464 fi
465 if [ "$BUILD_MACHINE" = "x86" -a "$TARGET_MACHINE" = "amd64" ]; then
466 [ -z "$CC64" ] && CC64="$CC -m64"
467 [ -z "$CXX64" ] && CXX64="$CXX -m64"
468 fi
469 if [ "$TARGET_MACHINE" = "amd64" -a $WITH_VMMRAW -eq 0 ]; then
470 CC32="undefined"
471 CXX32="undefined"
472 fi
473 if [ "$CC" != "gcc" ]; then
474 cnf_append "TOOL_GCC3_CC" "$CC"
475 cnf_append "TOOL_GCC3_AS" "$CC"
476 cnf_append "TOOL_GCC3_LD" "$CC"
477 cnf_append "TOOL_GXX3_CC" "$CC"
478 cnf_append "TOOL_GXX3_AS" "$CC"
479 fi
480 if [ "$CXX" != "g++" ]; then
481 cnf_append "TOOL_GCC3_CXX" "$CXX"
482 cnf_append "TOOL_GXX3_CXX" "$CXX"
483 cnf_append "TOOL_GXX3_LD" "$CXX"
484 fi
485 if [ "$CC32" != "gcc -m32" -a "$CC32" != "undefined" ]; then
486 cnf_append "TOOL_GCC32_CC" "$CC32"
487 cnf_append "TOOL_GCC32_AS" "$CC32"
488 cnf_append "TOOL_GCC32_LD" "$CC32"
489 cnf_append "TOOL_GXX32_CC" "$CC32"
490 cnf_append "TOOL_GXX32_AS" "$CC32"
491 fi
492 if [ "$CXX32" != "g++ -m32" -a "$CXX32" != "undefined" ]; then
493 cnf_append "TOOL_GCC32_CXX" "$CXX32"
494 cnf_append "TOOL_GXX32_CXX" "$CXX32"
495 cnf_append "TOOL_GXX32_LD" "$CXX32"
496 fi
497 # this isn't not necessary, there is not such tool.
498 if [ -n "$CC64" ]; then
499 cnf_append "TOOL_GCC64_CC" "$CC64"
500 cnf_append "TOOL_GCC64_AS" "$CC64"
501 cnf_append "TOOL_GCC64_LD" "$CC64"
502 cnf_append "TOOL_GXX64_CC" "$CC64"
503 cnf_append "TOOL_GXX64_AS" "$CC64"
504 fi
505 if [ -n "$CXX64" ]; then
506 cnf_append "TOOL_GCC64_CXX" "$CXX64"
507 cnf_append "TOOL_GXX64_CXX" "$CXX64"
508 cnf_append "TOOL_GXX64_LD" "$CXX64"
509 fi
510 if [ "$CC" != "gcc" ]; then
511 if [ -n "$CC64" ]; then
512 cnf_append "TOOL_Bs3Gcc64Elf64_CC" "$CC64"
513 else
514 cnf_append "TOOL_Bs3Gcc64Elf64_CC" "$CC"
515 fi
516 if [ -n "$CXX64" ]; then
517 cnf_append "TOOL_Bs3Gcc64Elf64_CXX" "$CXX64"
518 else
519 cnf_append "TOOL_Bs3Gcc64Elf64_CXX" "$CXX"
520 fi
521 fi
522 # Solaris sports a 32-bit gcc/g++.
523 if [ "$OS" = "solaris" -a "$BUILD_MACHINE" = "amd64" ]; then
524 [ "$CC" = "gcc" ] && CC="gcc -m64"
525 [ "$CXX" = "g++" ] && CXX="g++ -m64"
526 fi
527 fi
528 fi
529}
530
531
532#
533# Check for the OpenWatcom compiler, needed for compiling the BIOS
534#
535# If the system has Open Watcom installed, WATCOM will be set in the
536# environment. If the user has her/his own Open Watcom install it will be
537# pointed to by on the command line, which will set the WATCOM variable.
538# The only exception is detecting OpenWatcom in tools/common/openwatcom.
539#
540check_open_watcom()
541{
542 test_header "Open Watcom"
543
544 if [ -z "$WATCOM" ]; then
545 WATCOM=`/bin/ls -rd1 $PWD/tools/common/openwatcom/* 2> /dev/null | head -1`
546 if [ -z "$WATCOM" ]; then
547 if [ $OSE -eq 0 -a $OS = "linux" ]; then
548 log_failure "Open Watcom was not found"
549 exit 1
550 fi
551 log_failure "Open Watcom was not found, using alternative BIOS sources"
552 cnf_append "VBOX_WITH_OPEN_WATCOM" ""
553 return 0;
554 fi
555 fi
556
557 case "$OS" in
558 "darwin") wc_bin="binosx";; # ??
559 "dos") wc_bin="binw";;
560 "freebsd") wc_bin="binfbsd";; # ??
561 "linux") wc_bin="binl";;
562 "netbsd") wc_bin="binnbsd";; # ??
563 "solaris") wc_bin="binsol";; # ??
564 "os2") wc_bin="binp";;
565 "win") wc_bin="binnt";;
566 *) wc_bin="binl";;
567 esac
568
569 # Check that the tools we use are there.
570 for prog in wasm wcc wlink;
571 do
572 if [ ! -f "$WATCOM/$wc_bin/$prog" ]; then
573 log_failure "$WATCOM/$wc_bin/$prog does not exist or is not a regular file."
574 fail
575 fi
576 done
577
578 # Use WASM to get the version.
579 wasm_ver=`$WATCOM/$wc_bin/wasm -? 2>&1 | sed -e '1!d' -e 's/Open Watcom Assembler Version *//'`
580 if [ -z "$wasm_ver" ]; then
581 log_failure "$WATCOM/$wc_bin/wasm -? did not produce the expected response"
582 fail
583 fi
584 log_success "found version $wasm_ver"
585 cnf_append "PATH_TOOL_OPENWATCOM" "$WATCOM"
586 cnf_append "VBOX_WITH_OPEN_WATCOM" "1"
587
588 unset wasm_ver
589 unset wc_wasm
590 unset wc_bin
591}
592
593
594#
595# Check for yasm, needed to compile assembler files
596#
597check_yasm()
598{
599 test_header yasm
600 if check_avail "$YASM" YASM; then
601 yasm_ver=`$YASM --version|grep "^yasm"|sed 's+^yasm \(.*\)+\1+'`
602 if [ $? -ne 0 ]; then
603 log_failure "yasm not found"
604 fail
605 else
606 yasm_maj=`echo $yasm_ver|cut -d. -f1`
607 yasm_min=`echo $yasm_ver|cut -d. -f2`
608 yasm_rev=`echo $yasm_ver|cut -d. -f3`
609 yasm_ver_mul=`expr $yasm_maj \* 10000 + $yasm_min \* 100 + $yasm_rev`
610 if [ $yasm_ver_mul -lt 501 ]; then
611 log_failure "found version $yasm_ver, expected at least 0.5.1"
612 fail
613 else
614 log_success "found version $yasm_ver"
615 fi
616 fi
617 fi
618}
619
620
621#
622# Check for the iasl ACPI compiler, needed to compile vbox.dsl
623#
624check_iasl()
625{
626 test_header iasl
627 if check_avail "$IASL" IASL; then
628 iasl_ver=`$IASL|grep "ASL.*version"|sed 's+^ASL.*version \([0-9]*\).*+\1+'`
629 if [ $? -ne 0 ]; then
630 log_failure "iasl not found"
631 fail
632 else
633 log_success "found version $iasl_ver"
634 cnf_append "VBOX_IASLCMD" "`which_wrapper $IASL`"
635 fi
636 fi
637}
638
639
640#
641# Check for xsltproc, needed by Main
642#
643check_xsltproc()
644{
645 if [ -n "$BUILD_LIBXSLT" ]; then
646 return 0;
647 fi
648 test_header xslt
649 if check_avail "$XSLTPROC" XSLTPROC; then
650 xsltproc_ver=`$XSLTPROC --version`
651 if [ $? -ne 0 ]; then
652 log_failure "xsltproc not found"
653 fail
654 else
655 log_success "found"
656 cnf_append "VBOX_XSLTPROC" "`which_wrapper $XSLTPROC`"
657 fi
658 fi
659}
660
661
662#
663# Check for mkisofs, needed to build the CDROM image containing the additions
664#
665check_mkisofs()
666{
667 test_header mkisofs
668 if which_wrapper $GENISOIMAGE > /dev/null; then
669 mkisofs_ver=`$GENISOIMAGE --version`
670 if [ $? -ne 0 ]; then
671 log_failure "mkisofs not found"
672 fail
673 else
674 log_success "found $mkisofs_ver"
675 cnf_append "VBOX_MKISOFS" "`which_wrapper $GENISOIMAGE`"
676 fi
677 elif check_avail "$MKISOFS" MKISOFS; then
678 mkisofs_ver=`$MKISOFS --version`
679 if [ $? -ne 0 ]; then
680 log_failure "mkisofs not working"
681 fail
682 else
683 log_success "found $mkisofs_ver"
684 cnf_append "VBOX_MKISOFS" "`which_wrapper $MKISOFS`"
685 fi
686 fi
687}
688
689
690#
691# Check for libxml2, needed by VBoxSettings and Runtime.
692# 2.6.24 is known to NOT work, 2.6.26 is known to work (there is no 2.6.25 release)
693#
694check_libxml2()
695{
696 if [ -z "$BUILD_LIBXML2" ]; then
697 test_header libxml2
698 if which_wrapper pkg-config > /dev/null; then
699 libxml2_ver=`pkg-config libxml-2.0 --modversion 2>> $LOG`
700 if [ $? -ne 0 ]; then
701 log_failure "libxml2 not found"
702 fail
703 else
704 FLGXML2=`pkg-config libxml-2.0 --cflags`
705 INCXML2=`strip_I "$FLGXML2"`
706 LIBXML2=`pkg-config libxml-2.0 --libs`
707 cat > $ODIR.tmp_src.cc << EOF
708#include <cstdio>
709#include <libxml/xmlversion.h>
710extern "C" int main(void)
711{
712 printf("found version %s", LIBXML_DOTTED_VERSION);
713#if LIBXML_VERSION >= 20626
714 printf(", OK.\n");
715 return 0;
716#else
717 printf(", expected version 2.6.26 or higher\n");
718 return 1;
719#endif
720}
721EOF
722 [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
723 if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
724 if test_execute; then
725 cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
726 cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
727 fi
728 fi
729 fi
730 elif which_wrapper xml2-config; then
731 libxml2_ver=`xml2-config --version`
732 if [ $? -ne 0 ]; then
733 log_failure "xml2-config not found"
734 fail
735 else
736 log_success "found version $libxml2_ver"
737 FLGXML2=`xml2-config --cflags`
738 INCXML2=`strip_I "$FLGXML2"`
739 LIBXML2=`xml2-config --libs`
740 cat > $ODIR.tmp_src.cc << EOF
741#include <cstdio>
742#include <libxml/xmlversion.h>
743extern "C" int main(void)
744{
745 printf("found version %s", LIBXML_DOTTED_VERSION);
746#if LIBXML_VERSION >= 20626
747 printf(", OK.\n");
748 return 0;
749#else
750 printf(", expected version 2.6.26 or higher\n");
751 return 1;
752#endif
753}
754EOF
755 [ -n "$INCXML2" ] && I_INCXML2=`prefix_I "$INCXML2"`
756 if test_compile "$LIBXML2 $LIBPTHREAD $I_INCXML2" xml2 xml2; then
757 if test_execute; then
758 cnf_append "SDK_VBOX_LIBXML2_INCS" "$INCXML2"
759 cnf_append "SDK_VBOX_LIBXML2_LIBS" "`strip_l "$LIBXML2"`"
760 fi
761 fi
762 fi
763 else
764 log_failure "neither pkg-config nor xml2-config found"
765 fail
766 fi
767 fi
768}
769
770
771#
772# Check for libIDL, needed by xpcom
773#
774check_libidl()
775{
776 test_header libIDL
777
778 if which_wrapper libIDL-config-2 > /dev/null; then
779 libidl_ver=`libIDL-config-2 --version`
780 if [ $? -ne 0 ]; then
781 log_failure "libIDL-config-2 not working"
782 fail
783 else
784 log_success "found version $libidl_ver"
785 cnf_append "VBOX_LIBIDL_CONFIG" \
786 "PKG_CONFIG_PATH=`libIDL-config-2 --prefix`/$LIB/pkgconfig `which_wrapper libIDL-config-2`"
787 fi
788 elif check_avail "libIDL-config" libIDL-config; then
789 libidl_ver=`libIDL-config --version`
790 if [ $? -ne 0 ]; then
791 log_failure "libIDL-config not working"
792 fail
793 else
794 log_success "found version $libidl_ver"
795 cnf_append "VBOX_LIBIDL_CONFIG" "`which_wrapper libIDL-config`"
796 fi
797 fi
798}
799
800
801#
802# Check for libdevmapper, needed by the VBoxVolInfo
803#
804check_libdevmapper()
805{
806 test_header libdevmapper
807 cat > $ODIR.tmp_src.cc << EOF
808#include <cstdio>
809extern "C" {
810#define private
811#include <libdevmapper.h>
812int main()
813{
814 char version[80];
815
816 if (!dm_get_library_version(version, sizeof(version)))
817 {
818 printf("dm_get_library_version() failed.\n");
819 return 1;
820 }
821
822 const char* v=version;
823 unsigned int major = 0, minor = 0, micro = 0;
824
825 for (; *v !='.' && *v != '\0'; v++) major = major*10 + *v-'0';
826 if (*v == '.') v++;
827 for (; *v !='.' && *v != '\0'; v++) minor = minor*10 + *v-'0';
828 if (*v == '.') v++;
829 for (; *v !='.' && *v != '\0'; v++) micro = micro*10 + *v-'0';
830
831 printf("found version %s", version);
832 if (major*10000 + minor*100 + micro >= 10200)
833 {
834 printf(", OK.\n");
835 return 0;
836 }
837 else
838 {
839 printf(", expected version 1.02 or higher\n");
840 return 1;
841 }
842}
843}
844EOF
845 if test_compile "$LIBDEVMAPPER $INCDEVMAPPER" libdevmapper libdevmapper; then
846 if test_execute; then
847 cnf_append "VBOX_WITH_DEVMAPPER" "1"
848 fi
849 fi
850}
851
852
853#
854# Check for openssl, needed for RDP and S3
855#
856check_ssl()
857{
858 if [ -z "$BUILD_LIBSSL" ]; then
859 test_header ssl
860 cat > $ODIR.tmp_src.cc << EOF
861#include <cstdio>
862#include <openssl/opensslv.h>
863#include <openssl/ssl.h>
864extern "C" int main(void)
865{
866 printf("found version %s", OPENSSL_VERSION_TEXT);
867 SSL_library_init();
868#if OPENSSL_VERSION_NUMBER >= 0x00908000
869 printf(", OK.\n");
870 return 0;
871#else
872 printf(", expected version 0.9.8 or higher\n");
873 return 1;
874#endif
875}
876EOF
877 if test_compile "$INCCRYPTO $LIBCRYPTO" libcrypto openssl; then
878 if test_execute nofatal; then
879 cnf_append "SDK_VBOX_OPENSSL_INCS" "`strip_I "$INCCRYPTO"`"
880 cnf_append "SDK_VBOX_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
881 cnf_append "SDK_VBOX_BLD_OPENSSL_LIBS" "`strip_l "$LIBCRYPTO"`"
882 fi
883 fi
884 fi
885}
886
887
888#
889# Check for pthread, needed by VBoxSVC, frontends, ...
890#
891check_pthread()
892{
893 test_header pthread
894 cat > $ODIR.tmp_src.cc << EOF
895#include <cstdio>
896#include <pthread.h>
897extern "C" int main(void)
898{
899 pthread_mutex_t mutex;
900 if (pthread_mutex_init(&mutex, NULL)) {
901 printf("pthread_mutex_init() failed\n");
902 return 1;
903 }
904 if (pthread_mutex_lock(&mutex)) {
905 printf("pthread_mutex_lock() failed\n");
906 return 1;
907 }
908 if (pthread_mutex_unlock(&mutex)) {
909 printf("pthread_mutex_unlock() failed\n");
910 return 1;
911 }
912 printf("found, OK.\n");
913}
914EOF
915 if test_compile $LIBPTHREAD pthread pthread; then
916 if test_execute; then
917 cnf_append "LIB_PTHREAD" "`strip_l "$LIBPTHREAD"`"
918 fi
919 fi
920}
921
922
923#
924# Check for zlib, needed by VBoxSVC, Runtime, ...
925#
926check_z()
927{
928 test_header zlib
929 cat > $ODIR.tmp_src.cc << EOF
930#include <cstdio>
931#include <zlib.h>
932extern "C" int main(void)
933{
934 printf("found version %s", ZLIB_VERSION);
935#if ZLIB_VERNUM >= 0x1210
936 printf(", OK.\n");
937 return 0;
938#else
939 printf(", expected version 1.2.1 or higher\n");
940 return 1;
941#endif
942}
943EOF
944 [ -n "$INCZ" ] && I_INCZ=`prefix_I "$INCZ"`
945 if test_compile "$LIBZ $I_INCZ" zlib zlib; then
946 if test_execute; then
947 echo "if1of (\$(KBUILD_TARGET),darwin freebsd haiku linux)" >> $CNF
948 cnf_append " SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
949 cnf_append " SDK_VBOX_ZLIB_INCS" "$INCZ"
950 echo "endif" >> $CNF
951 fi
952 fi
953}
954
955
956#
957# Check for libpng, needed by kchmviewer
958#
959check_png()
960{
961 test_header libpng
962 cat > $ODIR.tmp_src.cc << EOF
963#include <cstdio>
964#include <png.h>
965extern "C" int main(void)
966{
967 printf("found version %s", PNG_LIBPNG_VER_STRING);
968#if PNG_LIBPNG_VER >= 10205
969 printf(", OK.\n");
970 return 0;
971#else
972 printf(", expected version 1.2.5 or higher\n");
973 return 1;
974#endif
975}
976EOF
977 [ -n "$INCPNG" ] && I_INCPNG=`prefix_I "$INCPNG"`
978 if test_compile "$LIBPNG $I_INCPNG" libpng libpng; then
979 if test_execute; then
980 cnf_append "SDK_VBOX_LIBPNG_LIBS" "`strip_l "$LIBPNG"`"
981 cnf_append "SDK_VBOX_LIBPNG_INCS" "$INCPNG"
982 fi
983 fi
984}
985
986#
987# Check for libvncserver, needed for VNC in OSE
988#
989check_vncserver()
990{
991 test_header libvncserver
992 cat > $ODIR.tmp_src.cc <<EOF
993#include <cstdio>
994#include <rfb/rfbconfig.h>
995
996extern "C" int main()
997{
998 const char* v=LIBVNCSERVER_VERSION;
999 unsigned int major = 0, minor = 0, micro = 0;
1000
1001 for (; *v !='.' && *v != '\0'; v++) major = major*10 + *v-'0';
1002 if (*v == '.') v++;
1003 for (; *v !='.' && *v != '\0'; v++) minor = minor*10 + *v-'0';
1004 if (*v == '.') v++;
1005 for (; *v !='.' && *v != '\0'; v++) micro = micro*10 + *v-'0';
1006
1007 printf("found version %s", LIBVNCSERVER_PACKAGE_VERSION);
1008 if (major*10000 + minor*100 + micro >= 900)
1009 {
1010 printf(", OK.\n");
1011 return 0;
1012 }
1013 else
1014 {
1015 printf(", expected version 0.9 or higher\n");
1016 return 1;
1017 }
1018}
1019EOF
1020 if test_compile "$LIBVNCSERVER $INCVNCSERVER" libvncserver libvncserver; then
1021 if test_execute; then
1022 cnf_append "VBOX_WITH_EXTPACK_VNC" "1"
1023 fi
1024 fi
1025}
1026
1027#
1028# Check for libcurl, needed by S3
1029#
1030check_curl()
1031{
1032 if [ -z "$BUILD_LIBCURL" ]; then
1033 test_header libcurl
1034 cat > $ODIR.tmp_src.cc << EOF
1035#include <cstdio>
1036#include <curl/curl.h>
1037extern "C" int main(void)
1038{
1039 printf("found version %s", LIBCURL_VERSION);
1040#if 10000*LIBCURL_VERSION_MAJOR + 100*LIBCURL_VERSION_MINOR + LIBCURL_VERSION_PATCH >= 71901
1041 printf(", OK.\n");
1042 return 0;
1043#else
1044 printf(", expected version 7.19.1 or higher\n");
1045 return 1;
1046#endif
1047}
1048EOF
1049 [ -n "$INCCURL" ] && I_INCCURL=`prefix_I "$INCCURL"`
1050 if test_compile "$LIBCURL $I_INCCURL" libcurl libcurl; then
1051 if test_execute; then
1052 cnf_append "SDK_VBOX_LIBCURL_LIBS" "`strip_l "$LIBCURL"`"
1053 cnf_append "SDK_VBOX_LIBCURL_INCS" "$INCCURL"
1054 fi
1055 fi
1056 fi
1057}
1058
1059
1060#
1061# Check for pam, needed by VRDPAuth
1062# Version 79 was introduced in 9/2005, do we support older versions?
1063# Debian/sarge uses 76
1064# OpenSUSE comes with 0.99.xxx where they changed the versioning scheme.
1065#
1066check_pam()
1067{
1068 test_header pam
1069 cat > $ODIR.tmp_src.cc << EOF
1070#include <cstdio>
1071#include <security/pam_appl.h>
1072extern "C" int main(void)
1073{
1074 printf("found version %d", __LIBPAM_VERSION);
1075 if (__LIBPAM_VERSION >= 76)
1076 {
1077 printf(", OK.\n");
1078 return 0;
1079 }
1080 else
1081 {
1082 printf(", expected version 76 or higher\n");
1083 return 1;
1084 }
1085}
1086EOF
1087 if test_compile "-lpam" pam pam nofatal; then
1088 if test_execute nofatal; then
1089 return 0;
1090 fi
1091 fi
1092 echo "pam0.x not found"
1093 test_header linux_pam
1094 cat > $ODIR.tmp_src.cc << EOF
1095#include <cstdio>
1096#include <security/pam_appl.h>
1097extern "C" int main(void)
1098{
1099 printf("found version %d.%d", __LINUX_PAM__, __LINUX_PAM_MINOR__);
1100 if (__LINUX_PAM__ >= 1)
1101 {
1102 printf(", OK.\n");
1103 return 0;
1104 }
1105 else
1106 {
1107 printf(", expected version 1.0 or higher\n");
1108 return 1;
1109 }
1110}
1111EOF
1112 if test_compile "-lpam" pam pam; then
1113 test_execute
1114 fi
1115}
1116
1117
1118#
1119# Check for the SDL library, needed by VBoxSDL and VirtualBox
1120# We depend at least on version 1.2.7
1121#
1122check_sdl()
1123{
1124 test_header SDL
1125 if [ "$OS" = "darwin" ]; then
1126 if [ -f "/System/Library/Frameworks/SDL.framework/SDL" ]; then
1127 PATH_SDK_LIBSDL="/System/Library/Frameworks/SDL.framework"
1128 elif [ -f "/Library/Frameworks/SDL.framework/SDL" ]; then
1129 PATH_SDK_LIBSDL="/Library/Frameworks/SDL.framework"
1130 fi
1131 if [ -n "$PATH_SDK_LIBSDL" ]; then
1132 foundsdl=1
1133 INCSDL="$PATH_SDK_LIBSDL/Headers"
1134 FLDSDL="-framework SDL"
1135 else
1136 log_failure "SDL framework not found"
1137 fail
1138 fi
1139 else
1140 if which_wrapper sdl-config > /dev/null; then
1141 FLGSDL=`sdl-config --cflags`
1142 INCSDL=`strip_I "$FLGSDL"`
1143 LIBSDL=`sdl-config --libs`
1144 LIBSDLMAIN="-lSDLmain"
1145 FLDSDL=
1146 foundsdl=1
1147 fi
1148 fi
1149 [ "$OS" = "linux" -o "$OS" = "darwin" -o "$OS" = "solaris" ] && LIBSDLMAIN=""
1150 if [ -n "$foundsdl" ]; then
1151 cat > $ODIR.tmp_src.cc << EOF
1152#include <cstdio>
1153#include <SDL.h>
1154#include <SDL_main.h>
1155#undef main
1156extern "C" int main(int argc, char** argv)
1157{
1158 printf("found version %d.%d.%d",
1159 SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
1160#if SDL_VERSION_ATLEAST(1,2,7)
1161 printf(", OK.\n");
1162 return 0;
1163#else
1164 printf(", expected version 1.2.7 or higher\n");
1165 return 1;
1166#endif
1167}
1168EOF
1169 [ -n "$INCSDL" ] && I_INCSDL=`prefix_I "$INCSDL"`
1170 if test_compile "$LIBSDL $LIBSDLMAIN $I_INCSDL $FLDSDL" SDL SDL; then
1171 if test_execute; then
1172 cnf_append "LIB_SDK_LIBSDL_SDL" "`strip_l "$LIBSDL"`"
1173 cnf_append "SDK_LIBSDL_LIBPATH" "`strip_L "$LIBSDL"`"
1174 cnf_append "LIB_SDK_LIBSDL_SDLMAIN" "`strip_l "$LIBSDLMAIN"`"
1175 [ -n "$INCSDL" ] && cnf_append "SDK_LIBSDL_INCS" "$INCSDL"
1176 [ -n "$FLDSDL" ] && cnf_append "SDK_LIBSDL_LDFLAGS" "$FLDSDL"
1177 fi
1178 fi
1179 else
1180 log_failure "SDL not found (can be disabled using --disable-sdl)"
1181 fail
1182 fi
1183}
1184
1185
1186#
1187# Check for the SDL_ttf library, needed by VBoxSDL (secure label)
1188#
1189check_sdl_ttf()
1190{
1191 test_header SDL_ttf
1192 cat > $ODIR.tmp_src.cc << EOF
1193#include <cstdio>
1194#include <SDL_ttf.h>
1195#ifndef SDL_TTF_MAJOR_VERSION
1196#define SDL_TTF_MAJOR_VERSION TTF_MAJOR_VERSION
1197#define SDL_TTF_MINOR_VERSION TTF_MINOR_VERSION
1198#define SDL_TTF_PATCHLEVEL TTF_PATCHLEVEL
1199#endif
1200extern "C" int main(void)
1201{
1202 printf("found version %d.%d.%d",
1203 SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL);
1204#if 10000*SDL_TTF_MAJOR_VERSION + 100*SDL_TTF_MINOR_VERSION + SDL_TTF_PATCHLEVEL >= 20006
1205 printf(", OK.\n");
1206 return 0;
1207#else
1208 printf(", expected version 2.0.6 or higher\n");
1209 return 1;
1210#endif
1211}
1212EOF
1213 if test_compile "-lSDL_ttf $I_INCSDL" SDL_ttf SDL_ttf nofatal; then
1214 test_execute nofatal || \
1215 cnf_append "VBOX_WITH_SECURELABEL" ""
1216 else
1217 echo "not found -- disabling VBoxSDL secure label."
1218 cnf_append "VBOX_WITH_SECURELABEL" ""
1219 fi
1220}
1221
1222
1223#
1224# Check for libasound, needed by the ALSA audio backend
1225#
1226check_alsa()
1227{
1228 test_header ALSA
1229 cat > $ODIR.tmp_src.cc << EOF
1230#include <cstdio>
1231#include <alsa/asoundlib.h>
1232extern "C" int main(void)
1233{
1234 printf("found version %d.%d.%d",
1235 SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR);
1236#if 10000*SND_LIB_MAJOR + 100*SND_LIB_MINOR + SND_LIB_SUBMINOR >= 10014
1237 printf(", OK.\n");
1238 return 0;
1239#else
1240 printf(", expected version 1.0.14 or higher\n");
1241 return 1;
1242#endif
1243}
1244EOF
1245 if test_compile "-lasound" asound asound; then
1246 test_execute
1247 fi
1248}
1249
1250
1251#
1252# Check for PulseAudio
1253#
1254check_pulse()
1255{
1256 test_header "PulseAudio"
1257 cat > $ODIR.tmp_src.cc << EOF
1258#include <cstdio>
1259#include <pulse/version.h>
1260extern "C" int main(void)
1261{
1262 printf("found version %s API version %d", pa_get_headers_version(), PA_API_VERSION);
1263#if PA_API_VERSION >= 9
1264 printf(", OK.\n");
1265 return 0;
1266#else
1267 printf(", expected version 0.9.0 (API version 9) or higher\n");
1268 return 1;
1269#endif
1270}
1271EOF
1272 if test_compile "$INCPULSE $LIBPULSE -lpulse" pulse pulse; then
1273 test_execute
1274 fi
1275}
1276
1277
1278#
1279# Check for the X libraries (Xext, X11)
1280#
1281check_x()
1282{
1283 test_header "X libraries"
1284 cat > $ODIR.tmp_src.cc << EOF
1285#include <cstdio>
1286#include <X11/Xlib.h>
1287extern "C" int main(void)
1288{
1289 Display *dpy;
1290 int scrn_num;
1291 Screen *scrn;
1292 Window win;
1293
1294 dpy = XOpenDisplay(NULL);
1295 scrn_num = DefaultScreen(dpy);
1296 scrn = ScreenOfDisplay(dpy, scrn_num);
1297 win = XCreateWindow(dpy, RootWindowOfScreen(scrn), 0, 0, 100, 100,
1298 0, 16, InputOutput, CopyFromParent, 0, NULL);
1299 XDestroyWindow(dpy, win);
1300 XCloseDisplay(dpy);
1301}
1302EOF
1303 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1304 if test_compile "$LIBX11 $I_INCX11" Xlibs Xlibs; then
1305 log_success "found"
1306 fi
1307}
1308
1309
1310#
1311# Check for the Xcursor library, needed by VBoxSDL.
1312#
1313check_xcursor()
1314{
1315 test_header Xcursor
1316 cat > $ODIR.tmp_src.cc << EOF
1317#include <cstdio>
1318#include <X11/Xlib.h>
1319#include <X11/Xcursor/Xcursor.h>
1320extern "C" int main(void)
1321{
1322 XcursorImage *cursor = XcursorImageCreate (10, 10);
1323 XcursorImageDestroy(cursor);
1324 return 0;
1325}
1326EOF
1327 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1328 if test_compile "$LIBX11 $LIBXCURSOR $I_INCX11" Xcursor Xcursor; then
1329 log_success "found"
1330 cnf_append "VBOX_XCURSOR_LIBS" "`strip_l "$LIBXCURSOR"`"
1331 fi
1332}
1333
1334
1335#
1336# Check for the Xinerama library, needed by the Qt GUI
1337#
1338check_xinerama()
1339{
1340 test_header Xinerama
1341 cat > $ODIR.tmp_src.cc << EOF
1342#include <X11/Xlib.h>
1343#include <X11/extensions/Xinerama.h>
1344extern "C" int main(void)
1345{
1346 Display *dpy;
1347 Bool flag;
1348 dpy = XOpenDisplay(NULL);
1349 if (dpy)
1350 {
1351 flag = XineramaIsActive(dpy);
1352 XCloseDisplay(dpy);
1353 }
1354}
1355EOF
1356 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1357 if test_compile "$LIBX11 $LIBXINERAMA $I_INCX11" Xinerama Xinerama; then
1358 log_success "found"
1359 fi
1360}
1361
1362
1363#
1364# Check for the Xinerama library, needed by the Qt GUI
1365#
1366check_xrandr()
1367{
1368 test_header Xrandr
1369 cat > $ODIR.tmp_src.cc << EOF
1370#include <X11/Xlib.h>
1371#include <X11/extensions/Xrandr.h>
1372extern "C" int main(void)
1373{
1374 Display *dpy;
1375 Bool flag;
1376 int major, minor;
1377 dpy = XOpenDisplay(NULL);
1378 if (dpy)
1379 {
1380 flag = XRRQueryVersion(dpy, &major, &minor);
1381 XCloseDisplay(dpy);
1382 }
1383}
1384EOF
1385 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1386 if test_compile "$LIBX11 $LIBXRANDR $I_INCX11" Xrandr Xrandr; then
1387 log_success "found"
1388 fi
1389}
1390
1391
1392#
1393# Check for OpenGL
1394#
1395check_opengl()
1396{
1397 # On darwin this is a on/off decision only
1398 if [ "$OS" = "darwin" ]; then
1399 test_header "OpenGL support"
1400 echo "enabled"
1401 cnf_append "VBOX_WITH_CROGL" "1"
1402 else
1403 check_xmu
1404 check_mesa
1405 fi
1406}
1407
1408
1409#
1410# Check for the Xmu library, needed by OpenGL
1411#
1412check_xmu()
1413{
1414 test_header Xmu
1415 cat > $ODIR.tmp_src.cc << EOF
1416#include <cstdio>
1417#include <X11/Xatom.h>
1418#include <X11/Xlib.h>
1419#include <X11/Xutil.h>
1420#include <X11/Xmu/StdCmap.h>
1421extern "C" int main(void)
1422{
1423 Display *dpy;
1424 int scrn_num;
1425 Screen *scrn;
1426
1427 dpy = XOpenDisplay(NULL);
1428 if (dpy)
1429 {
1430 scrn_num = DefaultScreen(dpy);
1431 scrn = ScreenOfDisplay(dpy, scrn_num);
1432 Status status = XmuLookupStandardColormap(dpy, RootWindowOfScreen(scrn), 0,
1433 24, XA_RGB_DEFAULT_MAP, False, True);
1434 printf("Status = %x\n", status);
1435 XCloseDisplay(dpy);
1436 }
1437 return 0;
1438}
1439EOF
1440 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1441 if test_compile "$LIBX11 $LIBXMU $I_INCX11" Xmu Xmu; then
1442 log_success "found"
1443 cnf_append "VBOX_XMU_LIBS" "`strip_l "$LIBXMU"`"
1444 fi
1445}
1446
1447#
1448# Check for Mesa, needed by OpenGL
1449#
1450check_mesa()
1451{
1452 test_header "Mesa / GLU"
1453 cat > $ODIR.tmp_src.cc << EOF
1454#include <cstdio>
1455#include <X11/Xlib.h>
1456#include <GL/glx.h>
1457#include <GL/glu.h>
1458extern "C" int main(void)
1459{
1460 Display *dpy;
1461 int major, minor;
1462
1463 dpy = XOpenDisplay(NULL);
1464 if (dpy)
1465 {
1466 Bool glx_version = glXQueryVersion(dpy, &major, &minor);
1467 XCloseDisplay(dpy);
1468 if (glx_version)
1469 {
1470 printf("found version %u.%u, OK.\n", major, minor);
1471 return 0;
1472 }
1473 }
1474 printf("found (inactive), OK.\n");
1475 return 0;
1476}
1477EOF
1478 [ -n "$INCX11" ] && I_INCX11=`prefix_I "$INCX11"`
1479 if test_compile "$LIBX11 $MESA $I_INCX11" Mesa Mesa; then
1480 [ $PASSIVE_MESA -eq 1 ] && unset DISPLAY
1481 test_execute
1482 fi
1483}
1484
1485
1486#
1487# Check for the Qt5 library, needed by the VirtualBox frontend
1488#
1489# Currently not fatal.
1490#
1491check_qt5()
1492{
1493 foundqt5=
1494 test_header Qt5
1495 cat > $ODIR.tmp_src.cc << EOF
1496#include <QtGlobal>
1497extern "C" int main(void)
1498{
1499EOF
1500 echo "#if QT_VERSION >= $(($QT5MAJ*65536+$QT5MIN*256))" >> $ODIR.tmp_src.cc
1501 cat >> $ODIR.tmp_src.cc << EOF
1502 return 0;
1503#else
1504 return 1;
1505#endif
1506}
1507EOF
1508 if [ "$OS" = "darwin" ]; then
1509 # First check if there is the internal version of Qt. If yes nothing else
1510 # has to be done.
1511 QT_INTERNAL=`/bin/ls -rd1 $PWD/tools/$BUILD_TARGET.$BUILD_PLATFORM_ARCH/qt/* 2> /dev/null`
1512 for t in $QT_INTERNAL; do
1513 if [ -f "$t/Frameworks/QtCoreVBox.framework/QtCoreVBox" ]; then
1514 cnf_append "VBOX_WITH_ORACLE_QT" "1"
1515 log_success "use internal version"
1516 return
1517 fi
1518 done
1519 # Now try the user provided directory and some of the standard directories.
1520 QT_TRIES="$QT5DIR /System/Library /Library"
1521 for t in $QT_TRIES; do
1522 if [ -f "$t/Frameworks/QtCore.framework/QtCore" ]; then
1523 PATH_SDK_QT5="$t"
1524 break
1525 fi
1526 done
1527 # Add the necessary params for building the test application
1528 if [ -n "$PATH_SDK_QT5" ]; then
1529 foundqt5=1
1530 INCQT5=-I$PATH_SDK_QT5/Frameworks/QtCore.framework/Headers
1531 LIBQT5=-F$PATH_SDK_QT5/Frameworks
1532 FLGQT5="-framework QtCore"
1533 else
1534 log_failure "Qt5 framework not found (can be disabled using --disable-qt)"
1535 fail
1536 fi
1537 else # !darwin
1538 if [ $QT5DIR_PKGCONFIG -eq 1 ]; then
1539 # Default is to use pkg-config:
1540 if which_wrapper pkg-config > /dev/null; then
1541 qt5_ver=`pkg-config Qt5Core --modversion 2>> $LOG`
1542 if [ $? -eq 0 ]; then
1543 echo "(Qt5 from pkg-config)" >> $LOG
1544 FLGQT5=`pkg-config Qt5Core --cflags`
1545 # gcc 4.8 is able to compile with C++11 (see also VBOX_GCC_std in Config.kmk)
1546 [ $cc_maj -eq 4 -a $cc_min -eq 8 ] && FLGQT5="$FLGQT5 -std=c++11"
1547 INCQT5=`strip_I "$FLGQT5"`
1548 LIBDIR5=`pkg-config Qt5Core --variable=libdir`
1549 LIBQT5=`pkg-config Qt5Core --libs`
1550 LIBQT5="-L$LIBDIR5 $LIBQT5"
1551 TOOLQT5=`pkg-config Qt5Core --variable=prefix`
1552 TOOLQT5BIN=`pkg-config Qt5Core --variable=host_bins`
1553 if test_compile "$LIBQT5 $LIBPTHREAD $FLGQT5" qt5 qt5 nofatal; then
1554 test_execute_path "`strip_L "$LIBQT5"`" nofatal && foundqt5=3 # pkg-config
1555 fi
1556 fi
1557 else
1558 log_failure "pkg-config not found"
1559 fail
1560 fi
1561 fi
1562 if [ -z "$foundqt5" ]; then
1563 # Do it the old way (e.g. user has specified QT5DIR):
1564 for q in $QT5DIR "$PWD/tools/linux.$TARGET_MACHINE"/qt/v5.*; do
1565 echo "(Qt5 from '$q')" >> $LOG
1566 INCQT5="$q/include $q/include/QtCore"
1567 FLGQT5="-DQT_SHARED"
1568 I_INCQT5=`prefix_I "$INCQT5"`
1569 LIBQT5="-L$q/lib -lQt5CoreVBox"
1570 TOOLQT5="$q"
1571 if test_compile "$LIBQT5 $LIBPTHREAD $I_INCQT5 $FLGQT5" qt5 qt5 nofatal &&
1572 test_execute_path "`strip_L "$LIBQT5"`" nofatal; then
1573 foundqt5=2 # internal
1574 break;
1575 fi
1576 LIBQT5="-L$q/lib -lQt5Core"
1577 if test_compile "$LIBQT5 $LIBPTHREAD $I_INCQT5 $FLGQT5" qt5 qt5 nofatal &&
1578 test_execute_path "`strip_L "$LIBQT5"`" nofatal; then
1579 foundqt5=1 # no pkg-config, Qt directory
1580 break;
1581 fi
1582 done
1583 fi
1584 fi
1585 if [ -n "$foundqt5" ]; then
1586 # We decided which version of Qt to use, now enforce the version requirement:
1587 cat > $ODIR.tmp_src.cc << EOF
1588#include <cstdio>
1589#include <QtGlobal>
1590extern "C" int main(void)
1591{
1592 printf("found version %s", QT_VERSION_STR);
1593EOF
1594 echo "#if QT_VERSION >= $(($QT5MAJ*65536+$QT5MIN*256))" >> $ODIR.tmp_src.cc
1595 cat >> $ODIR.tmp_src.cc << EOF
1596 printf(", OK.\n");
1597 return 0;
1598#else
1599EOF
1600echo " printf(\", expected version $QT5MAJ.$QT5MIN or higher\\\\n\");" >> $ODIR.tmp_src.cc
1601 cat >> $ODIR.tmp_src.cc << EOF
1602 return 1;
1603#endif
1604}
1605EOF
1606 [ -n "$INCQT5" ] && I_INCQT5=`prefix_I "$INCQT5"`
1607 if test_compile "$LIBQT5 $LIBPTHREAD $I_INCQT5 $FLGQT5" qt5 qt5 nofatal; then
1608 if test_execute_path "`strip_L "$LIBQT5"`"; then
1609 if [ "$OS" = "darwin" ]; then
1610 # Successful build & run the test application so add the necessary
1611 # params to AutoConfig.kmk:
1612 cnf_append "PATH_SDK_QT5_INC" "$PATH_SDK_QT5/Frameworks"
1613 cnf_append "PATH_SDK_QT5_LIB" "$PATH_SDK_QT5/Frameworks"
1614 cnf_append "PATH_SDK_QT5" "$PATH_SDK_QT5/Frameworks"
1615 # Check for the moc tool in the Qt directory found & some standard
1616 # directories.
1617 for q in $PATH_SDK_QT5 /usr /Developer/Tools/Qt; do
1618 if which_wrapper "$q/bin/moc" > /dev/null; then
1619 cnf_append "PATH_TOOL_QT5_BIN" "$q/bin"
1620 fi
1621 done
1622 else
1623 # Strip .../QtCore as we add components ourself:
1624 INCQT5=`echo "$INCQT5"|$KBUILD_SED 's|\([^ ]*\)/QtCore|\1|g; s| $||g'`
1625 # store only the first path, remove all other paths
1626 # most likely pkg-config gave us -I/usr/include/qt5 -I/usr/include/qt5/QtCore
1627 INCQT5=`echo "$INCQT5"|$KBUILD_SED 's|\([^ ]*\) .*|\1|'`
1628 cnf_append "VBOX_PATH_QT_LIB" "`strip_L "$LIBQT5"`"
1629 cnf_append "PATH_SDK_QT5_INC" "$INCQT5"
1630 # This is not quite right since the qt libpath does not have to be first...
1631 cnf_append "PATH_SDK_QT5_LIB" '$'"(firstword `strip_L "$LIBQT5"`)"
1632 if [ "$foundqt5" = "2" ]; then
1633 cnf_append "VBOX_WITH_ORACLE_QT" "1"
1634 fi
1635 if [ "$foundqt5" != "3" ]; then
1636 TOOLQT5BIN="$TOOLQT5/bin"
1637 fi
1638 test_header "Qt5 devtools"
1639 # Try it with a suffix, some platforms use that
1640 if which_wrapper "$TOOLQT5BIN/moc-qt5" > /dev/null; then
1641 QT5BINSUFF="-qt5"
1642 else
1643 QT5BINSUFF=""
1644 fi
1645 moc_ver=`$TOOLQT5BIN/moc$QT5BINSUFF -v 2>&1|sed 's+^.*(Qt \(.*\))+\1+'`
1646 if [ $? -ne 0 ]; then
1647 log_failure "moc$QT5BINSUFF not working"
1648 fail
1649 else
1650 log_success "found version $moc_ver"
1651 cnf_append "VBOX_PATH_QT" "$TOOLQT5"
1652 cnf_append "PATH_SDK_QT5" "$TOOLQT5"
1653 cnf_append "PATH_TOOL_QT5_BIN" "$TOOLQT5BIN"
1654 [ -n "$QT5BINSUFF" ] && cnf_append "TOOL_QT5_BIN_SUFF" "$QT5BINSUFF"
1655 fi
1656 fi
1657 fi
1658 else
1659 log_failure "qt5 not working"
1660 fail
1661 fi
1662 else
1663 log_failure "qt5 not found"
1664 fail
1665 fi
1666}
1667
1668
1669#
1670# Check for libvpx
1671#
1672check_vpx()
1673{
1674 if [ -z "$BUILD_LIBVPX" ]; then
1675 test_header libvpx
1676 if which_wrapper pkg-config > /dev/null; then
1677 libvpx_ver=`pkg-config vpx --modversion 2>> $LOG`
1678 if [ $? -eq 0 ]; then
1679 FLGVPX=`pkg-config vpx --cflags`
1680 INCVPX=`strip_I "$FLGVPX"`
1681 LIBVPX=`pkg-config vpx --libs`
1682 fi
1683 cat > $ODIR.tmp_src.cc << EOF
1684#include <cstdio>
1685#include <vpx/vpx_codec.h>
1686extern "C" int main(void)
1687{
1688 int version = vpx_codec_version();
1689 int verMajor = VPX_VERSION_MAJOR(version);
1690 int verMinor = VPX_VERSION_MINOR(version);
1691 int verPatch = VPX_VERSION_PATCH(version);
1692 printf("found version %d.%d.%d", verMajor, verMinor, verPatch);
1693 if ( verMajor == 1 && verMinor >= 0
1694 || verMajor == 0 && verMinor == 9 && verPatch >= 5)
1695 {
1696 printf(", OK.\n");
1697 return 0;
1698 }
1699 else
1700 {
1701 printf(", expected version 0.9.5 or higher\n");
1702 return 1;
1703 }
1704}
1705EOF
1706 [ -n "$INCVPX" ] && I_INCVPX=`prefix_I "$INCVPX"`
1707 if test_compile "$LIBVPX $I_INCVPX" vpx vpx; then
1708 if test_execute; then
1709 cnf_append "SDK_VBOX_VPX_INCS" "$INCVPX"
1710 cnf_append "SDK_VBOX_VPX_LIBS" "`strip_l "$LIBVPX"`"
1711 fi
1712 fi
1713 fi
1714 fi
1715}
1716
1717
1718#
1719# Check whether static libstdc++ is installed. This library is required
1720# for the Linux guest additions.
1721#
1722check_staticlibstdcxx()
1723{
1724 test_header "static stc++ library"
1725 libstdcxx=`$CXX -print-file-name=libstdc++.a`
1726 cat > $ODIR.tmp_src.cc << EOF
1727#include <string>
1728
1729extern "C" int main(void)
1730{
1731 std::string s = "test";
1732 return 0;
1733}
1734EOF
1735 if test_compile "$libstdcxx" libstdc++ libstdc++; then
1736 log_success "found"
1737 fi
1738}
1739
1740
1741#
1742# Check for Linux sources
1743#
1744check_linux()
1745{
1746 test_header "Linux kernel sources"
1747 cat > $ODIR.tmp_src.c << EOF
1748#include <linux/version.h>
1749int printf(const char *format, ...);
1750int main(void)
1751{
1752 printf("found version %d.%d.%d", LINUX_VERSION_CODE / 65536,
1753 (LINUX_VERSION_CODE % 65536) / 256,
1754 LINUX_VERSION_CODE % 256);
1755#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0)
1756 printf(", OK.\n");
1757 return 0;
1758#else
1759 printf(", expected version 2.4.0 or higher\n");
1760 return 1;
1761#endif
1762}
1763EOF
1764 echo "compiling the following source file:" >> $LOG
1765 cat $ODIR.tmp_src.c >> $LOG
1766 echo "using the following command line:" >> $LOG
1767 echo "$CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include " \
1768 "-I$LINUX/include/generated/uapi" >> $LOG
1769 $CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include \
1770 -I$LINUX/include/generated/uapi >> $LOG 2>&1
1771 if [ $? -ne 0 ]; then
1772 echo
1773 echo " Linux kernel headers not found at $LINUX"
1774 echo " Check the file $LOG for detailed error information."
1775 fail
1776 else
1777 if test_execute; then
1778 cat > $ODIR.tmp_src.c << EOF
1779#include <linux/version.h>
1780int printf(const char *format, ...);
1781int main(void)
1782{
1783 return LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0) ? 1 : 0;
1784}
1785EOF
1786 echo "compiling the following source file:" >> $LOG
1787 cat $ODIR.tmp_src.c >> $LOG
1788 echo "using the following command line:" >> $LOG
1789 echo "$CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include " \
1790 "-I$LINUX/include/generated/uapi" >> $LOG
1791 $CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include \
1792 -I$LINUX/include/generated/uapi >> $LOG 2>&1
1793 if [ $? -eq 0 ]; then
1794 $ODIR.tmp_out
1795 if [ $? -ne 0 ]; then
1796 cnf_append "VBOX_WITH_VBOXDRV" ""
1797 cnf_append "VBOX_WITH_ADDITION_DRIVERS" ""
1798 echo "Detected Linux >= 4.8 -- disabling compiling of Linux kernel modules."
1799 else
1800 cnf_append "VBOX_LINUX_SRC" "`cd $LINUX ; pwd`"
1801 fi
1802 fi
1803 fi
1804 fi
1805}
1806
1807#
1808# Check for kchmviewer, needed to display the online help
1809# (unused as we ship kchmviewer)
1810#
1811check_kchmviewer()
1812{
1813 test_header kchmviewer
1814 if check_avail "$KCHMVIEWER" KCHMVIEWER; then
1815 kchmviewer_ver=`$KCHMVIEWER --version|grep "^KchmViewer:"|sed 's+^KchmViewer: \(.*\)+\1+'`
1816 if [ $? -ne 0 ]; then
1817 log_failure "kchmviewer not working"
1818 fail
1819 else
1820 log_success "found version $kchmviewer_ver"
1821 fi
1822 fi
1823}
1824
1825
1826#
1827# Check for the kBuild tools, we don't support GNU make
1828#
1829check_kbuild()
1830{
1831 test_header kBuild
1832 if which_wrapper "$KBUILDDIR/bin/$OS.$BUILD_MACHINE/kmk" > /dev/null; then
1833 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.$BUILD_MACHINE"
1834 echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1835 echo "export PATH_KBUILD" >> $ENV
1836 echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1837 echo "export PATH_DEVTOOLS" >> $ENV
1838 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"" >> $ENV
1839 echo "export PATH_KBUILD_BIN" >> $ENV
1840 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1841 if [ "$OS" = "solaris" ]; then
1842 # Because of sh being non-default shell in Solaris we need to export PATH again when
1843 # sourcing env.sh. Simply exporting from ./configure does not export PATH correctly.
1844 echo "PATH=\"$ORGPATH\"" >> $ENV
1845 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1846 echo "echo \"\$PATH\" | /usr/sfw/bin/ggrep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1847 else
1848 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1849 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1850 fi
1851 echo "export PATH" >> $ENV
1852 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1853 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1854 elif [ "$OS.$BUILD_MACHINE" = "darwin.amd64" ]; then
1855 # Currently there are no amd64 kBuild bins. So use the x86 variant in any case.
1856 KBUILDDIR_BIN="$KBUILDDIR/bin/$OS.x86"
1857 echo "PATH_KBUILD=\"`cd $KBUILDDIR ; pwd`\"" >> $ENV
1858 echo "export PATH_KBUILD" >> $ENV
1859 echo "PATH_DEVTOOLS=\"$DEVDIR\"" >> $ENV
1860 echo "export PATH_DEVTOOLS" >> $ENV
1861 echo "path_kbuild_bin=\"\$PATH_KBUILD/bin/\$BUILD_TARGET.x86\"" >> $ENV
1862 echo "PATH_KBUILD_BIN=\"\$path_kbuild_bin\"" >> $ENV
1863 echo "export PATH_KBUILD_BIN" >> $ENV
1864 echo "path_dev_bin=\"\$PATH_DEVTOOLS/\$BUILD_TARGET.\$BUILD_PLATFORM_ARCH\"/bin" >> $ENV
1865 echo "echo \"\$PATH\" | grep -q \"\$path_kbuild_bin\" || PATH=\"\$path_kbuild_bin:\$PATH\"" >> $ENV
1866 echo "echo \"\$PATH\" | grep -q \"\$path_dev_bin\" || PATH=\"\$path_dev_bin:\$PATH\"" >> $ENV
1867 echo "export PATH" >> $ENV
1868 echo "unset path_kbuild_bin path_dev_bin" >> $ENV
1869 KBUILD_SED="$KBUILDDIR_BIN/kmk_sed"
1870 elif check_avail "kmk" KBUILDDIR really; then
1871 # check for installed kBuild
1872 KBUILD_SED="`which_wrapper kmk_sed`"
1873 else
1874 fail
1875 fi
1876 log_success "found"
1877}
1878
1879
1880#
1881# Check for compiler.h
1882# Some Linux distributions include "compiler.h" in their libc linux
1883# headers package, some don't. Most don't need it, building might (!)
1884# not succeed on openSUSE without it.
1885#
1886# See http://www.mail-archive.com/qemu-devel%40nongnu.org/msg07980.html
1887#
1888check_compiler_h()
1889{
1890 test_header compiler.h
1891 if test ! -f "/usr/include/linux/compiler.h"; then
1892 log_success "compiler.h not found"
1893 else
1894 cnf_append "VBOX_WITH_LINUX_COMPILER_H" "1"
1895 log_success "compiler.h found"
1896 fi
1897}
1898
1899#
1900# Check for libcap.
1901# Required to pass CAP_NET_RAW to our binaries to allow to open SOCK_RAW
1902# sockets for doing ICMP requests.
1903#
1904check_libcap()
1905{
1906 test_header "libcap library"
1907 cat > $ODIR.tmp_src.cc << EOF
1908#include <cstdio>
1909#include <sys/types.h>
1910#include <linux/types.h>
1911#include <sys/capability.h>
1912
1913extern "C" int main(void)
1914{
1915 char buf[1024];
1916 cap_t caps = cap_get_proc();
1917 snprintf(buf, sizeof(buf), "Current caps are '%s'\n", cap_to_text(caps, NULL));
1918 return 0;
1919}
1920EOF
1921 if test_compile $LIBCAP libcap libcap; then
1922 if test_execute; then
1923 log_success "found"
1924 fi
1925 fi
1926}
1927
1928#
1929# Check if we are able to build 32-bit applications (needed for the guest additions)
1930#
1931check_32bit()
1932{
1933 test_header "32-bit support"
1934 cat > $ODIR.tmp_src.c << EOF
1935#include <stdint.h>
1936int main(void)
1937{
1938 return 0;
1939}
1940EOF
1941 echo "compiling the following source file:" >> $LOG
1942 cat $ODIR.tmp_src.c >> $LOG
1943 echo "using the following command line:" >> $LOG
1944 echo "$CC -m32 -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c" >> $LOG
1945 $CC -m32 -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c >> $LOG 2>&1
1946 if [ $? -ne 0 ]; then
1947 echo
1948 echo " Cannot compile 32-bit applications (missing headers and/or libraries)!"
1949 echo " Check the file $LOG for detailed error information."
1950 fail
1951 else
1952 echo "executing the binary" >> $LOG
1953 $ODIR.tmp_out 2> $ODIR.test_execute.log
1954 rc=$?
1955 cat $ODIR.test_execute.log >> $LOG
1956 if [ $rc -ne 0 ]; then
1957 echo
1958 echo " Cannot execute 32-bit applications! Either enable 32-bit support in the"
1959 echo " kernel configuration or use --disable-vmmraw to disable 32-bit guests."
1960 fail
1961 return 1
1962 fi
1963 fi
1964 log_success ""
1965}
1966
1967
1968#
1969# Check for Python
1970#
1971check_python()
1972{
1973 test_header "Python support"
1974
1975 # On darwin this is a on/off decision only
1976 if [ "$OS" = "darwin" ]; then
1977 echo "enabled"
1978 cnf_append "VBOX_WITH_PYTHON" "1"
1979 return
1980 fi
1981
1982 cat > $ODIR.tmp_src.cc << EOF
1983#include <cstdio>
1984#include <Python.h>
1985extern "C" int main(void)
1986{
1987 Py_Initialize();
1988 printf("found version %s", PY_VERSION);
1989#if PY_VERSION_HEX >= 0x02060000
1990 printf(", OK.\n");
1991 return 0;
1992#else
1993 printf(", expected version 2.6 or higher\n");
1994 return 1;
1995#endif
1996}
1997EOF
1998 found=
1999 SUPPYTHONLIBS="python2.7 python2.6 python3.1 python3.2 python3.3 python3.4 python3.4m python3.5 python3.5m"
2000 for p in $PYTHONDIR; do
2001 for d in $SUPPYTHONLIBS; do
2002 for b in lib/x86_64-linux-gnu lib/i386-linux-gnu lib64 lib/64 lib; do
2003 echo "compiling the following source file:" >> $LOG
2004 cat $ODIR.tmp_src.cc >> $LOG
2005 echo "using the following command line:" >> $LOG
2006 echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so" >> $LOG
2007 $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
2008 if [ $? -eq 0 ]; then
2009 found=1
2010 break
2011 fi
2012 done
2013 if [ -n "$found" ]; then break; fi
2014 done
2015 if [ -n "$found" ]; then break; fi
2016 done
2017 if [ -n "$found" ]; then
2018 if test_execute; then
2019 cnf_append "VBOX_WITH_PYTHON" "1"
2020 cnf_append "VBOX_PATH_PYTHON_INC" "$p/include/$d"
2021 cnf_append "VBOX_LIB_PYTHON" "$p/$b/lib$d.so"
2022 else
2023 log_failure "Python not working"
2024 fail
2025 fi
2026 else
2027 log_failure "Python not found"
2028 fail
2029 fi
2030}
2031
2032
2033#
2034# Check for Java
2035#
2036check_java()
2037{
2038 test_header "Java support"
2039 log_success
2040}
2041
2042
2043#
2044# Setup wine
2045#
2046setup_wine()
2047{
2048 test_header "Wine support"
2049 if ! which_wrapper wine > /dev/null; then
2050 echo " wine binary not found"
2051 fail
2052 fi
2053 if ! which_wrapper wine > /dev/null; then
2054 echo " wine not found"
2055 fail
2056 fi
2057 wine_version="`wine --version`"
2058 case "`expr "$wine_version" : 'wine-\([0-9.]*\)' '>' 1.1.43`" in
2059 "0")
2060 if ! which_wrapper wineprefixcreate > /dev/null; then
2061 echo " wineprefixcreate not found"
2062 fail
2063 fi
2064 ;;
2065 *) eval "wineprefixcreate() { true ; }" ;; # now created automatically
2066 esac
2067 export WINEPREFIX="${ODIR}wine.$BUILD_MACHINE"
2068 echo "WINEPREFIX=\"${ODIR}wine.$BUILD_MACHINE\"" >> $ENV
2069 echo "export WINEPREFIX" >> $ENV
2070 rm -rf $WINEPREFIX
2071 mkdir -p $WINEPREFIX
2072 touch $WINEPREFIX/.no_prelaunch_window_flag
2073 if ! wineprefixcreate -q > /dev/null 2>&1; then
2074 echo " wineprefixcreate failed"
2075 fail
2076 fi
2077 tmp=.tmp.wine.reg
2078 rm -f $tmp
2079 echo 'REGEDIT4' > $tmp
2080 echo '' >> $tmp
2081 echo '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]' >> $tmp
2082 echo "\"PATH\"=\"c:\\\\\\\\windows\\\\\\\\system32;c:\\\\\\\\windows;z:$DEVDIR/win.x86/vcc/v8/bin/Microsoft.VC80.CRT;z:$DEVDIR/win.x86/HTML_Help_Workshop/v1.3\"" >> $tmp
2083 echo '' >> $tmp
2084 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhc.exe\DllOverrides]' >> $tmp
2085 echo '"itss"="native"' >> $tmp
2086 echo '' >> $tmp
2087 echo '[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hhw.exe\DllOverrides]' >> $tmp
2088 echo '"itss"="native"' >> $tmp
2089 echo '' >> $tmp
2090 if ! wine regedit $tmp > /dev/null 2>&1; then
2091 rm -f $tmp
2092 echo " failed to load registry changes (path)."
2093 fail
2094 fi
2095 rm -f $tmp
2096 log_success "found"
2097}
2098
2099
2100#
2101# Check for gSOAP.
2102#
2103check_gsoap()
2104{
2105 test_header "GSOAP compiler"
2106 if [ -z "$GSOAP" -a -z "$GSOAP_IMPORT" ]; then
2107 if which_wrapper pkg-config > /dev/null; then
2108 GSOAP_CXX_LIBS=`pkg-config gsoapssl++ --libs 2>> $LOG`
2109 if [ $? -eq 0 ]; then
2110 GSOAP=`pkg-config gsoapssl++ --variable=exec_prefix`
2111 GSOAP_IMPORT="$GSOAP/share/gsoap/import"
2112 if [ ! -d "$GSOAP_IMPORT" -a -d "$GSOAP/include/gsoap" ]; then
2113 GSOAP_IMPORT="$GSOAP/include/gsoap"
2114 fi
2115 cnf_append "VBOX_GSOAP_INSTALLED" "1"
2116 cnf_append "VBOX_PATH_GSOAP" "$GSOAP"
2117 cnf_append "VBOX_PATH_GSOAP_IMPORT" "$GSOAP_IMPORT"
2118 if [ -f "$GSOAP/share/gsoap/stdsoap2.cpp" ]; then
2119 cnf_append "VBOX_GSOAP_CXX_SOURCES" "$GSOAP/share/gsoap/stdsoap2.cpp"
2120 else
2121 cnf_append "VBOX_GSOAP_CXX_SOURCES" ""
2122 fi
2123 cnf_append "VBOX_GSOAP_CXX_LIBS" "`strip_l "$GSOAP_CXX_LIBS"`"
2124 gsoap_version=`pkg-config gsoapssl++ --modversion`
2125 log_success "found version $gsoap_version"
2126 return
2127 fi
2128 fi
2129 fi
2130 if [ -z "$GSOAP" ]; then
2131 GSOAP="/usr"
2132 fi
2133 if which_wrapper "$GSOAP/bin/soapcpp2" > /dev/null; then
2134 if which_wrapper "$GSOAP/bin/wsdl2h" > /dev/null; then
2135 if [ -f "$GSOAP/include/stdsoap2.h" ]; then
2136 # TODO: Check for libgsoap++.a/so
2137
2138 if [ -z "$GSOAP_IMPORT" ]; then
2139 GSOAP_IMPORT="$GSOAP/share/gsoap/import"
2140 if [ ! -d "$GSOAP_IMPORT" -a -d "$GSOAP/include/gsoap" ]; then
2141 GSOAP_IMPORT="$GSOAP/include/gsoap"
2142 fi
2143 fi
2144 if [ -f "$GSOAP_IMPORT/stlvector.h" ]; then
2145 cnf_append "VBOX_GSOAP_INSTALLED" "1"
2146 cnf_append "VBOX_PATH_GSOAP" "$GSOAP"
2147 cnf_append "VBOX_PATH_GSOAP_IMPORT" "$GSOAP_IMPORT"
2148 if [ -f "$GSOAP/share/gsoap/stdsoap2.cpp" ]; then
2149 cnf_append "VBOX_GSOAP_CXX_SOURCES" "$GSOAP/share/gsoap/stdsoap2.cpp"
2150 else
2151 cnf_append "VBOX_GSOAP_CXX_SOURCES" ""
2152 fi
2153 cnf_append "VBOX_GSOAP_CXX_LIBS" "libgsoapssl++"
2154 log_success "found"
2155 else
2156 log_failure "stlvector.h not found -- disabling webservice"
2157 cnf_append "VBOX_WITH_WEBSERVICES" ""
2158 fi
2159 else
2160 log_failure "stdsoap2.h not found -- disabling webservice"
2161 cnf_append "VBOX_WITH_WEBSERVICES" ""
2162 fi
2163 else
2164 log_failure "wsdl2h not found -- disabling webservice"
2165 cnf_append "VBOX_WITH_WEBSERVICES" ""
2166 fi
2167 else
2168 log_failure "soapcpp2 not found -- disabling webservice"
2169 cnf_append "VBOX_WITH_WEBSERVICES" ""
2170 fi
2171}
2172
2173
2174#
2175# Check Xcode path
2176#
2177check_xcode_sdk_path()
2178{
2179 # Check if WITH_XCODE_DIR is set.
2180 if [ -z "$WITH_XCODE_DIR" ]; then
2181 echo "Please specify --with-xcode-dir option."
2182 return 0
2183 fi
2184
2185 # Check if specified path exists and is a directory.
2186 if [ -d "$1" ]; then
2187 return 1
2188 else
2189 echo "Xcode path [$1] not found."
2190 return 0
2191 fi
2192}
2193
2194#
2195# Determines the Darwin version.
2196# @todo This should really check the Xcode/SDK version.
2197#
2198check_darwinversion()
2199{
2200 test_header "Darwin version"
2201 darwin_ver=`uname -r`
2202 case "$darwin_ver" in
2203 16\.*)
2204 check_xcode_sdk_path "$WITH_XCODE_DIR"
2205 [ $? -eq 1 ] || fail
2206 darwin_ver="10.12" # Sierra
2207 sdk=$WITH_XCODE_DIR/Developer/SDKs/MacOSX10.6.sdk
2208 cnf_append "VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL" "1"
2209 cnf_append "VBOX_PATH_MACOSX_DEVEL_ROOT" "$WITH_XCODE_DIR/Developer"
2210 ;;
2211 15\.*)
2212 check_xcode_sdk_path "$WITH_XCODE_DIR"
2213 [ $? -eq 1 ] || fail
2214 darwin_ver="10.11" # El Capitan
2215 sdk=$WITH_XCODE_DIR/Developer/SDKs/MacOSX10.6.sdk
2216 cnf_append "VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL" "1"
2217 cnf_append "VBOX_PATH_MACOSX_DEVEL_ROOT" "$WITH_XCODE_DIR/Developer"
2218 ;;
2219 14\.*)
2220 check_xcode_sdk_path "$WITH_XCODE_DIR"
2221 [ $? -eq 1 ] || fail
2222 darwin_ver="10.10" # Yosemite
2223 sdk=$WITH_XCODE_DIR/Developer/SDKs/MacOSX10.6.sdk
2224 cnf_append "VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL" "1"
2225 cnf_append "VBOX_PATH_MACOSX_DEVEL_ROOT" "$WITH_XCODE_DIR/Developer"
2226 ;;
2227 13\.*)
2228 check_xcode_sdk_path "$WITH_XCODE_DIR"
2229 [ $? -eq 1 ] || fail
2230 darwin_ver="10.9" # Mavericks
2231 sdk=$WITH_XCODE_DIR/Developer/SDKs/MacOSX10.6.sdk
2232 cnf_append "VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL" "1"
2233 cnf_append "VBOX_PATH_MACOSX_DEVEL_ROOT" "$WITH_XCODE_DIR/Developer"
2234 ;;
2235 12\.*)
2236 darwin_ver="10.8" # Mountain Lion
2237 if [ ! -z "$WITH_XCODE_DIR" ]; then
2238 sdk=$WITH_XCODE_DIR/Developer/SDKs/MacOSX10.6.sdk
2239 cnf_append "VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL" "1"
2240 cnf_append "VBOX_PATH_MACOSX_DEVEL_ROOT" "$WITH_XCODE_DIR/Developer"
2241 else
2242 sdk=/Developer/SDKs/MacOSX10.6.sdk
2243 fi
2244 CXX_FLAGS="-mmacosx-version-min=10.6 -isysroot $sdk -Wl,-syslibroot,$sdk"
2245 ;;
2246 11\.*)
2247 darwin_ver="10.7" # Lion
2248 sdk=/Developer/SDKs/MacOSX10.6.sdk
2249 CXX_FLAGS="-mmacosx-version-min=10.6 -isysroot $sdk -Wl,-syslibroot,$sdk"
2250 ;;
2251 10\.*)
2252 darwin_ver="10.6" # Snow Leopard
2253 if [ "$BUILD_MACHINE" = "x86" ]; then
2254 sdk=/Developer/SDKs/MacOSX10.5.sdk
2255 CXX_FLAGS="-mmacosx-version-min=10.5 -isysroot $sdk -Wl,-syslibroot,$sdk"
2256 cnf_append "VBOX_MACOS_10_5_WORKAROUND" "1"
2257 else
2258 sdk=/Developer/SDKs/MacOSX10.6.sdk
2259 CXX_FLAGS="-mmacosx-version-min=10.6 -isysroot $sdk -Wl,-syslibroot,$sdk"
2260 fi
2261# test "$CC" = "gcc" && CC="gcc-4.0"
2262# test "$CXX" = "g++" && CXX="g++-4.0"
2263 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_7" "1"
2264 ;;
2265 9\.*)
2266 darwin_ver="10.5" # Leopard
2267 sdk=/Developer/SDKs/MacOSX10.5.sdk
2268 CXX_FLAGS="-mmacosx-version-min=10.5 -isysroot $sdk -Wl,-syslibroot,$sdk"
2269# test "$CC" = "gcc" && CC="gcc-4.0"
2270# test "$CXX" = "g++" && CXX="g++-4.0"
2271 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6" "1"
2272 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_7" "1"
2273 ;;
2274 8\.*)
2275 darwin_ver="10.4" # Tiger
2276 sdk=/Developer/SDKs/MacOSX10.4u.sdk
2277 CXX_FLAGS="-mmacosx-version-min=10.4 -isysroot $sdk -Wl,-syslibroot,$sdk"
2278# test "$CC" = "gcc" && CC="gcc-4.0"
2279# test "$CXX" = "g++" && CXX="g++-4.0"
2280 cnf_append "VBOX_WITH_COCOA_QT" ""
2281 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6" "1"
2282 cnf_append "VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_7" "1"
2283 ;;
2284 *)
2285 echo " failed to determine Darwin version. (uname -r: $darwin_ver)"
2286 fail
2287 darwin_ver="unknown"
2288 ;;
2289 esac
2290 log_success "found version $darwin_ver (SDK: $sdk)"
2291}
2292
2293
2294check_makeself()
2295{
2296 test_header "makeself"
2297 if check_avail "$MAKESELF" makeself; then
2298 makeself_ver=`$MAKESELF --version|grep version|sed 's+^Makeself.*version \([0-9\.]*\).*+\1+'`
2299 if [ $? -ne 0 ]; then
2300 log_failure "makeself not working"
2301 fail
2302 else
2303 log_success "found version $makeself_ver"
2304 cnf_append "VBOX_MAKESELF" "`which_wrapper $MAKESELF`"
2305 fi
2306 fi
2307}
2308
2309
2310#
2311# Show help
2312#
2313show_help()
2314{
2315cat << EOF
2316Usage: ./configure [OPTIONS]...
2317
2318Configuration:
2319 -h, --help display this help and exit
2320 --nofatal don't abort on errors
2321EOF
2322[ $WITH_XPCOM -eq 1 ] && echo " --disable-xpcom disable XPCOM and related stuff"
2323[ $WITH_PYTHON -eq 1 ] && echo " --disable-python disable python bindings"
2324[ $WITH_JAVA -eq 1 ] && echo " --disable-java disable java bindings"
2325[ $WITH_VMMRAW -eq 1 ] && echo " --disable-vmmraw disable VMM raw mode (VT-x/AMD-V mandatory!)"
2326[ $WITH_SDL_TTF -eq 1 ] && echo " --disable-sdl-ttf disable SDL_ttf detection"
2327[ $WITH_QT5 -eq 1 ] && echo " --disable-qt disable Qt detection"
2328[ $WITH_ALSA -eq 1 ] && echo " --disable-alsa disable the ALSA sound backend"
2329[ $WITH_PULSE -eq 1 ] && echo " --disable-pulse disable the PulseAudio backend"
2330[ $WITH_DBUS -eq 1 ] && echo " --disable-dbus don't use DBus and hal for hardware detection"
2331[ $WITH_KMODS -eq 1 ] && echo " --disable-kmods don't build Linux kernel modules (host and guest)"
2332[ $WITH_OPENGL -eq 1 ] && echo " --disable-opengl disable OpenGL support (2D & 3D)"
2333[ $WITH_QT5 -eq 0 ] && echo " --enable-qt5 enable Qt5 detection"
2334[ $WITH_GSOAP -eq 0 ] && echo " --enable-webservice enable the webservice stuff"
2335[ $OSE -eq 1 ] && echo " --enable-vnc enable the VNC server"
2336[ $OSE -eq 0 ] && echo " --disable-extpack don't build the extpack"
2337[ $WITH_DOCS -eq 1 ] && echo " --disable-docs don't build the documentation"
2338[ $WITH_LIBVPX -eq 1 ] && echo " --disable-libvpx don't use libvpx for video capturing"
2339[ "$OS" = "linux" -o "$OS" = "freebsd" ] && echo " --enable-vde enable VDE networking"
2340cat << EOF
2341 --disable-udptunnel disable UDP tunnel networking
2342 --disable-devmapper disable device mapper library access
2343 --disable-hardening don't be strict about /dev/vboxdrv access
2344 --build-libxml2 build libxml2 from sources
2345EOF
2346[ $OSE -eq 0 ] && cat << EOF
2347 --build-libssl build openssl from sources
2348 --build-libcurl build libcurl from sources
2349 --build-libvpx build libvpx from sources
2350EOF
2351[ "$OS" != "darwin" ] && echo " --setup-wine setup a Wine directory and register the hhc hack"
2352cat << EOF
2353 --only-additions only build the Guest Additions
2354
2355Paths:
2356 --with-gcc=PATH location of the gcc compiler [$CC]
2357 --with-g++=PATH location of the g++ compiler [$CXX]
2358 --with-kbuild=DIR kbuild directory [$KBUILDDIR]
2359 --with-iasl=PATH location of the iasl compiler [$IASL]
2360 --with-mkisofs=PATH location of mkisofs [$MKISOFS]
2361 --with-makeself=PATH location of makeself [$MAKESELF]
2362EOF
2363[ "$OS" = "darwin" ] && echo " --with-xcode-dir=DIR custom path to Xcode root directory; it is assumed that Xcode"
2364[ "$OS" = "darwin" ] && echo " contains OS X 10.6 SDK (required for Mountain Lion and newer hosts"
2365[ "$OS" = "darwin" ] && echo " only, ignored for the rest)"
2366[ "$OS" = "linux" ] && echo " --with-linux=DIR Linux kernel source directory [$LINUX]"
2367[ $WITH_QT5 -eq 1 ] && echo " --with-qt-dir=DIR directory for Qt headers/libraries [pkgconfig]"
2368[ $WITH_GSOAP -eq 1 ] && echo " --with-gsoap-dir=PATH directory for gSOAP compiler/headers/libraries"
2369[ $WITH_GSOAP -eq 1 ] && echo " (soapcpp2 and wsdl2h, soapstd2.h, libgsoap++.a/so)"
2370[ $WITH_GSOAP -eq 1 ] && echo " --with-gsoap-import=PATH directory for gSOAP import files (stlvector.h)"
2371cat << EOF
2372 --with-openssl-dir=DIR directory for OpenSSL headers/libraries
2373 --with-ow-dir=DIR directory where Open Watcom can be found [$WATCOM]
2374 --out-path=PATH the folder to which configuration and build output
2375 should go
2376
2377Build type:
2378 -d, --build-debug build with debugging symbols and assertions
2379 --build-profile build with profiling support
2380 --build-headless build headless (without any GUI frontend)
2381EOF
2382 exit 0
2383}
2384
2385
2386#
2387# The body.
2388#
2389
2390# test if we are OSE
2391if [ $OSE -eq 1 -a -r "`cd \`dirname $0\`; pwd`/src/VBox/RDP/server/server.cpp" ]; then
2392 OSE=0
2393 # Set this as a reminder to print a log message once we know the path of the
2394 # log file
2395 NOT_OSE=1
2396fi
2397
2398# Change OS specific defaults; must be before all other stuff
2399if [ "$OS" = "darwin" ]; then
2400 WITH_SDL=0
2401 WITH_SDL_TTF=0
2402 WITH_X11=0
2403 WITH_ALSA=0
2404 WITH_PULSE=0
2405 WITH_DBUS=0
2406 WITH_KMODS=0
2407 BUILD_LIBXML2=1
2408 BUILD_LIBVPX=1
2409 [ $OSE -eq 1 ] || BUILD_LIBCURL=1
2410 [ $OSE -eq 1 ] && WITH_LIBVPX=0
2411 WITH_XCODE_DIR=""
2412elif [ "$OS" = "haiku" ]; then
2413 #WITH_SDL=0
2414 WITH_SDL_TTF=0
2415 WITH_X11=0
2416 WITH_ALSA=0
2417 WITH_PULSE=0
2418 WITH_DBUS=0
2419 WITH_KMODS=0
2420 WITH_LIBIDL=0
2421 WITH_XPCOM=0
2422 BUILD_LIBXSLT=1
2423 BUILD_LIBXML2=1
2424 WITH_LIBVPX=0
2425 # it is part of libroot, which is linked by default,
2426 # but the script wants something
2427 LIBPTHREAD="-lroot"
2428 #[ $OSE -eq 1 ] || BUILD_LIBCURL=1
2429 [ $OSE -eq 1 ] || BUILD_LIBSSL=1
2430elif [ "$OS" = "solaris" ]; then
2431 [ $OSE -eq 1 ] && WITH_LIBVPX=0
2432fi
2433
2434# scan command line options
2435for option in "$@"; do
2436 case "$option" in
2437 --help|-help|-h)
2438 show_help
2439 ;;
2440 --nofatal)
2441 nofatal=1
2442 ;;
2443 --env-only)
2444 ENV_ONLY=1
2445 ;;
2446 --with-gcc=*)
2447 CC=`echo $option | cut -d'=' -f2`
2448 ;;
2449 --with-g++=*)
2450 CXX=`echo $option | cut -d'=' -f2`
2451 ;;
2452 --with-kbuild=*)
2453 KBUILDDIR=`echo $option | cut -d'=' -f2`
2454 if echo $KBUILDDIR|grep -q "$INVALID_CHARS"; then
2455 echo "Error: KBUILDDIR contains invalid characters!"
2456 exit 1
2457 fi
2458 ;;
2459 --with-qt-dir=*)
2460 [ $WITH_QT5 -eq 1 ] && QT5DIR=`echo $option | cut -d'=' -f2`
2461 [ $WITH_QT5 -eq 1 ] && QT5DIR_PKGCONFIG=0
2462 ;;
2463 --with-qt5-minor=*)
2464 QT5MIN=`echo $option | cut -d'=' -f2`
2465 ;;
2466 --with-qt5-major=*)
2467 QT5MAJ=`echo $option | cut -d'=' -f2`
2468 ;;
2469 --with-openssl-dir=*)
2470 OPENSSLDIR=`echo $option | cut -d'=' -f2`
2471 INCCRYPTO="-I${OPENSSLDIR}/include"
2472 LIBCRYPTO="${OPENSSLDIR}/lib/libcrypto.a ${OPENSSLDIR}/lib/libssl.a"
2473 ;;
2474 --with-ow-dir=*)
2475 WATCOM=`echo $option | cut -d'=' -f2`
2476 ;;
2477 --with-gsoap-dir=*)
2478 GSOAP=`echo $option | cut -d'=' -f2`
2479 ;;
2480 --with-gsoap-import=*)
2481 GSOAP_IMPORT=`echo $option | cut -d'=' -f2`
2482 ;;
2483 --with-iasl=*)
2484 IASL=`echo $option | cut -d'=' -f2`
2485 ;;
2486 --with-xcode-dir=*)
2487 WITH_XCODE_DIR=`echo $option | cut -d'=' -f2`
2488 echo $option
2489 ;;
2490 --with-linux=*)
2491 LINUX=`echo $option | cut -d'=' -f2`
2492 ;;
2493 --with-mkisofs=*)
2494 MKISOFS=`echo $option | cut -d'=' -f2`
2495 ;;
2496 --with-makeself=*)
2497 MAKESELF=`echo $option | cut -d'=' -f2`
2498 ;;
2499 --target-arch=*)
2500 TARGET_MACHINE=`echo $option | cut -d'=' -f2`
2501 ;;
2502 --disable-xpcom)
2503 [ $WITH_XPCOM -eq 1 ] && WITH_XPCOM=0
2504 ;;
2505 --disable-python)
2506 [ $WITH_PYTHON -eq 1 ] && WITH_PYTHON=0
2507 ;;
2508 --disable-java)
2509 [ $WITH_JAVA -eq 1 ] && WITH_JAVA=0
2510 ;;
2511 --disable-vmmraw)
2512 [ $WITH_VMMRAW -eq 1 ] && WITH_VMMRAW=0
2513 ;;
2514 --disable-sdl-ttf)
2515 [ $WITH_SDL_TTF -eq 1 ] && WITH_SDL_TTF=0
2516 ;;
2517 --disable-qt)
2518 [ $WITH_QT5 -eq 1 ] && WITH_QT5=0
2519 ;;
2520 --enable-qt5)
2521 [ $WITH_QT5 -eq 0 ] && WITH_QT5=1
2522 ;;
2523 --passive-mesa)
2524 PASSIVE_MESA=1
2525 ;;
2526 --disable-alsa)
2527 [ $WITH_ALSA -eq 1 ] && WITH_ALSA=0
2528 ;;
2529 --disable-pulse)
2530 [ $WITH_PULSE -eq 1 ] && WITH_PULSE=0
2531 ;;
2532 --enable-pulse)
2533 WITH_PULSE=2
2534 ;;
2535 --disable-dbus)
2536 [ $WITH_DBUS -eq 1 ] && WITH_DBUS=0
2537 ;;
2538 --disable-kmods)
2539 [ $WITH_KMODS -eq 1 ] && WITH_KMODS=0
2540 ;;
2541 --disable-opengl)
2542 [ $WITH_OPENGL -eq 1 ] && WITH_OPENGL=0
2543 ;;
2544 --enable-webservice)
2545 [ $WITH_GSOAP -eq 0 ] && WITH_GSOAP=1
2546 ;;
2547 --enable-vnc)
2548 WITH_VNC=1
2549 ;;
2550 --disable-hardening)
2551 WITH_HARDENING=0
2552 ;;
2553 --disable-extpack)
2554 WITH_EXTPACK=0
2555 ;;
2556 --disable-docs)
2557 WITH_DOCS=0
2558 ;;
2559 --enable-hardening)
2560 WITH_HARDENING=2
2561 ;;
2562 --disable-udptunnel)
2563 WITH_UDPTUNNEL=0
2564 ;;
2565 --enable-vde)
2566 WITH_VDE=1
2567 ;;
2568 --disable-devmapper)
2569 WITH_DEVMAPPER=0
2570 ;;
2571 --disable-libvpx)
2572 WITH_LIBVPX=0
2573 ;;
2574 --disable-sdl)
2575 WITH_SDL=0
2576 ;;
2577 --build-debug|-d)
2578 BUILD_TYPE=debug
2579 ;;
2580 --build-profile)
2581 BUILD_TYPE=profile
2582 ;;
2583 --build-libxml2)
2584 BUILD_LIBXML2=1
2585 ;;
2586 --build-libssl)
2587 BUILD_LIBSSL=1
2588 ;;
2589 --build-libcurl)
2590 BUILD_LIBCURL=1
2591 ;;
2592 --build-libvpx)
2593 BUILD_LIBVPX=1
2594 ;;
2595 --build-headless)
2596 HEADLESS=1
2597 WITH_SDL=0
2598 WITH_SDL_TTF=0
2599 WITH_X11=0
2600 WITH_OPENGL=0
2601 WITH_QT5=0
2602 ;;
2603 --ose)
2604 OSE=2
2605 ;;
2606 --odir=*)
2607 ODIR="`echo $option | cut -d'=' -f2`/"
2608 ODIR_OVERRIDE=1
2609 ;;
2610 --out-path=*)
2611 out_path="`echo $option | cut -d'=' -f2`/"
2612 if [ -d $out_path ]; then
2613 saved_path="`pwd`"
2614 cd $out_path
2615 OUT_PATH="`pwd`"
2616 cd $saved_path
2617 OUT_PATH_OVERRIDE=1
2618 if [ $ODIR_OVERRIDE -eq 0 ]; then
2619 # This variable has not *yet* been overridden. That can still happen.
2620 ODIR=$OUT_PATH/
2621 fi
2622 else
2623 echo "Error: invalid folder \"$out_path\" in option \"$option\""
2624 exit 1
2625 fi
2626 ;;
2627 --setup-wine)
2628 [ "$OS" != "darwin" ] && SETUP_WINE=1
2629 ;;
2630 --only-additions)
2631 ONLY_ADDITIONS=1
2632 ;;
2633 *)
2634 echo
2635 echo "Unrecognized option \"$option\""
2636 echo
2637 show_help
2638 ;;
2639 esac
2640done
2641
2642LOG="$ODIR$LOG"
2643ENV="$ODIR$ENV"
2644CNF="$ODIR$CNF"
2645
2646# initialize output files
2647cat > $LOG << EOF
2648# Log file generated by
2649#
2650# '$0 $*'
2651#
2652
2653EOF
2654cat > $CNF << EOF
2655# -*- Makefile -*-
2656#
2657# automatically generated by
2658#
2659# '$0 $*'
2660#
2661# It will be completely overwritten if configure is executed again.
2662#
2663
2664EOF
2665cat > $ENV << EOF
2666#!/bin/bash
2667#
2668# automatically generated by
2669#
2670# '$0 $*'
2671#
2672# It will be completely overwritten if configure is executed again.
2673# Make sure you source this file once before you start to build VBox.
2674#
2675
2676EOF
2677
2678# Print log warning about OSE if necessary
2679if [ -n "$NOT_OSE" ]; then
2680 echo "Found RDP server, assuming VBOX_OSE = FALSE" >> $LOG
2681 echo >> $LOG
2682fi
2683
2684
2685if [ "$BUILD_TYPE" = "debug" ]; then
2686 echo "Creating DEBUG build!" >> $LOG
2687elif [ "$BUILD_TYPE" = "profile" ]; then
2688 echo "Creating PROFILE build!" >> $LOG
2689fi
2690
2691# first determine our environment
2692check_environment
2693check_kbuild
2694
2695[ -n "$ENV_ONLY" ] && exit 0
2696
2697# append the tools directory to the default search path
2698echo "$PATH" | grep -q "$DEVDIR_BIN" || PATH="$PATH:$DEVDIR_BIN"
2699export PATH
2700
2701# if we will be writing to a different out directory then set this up now
2702if [ $OUT_PATH_OVERRIDE -eq 1 ]; then
2703 echo "AUTOCFG=$OUT_PATH/AutoConfig.kmk" >> $ENV
2704 echo "export AUTOCFG" >> $ENV
2705 echo "LOCALCFG=$OUT_PATH/LocalConfig.kmk" >> $ENV
2706 echo "export LOCALCFG" >> $ENV
2707 echo "PATH_OUT_BASE=$OUT_PATH" >> $ENV
2708 echo "export PATH_OUT_BASE" >> $ENV
2709fi
2710
2711# don't bother people with -Werror
2712cnf_append "VBOX_GCC_WERR" "\$(NO_SUCH_VARIABLE)"
2713
2714# some things are not available in for OSE
2715if [ $OSE -ge 1 ]; then
2716 cnf_append "VBOX_OSE" "1"
2717 cnf_append "VBOX_WITH_VALIDATIONKIT" ""
2718 cnf_append "VBOX_WITH_WIN32_ADDITIONS" ""
2719
2720 if [ "$OS" = "linux" ]; then
2721 cnf_append "VBOX_WITH_LINUX_ADDITIONS" "1"
2722 else
2723 cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
2724 fi
2725 echo >> $CNF
2726fi
2727
2728# extpack
2729if [ $ONLY_ADDITIONS -eq 1 ]; then
2730 cnf_append "VBOX_WITH_EXTPACK_PUEL_BUILD" ""
2731elif [ $OSE -eq 0 ]; then
2732 if [ $WITH_EXTPACK -eq 1 ]; then
2733 BUILD_LIBSSL=1
2734 else
2735 cnf_append "VBOX_WITH_EXTPACK_PUEL_BUILD" ""
2736 fi
2737fi
2738
2739# headless
2740if [ -n "$HEADLESS" ]; then
2741 cnf_append "VBOX_HEADLESS" "1"
2742fi
2743
2744# emit disable directives corresponding to any --disable-xxx options.
2745if [ $WITH_OPENGL -eq 0 ]; then
2746 cnf_append "VBOX_WITH_CROGL" ""
2747 cnf_append "VBOX_WITH_VIDEOHWACCEL" ""
2748 cnf_append "VBOX_GUI_USE_QGL" ""
2749fi
2750[ $WITH_XPCOM -eq 0 ] && cnf_append "VBOX_WITH_MAIN" ""
2751[ $WITH_QT5 -eq 0 ] && cnf_append "VBOX_WITH_QTGUI" ""
2752[ $WITH_SDL_TTF -eq 0 ] && cnf_append "VBOX_WITH_SECURELABEL" ""
2753[ $WITH_PYTHON -eq 0 ] && cnf_append "VBOX_WITH_PYTHON" ""
2754[ $WITH_JAVA -eq 0 ] && cnf_append "VBOX_WITH_JXPCOM" ""
2755[ $WITH_JAVA -eq 0 ] && cnf_append "VBOX_WITH_JWS" ""
2756[ $WITH_HARDENING -eq 0 ] && cnf_append "VBOX_WITHOUT_HARDENING" "1"
2757[ $WITH_HARDENING -eq 2 ] && cnf_append "VBOX_WITH_HARDENING" "2"
2758[ $WITH_VMMRAW -eq 0 ] && cnf_append "VBOX_WITH_RAW_MODE" ""
2759if [ $WITH_LIBVPX -eq 0 ]; then
2760 cnf_append "VBOX_WITH_LIBVPX" ""
2761 cnf_append "VBOX_WITH_VIDEOREC" ""
2762fi
2763
2764# Darwin-specific
2765if [ "$OS" = "darwin" ]; then
2766 check_darwinversion
2767fi
2768# the tools
2769check_gcc
2770if [ $ONLY_ADDITIONS -eq 0 ]; then
2771 check_open_watcom
2772 [ "$OS" != "darwin" ] && check_iasl
2773 # don't check for yasm for the time beeing as 0.40 and 0.50 both have known bugs
2774 # [ "$OS" != "darwin" ] && check_yasm
2775 [ "$OS" != "darwin" ] && check_xsltproc
2776 [ "$OS" != "darwin" ] && check_mkisofs
2777fi
2778
2779# the libraries
2780if [ $ONLY_ADDITIONS -eq 0 ]; then
2781 [ "$OS" != "darwin" ] && check_pthread
2782 check_libxml2
2783 [ $WITH_LIBIDL -eq 1 ] && check_libidl
2784 check_ssl
2785 check_curl
2786 [ $WITH_LIBVPX -eq 1 ] && check_vpx
2787 [ "$OS" != "darwin" ] && check_z
2788 [ "$OS" != "darwin" ] && check_png
2789 [ $OSE -eq 0 -a "$OS" = "linux" ] && check_pam
2790 if [ $WITH_SDL -eq 1 ]; then
2791 check_sdl
2792 else
2793 cnf_append "VBOX_WITH_VBOXSDL" ""
2794 fi
2795 [ $WITH_SDL_TTF -eq 1 -a $OSE -eq 0 ] && check_sdl_ttf
2796 [ $WITH_X11 -eq 1 ] && check_x
2797 # TODO check for xcomposite-dev (X11/extensions/Xcomposite.h, additions only)
2798 # TODO check for libxdamange-dev (X11/extensions/Xdamage.h, additions only)
2799 [ $WITH_X11 -eq 1 ] && check_xcursor
2800 [ $WITH_X11 -eq 1 ] && check_xinerama
2801 [ $WITH_X11 -eq 1 ] && check_xrandr
2802 [ $WITH_OPENGL -eq 1 ] && check_opengl
2803 [ $WITH_QT5 -eq 1 ] && check_qt5
2804 [ $WITH_PYTHON -eq 1 ] && check_python
2805 [ $WITH_JAVA -eq 1 ] && check_java
2806
2807 # PulseAudio
2808 if [ "$OS" = "linux" -o "$OS" = "freebsd" -o "$OS" = "netbsd" ]; then
2809 if [ $WITH_PULSE -eq 1 ]; then
2810 check_pulse
2811 elif [ $WITH_PULSE -eq 0 ]; then
2812 cnf_append "VBOX_WITH_AUDIO_PULSE" ""
2813 fi
2814 fi
2815fi
2816
2817# Linux-specific
2818if [ "$OS" = "linux" ]; then
2819 # don't check for the static libstdc++ in the PUEL version as we build the
2820 # additions at a dedicated box
2821 [ $OSE -ge 1 ] && check_staticlibstdcxx
2822 if [ $WITH_KMODS -eq 1 ]; then
2823 check_linux
2824 else
2825 cnf_append "VBOX_LINUX_SRC" ""
2826 cnf_append "VBOX_WITH_VBOXDRV" ""
2827 cnf_append "VBOX_WITH_ADDITION_DRIVERS" ""
2828 fi
2829 if [ $ONLY_ADDITIONS -eq 0 ]; then
2830 if [ $WITH_ALSA -eq 1 ]; then
2831 check_alsa
2832 else
2833 cnf_append "VBOX_WITH_AUDIO_ALSA" ""
2834 fi
2835 if [ $WITH_DBUS -eq 0 ]; then
2836 cnf_append "VBOX_WITH_DBUS" ""
2837 fi
2838 if [ $WITH_DEVMAPPER -eq 1 ]; then
2839 check_libdevmapper
2840 else
2841 cnf_append "VBOX_WITH_DEVMAPPER" ""
2842 fi
2843 check_libcap
2844 fi
2845 check_compiler_h
2846 [ $ONLY_ADDITIONS -eq 0 -a "$BUILD_MACHINE" = "amd64" -a $WITH_VMMRAW -eq 1 ] && check_32bit
2847 # tools/common/makeself*
2848 [ $OSE -ge 1 ] && check_makeself
2849fi
2850
2851[ -n "$SETUP_WINE" ] && setup_wine
2852
2853if [ $ONLY_ADDITIONS -eq 0 -a $WITH_GSOAP -eq 1 ]; then
2854 check_gsoap
2855else
2856 if [ $OSE -ge 1 ]; then
2857 cnf_append "VBOX_WITH_WEBSERVICES" ""
2858 fi
2859fi
2860
2861# UDPTUNNEL
2862if [ $ONLY_ADDITIONS -eq 0 -a $WITH_UDPTUNNEL -eq 0 ]; then
2863 cnf_append "VBOX_WITH_UDPTUNNEL" ""
2864fi
2865
2866# VDE
2867if [ $ONLY_ADDITIONS -eq 0 -a "$OS" = "linux" -o "$OS" = "freebsd" ]; then
2868 if [ $WITH_VDE -eq 1 ]; then
2869 cnf_append "VBOX_WITH_VDE" "1"
2870 fi
2871fi
2872
2873# DOCS
2874if [ $ONLY_ADDITIONS -eq 1 -o $WITH_DOCS -eq 0 ]; then
2875 cnf_append "VBOX_WITH_DOCS" ""
2876 cnf_append "VBOX_WITH_DOCS_PACKING" ""
2877fi
2878
2879# VNC server support
2880if [ $ONLY_ADDITIONS -eq 0 -a $OSE -ge 1 ]; then
2881 if [ $WITH_VNC = 1 ]; then
2882 check_vncserver
2883 else
2884 cnf_append "VBOX_WITH_EXTPACK_VNC" ""
2885 fi
2886fi
2887
2888if [ $ONLY_ADDITIONS -eq 1 ]; then
2889 cnf_append "VBOX_ONLY_ADDITIONS" "1"
2890fi
2891
2892# success!
2893echo
2894echo "Successfully generated '$CNF' and '$ENV'."
2895echo "Source '$ENV' once before you start to build VBox:"
2896echo ""
2897echo " source $ENV"
2898echo " kmk"
2899echo ""
2900if [ "$OS" = "linux" ]; then
2901 if [ $OUT_PATH_OVERRIDE -eq 1 ]; then
2902 vbox_out_path=$OUT_PATH
2903 else
2904 vbox_out_path=./out
2905 fi
2906 echo "To compile the kernel modules, do:"
2907 echo ""
2908 echo " cd $vbox_out_path/$OS.$TARGET_MACHINE/$BUILD_TYPE/bin/src"
2909 echo " make"
2910 echo ""
2911fi
2912if [ $ONLY_ADDITIONS -eq 1 ]; then
2913 echo ""
2914 echo " Tree configured to build only the Guest Additions"
2915 echo ""
2916elif [ $WITH_HARDENING -gt 0 ]; then
2917 echo ""
2918 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2919 echo " Hardening is enabled which means that the VBox binaries will not run from"
2920 echo " the binary directory. The binaries have to be installed suid root and some"
2921 echo " more prerequisites have to be fulfilled which is normally done by installing"
2922 echo " the final package. For development, the hardening feature can be disabled"
2923 echo " by specifying the --disable-hardening parameter. Please never disable that"
2924 echo " feature for the final distribution!"
2925 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2926 echo ""
2927else
2928 echo ""
2929 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2930 echo " Hardening is disabled. Please do NOT build packages for distribution with"
2931 echo " disabled hardening!"
2932 echo " +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++"
2933 echo ""
2934fi
2935echo "Enjoy!"
2936cleanup
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use