File: Makefile.PL

package info (click to toggle)
liblocale-gettext-perl 1.07-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 140 kB
  • ctags: 21
  • sloc: perl: 248; makefile: 16
file content (75 lines) | stat: -rw-r--r-- 1,910 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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";
	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', 
    META_MERGE => {
        resources => {
            repository => 'https://github.com/vandry/Perl-Locale-gettext',
            license => 'http://dev.perl.org/licenses/',
        },
    },
    ABSTRACT => "Perl bindings for POSIX i18n gettext functions",
    AUTHOR => "Kim Vandry <vandry@TZoNE.ORG>",
    LICENSE => 'perl',
);

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 . " -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;
	}
}