• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -ex
2
3function find_kdir() {
4    local kdirs=(/usr/lib/modules/*/build/Makefile /usr/src/kernels/*/Makefile)
5    local kdir=""
6
7    for f in "${kdirs[@]}"; do
8        if [ -f "$f" ]; then
9            kdir=$f
10            break
11        fi
12    done
13
14    if [ -z "$kdir" ]; then
15        printf '==> Unable to find kernel headers to build modules for tests\n' >&2
16        exit 1
17    fi
18
19    kdir=${kdir%/Makefile}
20
21    echo $kdir
22}
23
24if [ -f configure ]; then
25    make distclean
26fi
27
28rm -rf build
29mkdir build
30cd build
31
32kdir=$(find_kdir)
33IFS=/ read _ _ _ kver _ <<<"$kdir"
34
35../autogen.sh c --disable-python
36make -j
37make check KDIR="$kdir" KVER="$kver"
38make install
39