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