1 | #!/bin/bash -x
|
---|
2 | # $Id: build-modules.sh 78140 2019-04-16 02:20:36Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Script for test building the VirtualBox kernel modules against a kernel.
|
---|
5 | #
|
---|
6 | # This script assumes the kernel directory it is pointed to was prepared using
|
---|
7 | # build-kernel.sh, as that script plants a couple of files and symlinks needed
|
---|
8 | # by this script.
|
---|
9 | #
|
---|
10 |
|
---|
11 | #
|
---|
12 | # Copyright (C) 2019 Oracle Corporation
|
---|
13 | #
|
---|
14 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
15 | # available from http://www.virtualbox.org. This file is free software;
|
---|
16 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
17 | # General Public License (GPL) as published by the Free Software
|
---|
18 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
19 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
20 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
21 | #
|
---|
22 |
|
---|
23 | if [ $# -lt 2 ]; then
|
---|
24 | echo "usage: modules.sh <PATH_STAGE> <kernel-dir>"
|
---|
25 | exit 2
|
---|
26 | fi
|
---|
27 | PATH_STAGE=$1
|
---|
28 | PATH_STAGE_GUEST_SRC="${PATH_STAGE}/bin/additions/src"
|
---|
29 | PATH_STAGE_HOST_SRC="${PATH_STAGE}/bin/src"
|
---|
30 | KERN_DIR=$2
|
---|
31 | KERN_NAME=`basename "${KERN_DIR}"`
|
---|
32 | KERN_VER=`echo ${KERN_NAME} | sed -e 's/^.*linux-//'`
|
---|
33 | KERN_BASE_DIR=`dirname "${KERN_DIR}"`
|
---|
34 | BLDDIR_BASE="/tmp/modbld"
|
---|
35 | BLDDIR="${BLDDIR_BASE}/`echo ${PATH_STAGE} ${KERN_BASE_DIR} | sha1sum | cut -b1-16`-${KERN_NAME}/"
|
---|
36 | JOBS=36
|
---|
37 | shift
|
---|
38 | shift
|
---|
39 |
|
---|
40 |
|
---|
41 | # Process other options
|
---|
42 | OPT_CLOBBER=
|
---|
43 | while [ $# -gt 0 ];
|
---|
44 | do
|
---|
45 | case "$1" in
|
---|
46 | clobber) OPT_CLOBBER=1;;
|
---|
47 | --version) KERN_VER="$2"; shift;;
|
---|
48 | *) echo "syntax error: $1" 1>&2
|
---|
49 | exit 2;;
|
---|
50 | esac
|
---|
51 | shift;
|
---|
52 | done
|
---|
53 |
|
---|
54 | #
|
---|
55 | # Prepare the sources we're to build.
|
---|
56 | #
|
---|
57 | set -e
|
---|
58 | test -n "${BLDDIR}"
|
---|
59 | if [ -d "${BLDDIR}" -a -n "${OPT_CLOBBER}" ]; then
|
---|
60 | rm -R "${BLDDIR}/"
|
---|
61 | fi
|
---|
62 |
|
---|
63 | mkdir -p "${BLDDIR}/" "${BLDDIR}/guest/" "${BLDDIR}/host/"
|
---|
64 | rsync -crlDp --exclude="*.tmp_versions/" --include="*/" --include="*.h" --include="*.c" --include="*.cpp" --include="Makefile*" --include="build_in_tmp" --exclude="*" "${PATH_STAGE_HOST_SRC}/" "${BLDDIR}/host/"
|
---|
65 | rsync -crlDp --exclude="*.tmp_versions/" --include="*/" --include="*.h" --include="*.c" --include="*.cpp" --include="Makefile*" --include="build_in_tmp" --exclude="*" "${PATH_STAGE_GUEST_SRC}/" "${BLDDIR}/guest/"
|
---|
66 |
|
---|
67 | #
|
---|
68 | # Do the building.
|
---|
69 | #
|
---|
70 | if [ -f "${KERN_DIR}/.bird-make" -a ! -f "${KERN_DIR}/.bird-failed" ]; then
|
---|
71 | if "${KERN_DIR}/.bird-make" --help 2>&1 | grep -q output-sync -; then
|
---|
72 | SYNC_OUTPUT="--output-sync=target"
|
---|
73 | else
|
---|
74 | SYNC_OUTPUT=""
|
---|
75 | fi
|
---|
76 | "${KERN_DIR}/.bird-make" -C "${BLDDIR}/guest/" \
|
---|
77 | VBOX_NOJOBS=1 -j${JOBS} `cat "${KERN_DIR}/.bird-overrides"` ${SYNC_OUTPUT} "KERN_DIR=${KERN_DIR}" "KERN_VER=${KERN_VER}"
|
---|
78 | case "${KERN_VER}" in
|
---|
79 | [3-9].*|2.6.3[789]*) ## todo fix this so it works back to 2.6.18 (-fno-pie, -Wno-declaration-after-statement)
|
---|
80 | "${KERN_DIR}/.bird-make" -C "${BLDDIR}/host/" \
|
---|
81 | VBOX_NOJOBS=1 -j${JOBS} `cat "${KERN_DIR}/.bird-overrides"` ${SYNC_OUTPUT} "KERN_DIR=${KERN_DIR}" "KERN_VER=${KERN_VER}"
|
---|
82 | ;;
|
---|
83 | esac
|
---|
84 | else
|
---|
85 | echo "${KERN_DIR}: Skipping..."
|
---|
86 | fi
|
---|
87 |
|
---|