automake
[Top][All Lists]
Advanced

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

Re: Portable $addprefix


From: Quinn Grier
Subject: Re: Portable $addprefix
Date: Mon, 28 Aug 2017 11:03:31 -0700
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 2017-08-24 19:02, Kip Warner wrote:
> Hey list,
> 
> I'd like to transform the following variable in my Makefile.am from...
> 
>     files_only = a.foo b.foo c.foo d.foo ...
> 
> Into...
> 
>     files_with_path = dir/a.foo dir/b.foo dir/c.foo dir/d.foo ...
> 
> I'm aware of GNU Make's $addprefix magic. I'm also aware it's naughty
> to use where portability is a concern and a different implementation of
> make may be used behind Automake. I was wondering if anyone has come up
> with a recipe for scenarios like this?

A portable way to do this is to do the work in configure.ac and transfer
it to the Makefile with AC_SUBST. For example, with an empty Makefile.am
and the following configure.ac:

      AC_INIT([Example], [1.0])
      AM_INIT_AUTOMAKE([foreign])

      m4_define([m_files_only], [a.foo b.foo c.foo])
      files_only='m_files_only'
      files_with_path='m4_map_args_w(m_files_only, [dir/], [], [ ])'
      AC_SUBST([files_only])
      AC_SUBST([files_with_path])

      AC_CONFIG_FILES([Makefile])
      AC_OUTPUT

The desired macros will appear in the resulting Makefile:

      files_only = a.foo b.foo c.foo
      files_with_path = dir/a.foo dir/b.foo dir/c.foo

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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