1 # $Id: Makefile.PL,v 1.13 2001/08/28 19:14:21 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))
32 if (-f "$devkit/libfcgi/libfcgi.a") {
33 push @libs, "-L$devkit/libfcgi -lfcgi";
35 elsif (-f "$devkit/libfcgi/Release/libfcgi.dll") {
36 push @libs, "-L$devkit/libfcgi/Release -lfcgi";
38 elsif (-f "$devkit/libfcgi/Debug/libfcgi.dll") {
39 push @libs, "-L$devkit/libfcgi/Debug -lfcgi";
42 warn "Please compile the library before attempting " .
43 "to compile the perl module.\n";
49 for $dir ("/usr", "/usr/local") {
50 if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a"
51 && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h))
53 print "Found fcgi library and include files in $dir\n";
54 print "Will be using that instead of included files\n";
55 print "Edit Makefile.PL if you don't like it\n";
58 push @libs, "-L$dir/lib -lfcgi";
64 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
65 push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
66 $inc = $prefix ? "-I$prefix/include" : '-I.';
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)')
75 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
77 $plfiles = { 'echo.PL' => 'echo.fpl',
78 'remote.PL' => 'remote.fpl',
79 'threaded.PL' => 'threaded.fpl',
80 'FCGI.PL' => 'FCGI.pm',
82 $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
93 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
94 # the contents of the Makefile that is written.
96 # Work around bug in previous versions of MakeMaker
97 WriteMakefile(NAME => 'FCGI')
98 if $ExtUtils::MakeMaker::VERSION <= 5.4302;
102 'VERSION_FROM' => 'FCGI.PL',
103 'dist' => { 'COMPRESS' => 'gzip -9f',
105 'PREOP' => '$(CP) '.join(' ',
106 map {"../$_"} @dist1,
107 (map {"libfcgi/$_"} @dist2),
108 map {"include/$_"} @dist3).' $(DISTVNAME);'.
109 '$(CP) MANIFEST MANIFEST.old;'.
110 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
111 '>> $(DISTVNAME)/MANIFEST',
113 '$(MV) MANIFEST.old MANIFEST',
115 'clean' => { FILES => 'config.cache fcgi_config.h' .
116 ' FCGI.xs FCGI.c FCGI.cfg ' .
117 (join ' ', values %$plfiles)},
118 'PL_FILES' => $plfiles,
119 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
122 # don't install oldinterface pod
123 delete $mm->{MAN3PODS}{oldinterface.pod};
126 if ($sys eq "win32") {
127 # Win can't deal with existence of FCGI.xs or absence of FCGI.c
129 open(F, ">FCGI.c"); close(F);
130 $now = time; $before = $now - 600;
131 utime $before, $before, "FCGI.c";
132 utime $now, $now, "FCGI.PL";
135 exit if -f 'fcgi_config.h' or $prefix 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 use File::Copy qw(copy);
143 print "Using prebuilt fcgi_config.h file for Windows\n";
144 unlink("fcgi_config.h");
145 die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
147 print "Running ./configure for you\n";
148 print "Please read configure.readme for information on how to run it yourself\n";
150 $ENV{'CC'} = $Config{'cc'};
151 system("./configure");