I'm trying to check if a variable contains a particular string. I've tried a solution posted here: Makefile : contains string but in my case it does not seem wot work.
@echo $(findstring 2025, $(basename $(<F)))`
returns 2025
, but :
ifeq ($(findstring 2025, $(basename $(<F))),2025)
@echo $(findstring 2025, $(basename $(<F)))
endif
does not return 2025
. Why?
If you want help, especially with makefiles, you have to provide a minimal but fully-functioning example. Makefiles are extremely context dependent, so often how something behaves depends entirely on where in the makefile it appears: is it in a recipe? In a variable assignment? Etc.
In your case, you're using ifeq
and since you don't say that you got a syntax error it must be that this is not in a recipe. ifeq
is a make keyword not a valid shell command, so it can't be in a recipe.
If you check the documentation for automatic variables like $(<F)
you'll find that they are only set in a recipe context. So you can't ever use automatic variables in ifeq
conditionals: they will always be the empty string.
Without more information on what you want to do, that's about all we can say.