Reputation: 39
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.
Upvotes: 0
Views: 144
Reputation: 25523
Well, the mistake is in the following statement:
OBJ := $(addprefix 'obj_', $(basename $(notdir /build/common.mk))) so now OBJ1 is "obj_common"
In fact, OBJ1
becomes 'obj'_common
because of quotes that you used in the first argument to addprefix
.
So without the quotes it should work fine:
OBJ := $(addprefix obj_, $(basename $(notdir /build/common.mk)))
Use warning
and error
functions for debugging your scripts:
OBJ := ...
$(warning so now OBJ1 is [$(OBJ1)])
Upvotes: 1