automake
[Top][All Lists]
Advanced

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

Re: Portable $addprefix


From: Mathieu Lirzin
Subject: Re: Portable $addprefix
Date: Mon, 28 Aug 2017 11:31:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Kip Warner <address@hidden> writes:

> On Sun, 2017-08-27 at 19:44 +0200, Mathieu Lirzin wrote:
>> Would something like this work for you?
>> 
>>   files_with_path = `for f in $(files_only); do echo "dir/$$f"; done`
>
> Hey Mathieu,
>
> Thank you for the suggestion. I'm only hesitant to use that because I'm
> not sure if Automake needs to initialize the variable prior to emitting
> Makefile from Makefile.am. Do you know if this is the case?

'files_with_path' will not be interpreted by Automake, it will just copy
the line in the generated Makefile. Since Make variables are macros the
content of the variable will be simply be copied by Make where
$(files_with_path) is used.  As a consequence it should only be used in
the recipe of a rule, not as a target or prerequisite.

> I went to test it, but for some reason I keep getting these errors on
> that line:
>
>     Makefile:836: *** missing separator. Stop.

There is a bug in my suggestion.  I guess this error is related to that.

o--8<---------------cut here---------------start------------->8---
files_only = foo.x bar.x baz.x
files_with_path = `for f in $(files_only); do echo "dir/$$f"; done`

all:
        @echo "$(files_with_path)"
--8<---------------cut here---------------end--------------->8---

   $ make
   dir/foo.x
   dir/bar.x
   dir/baz.x
   
with that version it seems to work better:

--8<---------------cut here---------------start------------->8---
files_only = foo.x bar.x baz.x
files_with_path = `for f in $(files_only); do printf "dir/%s " $$f; done`

all:
        @echo "$(files_with_path)"
--8<---------------cut here---------------end--------------->8---

   $ make
   dir/foo.x dir/bar.x dir/baz.x 

HTH.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37



reply via email to

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