3 # Copyright (C) 2012, Luis R. Rodriguez <mcgrof@frijolero.org>
4 # Copyright (C) 2012, Hauke Mehrtens <hauke@hauke-m.de>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation.
10 # You can use this to compile a module accross all installed kernels
11 # found. This relies on distribution specific kernels, but can handle
12 # your own custom list of target kernels. Log is setnt to LOG variable.
24 #export KCFLAGS="-Wno-unused-but-set-variable"
25 KERNEL_DIR="/lib/modules"
29 LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
32 for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r); do
37 echo -e "Unsupported distribution"
42 nice make clean 2>&1 > $LOG
44 function tee_color_split()
47 echo -e $REPLY | ./scripts/skip-colors >> $LOG
52 function log_try_kernel()
54 echo -en "Trying kernel ${BLUE}"
55 printf "%40s\t" "${1}"
62 echo -e "--------------------------------------------" >> $LOG
64 if [[ ! -d $DIR ]]; then
68 # We cannot use tee_color_split() as bash read only spits
69 # out output when a newline comes in. We can modif IFS but
70 # I am still not sure how to do this properly.
71 log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG
72 log_try_kernel $KERNEL
74 ionice -c 3 nice -n 20 make KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG
75 if [[ $? -eq 0 ]]; then
76 echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split
78 echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split
81 nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG