Reputation: 8098
Assume I have two source directories:
I create file list for srcdir0
and srcdir1
S0SRCS := $(wildcard $(srcdir0)/*.c)
S1SRCS := $(wildcard $(srcdir1)/*.c)
I'm trying to create a final list that has the base srcdir0
files but are substituted by srcdir1
files of the same name. In other words the srcdir1
files take precedence.
I'm thinking that the filter
or filter-out
functions may be my friend here but I'm not experienced enough to know better.
Upvotes: 0
Views: 49
Reputation: 2898
I think it suffices to filter out the names from the S1
directory from the names of the S0
:
S0NAMES := $(notdir $(S0SRCS))
S1NAMES := $(notdir $(S1SRCS))
FINAL-LIST := $(addprefix $(srcdir0)/,$(filter-out $(S1NAMES),$(S0NAMES))) $(S1SRCS)
Please test this first, I didn't have the opportunity to do so and wrote it just off the top of my head.
Upvotes: 3