Author image Vadim Zeitlin
and 1 contributors

NAME

Makefile::Update::Makefile - Update lists of files in makefile variables.

VERSION

version 0.4

SYNOPSIS

This can be used to update the contents of a variable containing a list of files in a makefile.

    use Makefile::Update::Makefile;
    Makefile::Update::upmake('GNUmakefile', \&update_makefile, $vars);

FUNCTIONS

update_makefile

Update variable definitions in a makefile format with the data from the hash ref containing all the file lists.

Only most straightforward cases of variable or target definitions are recognized here, i.e. just "var := value", "var = value" or "target: value". In particular we don't support any GNU make extensions such as "export" or "override" without speaking of anything more complex.

On top of it, currently the value should contain a single file per line with none at all on the first line (but this restriction could be relaxed later if needed), i.e. the only supported case is

    var = \
          foo \
          bar \
          baz

and it must be followed by an empty line, too.

Notice that if any of the "files" in the variable value looks like a makefile variable, i.e. has "$(foo)" form, it is ignored by this function, i.e. not removed even if it doesn't appear in the list of files (which will never be the case normally).

Takes the (open) file handles of the files to read and to write and the file lists hash ref as arguments.

Returns 1 if any changes were made.

SEE ALSO

Makefile::Update

AUTHOR

Vadim Zeitlin <vz-cpan@zeitlins.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Vadim Zeitlin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.