[GRASS-dev] cp -r vs -R in make

Anna Petrášová kratochanna at gmail.com
Tue Jan 26 18:02:40 PST 2016


On Tue, Jan 26, 2016 at 7:28 AM, Glynn Clements <glynn at gclements.plus.com>
wrote:

>
> Anna Petrášová wrote:
>
> > cp: the -H, -L, and -P options may not be specified with the -r option.
> >
> > make: *** [install] Error 1
> >
> >
> > It seems cp -r (lowercase r) is not portable, see [1]. Mac cp man page
> says:
> >
> > Historic versions of the cp utility had a -r option. This implementation
> > supports that option; how-ever, however, ever, its use is strongly
> > discouraged, as it does not correctly copy special files, symbolic links,
> > or fifo's.
> >
> > lowercase r is used on couple of places, mainly
> include/Make/Install.make.
> > So my question is if anyone thinks there are some valid reasons for using
> > lowercase r.
>
> "cp" probably shouldn't be used at all.
>
> Executable files should be installed with $(INSTALL), non-executable
> files with $(INSTALL_DATA).
>
> In either case, they should only be used to copy a rule's prerequisite
> to its target (i.e. no unconditional "bulk" copies in the body of an
> unrelated rule), as in:
>
>         destination: source
>                 $(INSTALL_DATA) $< $@
>
> If the number of files is large, $(wildcard ...) and $(patsubst ...)
> should be used to construct a list of targets which should then be
> made prerequisites of the Makefile's "default" rule, with the
> installation performed by a pattern rule.
>
> The only places "cp" is used in the actual GRASS source tree (not
> including "addons") are in Install.make, the "install" targets of a
> couple of other *.make files, and the "update-po" target in
> locale/Makefile. None of these are part of the actual build process.
>
> (I just removed the one in simlib; Rules.make already has a pattern
> rule for installing headers).
>
> FWIW, the "portable" solution for recursive copies has historically
> been to use "tar c ... | tar x ...".
>

Thanks for the information on this. However, for now, I just fixed one of
the usages in Script.make (by changing -r to -R) to be able to install the
addon, since I can't fix it properly.

Anna

>
> --
> Glynn Clements <glynn at gclements.plus.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20160126/2187b9ff/attachment.html>


More information about the grass-dev mailing list