So, I have the following code:
OBJ := $(addprefix 'obj_', $(basename $(notdir /build/common.mk)))
so now OBJ1 is “obj_common”
ifeq ($(OBJ),obj_common)
@echo equal (**don't know how to format indent in this website..assume there is.**)
endif
the ifeq can’t compare $(OBJ) to obj_common, at least it didn’t echo…
(However, if I get rid of addprefix function as follow:)
OBJ := $(basename $(notdir /build/common.mk))
so now OBJ1 is “common”
ifeq ($(OBJ),common)
@echo equal
endif
this code would echo, which means they can compare and are equal.
I need to reference the variable $(OBJ_common) (I have a big list of this kind of variable, so I can’t manually input the string by hand), but now addprefix function makes this string not a string…
Could anyone please help me resolve the issue? If my question is not clear, please let me know. Thank you very much.
Well, the mistake is in the following statement:
In fact,
OBJ1becomes'obj'_commonbecause of quotes that you used in the first argument toaddprefix.So without the quotes it should work fine:
Tip
Use
warninganderrorfunctions for debugging your scripts: