----- Original Message -----
From: "John R. Hogerhuis" <jho...@pobox.com>
To: <inline@perl.org>
Sent: Wednesday, January 28, 2009 8:09 AM
Subject: conditional use Inline for windows vs. linux
I need parts of
use Inline =>
to be conditional on platform ($^O)
i.e., different LIB and INC name value pairs depending on windows vs
linux.
Here's one way that works for me in an actual script (that I've just
modified to verify that it does, in fact, work):
###############################################
use warnings;
use strict;
BEGIN{
$main::inc = $^O =~ /MSWin32/i ? '-IC:/_32/msys/1.0/local/include' :
'-I/home/me/elsewhere/include';
$main::libs = $^O =~ /MSWin32/i ? '-LC:/_32/msys/1.0/local/lib -lgmp' :
'-L/home/me/elsewhere/lib -lgmp';
$main::typemaps = $^O =~ /MSWin32/i ?
'C:/_32/comp/working/math-gmpq/Math-GMPq-0.27/typemap' :
'-I/home/me/elsewhere/typemap';
};
use Inline C => Config =>
INC => $main::inc,
LIBS => $main::libs,
TYPEMAPS => $main::typemaps,
BUILD_NOISY => 1;
use Inline C => <<'EOC';
/* The Inline::C functions /*
###############################################
If you don't 'use strict;' you can dispense with the 'main::' crap - ie just
name the variables $inc, $libs and $typemaps (or whatever).
Cheers,
Rob