0

I have a (GNU) make file with two-levelled dependencies like this:

INP ?= main
DEPS ?= bibliography.bib
# md-->tex rule
%.tex: %.md $(DEPS)
    panzer  -o $@ $<

# tex-->pdf rule
%.pdf: %.tex
    latexmk $<

.PHONY: show 
show: $(INP).pdf
    showpdf $<

This works as expected: make show creates and displays a PDF from main.md (or any other markdown file I specify) when the markdown file has changed by invoking first the md-->tex rule, then the tex-->pdf and finally the showpdf rule.

Now I want to add a target force which triggers the rules md-->tex, tex-->pdf and showpdf regardless of the state of main.md.

From this answer I tried

force:
    rm $(INP).pdf
    make show

but this is not very elegant and rather fragile. - I suspect there must be a way to create a target inside the current make invocation to say:

Pretend the dependencies for rule X (here show) is out of date and trigger everything accordingly.

What the best way to achieve this?

Community
  • 1
  • 1
halloleo
  • 9,216
  • 13
  • 64
  • 122

1 Answers1

5

You most definitely want to just use the -B flag. .phony won't quite work in this case. You should try:

force: make -B show

That should invoke the show target with the flag and make everything rebuild itself appropriately.

[ Original Answer ]

You either declare that target to be .phony, or you pass the flag -B (which I believe should be shorthand for --always-make). This should have (gnu) make disregard all the timestamps and make everything. I prefer the -B flag myself.

ThePhD
  • 290
  • 4
  • 10