help-make
[Top][All Lists]
Advanced

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

setting a variable only on condition that a rule is applied?


From: David Wuertele
Subject: setting a variable only on condition that a rule is applied?
Date: Mon, 29 Mar 2004 11:16:01 -0800
User-agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.2 (gnu/linux)

Can I set a variable only on condition that a rule is applied?  For
example:

# Running "make rule1" should echo "rule1text" on the console.

rule1: dorule1 print
rule2: dorule2 print

dorule1:
        @echo in rule1
        RULE_DEPENDENT_VAR+=rule1text

dorule2:
        @echo in rule2
        RULE_DEPENDENT_VAR+=rule2text

print:
        @echo $(RULE_DEPENDENT_VAR)

(Unforunately, the above results in the error
 "RULE_DEPENDENT_VAR+=rule1text: command not found")

Goal:
I have some rules that unpacks some sources, applies patches, and
builds.  The rules are designed so that the sources can be .tar.gz or
.tar.bz2 (and many other options as well).  At the end of building
everything, I want to copy all sources into a package, but I only want
to copy the version that was actually used.  Here is an example:

$(BUILD)/%/.unpacked: $(TARBALLS)/%.tar.gz
        rm -rf $(@D)
        mkdir -p $(BUILD)
        cd $(BUILD) && tar xvzf $<

$(BUILD)/%/.unpacked: $(TARBALLS)/%.tar.bz2
        rm -rf $(@D)
        mkdir -p $(BUILD)
        cd $(BUILD) && tar xvjf $<

I would like to have a variable called something like MANIFEST that
gets appended to automatically when one of the above rules is
invoked.  For example, if I have the files

          fred.tar.gz
          fred.tar.bz2

in my sources directory, and I do a build, maybe "fred.tar.gz" will
get unpacked, maybe "fred.tar.bz2" will get unpacked.  Only one gets
unpacked.  I want THAT one to be added to MANIFEST.  So, if the first
rule (the tar.gz rule) was activated, I want MANIFEST to contain
"fred.tar.gz", and if the second rule was activated, I want MANIFEST
to contain "fred.tar.bz2".

Is there an easy way to accomplish this?





reply via email to

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