On 4/16/07, Rick Flower <address@hidden> wrote:
I took a different approach and listed all of the possible paths in a
variable called "OBJDIRS" and wanted to write some makefile 'code' that
could pick out the only one that exists for the directory tree where
Make was invoked from.. Below is what I was trying but found that it
would only return a valid OBJDIR when the valid directory was at the end
of the list (IIRC) or other odd conditions:
OBJDIR =
OBJDIRS := \
../../${proc}/obj/${target) \
../../${target}/obj \
../../obj/${target}
First: note that you have "${target)" - you should probably use either
"${target}" or "$(target)", rather than mix and match your parens :).
find_files = $(if $(wildcard $(dir)),OBJDIR=${dir})
OBJDIR := $(foreach dir,$(OBJDIRS),$(find_files))
$(wildcard) already operates separately on each element in the list,
so you don't need to wrap it with a $(foreach) in this case. Also, you
wouldn't want OBJDIR= in the $(if) statement, since you aren't
actually executing statements there.
Anyway, this could probably be much simplified by just doing:
OBJDIR := $(firstword $(wildcard $(OBJDIRS)))