Work around old buggy glibcs for langinfo constants,
[p5sagit/p5-mst-13.2.git] / ext / I18N / Langinfo / Makefile.PL
1 use ExtUtils::MakeMaker;
2 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
3 # the contents of the Makefile that is written.
4 WriteMakefile(
5     'NAME'              => 'I18N::Langinfo',
6     'VERSION_FROM'      => 'Langinfo.pm', # finds $VERSION
7     'PREREQ_PM'         => {}, # e.g., Module::Name => 1.1
8     ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
9       (ABSTRACT_FROM => 'Langinfo.pm', # retrieve abstract from module
10        AUTHOR     => 'Jarkko Hietaniemi <jhi@hut.fi>') : ()),
11     'LIBS'              => [''], # e.g., '-lm'
12     'DEFINE'            => '', # e.g., '-DHAVE_SOMETHING'
13         # Insert -I. if you add *.h files later:
14     'INC'               => '', # e.g., '-I/usr/include/other'
15     # Without this the constants xs files are spotted, and cause rules to be
16     # added to delete the similarly named C files, which isn't what we want.
17     XS => {'Langinfo.xs' => 'Langinfo.c'},
18     realclean => {FILES=> 'constants.c constants.xs'},
19         # Un-comment this if you add C files to link with later:
20     # 'OBJECT'          => '$(O_FILES)', # link all the C files too
21 );
22 if (eval {require ExtUtils::Constant; 1}) {
23   # Some older versions of glibc use only enums, no defines, hence all this
24   # hassle (so old glibc that the define is GNU_LIBRARY, not GLIBC):
25   my @names = 'CODESET'; # CODESET isn't an enum in old glibc's langinfo.h
26   push @names,           # This lot are always enums in old langinfo.h:
27     {name=>$_, type=>"IV",
28      macro=>["#if defined($_) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM))\n",
29              "#endif\n"]}
30       foreach qw (ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7
31                   ABMON_1 ABMON_10 ABMON_11 ABMON_12 ABMON_2 ABMON_3 ABMON_4
32                   ABMON_5 ABMON_6 ABMON_7 ABMON_8 ABMON_9 ALT_DIGITS AM_STR
33                   DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7 D_FMT D_T_FMT ERA
34                   ERA_D_FMT ERA_D_T_FMT ERA_T_FMT MON_1 MON_10 MON_11 MON_12
35                   MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 NOEXPR NOSTR
36                   PM_STR T_FMT T_FMT_AMPM YESEXPR YESSTR);
37   push @names,           # This lot are only enums for __SVR4_I386_ABI_L1__:
38     {name=>$_, type=>"IV",
39      macro=>["#if defined($_) || (defined(__GNU_LIBRARY__) && defined(_NL_ITEM) && defined(__SVR4_I386_ABI_L1__))\n",
40              "#endif\n"]}
41       foreach qw (CRNCYSTR THOUSEP RADIXCHAR);
42   ExtUtils::Constant::WriteConstants(
43                                      NAME => 'I18N::Langinfo',
44                                      NAMES => \@names,
45                                     );
46 } else {
47   use File::Copy;
48   copy ('fallback.c', 'constants.c')
49     or die "Can't copy fallback.c to constants.c: $!";
50   copy ('fallback.xs', 'constants.xs')
51     or die "Can't copy fallback.xs to constants.xs: $!";
52 }