makefilecflags

Makefile CFLAGS and SRCS-y are ignored in function form


I have some trouble with making Makefile. This is a part of Makefile.

dirs := fwd common bp bp_manager $(XRTE_HASH)
VPATH_ = $(foreach dir,$(dirs),$(SRCDIR)/$(dir))
INC_ = $(foreach dir,$(dirs),$(wildcard $(dir)/*.h))
CFLAGS_ = $(foreach dir,$(dirs),-I$(SRCDIR)/$(dir))   
SRCS-y_ = $(foreach dir,$(dirs),$(notdir $(wildcard $(dir)/*.c))) 
VPATH += $(VPATH_)
INC += $(INC_)
CFLAGS += $(CFLAGS_)
SRCS-y += $(SRCS-y_)

check: 
    echo $(CFLAGS)
    echo $(SRCS-y)

I thought Makefile is almost same with csh. Can you explain me why the "make" ignores functions? Thanks.


Solution

  • CFLAGS_ is just a string. $(CFLAGS_) is a variable's value. So you should have:

    CFLAGS += $(CFLAGS_)
    SRCS-y += $(SRCS-y_)