[Top][All Lists]

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

Re: Portable $addprefix

From: Quinn Grier
Subject: Re: Portable $addprefix
Date: Fri, 1 Sep 2017 20:27:02 -0700
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 2017-09-01 17:34, Kip Warner wrote:
> On Mon, 2017-08-28 at 11:03 -0700, Quinn Grier wrote:
>> A portable way to do this is to do the work in and
>> transfer
>> it to the Makefile with AC_SUBST. For example, with an empty
>> and the following
>>       AC_INIT([Example], [1.0])
>>       AM_INIT_AUTOMAKE([foreign])
>>       m4_define([m_files_only], [])
>>       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 =
>>       files_with_path = dir/ dir/ dir/
> Hey Quinn. This would have worked perfectly, except automake bails when
> I run autoreconf:
>     autoreconf: running: automake --add-missing --copy --no-force
> error: 'parser_clobbered_source_full_paths' includes 
> configure substitution     '@parser    _clobbered_source_full_paths@'
> and is referred to from 
> 'nodist_narayan_designer_SOURCES';
> configure substitutions are not allowed in _SOURCES 
> variables
>     autoreconf: automake failed with exit status: 1
> This is likely because as the message says, I am attempting to use the
> substitution within a *_SOURCES variable.
> Is this a dead end or is there a workaround? Assume a reference within
> a _SOURCES variable is probably necessary.

You can fix this by generating the complete macro definitions before
Automake runs and including them in

One way you can do this is with a shell script that you must run before
autoreconf. For example:

      for f in $files_only; do
        files_with_path=$files_with_path\ $files_path$f
      echo files_only = \
        $files_only > || exit 1
      echo files_with_path = \
        $files_with_path > || exit 1

And, inside, you add these lines:


This is a natural fit if you're already using an script, as
you can put this code in there. If you're not using one, then this would
essentially force you to start using one, as you need to remember to run
this code before autoreconf.

Another idea is to generate the .am files in at M4 time,
which should cause autoreconf to generate them before it runs Automake.
In this case, an script is unnecessary.

Here is an example that does this:

      AC_INIT([Example], [1.0])

      m4_define([m_files_only], [[]])
      m4_define([m_files_path], [[[dir/]]])
                                        m_files_path, [], [ ])))
      m4_syscmd([echo files_only = ]dnl
                m_files_only[ >])
      m4_assert(m4_sysval[ == 0])
      m4_syscmd([echo files_with_path = ]dnl
                m_files_with_path[ >])
      m4_assert(m4_sysval[ == 0])


And here is the accompanying example

      bin_PROGRAMS = foo
      foo_SOURCES = foo.c $(files_with_path)

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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