|
From: | Boris Godin |
Subject: | Re: Multiple target patterns |
Date: | Thu, 12 Jun 2008 15:40:48 -0300 |
User-agent: | Thunderbird 2.0.0.14 (Windows/20080421) |
Yeah, but there is another way to do it. Instead of using patterns, I use a variable to hold all source files and then I create a rule for every one of them. DIRS_SOURCE = src1 src2 PATHS_INSIDE_SOURCE = . dir1 dir2 EXTENSIONS_SRC = .c #Source files without leading src1 or src2, sort is for remove duplicates (if not, we will create duplicate rules) SRC_FILES = $(sort \ $(foreach DIR,$(DIRS_SOURCE), \ $(foreach DIR1,$(PATHS_INSIDE_SOURCE), \ $(foreach EXT,$(EXTENSIONS_SRC), \ $(subst $(DIR)/,,$(wildcard $(DIR)/$(DIR1)/*$(EXT))) \ ) \ ) \ ) \ ) DIR_BUILD_SRC = store BUILD_SRC_FILES = $(foreach FILE,$(SRC_FILES),$(DIR_BUILD_SRC)/$(FILE)) all: $(BUILD_SRC_FILES) #------------------------------------------------------------------------------- # Parameters: # 1) filename with path inside source folder # 2) directory where combined file will be stored # 3) directories where to look for file (src1 src2) #------------------------------------------------------------------------------- define COMBINE_FILES $(2)/$(1): $(wildcard $(foreach DIR,$(3),$(DIR)/$(1))) @echo combine $$? into $$@; endef $(foreach FILE,$(SRC_FILES),\ $(eval $(call COMBINE_FILES,$(FILE),$(DIR_BUILD_SRC),$(DIRS_SOURCE)))\ ) Thanks! Paul Smith wrote: On Thu, 2008-06-12 at 11:58 -0300, Boris Godin wrote:I tried this but it's not working. I think it's because make gives priority to wildcard before %That won't work. It's not a priority issue, it's an expansion order issue. Expansion of targets and prerequisites, even for pattern rules, are expanded as the makefile is read in. That's when all variables and functions are handled, and it's long before make tries to find rules that match various patterns and expands the "%" tokens in pattern rules. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
[Prev in Thread] | Current Thread | [Next in Thread] |