On Tue, Mar 20, 2012 at 15:47, Nick Bowler <nbow...@elliptictech.com> wrote: > On 2012-03-20 07:00 +0900, Miles Bader wrote: >> Is there a recommended way for dealing with binaries that are simple >> shell scripts in automake? I currently use something like the >> following: >> >> bin_PROGRAMS = myprog >> >> myprog_SOURCES = myprog.sh >> myprog: myprog.sh >> >> %: %.sh >> $(shbin_verbose)cp $< $@; chmod +x $@ > > Notwithstanding what others have already said, the above rule has some > issues of its own: > > (1) If the "chmod" command fails: the failure will be noticed (make > will stop), but the target file has already been created at this > point. The target will thus be considered up-to-date on a > subsequent make run, despite the fact that it was not created > correctly. > > (2) If the "cp" command fails: the chmod is still attempted, which may > succeed if the target file exists but is out-of-date. If chmod > succeeds, the failure will not be noticed by make, and the build > will continue using an out-of-date target. > > Moreover, the use of GNU make-specific pattern rules here is pointless > because the same can be accomplished by a more portable single-suffix > rule. > > Better to write it as follows: > > SUFFIXES = .sh > > .sh: > $(shbin_verbose) cp $< $@.tmp > $(AM_V_at) chmod +x $@.tmp > $(AM_V_at) mv -f $@.tmp $@ >
Why do not use install(1) instead of cp(1)+chmod(1) or cp(1)+chmod(1)+mv(1)? -- Andrew W. Nosenko <andrew.w.nose...@gmail.com>