1 # $Id: Makefile.PL,v 1.33 2002/12/15 19:40:19 skimo Exp $
3 use ExtUtils::MakeMaker;
8 use File::Copy qw(copy);
10 @h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
11 @h = (@h1, 'fcgi_config.h');
13 @dist1 = qw(LICENSE.TERMS);
14 @dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
15 @dist3 = (@h1, qw(fcgi_config_x86.h));
17 GetOptions ("pure-perl!" => \$pure,
18 "use-installed:s" => \$useinstalled);
19 $pure = "0" unless defined $pure;
20 open(CFG,">FCGI.cfg");
21 print CFG "\$pure = $pure;1;\n";
29 my $devkit = "$cwd/..";
31 if (defined $useinstalled) {
32 require ExtUtils::Liblist;
33 my $libspec = $useinstalled ? "-L$useinstalled/lib " : "";
35 my @l = MM->ext($libspec);
36 if ($l[0] || $l[1] || $l[2]) {
37 $prefix = "$useinstalled/include" if $useinstalled;
42 if (!$libfound && -d "$devkit/libfcgi" && -d "$devkit/include") {
44 if (grep { ! -f "$devkit/include/$_" } @dist3
45 or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
47 warn "This appears to be a FastCGI devkit distribution, " .
48 "but one or more FastCGI library files are missing. \n" .
49 "Please check the integrity of the distribution.\n";
53 my $extrarules = join "\n",
54 map { $b = $_; $b =~ s/\.c$//; my $s="$devkit/libfcgi/$b.c";
55 "$b\$(OBJ_EXT): $s\n\t".
56 '$(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) '."$s\n"; }
58 eval 'package MY; sub postamble { $extrarules; }';
63 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
64 push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
65 $inc = '-I.' unless $libfound;
66 $inc .= " -I$prefix/include" if $prefix;
68 push(@extras, CAPI => 'TRUE')
69 if ($] >= 5.005 and $^O eq 'MSWin32'
70 and $Config{archname} =~ /-object\b/i);
73 ABSTRACT => 'Fast CGI module',
74 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)'
76 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
78 push @extras, META_MERGE => {
80 repository => 'git://git.shadowcat.co.uk/catagits/fcgi2.git',
82 } if $ExtUtils::MakeMaker::VERSION >= 6.46;
85 'echo.PL' => 'echo.fpl',
86 'remote.PL' => 'remote.fpl',
87 'threaded.PL' => 'threaded.fpl',
88 'FCGI.PL' => 'FCGI.pm',
90 $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
96 if ("$sys" eq "win32") {
97 push @libs, ":nosearch -lws2_32";
98 push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
102 'LIBS' => [ "@libs" ],
107 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
108 # the contents of the Makefile that is written.
110 # Work around bug in previous versions of MakeMaker
113 'VERSION_FROM' => 'version.pm',
115 'COMPRESS' => 'gzip -9f',
117 'PREOP' => '$(CP) '.join(' ',
118 map {"../$_"} @dist1,
119 (map {"libfcgi/$_"} @dist2),
120 map {"include/$_"} @dist3).' $(DISTVNAME);'.
121 '$(CP) MANIFEST MANIFEST.old;'.
122 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
123 '>> $(DISTVNAME)/MANIFEST',
125 '$(MV) MANIFEST.old MANIFEST',
127 'clean' => { FILES => 'config.cache fcgi_config.h' .
128 ' FCGI.xs FCGI.c FCGI.cfg ' .
129 (join ' ', values %$plfiles)},
130 'PL_FILES' => $plfiles,
131 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
135 exit if -f 'fcgi_config.h' or $libfound or $pure;
137 # CPAN and no installed lib found
138 if ($sys eq "win32") {
139 # configure will almost certainly not run on a normal NT install,
140 # use the pregenerated configuration file
142 print "Using prebuilt fcgi_config.h file for Windows\n";
143 unlink("fcgi_config.h");
144 my $confdir = $prefix ? "$prefix/include/" : '';
145 die $! unless copy("${confdir}fcgi_config_x86.h","fcgi_config.h");
147 # Win can't deal with existence of FCGI.xs or absence of FCGI.c
149 open(F, ">FCGI.c"); close(F);
150 $now = time; $before = $now - 600;
151 utime $before, $before, "FCGI.c";
152 utime $now, $now, "FCGI.PL";
154 print "Running ./configure for you\n";
155 print "Please read configure.readme for information on how to run it yourself\n";
157 $ENV{'CC'} = $Config{'cc'};
158 system("$Config{sh} configure");