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"
30 LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
33 for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do
38 echo -e "Unsupported distribution"
43 function tee_color_split()
46 echo -e $REPLY | ./scripts/skip-colors >> $LOG
51 function log_try_kernel()
53 echo -en "Trying kernel ${BLUE}"
54 printf "%40s\t" "${1}"
60 echo -e "Usage: $0 [-t]"
61 echo -e "-t will run: 'time ckmake; time ckmake' account for"
62 echo -e " benchmark how long it takes to compile without ccache"
63 echo -e " and a run after cache kicks in"
66 if [[ $# -gt 1 ]]; then
71 if [[ $# -eq 1 ]]; then
72 if [[ $1 != "-t" ]]; then
84 echo -e "--------------------------------------------" >> $LOG
86 if [[ ! -d $DIR ]]; then
90 # We cannot use tee_color_split() as bash read only spits
91 # out output when a newline comes in. We can modif IFS but
92 # I am still not sure how to do this properly.
93 log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG
94 log_try_kernel $KERNEL
96 ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG
97 if [[ $? -eq 0 ]]; then
98 echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split
100 echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split
103 nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG
107 nice make clean 2>&1 > $LOG
109 if [[ $TIME != "1" ]]; then
115 time $0 | egrep "real|user|sys"