automake
[Top][All Lists]
Advanced

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

Re: dealing with executable shell scripts


From: Nick Bowler
Subject: Re: dealing with executable shell scripts
Date: Tue, 20 Mar 2012 09:47:39 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

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 $< address@hidden
        $(AM_V_at) chmod +x address@hidden
        $(AM_V_at) mv -f address@hidden $@

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)




reply via email to

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