VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/linux/build_in_tmp@ 62517

Last change on this file since 62517 was 58433, checked in by vboxsync, 9 years ago

linux/build_in_tmp: Parallel building, please.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1#!/bin/sh
2
3#
4# Script to build a kernel module in /tmp. Useful if the module sources
5# are installed in read-only directory.
6#
7# Copyright (C) 2007-2015 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17
18# find a unique temp directory
19num=0
20while true; do
21 tmpdir="/tmp/vbox.$num"
22 if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
23 break
24 fi
25 num=`expr $num + 1`
26 if [ $num -gt 200 ]; then
27 echo "Could not find a valid tmp directory"
28 exit 1
29 fi
30done
31
32# Guest optimal number of make jobs.
33MAKE_JOBS=`grep vendor_id /proc/cpuinfo | wc -l`
34if [ "${MAKE_JOBS}" -le "0" ]; then MAKE_JOBS=1; fi
35
36# Parse our arguments, anything we don't grok is for make.
37while true; do
38 if [ "$1" = "--save-module-symvers" ]; then
39 shift
40 SAVE_MOD_SYMVERS="$1"
41 shift
42 elif [ "$1" = "--use-module-symvers" ]; then
43 shift
44 USE_MOD_SYMVERS="$1"
45 shift
46 elif [ "$1" = "--module-source" ]; then
47 shift
48 MODULE_SOURCE="$1"
49 shift
50 else
51 break
52 fi
53done
54
55# copy
56if [ -n "$MODULE_SOURCE" ]; then
57 cp -a "$MODULE_SOURCE"/* $tmpdir/
58else
59 cp -a ${0%/*}/* $tmpdir/
60fi
61if [ -n "$USE_MOD_SYMVERS" ]; then
62 cp $USE_MOD_SYMVERS $tmpdir/Module.symvers
63fi
64
65# make, cleanup if success
66cd "$tmpdir"
67if make "-j${MAKE_JOBS}" "$@"; then
68 if [ -n "$SAVE_MOD_SYMVERS" ]; then
69 if [ -f Module.symvers ]; then
70 cp -f Module.symvers $SAVE_MOD_SYMVERS
71 else
72 cat /dev/null > $SAVE_MOD_SYMVERS
73 fi
74 fi
75 rm -rf $tmpdir
76 exit 0
77fi
78
79# failure
80rm -rf $tmpdir
81exit 1
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette