Matt Czar
Matt Czar

Reputation: 11

Makefile with shell command grep

I am having an issue i have beating my head in with all morning. I am a newbie to modifying makefiles so i have come across an issue i do not know how to solve. I am trying to search through a directory for any files ending in 'Findings.txt' that has the string 'No Findings!' contained inside it. For some reason i cannot get my conditional statement to work properly. I am assuming it might have to do with the wildcard character but everything i have tried has not worked including the wilcard function. My only othera thought is the shell might have an issue with a variable in the path.

GREP_FINDINGS := $(shell grep 'No Findings'  $(C_DIR)/*Findings.txt)

I want to conditionalize the output of the grep result but i am doing something wrong.

ifeq ($(GREP_FINDINGS), )
    @echo "Nothing was found for current build"    
else  
    @echo "***Found string in Findings.txt***"
endif               

Upvotes: 1

Views: 10274

Answers (1)

Thor
Thor

Reputation: 47109

Makefiles are generally case sensitive, so you need to use ifeq and else, the following works here with GNU Make:

ifeq ($(GREP_FINDINGS), )
  @echo true
else
  @echo false
endif

You might also want to check this out.

Upvotes: 3

Related Questions