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"
34 for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do
38 function tee_color_split()
41 echo -e $REPLY | ./scripts/skip-colors >> $LOG
46 function log_try_kernel()
48 echo -en "Trying kernel ${BLUE}"
49 printf "%40s\t" "${1}"
55 echo -e "Usage: $0 [-t] <optional-target>"
56 echo -e "-t will run: 'time ckmake; time ckmake' account for"
57 echo -e " benchmark how long it takes to compile without ccache"
58 echo -e " and a run after cache kicks in"
59 echo -e "-q will ask ckmake to run make with -s to only output errors"
61 echo -e "<optional-target> is the arguments you want to pass to the"
62 echo -e "child make call that ckmake will use. For example if you have"
63 echo -e "a target 'linux' on your Makefile you can run 'cmake linux'"
95 echo -e "--------------------------------------------" >> $LOG
97 if [[ ! -d $DIR ]]; then
101 # We cannot use tee_color_split() as bash read only spits
102 # out output when a newline comes in. We can modif IFS but
103 # I am still not sure how to do this properly.
104 log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG
105 log_try_kernel $KERNEL
107 ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG
110 if [[ $RET = "" ]]; then
114 if [[ $CUR_RET -eq 0 ]]; then
115 echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split
117 echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split
121 nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG
125 nice make clean 2>&1 > $LOG
127 if [[ $TIME != "1" ]]; then
133 time $0 $QUIET $ARGS | egrep "real|user|sys"