1 # $Id: Makefile.PL,v 1.33 2002/12/15 19:40:19 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 $libspec = $useinstalled ? "-L$useinstalled/lib " : "";
34 my @l = MM->ext($libspec);
35 if ($l[0] || $l[1] || $l[2]) {
36 $prefix = "$useinstalled/include" if $useinstalled;
41 if (!$libfound && -d "$devkit/libfcgi" && -d "$devkit/include") {
43 if (grep { ! -f "$devkit/include/$_" } @dist3
44 or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
46 warn "This appears to be a FastCGI devkit distribution, " .
47 "but one or more FastCGI library files are missing. \n" .
48 "Please check the integrity of the distribution.\n";
52 my $extrarules = join "\n",
53 map { $b = $_; $b =~ s/\.c$//; my $s="$devkit/libfcgi/$b.c";
54 "$b\$(OBJ_EXT): $s\n\t".
55 '$(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) '."$s\n"; }
57 eval 'package MY; sub postamble { $extrarules; }';
62 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
63 push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
64 $inc = '-I.' unless $libfound;
65 $inc .= " -I$prefix/include" if $prefix;
67 push(@extras, CAPI => 'TRUE')
68 if ($] >= 5.005 and $^O eq 'MSWin32'
69 and $Config{archname} =~ /-object\b/i);
72 ABSTRACT => 'Fast CGI module',
73 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)')
74 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
76 $plfiles = { 'echo.PL' => 'echo.fpl',
77 'remote.PL' => 'remote.fpl',
78 'threaded.PL' => 'threaded.fpl',
79 'FCGI.PL' => 'FCGI.pm',
81 $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
87 if ("$sys" eq "win32") {
88 push @libs, ":nosearch -lws2_32";
89 push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
93 'LIBS' => [ "@libs" ],
98 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
99 # the contents of the Makefile that is written.
101 # Work around bug in previous versions of MakeMaker
102 WriteMakefile(NAME => 'FCGI')
103 if $ExtUtils::MakeMaker::VERSION <= 5.4302;
107 'VERSION_FROM' => 'version.pm',
108 'dist' => { 'COMPRESS' => 'gzip -9f',
110 'PREOP' => '$(CP) '.join(' ',
111 map {"../$_"} @dist1,
112 (map {"libfcgi/$_"} @dist2),
113 map {"include/$_"} @dist3).' $(DISTVNAME);'.
114 '$(CP) MANIFEST MANIFEST.old;'.
115 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
116 '>> $(DISTVNAME)/MANIFEST',
118 '$(MV) MANIFEST.old MANIFEST',
120 'clean' => { FILES => 'config.cache fcgi_config.h' .
121 ' FCGI.xs FCGI.c FCGI.cfg ' .
122 (join ' ', values %$plfiles)},
123 'PL_FILES' => $plfiles,
124 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
127 # don't install oldinterface pod
128 delete $mm->{MAN3PODS}{oldinterface.pod};
131 exit if -f 'fcgi_config.h' or $libfound or $pure;
133 # CPAN and no installed lib found
134 if ($sys eq "win32") {
135 # configure will almost certainly not run on a normal NT install,
136 # use the pregenerated configuration file
138 use File::Copy qw(copy);
139 print "Using prebuilt fcgi_config.h file for Windows\n";
140 unlink("fcgi_config.h");
141 my $confdir = $prefix ? "$prefix/include/" : '';
142 die $! unless copy("${confdir}fcgi_config_x86.h","fcgi_config.h");
144 # Win can't deal with existence of FCGI.xs or absence of FCGI.c
146 open(F, ">FCGI.c"); close(F);
147 $now = time; $before = $now - 600;
148 utime $before, $before, "FCGI.c";
149 utime $now, $now, "FCGI.PL";
151 print "Running ./configure for you\n";
152 print "Please read configure.readme for information on how to run it yourself\n";
154 $ENV{'CC'} = $Config{'cc'};
155 system("$Config{sh} configure");