Stop claiming we ship a file called -e
[catagits/fcgi2.git] / perl / Makefile.PL
CommitLineData
aff18d25 1# $Id: Makefile.PL,v 1.33 2002/12/15 19:40:19 skimo Exp $
1b64d24d 2
3use ExtUtils::MakeMaker;
4use IO::File;
5use Config;
6use Cwd 'cwd';
7bb01969 7use Getopt::Long;
1e48c05a 8use File::Copy qw(copy);
1b64d24d 9
ffaa0e42 10@h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
1b64d24d 11@h = (@h1, 'fcgi_config.h');
12@o = qw(FCGI.o);
e12d4fb3 13@dist1 = qw(LICENSE.TERMS);
1b64d24d 14@dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
7ef79c64 15@dist3 = (@h1, qw(fcgi_config_x86.h));
1b64d24d 16
c737f293 17GetOptions ("pure-perl!" => \$pure,
1e48c05a 18 "use-installed:s" => \$useinstalled);
cd834ed1 19$pure = "0" unless defined $pure;
0833402a 20open(CFG,">FCGI.cfg");
21print CFG "\$pure = $pure;1;\n";
22close CFG;
23
e12d4fb3 24$libfound = 0;
c737f293 25@libs = ();
e12d4fb3 26
e87ca2dd 27if (! $pure) {
e12d4fb3 28 my $cwd = cwd();
29 my $devkit = "$cwd/..";
30
c737f293 31 if (defined $useinstalled) {
1e48c05a 32 require ExtUtils::Liblist;
33 my $libspec = $useinstalled ? "-L$useinstalled/lib " : "";
34 $libspec .= "-lfcgi";
35 my @l = MM->ext($libspec);
36 if ($l[0] || $l[1] || $l[2]) {
37 $prefix = "$useinstalled/include" if $useinstalled;
38 $libfound = 1;
39 push @libs, $libspec;
40 }
c737f293 41 }
42 if (!$libfound && -d "$devkit/libfcgi" && -d "$devkit/include") {
1e48c05a 43 # devkit
44 if (grep { ! -f "$devkit/include/$_" } @dist3
45 or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
46 {
47 warn "This appears to be a FastCGI devkit distribution, " .
48 "but one or more FastCGI library files are missing. \n" .
49 "Please check the integrity of the distribution.\n";
50 exit -1;
51 }
52
53 my $extrarules = join "\n",
54 map { $b = $_; $b =~ s/\.c$//; my $s="$devkit/libfcgi/$b.c";
55 "$b\$(OBJ_EXT): $s\n\t".
56 '$(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) '."$s\n"; }
57 @dist2;
58 eval 'package MY; sub postamble { $extrarules; }';
59 $prefix = $devkit;
e12d4fb3 60 }
1b64d24d 61}
62
63$sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
e12d4fb3 64push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
92079298 65$inc = '-I.' unless $libfound;
66$inc .= " -I$prefix/include" if $prefix;
1b64d24d 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',
1e48c05a 74 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)'
75)
76 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
77
f8d0fe1d 78push @extras, META_MERGE => {
79 resources => {
80 repository => 'git://git.shadowcat.co.uk/catagits/fcgi2.git',
81 },
82} if $ExtUtils::MakeMaker::VERSION >= 6.46;
83
1e48c05a 84$plfiles = {
85 'echo.PL' => 'echo.fpl',
86 'remote.PL' => 'remote.fpl',
87 'threaded.PL' => 'threaded.fpl',
88 'FCGI.PL' => 'FCGI.pm',
89};
0833402a 90$plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
236be38d 91if ($pure) {
92 push @extras,
1e48c05a 93 LINKTYPE => ' ';
236be38d 94} else {
e87ca2dd 95
1e48c05a 96 if ("$sys" eq "win32") {
97 push @libs, ":nosearch -lws2_32";
98 push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
99 }
e87ca2dd 100
0833402a 101 push @extras,
1e48c05a 102 'LIBS' => [ "@libs" ],
103 'OBJECT' => "@o",
104 'INC' => $inc;
0833402a 105}
1e48c05a 106
1b64d24d 107# See lib/ExtUtils/MakeMaker.pm for details of how to influence
108# the contents of the Makefile that is written.
00cbdd93 109
110# Work around bug in previous versions of MakeMaker
d81643d2 111WriteMakefile(
1e48c05a 112 'NAME' => 'FCGI',
113 'VERSION_FROM' => 'version.pm',
114 'dist' => {
115 'COMPRESS' => 'gzip -9f',
116 'SUFFIX' => 'gz',
117 'PREOP' => '$(CP) '.join(' ',
118 map {"../$_"} @dist1,
119 (map {"libfcgi/$_"} @dist2),
120 map {"include/$_"} @dist3).' $(DISTVNAME);'.
121 '$(CP) MANIFEST MANIFEST.old;'.
3e13286a 122 'echo '. join('\\\n',@dist1,@dist2,@dist3) .
1e48c05a 123 '>> $(DISTVNAME)/MANIFEST',
124 'POSTOP' =>
125 '$(MV) MANIFEST.old MANIFEST',
126 },
127 'clean' => { FILES => 'config.cache fcgi_config.h' .
128 ' FCGI.xs FCGI.c FCGI.cfg ' .
129 (join ' ', values %$plfiles)},
130 'PL_FILES' => $plfiles,
131 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
0074e702 132 @extras,
d81643d2 133);
1b64d24d 134
e12d4fb3 135exit if -f 'fcgi_config.h' or $libfound 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
142 print "Using prebuilt fcgi_config.h file for Windows\n";
143 unlink("fcgi_config.h");
18c10cb1 144 my $confdir = $prefix ? "$prefix/include/" : '';
aff18d25 145 die $! unless copy("${confdir}fcgi_config_x86.h","fcgi_config.h");
e87ca2dd 146
147 # Win can't deal with existence of FCGI.xs or absence of FCGI.c
148 unlink("FCGI.xs");
149 open(F, ">FCGI.c"); close(F);
150 $now = time; $before = $now - 600;
151 utime $before, $before, "FCGI.c";
152 utime $now, $now, "FCGI.PL";
1b64d24d 153} else {
154 print "Running ./configure for you\n";
6ef7789b 155 print "Please read configure.readme for information on how to run it yourself\n";
1b64d24d 156
157 $ENV{'CC'} = $Config{'cc'};
d4b5dccc 158 system("$Config{sh} configure");
1b64d24d 159}
1e48c05a 160