I am using target-specific variable values in make, they are OK but it's not applied in targets and prerequisites, just in recipes. Here is the Makefile:
CXX := g++
TARGET := exec
BIN.PATH =
SOURCES := $(wildcard *.cpp)
OBJECTS.NAME := $(patsubst %.cpp, %.o, $(SOURCES))
OBJECTS.PATH = $(addprefix $(BIN.PATH)/, $(OBJECTS.NAME))
debug: BIN.PATH = debug
debug: $(TARGET)
$(TARGET): $(OBJECTS.PATH)
@echo $(BIN.PATH) # debug
@echo $(OBJECTS.PATH) # debug/main.o
@echo $^ # /main.o
# ...
$(BIN.PATH)/%.o: %.cpp
@echo $@ # /main.o
# ...
Any ideas how to fix it? Or it's not possible?