diff --git a/Makefile b/Makefile index 74a5a69..6ed3494 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,11 @@ VERSION := 0.5.0 +# a bit of a hack to make sure this runs before any rules +ifneq ($(CALCULATING),yes) +TOTAL := $(shell $(MAKE) CALCULATING=yes -n | sed -n 's/^.*Compiling: \([^"]\+\)"/\1/p' > .files ) +endif + all: make.conf FL Timeline make.conf: configure @@ -30,8 +35,14 @@ INCLUDES := -I. -Iutil -IFL include scripts/colors +ifneq ($(CALCULATING),yes) + COMPILING="$(BOLD)$(BLACK)[$(SGR0)$(CYAN)`scripts/percent-complete .files "$<"`$(SGR0)$(BOLD)$(BLACK)]$(SGR0) Compiling: $(BOLD)$(YELLOW)$<$(SGR0)" +else + COMPILING="Compiling: $<" +endif + .C.o: - @ echo "Compiling: $(BOLD)$(YELLOW)$<$(SGR0)" + @ echo $(COMPILING) @ $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ %.C : %.fl diff --git a/scripts/percent-complete b/scripts/percent-complete new file mode 100755 index 0000000..31b2c6c --- /dev/null +++ b/scripts/percent-complete @@ -0,0 +1,20 @@ +#!/bin/sh + +# May 2008 Jonathan Moore Liles +# +# Given the name of a file containing a list of files and a filename +# from that list, return the percentage of the distance from the +# beginning of the list. + +[ $# -ne 2 ] && exit + +MATCH="`grep -nFx \"$2\" \"$1\"`" +MATCH=${MATCH%%:*} +TOTAL="`cat \"$1\" | wc -l`" + +if [ -z "$MATCH" ] +then + echo "0%" +else + printf "%3s%%" $(( $MATCH * 100 / $TOTAL )) +fi \ No newline at end of file