all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Calling functions in `make-flags'
@ 2014-02-22  1:13 Sree Harsha Totakura
  2014-02-22  7:34 ` Mark H Weaver
  0 siblings, 1 reply; 5+ messages in thread
From: Sree Harsha Totakura @ 2014-02-22  1:13 UTC (permalink / raw)
  To: guix-devel

Hi,

I am trying to build a package which does not have 'configure' script.
It instead relies solely on a makefile.  For this to function, I have to
set the 'SH' variable inside the Makefile to a valid shell.

I am trying to set the 'SH' variable through build-flags like this:
> (arguments
>     '(#:make-flags '((string-append "SH=" (which "sh")))

But this fails with the following error:

> 203: 1 [build #:make-flags ((string-append "SH=" (which "sh"))) ...]
> In unknown file:
>    ?: 0 [system* "make" "-j" "4" (string-append "SH=" (which "sh"))]
> 
> ERROR: In procedure system*:
> ERROR: Wrong type (expecting string): (string-append "SH=" (which "sh"))

How can I get this to work?

Regards,
Sree

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Calling functions in `make-flags'
  2014-02-22  1:13 Calling functions in `make-flags' Sree Harsha Totakura
@ 2014-02-22  7:34 ` Mark H Weaver
  2014-02-22  9:07   ` Sree Harsha Totakura
  0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2014-02-22  7:34 UTC (permalink / raw)
  To: Sree Harsha Totakura; +Cc: guix-devel

Sree Harsha Totakura <sreeharsha@totakura.in> writes:

> Hi,
>
> I am trying to build a package which does not have 'configure' script.
> It instead relies solely on a makefile.  For this to function, I have to
> set the 'SH' variable inside the Makefile to a valid shell.
>
> I am trying to set the 'SH' variable through build-flags like this:
>> (arguments
>>     '(#:make-flags '((string-append "SH=" (which "sh")))

Try this instead:

  (arguments
   '(#:make-flags (list (string-append "SH=" (which "sh")))
     ...))

If that doesn't work, then try this:

  (arguments
   '(#:make-flags (list (string-append "SH="
                                       (assoc-ref %build-inputs "bash")
                                       "/bin/sh"))
     ...))

I don't have time at the moment to research whether the first one would
work (it depends on when the code is evaluated), but I didn't want to
keep you waiting.

      Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Calling functions in `make-flags'
  2014-02-22  7:34 ` Mark H Weaver
@ 2014-02-22  9:07   ` Sree Harsha Totakura
  2014-02-23  6:20     ` Mark H Weaver
  0 siblings, 1 reply; 5+ messages in thread
From: Sree Harsha Totakura @ 2014-02-22  9:07 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel

On 02/22/2014 08:34 AM, Mark H Weaver wrote:
> Try this instead:
> 
>   (arguments
>    '(#:make-flags (list (string-append "SH=" (which "sh")))
>      ...))
> 

That did not work, but the following did:

> If that doesn't work, then try this:
> 
>   (arguments
>    '(#:make-flags (list (string-append "SH="
>                                        (assoc-ref %build-inputs "bash")
>                                        "/bin/sh"))
>      ...))

Can you explain why my earlier code did not work?

Sree

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Calling functions in `make-flags'
  2014-02-22  9:07   ` Sree Harsha Totakura
@ 2014-02-23  6:20     ` Mark H Weaver
  2014-02-23  7:28       ` Sree Harsha Totakura
  0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2014-02-23  6:20 UTC (permalink / raw)
  To: Sree Harsha Totakura; +Cc: guix-devel

Sree Harsha Totakura <sreeharsha@totakura.in> writes:
> Can you explain why my earlier code did not work?

Your earlier code was:

> (arguments
>     '(#:make-flags '((string-append "SH=" (which "sh")))

The expression immediately following "#:make-flags" is evaluated to
produce the list of make flags.  In this case, that expression is:

  '((string-append "SH=" (which "sh")))

The single-quote at the beginning means that this is a literal
expression.  In other words, it inhibits evaluation of all nested forms
within, and simply returns the following datum:

  ((string-append "SH=" (which "sh")))

i.e. a list containing one element:

  (string-append "SH=" (which "sh"))

which is a list whose first element is the symbol 'string-append', whose
second element is the string "SH=", etc.

What you want it to return is something like this:

  ("SH=/nix/store/1bjqv56slfsgpfs0dngj9zww1mx9ikny-bash-4.2/bin/sh")

In other words, you need it to evaluate (string-append "SH=" ...)
instead of returning that code as a data structure.

One way to do this is to use (list (string-append "SH=" ...)).  Whereas
the single-quote inhibits evaluation of all forms within, 'list' is a
normal procedure that evaluates its arguments before combining the
results into a list.

Another way is to use quasiquote (`), and to unquote (,) the inner
expressions that you'd like to evaluate:

  `(,(string-append "SH=" ...))

In this case, I think the quasiquote doesn't add much readability, but
it's a matter of taste I suppose.

As for why 'which' didn't work, I suspect it's because this code is
evaluated very early in the build process, before the PATH variable has
been set.

You can use 'which' in the code segments passed to #:phases because
those are wrapped with 'lambda', which defines an anonymous procedure.
The procedure returned by that lambda expression is not called until
it's time to run the phase.  At that point, PATH is set.

Does that make sense?

    Regards,
      Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Calling functions in `make-flags'
  2014-02-23  6:20     ` Mark H Weaver
@ 2014-02-23  7:28       ` Sree Harsha Totakura
  0 siblings, 0 replies; 5+ messages in thread
From: Sree Harsha Totakura @ 2014-02-23  7:28 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel

On 02/23/2014 07:20 AM, Mark H Weaver wrote:
> As for why 'which' didn't work, I suspect it's because this code is
> evaluated very early in the build process, before the PATH variable has
> been set.
> 
> You can use 'which' in the code segments passed to #:phases because
> those are wrapped with 'lambda', which defines an anonymous procedure.
> The procedure returned by that lambda expression is not called until
> it's time to run the phase.  At that point, PATH is set.
> 
> Does that make sense?

Yes, a lot! :-)

Thank you Mark.

Sree

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-02-23  7:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-22  1:13 Calling functions in `make-flags' Sree Harsha Totakura
2014-02-22  7:34 ` Mark H Weaver
2014-02-22  9:07   ` Sree Harsha Totakura
2014-02-23  6:20     ` Mark H Weaver
2014-02-23  7:28       ` Sree Harsha Totakura

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.