1 # $Id: Makefile.PL,v 1.12 2001/08/27 19:53:58 robs 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 acconfig.h);
13 @dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
14 @dist3 = (@h1, qw(fcgi_config.h.in fcgi_config_x86.h));
16 GetOptions ("pure-perl!" => \$pure);
18 (prompt("Do you want to use the pure perl implementation", "no") =~ /^y/)
19 ? "1" : "0" unless defined $pure;
20 open(CFG,">FCGI.cfg");
21 print CFG "\$pure = $pure;1;\n";
24 $devkit = cwd() . "/..";
26 if (-d "$devkit/libfcgi/"
27 && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h))
29 unless (-f "$devkit/libfcgi/libfcgi.a") {
30 warn "Please compile the library before attempting " .
31 "to compile the perl module.\n";
36 push @libs, "-L$devkit/libfcgi -lfcgi";
40 for $dir ("/usr", "/usr/local") {
41 if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a"
42 && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h))
44 print "Found fcgi library and include files in $dir\n";
45 print "Will be using that instead of included files\n";
46 print "Edit Makefile.PL if you don't like it\n";
49 push @libs, "-L$dir/lib -lfcgi";
55 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
56 push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
57 $inc = $prefix ? "-I$prefix/include" : '-I.';
59 push(@extras, CAPI => 'TRUE')
60 if ($] >= 5.005 and $^O eq 'MSWin32'
61 and $Config{archname} =~ /-object\b/i);
64 ABSTRACT => 'Fast CGI module',
65 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)')
66 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
68 $plfiles = { 'echo.PL' => 'echo.fpl',
69 'remote.PL' => 'remote.fpl',
70 'threaded.PL' => 'threaded.fpl',
71 'FCGI.PL' => 'FCGI.pm',
73 $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
84 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
85 # the contents of the Makefile that is written.
87 # Work around bug in previous versions of MakeMaker
88 WriteMakefile(NAME => 'FCGI')
89 if $ExtUtils::MakeMaker::VERSION <= 5.4302;
93 'VERSION_FROM' => 'FCGI.PL',
94 'dist' => { 'COMPRESS' => 'gzip -9f',
96 'PREOP' => '$(CP) '.join(' ',
98 (map {"libfcgi/$_"} @dist2),
99 map {"include/$_"} @dist3).' $(DISTVNAME);'.
100 '$(CP) MANIFEST MANIFEST.old;'.
101 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
102 '>> $(DISTVNAME)/MANIFEST',
104 '$(MV) MANIFEST.old MANIFEST',
106 'clean' => { FILES => 'config.cache fcgi_config.h' .
107 ' FCGI.xs FCGI.c FCGI.cfg ' .
108 (join ' ', values %$plfiles)},
109 'PL_FILES' => $plfiles,
110 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
113 # don't install oldinterface pod
114 delete $mm->{MAN3PODS}{oldinterface.pod};
117 exit if -f 'fcgi_config.h' or $prefix or $pure;
119 # CPAN and no installed lib found
120 if ($sys eq "win32") {
121 # configure will almost certainly not run on a normal NT install,
122 # use the pregenerated configuration file
124 use File::Copy qw(copy);
125 print "Using prebuilt fcgi_config.h file for Windows\n";
126 unlink("fcgi_config.h");
127 die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
129 # Win build system also can't deal with existence of FCGI.xs or absence of
132 open(F, ">FCGI.c"); close(F);
133 $now = time; $before = $now - 600;
134 utime $before, $before, "FCGI.c";
135 utime $now, $now, "FCGI.PL";
138 print "Running ./configure for you\n";
139 print "Please read configure.readme for information on how to run it yourself\n";
141 $ENV{'CC'} = $Config{'cc'};
142 system("./configure");