Skip Menu |

This queue is for tickets about the Gettext CPAN distribution.

Report information
The Basics
Id: 16098
Status: open
Priority: 0/
Queue: Gettext

People
Owner: Nobody in particular
Requestors: nospam [...] spamerado.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.05
  • 1.07
Fixed in: (no value)



Subject: Makefile PL does not detect libintl on FreeBSD with fix
Makefile.PL does not detect libintl on FreeBSD, here is the new Makefile.PL that works: use ExtUtils::MakeMaker; use Config; my $cc; if (defined($ENV{'CC'})) { $cc = $ENV{'CC'}; } else { $cc = $Config{'cc'}; } my $libs = ''; unless (conftest("char *x = gettext(\"foo\");", "gettext", 0)) { # try with -lintl $libs = "-lintl -liconv"; unless (conftest("char *x = gettext(\"foo\");", "gettext", 0)) { unlink("conftest.c"); unlink("conftest"); die "gettext function not found. Please install libintl"; } } open(CONFIG, ">config.h"); print CONFIG "/* Generated automatically by ", $0, ". Do not edit */\n"; conftest("char *x = dcgettext(\"foo\", \"bar\", 0);", "dgettext", 1); conftest("char *x = ngettext(\"foo\", \"foos\", 1);", "ngettext", 1); conftest("char *x = bind_textdomain_codeset(\"foo\", \"UTF-8\");", "bind_textdomain_codeset", 1); close CONFIG; unlink("conftest.c"); unlink("conftest"); WriteMakefile( NAME => "Locale::gettext", LIBS => ($libs eq '') ? [] : [$libs], VERSION_FROM => 'gettext.pm', ); sub conftest { my ($testcode, $func, $record) = @_; print "checking for ", $func; print(" in ", $libs) if ($libs ne ''); print "..."; open(TEST, ">conftest.c"); print TEST "#include <libintl.h>\n\nint main(int argc, char **argv)\n{\n"; print TEST $testcode; print TEST "return 0;}\n"; close TEST; open(SAVE, ">&STDERR"); open(STDERR, ">/dev/null"); system($cc . " -L/usr/local/lib -I/usr/local/include -o conftest conftest.c " . $libs); my $exitstatus = $?; open(STDERR, ">&SAVE"); if ($exitstatus != 0) { print " no\n"; return 0; } else { print " yes\n"; if ($record) { print CONFIG "#define HAVE_", uc($func), "\n"; } return 1; } }
From: nospam [...] spamerado.com
I forgot to mention that gettext.xs should be modified to include the full include path in: #include <libintl.h> must be changed for #include </usr/local/include/libintl.h>
From: Phillip Vandry <vandry [...] TZoNE.ORG>
Date: Thu, 24 Nov 2005 16:13:17 -0500
To: Guest via RT <bug-Gettext [...] rt.cpan.org>
CC: undisclosed-recipients: ;
Subject: Re: [cpan #16098] Makefile PL does not detect libintl on FreeBSD with fix
RT-Send-Cc:
On Thu, Nov 24, 2005 at 03:52:27PM -0500, Guest via RT wrote: Show quoted text
> Makefile.PL does not detect libintl on FreeBSD, here is the new Makefile.PL > that works:
To summarize, you are proposing this: 14c14 < $libs = "-lintl"; --- Show quoted text
> $libs = "-lintl -liconv";
53c53 < system($cc . " -o conftest " . $libs . " conftest.c"); --- Show quoted text
> system($cc . " -L/usr/local/lib -I/usr/local/include -o conftest conft
est.c " . $libs); Firstly, do you really need to specify -liconv? What is the dependancy that including this resolves? If it is implicitely required by libintl by the way, then libintl should pull it in automatically. I'm concerned how systems that do not require -liconv behave with this change. Second, I quite disagree with hardcoding -L/usr/local/lib -I/usr/local/include . Your libintl is installed in /usr/local? I'm not sure how to deal with that except by adding a much more comprehensive autoconfiguration function. Let me see what some other packages do. Also your followup suggestion, #include </usr/local/include/libintl.h> is no good at all, it would definately break almost every other system than yours! -Phil
From: igor.sutton [...] gmail.com
On Thu Nov 24 16:13:58 2005, vandry@TZoNE.ORG wrote: Show quoted text
> Second, I quite disagree with hardcoding -L/usr/local/lib > -I/usr/local/include . Your libintl is installed in /usr/local? I'm > not > sure how to deal with that except by adding a much more comprehensive > autoconfiguration function. Let me see what some other packages do.
I agree with that. Attached is a patch for Makefile.PL in the same shape of XML::Parser. It worked on my Mac OS X, gettext installed from fink (should work for FreeBSD ports or DarwinPorts). The basic usage is: perl Makefile.PL INTLLIBPATH=/sw/lib INTLINCPATH=/sw/include [other options here] Hope this helps!
--- Makefile.PL.orig 2007-10-24 16:03:13.000000000 +0200 +++ Makefile.PL 2007-10-24 16:25:54.000000000 +0200 @@ -1,6 +1,25 @@ use ExtUtils::MakeMaker; use Config; +my $intl_libpath = ''; +my $intl_incpath = ''; + +my @replacement_args; +foreach (@ARGV) { + if (/^INTL(LIB|INC)PATH=(.*)$/) { + if ($1 eq 'LIB') { + $intl_libpath = $2; + } + else { + $intl_incpath = $2; + } + } + else { + push(@replacement_args, $_); + } +} +@ARGV = @replacement_args; + my $cc; if (defined($ENV{'CC'})) { $cc = $ENV{'CC'}; @@ -8,14 +27,28 @@ $cc = $Config{'cc'}; } my $libs = ''; +my $includes = ''; + +$includes = "-I$intl_incpath $includes" + if $intl_incpath; unless (conftest("char *x = gettext(\"foo\");", "gettext", 0)) { # try with -lintl $libs = "-lintl"; + + $libs = "-L$intl_libpath $libs" + if $intl_libpath; + unless (conftest("char *x = gettext(\"foo\");", "gettext", 0)) { unlink("conftest.c"); unlink("conftest"); - die "gettext function not found. Please install libintl"; + die <<'TEXT' + +gettext() function not found. Please specify INTLLIBPATH and INTLINCPATH like: + +$ perl Makefile.PL INTLLIBPATH=/sw/lib INTINCPATH=/sw/include + +TEXT } } @@ -34,6 +67,7 @@ WriteMakefile( NAME => "Locale::gettext", LIBS => ($libs eq '') ? [] : [$libs], + INC => $includes, VERSION_FROM => 'gettext.pm', ); @@ -50,7 +84,7 @@ close TEST; open(SAVE, ">&STDERR"); open(STDERR, ">/dev/null"); - system($cc . " -o conftest " . $libs . " conftest.c"); + system($cc . " -o conftest " . $libs . " " . $includes . " conftest.c"); my $exitstatus = $?; open(STDERR, ">&SAVE"); if ($exitstatus != 0) {
RT-Send-CC: vandry [...] TZoNE.ORG
Hi everyone, I just found this ticket and figured out a simple and clean solution, and will add it for anyone else who doesn't want to modify the Makefile file and still get it to work :-) So my solution is pretty simple: CC='cc -L/usr/local/lib -I/usr/local/include' perl Makefile.PL Tada! My logic is we piggy back off of the environment variable that is already built-in into the Makefile.pl and have it go for the compiler, but also inject the various paths (since apparently it's having trouble finding it on its own). With this method you will go from: BEFORE: Show quoted text
prompt> perl Makefile.PL
checking for gettext... no checking for gettext in -lintl... no gettext function not found. Please install libintl at Makefile.PL line 20. AFTER: Show quoted text
prompt> CC='cc -L/usr/local/lib -I/usr/local/include' perl Makefile.PL
checking for gettext... no checking for gettext in -lintl... yes checking for dgettext in -lintl... yes checking for ngettext in -lintl... yes checking for bind_textdomain_codeset in -lintl... yes Writing Makefile for Locale::gettext Show quoted text
prompt> make
cp gettext.pm blib/lib/Locale/gettext.pm /usr/bin/perl /usr/local/lib/perl5/5.10.1/ExtUtils/xsubpp - typemap /usr/local/lib/perl5/5.10.1/ExtUtils/typemap gec Please specify prototyping behavior for gettext.xs (see perlxs manual) cc -c -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing - pipe -fstack-protector -I/usr/local/include -O c Running Mkbootstrap for Locale::gettext () chmod 644 gettext.bs rm -f blib/arch/auto/Locale/gettext/gettext.so LD_RUN_PATH="/usr/local/lib" cc -shared -L/usr/local/lib -fstack- protector gettext.o -o blib/arch/auto/Locale/get chmod 755 blib/arch/auto/Locale/gettext/gettext.so cp gettext.bs blib/arch/auto/Locale/gettext/gettext.bs chmod 644 blib/arch/auto/Locale/gettext/gettext.bs Manifying blib/man3/Locale::gettext.3 Show quoted text
prompt> make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Installing /usr/local/lib/perl5/site_perl/5.10.1/i386- freebsd/auto/Locale/gettext/gettext.so Installing /usr/local/lib/perl5/site_perl/5.10.1/i386- freebsd/auto/Locale/gettext/gettext.bs Installing /usr/local/lib/perl5/site_perl/5.10.1/i386- freebsd/Locale/gettext.pm Installing /usr/local/man/man3/Locale::gettext.3 Appending installation info to /usr/local/lib/perl5/5.10.1/i386- freebsd/perllocal.pod Hope this helps. Milan Adamovsky http://www.perlscript.com http://milan.adamovsky.com
On 2005-11-24 15:52:26, guest wrote: Show quoted text
> Makefile.PL does not detect libintl on FreeBSD, here is the new > Makefile.PL > that works: > > use ExtUtils::MakeMaker; > use Config; > > my $cc; > if (defined($ENV{'CC'})) { > $cc = $ENV{'CC'}; > } else { > $cc = $Config{'cc'}; > } > my $libs = ''; > > unless (conftest("char *x = gettext(\"foo\");", "gettext", 0)) { > # try with -lintl > $libs = "-lintl -liconv"; > unless (conftest("char *x = gettext(\"foo\");", "gettext", 0)) > { > unlink("conftest.c"); > unlink("conftest"); > die "gettext function not found. Please install > libintl"; > } > } > > open(CONFIG, ">config.h"); > print CONFIG "/* Generated automatically by ", $0, ". Do not edit > */\n"; > > conftest("char *x = dcgettext(\"foo\", \"bar\", 0);", "dgettext", 1); > conftest("char *x = ngettext(\"foo\", \"foos\", 1);", "ngettext", 1); > conftest("char *x = bind_textdomain_codeset(\"foo\", \"UTF-8\");", > "bind_textdomain_codeset", 1); > > close CONFIG; > > unlink("conftest.c"); > unlink("conftest"); > > WriteMakefile( > NAME => "Locale::gettext", > LIBS => ($libs eq '') ? [] : [$libs], > VERSION_FROM => 'gettext.pm', > ); > > sub conftest { > my ($testcode, $func, $record) = @_; > > print "checking for ", $func; > print(" in ", $libs) if ($libs ne ''); > print "..."; > open(TEST, ">conftest.c"); > print TEST "#include <libintl.h>\n\nint main(int argc, char > **argv)\n{\n"; > print TEST $testcode; > print TEST "return 0;}\n"; > close TEST; > open(SAVE, ">&STDERR"); > open(STDERR, ">/dev/null"); > system($cc . " -L/usr/local/lib -I/usr/local/include -o conftest > conftest.c " . $libs); > my $exitstatus = $?; > open(STDERR, ">&SAVE"); > if ($exitstatus != 0) { > print " no\n"; > return 0; > } else { > print " yes\n"; > if ($record) { > print CONFIG "#define HAVE_", uc($func), "\n"; > } > return 1; > } > }
This problem still exists with gettext 1.07. Possible patches: - the freebsd port (see https://svnweb.freebsd.org/ports/head/devel/p5-Locale-gettext/ and there especially the patch in the files directory) - CPAN.pm users may use the following distroprefs file for automatic fixing: https://github.com/eserte/srezic-cpan-distroprefs/blob/master/gettext.yml