On Mon, Nov 25, 2002 at 10:14:07PM -0800, Michael G Schwern wrote:
>        PERLPREFIX = $(PERLRUN) -e 'q{$(PREFIX)} ? q{$$(PREFIX)} : "/usr"'
>        SITEPREFIX = $(PERLRUN) -e 'q{$(PREFIX)} ? q($$(PREFIX)} : "/opt"'
> 
> I think that'll work.  Thoughts?

Of course it was all too easy.  I'm wrong.

Values on the RHS of a macro assigment aren't run through the shell, of
course.  So the above just creates a macro containing a perl oneliner, not
the results of that one liner.

If it can be guaranteed that the *PREFIX macros, and any macro with
$(*PREFIX) in it, is always used on the shell line, this works.

        PERLPREFIX = `$(PERLRUN) -e 'q{$(PREFIX)} ? q{$(PREFIX)} : "/usr"'`
        SITEPREFIX = `$(PERLRUN) -e 'q{$(PREFIX)} ? q($(PREFIX)} : "/opt"'`

but that situation is only true on Unix, and its precarious at best. And it
means that little Perl program is run over and over and over again as the
Makefile runs, crushingly slow on Windows. Besides, I have no idea what the
portable shell equivalent to `` is.

I need some way to define a macro using the results of a shell command, as I
had originally assumed.

Otherwise, I need a portable version of this:

    if PREFIX
        PERLPREFIX = $(PREFIX)
        SITEPREFIX = $(PREFIX)
    else
        PERLPREFIX = /usr
        SITEPREFIX = /top
    endif

Gnu make can do something like that, but I doubt most other make variants
can.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
It's Airplane Glue sniffing time!

Reply via email to