1
2use ExtUtils::MakeMaker;
3
4use Config;
5
6if ($^O eq "MSWin32") {
7   # configuration on windows is hardcoded - as always
8
9   print STDERR <<EOF;
10
11***
12*** Your platform is not standards compliant. To get this module working, you need to
13*** download and install win32 pthread (http://sourceware.org/pthreads-win32/).
14***
15
16EOF
17
18   if(0){
19      if ($Config{cc} =~ /(?:^|\\|\/)gcc(?:|.*\.exe)$/) {
20         $INC  = "$ENV{INC} -I/gtk/include";
21         $LIBS = ["$ENV{LIBS} -L/gtk/lib -lpthreadGC2"];
22      } else {
23         $INC  = "$ENV{INC} -I/sdk/include -I/vc98/include -I/gtk/include";
24         $LIBS = ["$ENV{LIBS} -L/gtk/lib -lpthreadVC2"];
25      }
26   }
27
28   open my $fh, ">config.h"
29      or die "config.h: $!";
30   print $fh <<EOF;
31EOF
32
33} else {
34
35   $INC  = "";
36   $LIBS = ['-lpthread', '-lpthreads', ''];
37
38   if ($^O =~ /bsd/i) {
39      print <<EOF;
40
41If you have problems with deadlocks or crashes on your system,
42make sure your perl has been linked with -lpthread (you might try
43LD_PRELOAD=/path/to/libpthread.so as a workaround). Also, pthread support
44under many BSDs is not the best - before reporting a bug in this module,
45make sure it's not an OS bug.
46
47EOF
48   }
49
50   {
51      local %ENV = %ENV;
52
53      while (my ($k, $v) = each %Config) {
54         $ENV{$k} = $v;
55      }
56
57      $ENV{MAKE}     = $Config{make};
58      $ENV{SHELL}    = $Config{sh};
59      $ENV{CC}       = $Config{cc};
60      $ENV{CPPFLAGS} = "$Config{cppflags} -I$Config{archlibexp}/CORE";
61      $ENV{CFLAGS}   = $Config{ccflags};
62      $ENV{LDFLAGS}  = "$Config{ldflags} $Config{ccdlflags}";
63      $ENV{LINKER}   = $Config{ld}; # nonstandard
64      $ENV{LIBS}     = "-L$Config{archlibexp}/CORE -L$Config{privlibexp} -lperl $Config{perllibs}";
65
66      system $ENV{SHELL}, -c => "./configure --prefix \Q$Config{prefixexp}\E"
67         and exit $? >> 8;
68   }
69}
70
71if ($^O =~ /linux/ && $Config{usemymalloc} eq "y") {
72   print <<EOF;
73
74***
75*** WARNING:
76***
77*** Your perl uses its own memory allocator (-Dusemymalloc=y),
78*** which is known not to be threadsafe on GNU/Linux and probably
79*** other platforms (even when not used concurrently, it trashes
80*** the data structures of the system malloc running concurrently),
81*** for perls up to 5.8.8 and possibly later versions.
82***
83*** If you are unsure wether your perl has been fixed, your system
84*** is safe for other reasons, or you experience spurious segfaults,
85*** please compile your perl with -Dusemymalloc=n.
86***
87
88EOF
89}
90
91my $mm = MM->new({
92    dist         => {
93       PREOP	=> 'pod2text AIO.pm | tee README >$(DISTVNAME)/README; chmod -R u=rwX,go=rX . ;',
94       COMPRESS	=> 'gzip -9v',
95       SUFFIX	=> '.gz',
96    },
97    depend => {
98       "AIO.c" => "schmorp.h libeio/eio.h libeio/xthread.h libeio/etp.c libeio/eio.c config.h",
99    },
100    NAME         => "IO::AIO",
101    VERSION_FROM => "AIO.pm",
102    INC          => $INC,
103    LIBS         => $LIBS,
104    EXE_FILES    => ["bin/treescan"],
105    PM           => {
106       'AIO.pm'		=> '$(INST_LIB)/IO/AIO.pm',
107    },
108    CONFIGURE_REQUIRES => { ExtUtils::MakeMaker => 6.52 },
109    PREREQ_PM => {
110       "common::sense" => 0,
111    },
112    clean        => { FILES => "config.h libeio/config.h libeio/config.log libeio/config.status" },
113});
114
115$mm->flush;
116
117