#!/bin/sh # # ProcMake 0.2: a GNU Make wrapper which produces a progress report. # 2004-04-25 groundzero@zuavra.net http://software.zuavra.net/procmake/ # # ProcMake is free to use and to distribute further, as long as no # modifications are made upon it. I make no guarantees for its effects # and functionality. By using it you assume all the responsability for # the outcome. # # The following options are customizable. BAR_WIDTH=50 # From this point forward, do not modify anything unless you know # what you're doing. TSTART=`date +%s` # function to draw a percentage bar function drawbar() { if (( BARS < BAR_WIDTH )); then echo -en "\033[1G" echo -n "[" PAR=${1:-0} BARS=$((BAR_WIDTH*PAR/100)) for i in `seq 1 1 $BARS 2>/dev/null`; do echo -n "=" done for i in `seq 1 1 $((BAR_WIDTH-BARS)) 2>/dev/null`; do echo -n " " done echo -n "] ${PAR}% " fi } # function to transform seconds in hours-minutes-seconds function showtime() { TIME=${1:-0} SECS=$((TIME%3600)) HOURS=$(((TIME-SECS)/3600)) TIME=$SECS SECS=$((TIME%60)) MINS=$(((TIME-SECS)/60)) echo "${HOURS}h ${MINS}m ${SECS}s" } # the simulation run echo -n "Counting marker lines ... " TOTAL=`make -dnk ${@} 2>&1|grep -i "Finished prerequisites"|wc -l|tr -d "[:space:]"` echo "expecting $TOTAL marker lines." # the real run PARTIAL=0 OLD=0 drawbar 0 make -d ${@} 2>&1|grep -i "Finished prerequisites"|\ while read LINE; do PARTIAL=$((PARTIAL+1)) NEW=$((PARTIAL*100/TOTAL)) if [ "$OLD" != "$NEW" ]; then drawbar $NEW fi OLD=$NEW done RET=${PIPESTATUS[0]} echo # output results TSTOP=`date +%s` echo -n "It took `showtime $((TSTOP-TSTART))`, " echo "and make returned code ${RET}." exit $RET