tags:

views:

25

answers:

1

ExtUtils::MakeMaker splits PERL_MM_OPT on whitespace, which means that something like the following will not work.

export PERL_MM_OPT='LIBS="-L/usr/sfw/lib -lssl -lcrypto" INC=/usr/sfw/include'

Is there a known workaround for this, or will I have to avoid using PERL_MM_OPT in this scenario?

-- update --

mobrule came up with the excellent suggestion to use tabs instead of spaces. mobrule is right about it splitting on spaces only. However, the solution doesn't work because it looks like tabs are converted to spaces in environment variables.

> cat tmp.sh 
export PERL_MM_OPT='LIBS="-L/usr/sfw/lib        -lssl   -lcrypto" INC=-I/usr/sfw/include'
echo $PERL_MM_OPT | perl -pe 's/\t/[t]/g' | perl -pe 's/ /[s]/g'

> head -1 tmp.sh | perl -pe 's/\t/[t]/g' | perl -pe 's/ /[s]/g'
export[s]PERL_MM_OPT='LIBS="-L/usr/sfw/lib[t]-lssl[t]-lcrypto"[s]INC=-I/usr/sfw/include'

> bash tmp.sh 
LIBS="-L/usr/sfw/lib[s]-lssl[s]-lcrypto"[s]INC=-I/usr/sfw/include

-- update 2 --

So, the tab suggestion worked (I was misled by the behavior of echo, and came to the wrong conclusion as to why it failed,) but it doesn't solve the problem.

Now the problem is that ExtUtils/Liblist/Kid.pm isn't expecting a leading doublequote (same result happens with singlequote.)

Unrecognized argument in LIBS ignored: '"-L/usr/sfw/lib

So, it seems that the solution to this problem (if one exists) can't depend on quotes.

+1  A: 

Actually, MakeMaker.pm splits on spaces but not on all whitespace. Could you use tabs?

export PERL_MM_OPT='LIBS="-L/usr/sfw/libTab-lsslTab-lcrypto" INC=/usr/sfw/include


I think you the way you have set environment variables with tabs is OK -- it is the echo command that is converting tabs to spaces:

$ VAR='abc^Idef'
$ echo $VAR | od -c
0000000   a   b   c       d   e   f  \n
0000010

That looks like it didn't work. But wait:

$ export VAR
$ perl -e 'print $ENV{VAR}' | od -c
0000000   a   b   c  \t   d   e   f
0000007

This still might or might not work in ExtUtils::MakeMaker depending on how the parameters in $ENV{PERL_MM_OPT} get passed to a subprocess (via system, exec, open |, etc.):

system("gcc helloworld.c -lssl\t-lcrypto\t-L/usr/sfw/lib")            ### 1 ###
system("gcc", "helloworld.c", "-lssl\t-lcrypto\t-L/usr/sfw/lib")      ### 2 ###

system call 1 will work because when the system call has one arg with any metacharacters, it passes the command to the shell. The shell will parse the arguments correctly.

system call 2 fails because multi-arg system always bypasses the shell and gcc is stuck looking for a library with the unlikely name of"libssl^I-lcrypto^I-L/usf/sfw/lib.a". If ExtUtils::MakeMaker is using this calling style to run the compiler, then this workaround won't get the job done.

mobrule
> it is the echo command that is converting tabs to spacesYou're right. The tab suggestion did work, and I came to the wrong conclusion as to why it failed.Now the problem is that ExtUtils/Liblist/Kid.pm isn't expecting a leading quote. Unrecognized argument in LIBS ignored: '"-L/usr/sfw/lib'So, it seems that the solution to this problem (if one exists) can't depend on quotes or spaces.
Jesse