2016-06-19 01:53:25 +03:00
#!/bin/sh -ex
2017-11-29 06:52:27 +03:00
type sudo >/dev/null 2>& 1 && sudo = sudo || sudo =
common_packages = 'autoconf automake file gawk gcc-multilib git gzip make xz-utils'
2016-06-19 01:53:25 +03:00
updated =
apt_get_install( )
{
[ -n " $updated " ] || {
2017-11-29 06:52:27 +03:00
$sudo apt-get -qq update
2016-06-19 01:53:25 +03:00
updated = 1
}
2017-11-29 06:52:27 +03:00
$sudo apt-get -qq --no-install-suggests --no-install-recommends \
2016-06-19 01:53:25 +03:00
install -y " $@ "
}
2017-04-13 21:24:09 +03:00
case " $KHEADERS " in
*/*)
git clone --depth= 1 https://github.com/" $KHEADERS " kernel
2017-11-29 06:52:27 +03:00
$sudo make -C kernel headers_install INSTALL_HDR_PATH = /opt/kernel
$sudo rm -rf kernel
2017-04-13 21:24:09 +03:00
KHEADERS_INC = /opt/kernel/include
; ;
*)
KHEADERS_INC = /usr/include
; ;
esac
2016-06-19 01:53:25 +03:00
case " $CC " in
gcc)
2017-11-29 06:52:27 +03:00
apt_get_install $common_packages
2016-06-19 01:53:25 +03:00
; ;
2017-04-12 06:06:32 +03:00
gcc-*)
2017-11-29 06:52:27 +03:00
$sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt_get_install $common_packages " $CC " -multilib
2017-04-12 06:06:32 +03:00
; ;
2017-11-29 06:52:27 +03:00
clang*)
apt_get_install $common_packages " $CC "
2016-06-19 01:53:25 +03:00
; ;
musl-gcc)
2017-11-29 06:52:27 +03:00
apt_get_install $common_packages ca-certificates
2016-08-04 03:40:33 +03:00
git clone --depth= 1 https://github.com/strace/musl
cd musl
CC = gcc
2016-09-08 20:11:51 +03:00
build =
case " ${ TARGET - } " in
x32)
CC = " $CC -mx32 "
; ;
x86)
CC = " $CC -m32 "
build = '--build=i686-pc-linux-gnu --target=i686-pc-linux-gnu'
; ;
esac
./configure --prefix= /opt/musl --exec-prefix= /usr ${ build }
2016-08-04 03:40:33 +03:00
make
2017-11-29 06:52:27 +03:00
$sudo make install
2016-08-04 03:40:33 +03:00
cd -
rm -rf musl
2017-11-29 06:52:27 +03:00
$sudo ln -s \
2017-04-13 21:24:09 +03:00
$KHEADERS_INC /asm* \
$KHEADERS_INC /linux \
$KHEADERS_INC /mtd \
2016-08-04 03:40:33 +03:00
/opt/musl/include/
2016-06-19 01:53:25 +03:00
; ;
esac
2016-12-18 03:12:48 +03:00
case " ${ CHECK - } " in
coverage)
apt_get_install lcov
pip install --user codecov
; ;
2017-07-22 21:46:16 +03:00
valgrind)
apt_get_install valgrind
; ;
2016-12-18 03:12:48 +03:00
esac