help-make
[Top][All Lists]
Advanced

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

Compute dependencies from target name


From: Stefan Monnier
Subject: Compute dependencies from target name
Date: Sat, 12 Dec 2020 23:40:15 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

I'm trying to make a rule along the following lines:

    packages/%.tar.gz : $(shell find packages/% -name '*.el' -print | sed 
's/\.el/.elc/')
        tar -zcf packages/$*.tar.gz packages/$*

I expect the `%` which appears within the $(shell..) to be replaced with
the target's stem, but tests indicate that obviously this is not how
it works.  I think this is related to what the manual says:

       Note that expansion using '%' in pattern rules occurs *after* any
    variable or function expansions, which take place when the makefile is
    read.  *Note How to Use Variables: Using Variables, and *note Functions
    for Transforming Text: Functions.

But I don't know how to work around that.  So far I've been using
a function to generate instances of this rule for the `packages/<foo>`
that are currently found in the filesystem, but I now need to change my
rule so it applies for arbitrary values that match the pattern (I can't
enumerate them beforehand).

I know how to get the result with an indirection like

    packages/%.tar.gz :
        $(MAKE) $(shell find packages/$* -name '*.el' -print | sed 
's/\.el/.elc/')
        tar -zcf packages/$*.tar.gz packages/$*

But ... is there really no way to get what I want more directly?


        Stefan




reply via email to

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