#! /usr/local/bin/perl -w
use
5.004;
select
STDERR; $| = 1;
select
STDOUT; $| = 1;
my
$c_code
=
<<'EOF';
/* The following code only compiles if the interface to gettext is
complete. */
#include <libintl.h>
/* Handle the case that we link against GNU libintl but include a non
* GNU libintl.h. */
#ifndef __USE_GNU_GETTEXT
# error "<libintl.h> is not GNU gettext. Maybe you have to adjust your include path."
#endif
#include <locale.h>
int
main (argc, argv)
int argc;
char* argv[];
{
/* FIXME: The gettext runtime libraries provided by Solaris 8 and 9
are not sufficient. Those of Solaris 10 *may* work. To play
safe, we currently only compile the XS version for GNU gettext
and use some undocumented features, to test for that. Thanks
to Bruno Haible for the hint. */
extern int _nl_msg_cat_cntr;
#if 0
/* This seems to be defined in the GNU libc only, not in standalone
* GNU gettext. */
extern int* _nl_domain_bindings;
#endif
textdomain ("dummy");
bindtextdomain ("dummy", ".");
bind_textdomain_codeset ("dummy", "us-ascii");
gettext ("msgid");
dgettext ("dummy", "msgid");
dcgettext ("dummy", "msgid", LC_MESSAGES);
ngettext ("msgid", "msgid_plural",
#if 0
_nl_msg_cat_cntr + *_nl_domain_bindings);
#else
_nl_msg_cat_cntr);
#endif
dngettext ("dummy", "msgid", "msgid_plural", 1);
dcngettext ("dummy", "msgid", "msgid_plural", 1, LC_MESSAGES);
return 0;
}
EOF
my
$cc
=
$Config
{cc};
print
STDERR
"Checking whether we can compile the XS version ... "
;
local
*HANDLE
;
open
HANDLE,
">gettest.c"
or
die
"cannot create file 'gettest.c': $!\n"
;
print
HANDLE
$c_code
;
close
HANDLE or
die
"cannot close file 'gettest.c': $!\n"
;
my
@cmd
=
$cc
;
push
@cmd
,
$Config
{ccflags};
push
@cmd
,
$Config
{ldflags};
push
@cmd
,
$Config
{libs};
push
@cmd
,
"-o"
,
"gettest.exe"
,
"gettest.c"
;
my
$cmd
=
join
' '
,
@cmd
;
open
OLDOUT,
">&STDOUT"
or
die
"cannot dup STDOUT: $!"
;
open
OLDERR,
">&STDERR"
or
die
"cannot dup STDERR: $!"
;
open
STDOUT,
">config.log"
or
die
"cannot redirect STDOUT: $!"
;
open
STDERR,
">&STDOUT"
or
die
"cannot dup STDOUT: $!"
;
select
STDERR; $| = 1;
select
STDOUT; $| = 1;
print
"$cmd\n"
;
my
$result
=
system
$cmd
;
unless
(
$result
== 0) {
$cmd
.=
" -lintl"
;
print
"$cmd\n"
;
$result
=
system
$cmd
;
}
unless
(
$result
== 0) {
$cmd
.=
" -liconv"
;
print
"$cmd\n"
;
$result
=
system
$cmd
;
}
close
STDOUT;
close
STDERR;
open
STDOUT,
">&OLDOUT"
or
die
"cannot dup \$oldout: $!"
;
open
STDERR,
">&OLDERR"
or
die
"cannot dup OLDERR: $!"
;
close
OLDOUT;
close
OLDERR;
unless
(
$result
== 0) {
print
STDERR
<<EOF;
no
=> Cannot build the XS version of libintl-perl (see 'config.log' for
=> details). This is harmless!
EOF
}
else
{
print
STDERR
<<EOF;
ok
=> Building the XS version of libintl-perl.
EOF
}
unlink
"gettest.c"
,
"gettest.exe"
;
sub
libscan
{
my
(
$self
,
$file
) =
@_
;
return
if
'MyInstall.pm'
eq
$file
;
$self
->SUPER::libscan (
$file
);
}
sub
tools_other
{
my
$self
=
shift
;
my
$fragment
=
$self
->SUPER::tools_other (
@_
);
$fragment
=~ s/^MOD_INSTALL\s*=\s*(.*?)-MExtUtils::Install
/MOD_INSTALL =$1-MMyInstall/msx;
return
$fragment
;
}
my
$name
= $0;
$name
=~ s,Makefile\.PL$,xs_disabled,;
local
*HANDLE
;
open
HANDLE,
">$name"
or
die
"cannot open '$name' for writing: $!"
;
print
HANDLE
$result
;
close
HANDLE or
die
"cannot close '$name': $!"
;
WriteMakefile (
NAME
=>
'libintl-perl'
,
VERSION_FROM
=>
'lib/Locale/TextDomain.pm'
,
($] >= 5.005 ?
(
ABSTRACT
=>
'High-Level Interface to Uniforum Message Translation'
,
AUTHOR
=>
'Guido Flohr <guido@imperia.net>'
,
) : (),
),
PREREQ_PM
=> { File::
Spec
=> 0 },
PL_FILES
=> {},
DIR
=> [
$result
== 0 ? (
'gettext_xs'
) : ()],
);