Don't try to compile anything on pure perl build
[catagits/fcgi2.git] / perl / Makefile.PL
CommitLineData
236be38d 1# $Id: Makefile.PL,v 1.9 2001/03/28 15:49:20 skimo Exp $
1b64d24d 2
3use ExtUtils::MakeMaker;
4use IO::File;
5use Config;
6use Cwd 'cwd';
7
8@h1 = qw(fastcgi.h fcgiapp.h fcgiappmisc.h fcgimisc.h fcgios.h);
9@h = (@h1, 'fcgi_config.h');
10@o = qw(FCGI.o);
11@dist1 = qw(LICENSE.TERMS acconfig.h);
12@dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
13@dist3 = (@h1, qw(fcgi_config.h.in fcgi_config_x86.h));
14
0833402a 15$pure =
16 (prompt("Do you want to use the pure perl implementation", "no") =~ /^y/)
17 ? "1" : "0";
18open(CFG,">FCGI.cfg");
19print CFG "\$pure = $pure;1;\n";
20close CFG;
21
1b64d24d 22$devkit = cwd() . "/..";
23
8a851875 24if (-d "$devkit/libfcgi/"
1b64d24d 25 && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h))
26{
8a851875 27 unless (-f "$devkit/libfcgi/libfcgi.a") {
28 warn "Please compile the library before attempting " .
29 "to compile the perl module.\n";
30 exit -1;
31 }
1b64d24d 32 # devkit
33 $prefix = $devkit;
34 push @libs, "-L$devkit/libfcgi -lfcgi";
35}
36else {
37 # CPAN
38 for $dir ("/usr", "/usr/local") {
39 if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a"
40 && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h))
41 {
42 print "Found fcgi library and include files in $dir\n";
43 print "Will be using that instead of included files\n";
44 print "Edit Makefile.PL if you don't like it\n";
45
46 $prefix = $dir;
47 push @libs, "-L$dir/lib -lfcgi";
48 last;
49 }
50 }
51}
52
53$sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
54push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
55$inc = $prefix ? "-I$prefix/include" : '-I.';
56
0074e702 57push(@extras, CAPI => 'TRUE')
58 if ($] >= 5.005 and $^O eq 'MSWin32'
59 and $Config{archname} =~ /-object\b/i);
60
61push(@extras,
62 ABSTRACT => 'Fast CGI module',
63 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)')
64 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
0833402a 65
66$plfiles = { 'echo.PL' => 'echo.fpl',
67 'remote.PL' => 'remote.fpl',
68 'threaded.PL' => 'threaded.fpl',
69 'FCGI.PL' => 'FCGI.pm',
70 };
71$plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
236be38d 72if ($pure) {
73 push @extras,
74 LINKTYPE => ' ';
75} else {
0833402a 76 push @extras,
77 'LIBS' => [ @libs ],
78 'OBJECT' => "@o",
79 'INC' => $inc;
80}
0074e702 81
1b64d24d 82# See lib/ExtUtils/MakeMaker.pm for details of how to influence
83# the contents of the Makefile that is written.
0833402a 84$mm = MM->new({
1b64d24d 85 'NAME' => 'FCGI',
0833402a 86 'VERSION_FROM' => 'FCGI.PL',
1b64d24d 87 'dist' => { 'COMPRESS' => 'gzip -9f',
88 'SUFFIX' => 'gz',
89 'PREOP' => '$(CP) '.join(' ',
90 map {"../$_"} @dist1,
91 (map {"libfcgi/$_"} @dist2),
92 map {"include/$_"} @dist3).' $(DISTVNAME);'.
93 '$(CP) MANIFEST MANIFEST.old;'.
94 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
95 '>> $(DISTVNAME)/MANIFEST',
96 'POSTOP' =>
97 '$(MV) MANIFEST.old MANIFEST',
98 },
236be38d 99 'clean' => { FILES => 'config.cache fcgi_config.h' .
100 ' FCGI.xs FCGI.c FCGI.cfg ' .
101 (join ' ', values %$plfiles)},
0833402a 102 'PL_FILES' => $plfiles,
103 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
0074e702 104 @extras,
0833402a 105});
106# don't install oldinterface pod
107delete $mm->{MAN3PODS}{oldinterface.pod};
108$mm->flush;
1b64d24d 109
236be38d 110exit if -f 'fcgi_config.h' or $prefix or $pure;
1b64d24d 111
112# CPAN and no installed lib found
113if ($sys eq "win32") {
114 # configure will almost certainly not run on a normal NT install,
115 # use the pregenerated configuration file
116
09c3bca2 117 use File::Copy qw(copy);
1b64d24d 118 print "Using prebuilt fcgi_config.h file for Windows\n";
119 unlink("fcgi_config.h");
09c3bca2 120 die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
1b64d24d 121
122 # Win build system also can't deal with existence of FCGI.xs or absence of
123 # FCGI.c
124 unlink("FCGI.xs");
125 open(F, ">FCGI.c"); close(F);
126 $now = time; $before = $now - 600;
127 utime $before, $before, "FCGI.c";
128 utime $now, $now, "FCGI.PL";
129
130} else {
131 print "Running ./configure for you\n";
6ef7789b 132 print "Please read configure.readme for information on how to run it yourself\n";
1b64d24d 133
134 $ENV{'CC'} = $Config{'cc'};
135 system("./configure");
136}