help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why doesn't this work properly?


From: Rick Flower
Subject: Re: Why doesn't this work properly?
Date: Sat, 01 Sep 2007 22:14:37 -0700
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

Philip Guenther wrote:

That requires all the possibilities to exist, and then always makes a
link to the one under 'hardware'.  There are two ways to do what you
want:

1) include a static pattern rule for each source directory:

# create static rules for all the files under .../hardware/src/
$(notdir $(filter \
    ${TOP_DIR}/teststubs/hardware/src/%,$(TESTSTUB_SOURCES))): %: \
    ${TOP_DIR}/teststubs/hardware/src/%
        ln -sf $< $@

# create static rules for all the files under .../common/src/
$(notdir $(filter \
    ${TOP_DIR}/teststubs/common/src/%,$(TESTSTUB_SOURCES))): %: \
    ${TOP_DIR}/teststubs/common/src/%
        ln -sf $< $@

I think I tried this and make was complaining about macro
redefinitions or something along those lines.  However, I'll try
it again..


2) instead of specifying the full path of each stub, just specify the name
    and let make pick the path by searching the directories in some order
    by supplying multiple pattern rules:

# make tries these in order
%: ${TOP_DIR}/teststubs/hardware/src/%
        ln -sf $< $@
%: ${TOP_DIR}/teststubs/common/src/%
        ln -sf $< $@

It helps if you can narrow down the left side of the pattern (.cc
files only?  use "%.cc", etc), or limit the files in the source
directories to exactly the files that you want link rules for, but
this method suffers from giving make rules for more than you might
want.

Cool.. I'll try that out too..

3) like (1), but use foreach and eval to generate the rules for all the
    directories in the list automatically:

# Given ${d} set to the name of a directory (with trailing slash) of
# stub sources, expand to the rule that should be eval'ed:
define link-rule
$$(notdir $$(filter ${d}%,$${TESTSTUB_SOURCES})): %: ${d}%
        ln -sf $$< $$@
endef

# eval the above link rule, setting ${d} in turn to each directory that
# contains stub sources:
$(foreach d,$(sort $(dir ${TESTSTUB_SOURCES})),$(eval ${link-rule}))

Good.. three things to try.. I like choices.. (8->

Anyway, I won't be able to try these until Tuesday.. Thanks again!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]