2

I have a makefile for a Latex document which contains the following rules:

TEX=index.tex

DVI=$(TEX:.tex=.dvi)
PS=$(TEX:.tex=.ps)
PDF=$(TEX:.tex=.pdf)

all: images $(PDF)

images:
    make -C $@

%.dvi: %.tex
    latex $<

%.ps: %.dvi
    dvips $<

%.pdf: %.ps
    ps2pdf $<

what does the syntax DVI=$(TEX:.tex=.dvi) exactly do? how is it expanded? I tried to print the result with an echo but nothing is printed.

sarah.ferguson
  • 3,167
  • 2
  • 23
  • 31
  • Possible duplicate of [How to change the extension of each file in a list with multiple extensions in GNU make?](https://stackoverflow.com/questions/12069457/how-to-change-the-extension-of-each-file-in-a-list-with-multiple-extensions-in-g) – John Bollinger Aug 02 '19 at 20:29
  • 1
    That form is called a "substitution reference", which term should produce plenty of search hits for you, including many here at SO. The particular one you asked about expands to the value of variable `TEX`, with all the `.tex` suffixes replaced by `.dvi` (or `.ps`, or `.pdf` in the other, similar cases). – John Bollinger Aug 02 '19 at 20:32
  • thank you.. can you make this an answer? – sarah.ferguson Aug 02 '19 at 21:09
  • I could write that as an answer, but inasmuch as I have voted to close the question as a dupe, that would be a bit inconsistent. I merely summarized the relevant information from the dupe target as a convenience to you. Thanks, though. – John Bollinger Aug 02 '19 at 21:52

1 Answers1

0

That line sets DVI to the same thing as TEX but substitutes .tex for .dvi

Felipe Balbi
  • 147
  • 7