autoconf 2.52 update and check for limits.h
[catagits/fcgi2.git] / perl / Makefile.PL
CommitLineData
889959f2 1# $Id: Makefile.PL,v 1.13 2001/08/28 19:14:21 robs Exp $
1b64d24d 2
3use ExtUtils::MakeMaker;
4use IO::File;
5use Config;
6use Cwd 'cwd';
7bb01969 7use Getopt::Long;
1b64d24d 8
ffaa0e42 9@h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
1b64d24d 10@h = (@h1, 'fcgi_config.h');
11@o = qw(FCGI.o);
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));
15
7bb01969 16GetOptions ("pure-perl!" => \$pure);
0833402a 17$pure =
18 (prompt("Do you want to use the pure perl implementation", "no") =~ /^y/)
7bb01969 19 ? "1" : "0" unless defined $pure;
0833402a 20open(CFG,">FCGI.cfg");
21print CFG "\$pure = $pure;1;\n";
22close CFG;
23
1b64d24d 24$devkit = cwd() . "/..";
25
8a851875 26if (-d "$devkit/libfcgi/"
1b64d24d 27 && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h))
28{
29 # devkit
30 $prefix = $devkit;
889959f2 31
32 if (-f "$devkit/libfcgi/libfcgi.a") {
33 push @libs, "-L$devkit/libfcgi -lfcgi";
34 }
35 elsif (-f "$devkit/libfcgi/Release/libfcgi.dll") {
36 push @libs, "-L$devkit/libfcgi/Release -lfcgi";
37 }
38 elsif (-f "$devkit/libfcgi/Debug/libfcgi.dll") {
39 push @libs, "-L$devkit/libfcgi/Debug -lfcgi";
40 }
41 else {
42 warn "Please compile the library before attempting " .
43 "to compile the perl module.\n";
44 exit -1;
45 }
1b64d24d 46}
47else {
48 # CPAN
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))
52 {
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";
56
57 $prefix = $dir;
58 push @libs, "-L$dir/lib -lfcgi";
59 last;
60 }
61 }
62}
63
64$sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
65push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
66$inc = $prefix ? "-I$prefix/include" : '-I.';
67
0074e702 68push(@extras, CAPI => 'TRUE')
69 if ($] >= 5.005 and $^O eq 'MSWin32'
70 and $Config{archname} =~ /-object\b/i);
71
72push(@extras,
73 ABSTRACT => 'Fast CGI module',
74 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)')
75 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
0833402a 76
77$plfiles = { 'echo.PL' => 'echo.fpl',
78 'remote.PL' => 'remote.fpl',
79 'threaded.PL' => 'threaded.fpl',
80 'FCGI.PL' => 'FCGI.pm',
81 };
82$plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
236be38d 83if ($pure) {
84 push @extras,
85 LINKTYPE => ' ';
86} else {
0833402a 87 push @extras,
88 'LIBS' => [ @libs ],
89 'OBJECT' => "@o",
90 'INC' => $inc;
91}
0074e702 92
1b64d24d 93# See lib/ExtUtils/MakeMaker.pm for details of how to influence
94# the contents of the Makefile that is written.
00cbdd93 95
96# Work around bug in previous versions of MakeMaker
97WriteMakefile(NAME => 'FCGI')
98 if $ExtUtils::MakeMaker::VERSION <= 5.4302;
99
0833402a 100$mm = MM->new({
1b64d24d 101 'NAME' => 'FCGI',
0833402a 102 'VERSION_FROM' => 'FCGI.PL',
1b64d24d 103 'dist' => { 'COMPRESS' => 'gzip -9f',
104 'SUFFIX' => 'gz',
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',
112 'POSTOP' =>
113 '$(MV) MANIFEST.old MANIFEST',
114 },
236be38d 115 'clean' => { FILES => 'config.cache fcgi_config.h' .
116 ' FCGI.xs FCGI.c FCGI.cfg ' .
117 (join ' ', values %$plfiles)},
0833402a 118 'PL_FILES' => $plfiles,
119 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
0074e702 120 @extras,
0833402a 121});
122# don't install oldinterface pod
123delete $mm->{MAN3PODS}{oldinterface.pod};
124$mm->flush;
1b64d24d 125
889959f2 126if ($sys eq "win32") {
127 # Win can't deal with existence of FCGI.xs or absence of FCGI.c
128 unlink("FCGI.xs");
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";
133}
134
236be38d 135exit if -f 'fcgi_config.h' or $prefix or $pure;
1b64d24d 136
137# CPAN and no installed lib found
138if ($sys eq "win32") {
139 # configure will almost certainly not run on a normal NT install,
140 # use the pregenerated configuration file
141
09c3bca2 142 use File::Copy qw(copy);
1b64d24d 143 print "Using prebuilt fcgi_config.h file for Windows\n";
144 unlink("fcgi_config.h");
09c3bca2 145 die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
1b64d24d 146} else {
147 print "Running ./configure for you\n";
6ef7789b 148 print "Please read configure.readme for information on how to run it yourself\n";
1b64d24d 149
150 $ENV{'CC'} = $Config{'cc'};
151 system("./configure");
152}