The Makefile
is:
%.pdf: %.tex
rubber -d $<
If there is a doc.tex
in the directory, then make doc.pdf
builds doc.pdf
. The problem is that when I type make
, the autocompletion gives nothing: it doesn't even allow to autocomplete to make doc.tex
. What can be done about it?
Best Answer
The
bash-completion
package doesn't do this, it does some acrobatics to handle both command line options and extract a list ofMakefile
targets, but it does not try to generate matches by applying wildcards or otherwise handling any pattern rules.It can be done however, here's a simple version with a few caveats.
There are two parts, a function
_mkcache
extracts all the rules and targets from aMakefile
and caches these. It also does a bit of processing so the rules are simplified to a single "target : pre-req
" form in that cache.Then, a completion function
_bc_make
takes the token you attempt completion on and tries to match against targets, and uses the pattern rules to expand a glob based on the pre-requisites and the word for completion. If one or more matches are found, it builds a list of targets based on the pattern rules.GNU
make
is assumed. It should correctly handle:.c.o
→%.o : %.c
RCS/
)-r
tomake
if preferred)Caveats, and not supported:
make
VPATH
orvpath
.SUFFIXES
make -C dir
make
options expansionTERMCAP
for example)Makefile
Some of the above can be added relatively simply, others like archive handling are not so simple.