Subject: [bug#30147] Simplify “scripts/guix”

From: Mathieu Lirzin <[email-masked]>
Date: Tue, 23 Jan 2018 12:06:40 +0100

Eric Bavier <[email-masked]> writes:

> On Wed, 17 Jan 2018 20:25:14 +0100
> Mathieu Lirzin <[email-masked]> wrote:
>
>> This moves the complexity of Autotools variable expansion outside of the
>> application code.
>> 
>> * scripts/guix.in (config-lookup): Delete.
>> (maybe-augment-load-paths!, run-guix-main): Use fully expanded variables
>> instead of calling ‘config-lookup’.
>> * configure.ac: Don't use AC_CONFIG_FILES for ‘scripts/guix’.
>> * Makefile.am (scripts/guix): New rule.
>> (do_subst): New variable.
>> (CLEANFILES, EXTRA_DIST): Adapt.
>
> FWIW this is what my Joy compiler does for its entry script.  It works
> well.
>
> https://notabug.org/bavier/joy-in-the-morning.git

Thanks for sharing your Joy. :-)

>> +scripts/guix: scripts/guix.in Makefile
>> +	$(AM_V_GEN)rm -f $@ $@-t \
>> +	  && $(MKDIR_P) $(@D) \
>> +	  && $(do_subst) <$(srcdir)/$@.in >$@-t \
>> +	  && chmod a+x,a-w $@-t && mv -f $@-t $@
>
> I think. since there's no state variables that needs to carry accross
> commands, that this would read better without the line continuations and
> appropriate use of $(AM_V_at).
>
> While we're looking at it: I'm not certain, but I think Guix currently
> work if one overrides the "prefix" variable when invoking 'make
> install', which is a use-case suggested by the GNU Coding Standards
> (Section 7.2.5).

I had this in mind too, but I am not sure how to achieve that.
Generating scripts that depend on $(prefix) at make time is indeed a
first start in conforming to that GCS requirement.  However in practice
I don't know any GNU package that conform to it.

> I bring it up because adding '$(prefix)/bin/guix' to the above rule
> might be a start.

If you mean:

--8<---------------cut here---------------start------------->8---
$(prefix)/bin/guix scripts/guix: scripts/guix.in Makefile
	...
--8<---------------cut here---------------end--------------->8---

I don't think it would work.  Installed files are not part of the
dependency graph, so I don't think this rule would be triggered when
doing ‘make install’.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37