First: I'm pretty new to linux and I'm already sorry for asking a probably dumb question.
I have a makefile that compiles a latex text into a pdf. That creates a logfile and I have to search for a string in that log file and compile again if the string is in the log-file.
So everything works fine until to the point of my if-statement.
I'm trying to check for the sub-string with the grep command but dont get it to work.
In my solution the if statement is executed even if the substring is not in my logfile.
GREP_FINDINGS := $(shell grep 'undefhrined' linux-20.log)
all: clean linux-20.pdf
ifeq ($(GREP_FINDINGS),)
pdflatex linux-20
endif
linux-20.pdf:
pdflatex linux-20
bibtex linux-20
pdflatex linux-20
.PHONY: clean
clean:
echo Cleaning .aux .bbl .blg .log files
-rm -f *.aux *.bbl *.blg *.log *.pdf
echo Cleaning complete.
CodePudding user response:
Some parts of this question make me uneasy (such as something being undefined after the first pass but all square after the second -- or third?), but if what you're asking for is actually what you want, then I'd put the conditional inside the rule:
linux-20.pdf:
pdflatex linux-20
bibtex linux-20
pdflatex linux-20
!(grep undefined linux-20.log) || pdflatex linux-20