Files
linux-kernel-module-cheat/configure
Ciro Santilli 2f413958b0 gem5: fix submodule fetch
Only shallow clone the Linux kernel for now

Saner defaults for ./configure:

* ./configure only gets gem5
* ./configure -g only gets gem5
* ./configure -qg both
2018-09-14 09:45:39 +01:00

148 lines
3.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
interactive_pkgs=libsdl2-dev
gem5=false
gem5_given=false
qemu=true
qemu_given=false
submodules_dir=submodules
submodules=buildroot
y=
while getopts gpqt OPT; do
case "$OPT" in
g)
gem5_given=true
;;
p)
submodules="${submodules} parsec-benchmark"
;;
q)
qemu_given=true
;;
t)
interactive_pkgs=
y=-y
;;
esac
done
shift $(($OPTIND - 1))
if "$gem5_given" && ! "$qemu_given"; then
qemu=false
fi
if "$gem5_given"; then
gem5=true
fi
## apt-get
pkgs="\
automake \
bc \
build-essential \
coreutils \
cpio \
expect \
git \
moreutils \
tmux \
unzip \
vinagre \
wget \
"
if "$gem5"; then
pkgs="$pkgs \
ccache \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi \
libgoogle-perftools-dev \
protobuf-compiler \
python-dev \
python-pip \
scons \
"
fi
command -v apt-get >/dev/null 2>&1 || {
cat <<EOF
apt-get not found. You're on your own for installing dependencies.
On Ubuntu they are:
$pkgs
EOF
exit 0
}
# Without this started failing in kernel 4.15 with:
# Makefile:932: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
pkgs="$pkgs libelf-dev"
# https://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker
if [ -f /.dockerenv ]; then
mysudo=
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
sed -Ei 's/^# deb-src/deb-src/' /etc/apt/sources.list
y=-y
else
mysudo=sudo
fi
$mysudo apt-get update $y
# Building SDL for QEMU in Buildroot was rejected upstream because it adds many dependencies:
# https://patchwork.ozlabs.org/patch/770684/
# We are just using the host SDL for now, if it causes too much problems we might remove it.
# libsdl2-dev needs to be installed separatedly from sudo apt-get build-dep qemu
# because Ubuntu 16.04's QEMU uses SDL 1.
$mysudo apt-get install $y \
$pkgs \
$interactive_pkgs \
;
if "$qemu"; then
$mysudo apt-get build-dep $y qemu
fi
if "$gem5"; then
# Generate graphs of config.ini under m5out.
pip install --user pydot
fi
## Submodules
if "$qemu"; then
submodules="${submodules} qemu"
fi
if "$gem5"; then
submodules="${submodules} gem5"
fi
submodules="$(for submodule in ${submodules}; do printf "${submodules_dir}/${submodule} "; done)"
# == Shallow cloning.
#
# TODO Ideally we should shallow clone --depth 1 all of them.
#
# However, most git servers out there are crap or craply configured
# and don't allow shallow cloning except for branches.
#
# So for now, let's shallow clone only the Linux kernel, which has by far
# the largest .git repo history, and full clone the others.
#
# Then we will maintain a GitHub Linux kernel mirror / fork that always has a
# lkmc branch, and point to it, so that it will always succeed.
#
# See also:
#
# * https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset
# * https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
# * https://unix.stackexchange.com/questions/338578/why-is-the-git-clone-of-the-linux-kernel-source-code-much-larger-than-the-extrac
#
# == Other nice git options for when distros move to newer Git
#
# Currently not on Ubuntu 16.04:
#
# `--progress`: added on Git 2.10:
#
# * https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching
# * https://stackoverflow.com/questions/4640020/progress-indicator-for-git-clone
#
# `--jobs"`: https://stackoverflow.com/questions/26957237/how-to-make-git-clone-faster-with-multiple-threads/52327638#52327638
#
git submodule update --init --recursive -- ${submodules}
git submodule update --depth 1 --init --recursive -- "${submodules_dir}/linux"