0

I am using the following makefile to run the command

texi2pdf 06a-amcoh.texi

But I also have two other files, namely 06a-amcoh-igm.texi and 06a-amcoh-rfc.texi, which I also want to be able to call texi2pdf 06a-amcoh-igm.texi and texi2pdf 06a-amcoh-rfc.texi.

How may I modify the makefile to be able to call texi2pdf for the specific files.

.PHONY: all new again clean

ch6 := $(wildcard *amcoh.texi)
igm := $(wildcard *igm.texi)
rfc := $(wildcard *rfc.texi)

pdfs := $(tfiles:.texi=.pdf)

all: ${pdfs}

%.pdf: %.texi
    texi2pdf $< -o $@

clean:
    rm -f ${pdfs}

again:
    ${MAKE} clean
    ${MAKE}

new:
    ${MAKE} again
0

change

pdfs := 06a-amcoh.pdf

to

pdfs := 06a-amcoh.pdf 06a-amcoh-igm.pdf 06a-amcoh-rfc.pdf
0

You need to include their names in the pdfs list.

But the idiomatic way to do it is to start from source (in your case the .texi files) and from them, dynamically generate the output list (in your case .pdf files)

Also, you should mark the targets as .PHONY for which no corresponding file exists.

.PHONY: all new again clean ch6 igm rf 

ch6 := $(wildcard *amcoh.texi)
igm := $(wildcard *igm.texi)
rfc := $(wildcard *rfc.texi)

tfiles := $(ch6) $(igm) $(rfc)
pdfs := $(tfiles:.texi=.pdf)

define mkRule
$(eval $1: $$(filter $$($1:.texi=.pdf),$$(pdfs)))
endef
$(call mkRule,ch6)
$(call mkRule,igm)
$(call mkRule,rfc)

all: ${pdfs}

%.pdf: %.texi
    texi2pdf $< -o $@

clean:
    rm -f ${pdfs}

again:
    ${MAKE} clean
    ${MAKE} all

new:
    ${MAKE} again

Now invoke make as :

make igm    #to process *igm.texi 
10
  • One difficulty is that I do not want to run texi2pdf automatically on all files. But, rather, I want to instruct make which file to use,
    – Pietru
    Jun 28 at 4:02
  • Then list them out individually in that case. My answer is edited to reflect that
    – guest_7
    Jun 28 at 4:05
  • Thanks. Still I find a problem because I have to modify the makefile everytime I want to run texi2pdf on a different file.
    – Pietru
    Jun 28 at 4:14
  • If you don't want to touch the Makefile, then supply the .texi files to make from the command line in that case.
    – guest_7
    Jun 28 at 4:26
  • Would need different strings that I can pass to make, so it will run the command on the appropriate file. Would need to pass something to the command line as you say.
    – Pietru
    Jun 28 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.