0

I have a latex project containing at least two options: printable (witch put clickable link on footnote) and monochrome (witch put the wool document on black). This options could be used as single option or, it could be used at the same time (if I want a monochrome document with the links in footnotes).

So, this is the skeleton of my makefile:

 printable:
     ${TEX} -jobname=${NAME} "\def\isprintable{1} \input{main.tex}"

 monochrome:
     ${TEX} -jobname=${NAME} "\def\ismonochrome{1} \input{main.tex}"

This code only permit me to get a document on a printable format Xor a monochrome document. But not twice on the same time.

I tried the target printable monochrome: but in this case, I always get a a printable and monochrome document, also when I invoke make with only on of printable or monochrome target. I can’t get an only monochrome document or an only printable document.

So, is it possible to make an ifthen structure before the targets on the makefile to evaluate the targets pasted to make before execute it?

Something like:

if targets contain monochrome
     then: ARG=${ARG} "\def\ismonochrome{1}"

if tragets contain printable
     then: ARG=${ARG} "\def\isprintable{1}"

${TEX} -jobname=${NAME} "${ARG} \input{main.tex}"

Is it possible to do this with a makefile or I have to develop another way?

fauve
  • 226
  • 1
  • 10

1 Answers1

0
ifdef MONOCHROME
ARGS += \\def\\ismonochrome{1}
endif

ifdef PRINTABLE
ARGS += \\def\\isprintable{1}
endif

project:
    ${TEX} -jobname=${NAME} \"$(ARGS)\"

You can invoke this with, e.g.

make MONOCHROME=true PRINTABLE=yes

Notice that some "escaping" may be necessary to deal with double-quotes, back-slashes and other special characters; this may require some fine-tuning on your system.

Beta
  • 96,650
  • 16
  • 149
  • 150
  • It seems working except one detail: the `+=` operator put a space between the first content and the next content. For example, with `VAR+=1 ; VAR+=2` the variable `VAR` will be equal to `1 2` and not `12`. There is a way to fix that? Another concatenation operator, perhaps? – fauve Apr 02 '15 at 22:25
  • The best operator to use here is `:=`. He didn’t put space. So, could you @Beta edit your post to correct it for other users? Thank you. – fauve Apr 02 '15 at 23:15
  • @fauve: The space is there by design; your question is not entirely clear, but it strongly suggests that to omit the space would be wrong. You might consider editing your question to show the desired command line. – Beta Apr 02 '15 at 23:47
  • Yes you're right. I define another variable (witch note include commands but suffxes of the name’s output like “-print” and “-monochrome”). So, the answer you give is correct. That’s all :) – fauve Apr 03 '15 at 00:02