[linux-elitists] Fun* with inotify and make

Don Marti dmarti at zgp.org
Sat Jul 27 06:29:49 PDT 2013


begin Teh Entar-Nick quotation of Sat, Jul 27, 2013 at 10:47:48AM +0000:

> Neat, but nearly all of my Makefiles use patterns like this:
> 
>     MARKDOWNS=$(wildcard *.md)
>     all: $(patsubst %.md,%.html,$(MARKDOWNS))
>     %.html: %.md
>             pandoc -t html5 --ascii --section-divs --standalone --smart -o
>             $@ $<
>     %.pdf: %.md
>             pandoc --chapters --variable=papersize:'a5paper' -o $@ $<
> 
> It doesn't seem that this kind of automatic pattern-driven makefile is
> supported by your script.

Arr, if only we had a program that would parse
Makefiles...

_make_prereqs() {
    make -dnr $* | tr ' ' '\n' | \
        grep ".*'.$" | grep -o '\w.*\b'
}

make_prereqs() {
    # prerequisites mentioned in a Makefile
    # that are actual files.
    for f in `_make_prereqs $* | sort -u`; do
        [ -e $f ] && echo -n "$f ";
    done
    echo
}

Now it should only watching the files that "make"
thinks are relevant to the target.  Still an extra
"grep" in there, probably.

-- 
Don Marti                      +1-510-332-1587 (mobile)
http://zgp.org/~dmarti/        Alameda, California, USA
dmarti at zgp.org


More information about the linux-elitists mailing list