1 # $Id: Makefile.PL,v 1.28 2001/09/23 20:29:40 skimo Exp $
3 use ExtUtils::MakeMaker;
9 @h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
10 @h = (@h1, 'fcgi_config.h');
12 @dist1 = qw(LICENSE.TERMS);
13 @dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
14 @dist3 = (@h1, qw(fcgi_config_x86.h));
16 GetOptions ("pure-perl!" => \$pure,
17 "use-installed:s" => \$useinstalled);
18 $pure = "0" unless defined $pure;
19 open(CFG,">FCGI.cfg");
20 print CFG "\$pure = $pure;1;\n";
28 my $devkit = "$cwd/..";
30 if (defined $useinstalled) {
31 require ExtUtils::Liblist;
32 my $mm = MM->new({NAME => 'FCGI'});
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;
41 # avoid duplicate check for complete kit
42 ExtUtils::MakeMaker::WriteEmptyMakefile() if ! -f "Makefile";
44 if (!$libfound && -d "$devkit/libfcgi" && -d "$devkit/include") {
46 if (grep { ! -f "$devkit/include/$_" } @dist3
47 or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
49 warn "This appears to be a FastCGI devkit distribution, " .
50 "but one or more FastCGI library files are missing. \n" .
51 "Please check the integrity of the distribution.\n";
55 my $extrarules = join "\n",
56 map { $b = $_; $b =~ s/\.c$//; my $s="$devkit/libfcgi/$b.c";
57 "$b\$(OBJ_EXT): $s\n\t".
58 '$(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) '."$s\n"; }
60 eval 'package MY; sub postamble { $extrarules; }';
65 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
66 push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
67 $inc = $prefix ? "-I$prefix/include" : '-I.';
69 push(@extras, CAPI => 'TRUE')
70 if ($] >= 5.005 and $^O eq 'MSWin32'
71 and $Config{archname} =~ /-object\b/i);
74 ABSTRACT => 'Fast CGI module',
75 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)')
76 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
78 $plfiles = { 'echo.PL' => 'echo.fpl',
79 'remote.PL' => 'remote.fpl',
80 'threaded.PL' => 'threaded.fpl',
81 'FCGI.PL' => 'FCGI.pm',
83 $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
89 if ("$sys" eq "win32") {
90 push @libs, ":nosearch -lws2_32";
91 push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
95 'LIBS' => [ "@libs" ],
100 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
101 # the contents of the Makefile that is written.
103 # Work around bug in previous versions of MakeMaker
104 WriteMakefile(NAME => 'FCGI')
105 if $ExtUtils::MakeMaker::VERSION <= 5.4302;
109 'VERSION_FROM' => 'version.pm',
110 'dist' => { 'COMPRESS' => 'gzip -9f',
112 'PREOP' => '$(CP) '.join(' ',
113 map {"../$_"} @dist1,
114 (map {"libfcgi/$_"} @dist2),
115 map {"include/$_"} @dist3).' $(DISTVNAME);'.
116 '$(CP) MANIFEST MANIFEST.old;'.
117 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
118 '>> $(DISTVNAME)/MANIFEST',
120 '$(MV) MANIFEST.old MANIFEST',
122 'clean' => { FILES => 'config.cache fcgi_config.h' .
123 ' FCGI.xs FCGI.c FCGI.cfg ' .
124 (join ' ', values %$plfiles)},
125 'PL_FILES' => $plfiles,
126 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
129 # don't install oldinterface pod
130 delete $mm->{MAN3PODS}{oldinterface.pod};
133 exit if -f 'fcgi_config.h' or $libfound or $pure;
135 # CPAN and no installed lib found
136 if ($sys eq "win32") {
137 # configure will almost certainly not run on a normal NT install,
138 # use the pregenerated configuration file
140 use File::Copy qw(copy);
141 print "Using prebuilt fcgi_config.h file for Windows\n";
142 unlink("fcgi_config.h");
143 die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
145 # Win can't deal with existence of FCGI.xs or absence of FCGI.c
147 open(F, ">FCGI.c"); close(F);
148 $now = time; $before = $now - 600;
149 utime $before, $before, "FCGI.c";
150 utime $now, $now, "FCGI.PL";
152 print "Running ./configure for you\n";
153 print "Please read configure.readme for information on how to run it yourself\n";
155 $ENV{'CC'} = $Config{'cc'};
156 system("$Config{sh} configure");