canonicalize contributors
[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
043e7beb 3use 5.006;
1b64d24d 4use ExtUtils::MakeMaker;
5use IO::File;
6use Config;
7use Cwd 'cwd';
7bb01969 8use Getopt::Long;
1e48c05a 9use File::Copy qw(copy);
1b64d24d 10
ffaa0e42 11@h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
1b64d24d 12@h = (@h1, 'fcgi_config.h');
13@o = qw(FCGI.o);
e12d4fb3 14@dist1 = qw(LICENSE.TERMS);
1b64d24d 15@dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
7ef79c64 16@dist3 = (@h1, qw(fcgi_config_x86.h));
1b64d24d 17
08461774 18GetOptions ("use-installed:s" => \$useinstalled);
0833402a 19
e12d4fb3 20$libfound = 0;
c737f293 21@libs = ();
e12d4fb3 22
08461774 23my $cwd = cwd();
24my $devkit = "$cwd/..";
e12d4fb3 25
08461774 26if (defined $useinstalled) {
1e48c05a 27 require ExtUtils::Liblist;
28 my $libspec = $useinstalled ? "-L$useinstalled/lib " : "";
29 $libspec .= "-lfcgi";
30 my @l = MM->ext($libspec);
31 if ($l[0] || $l[1] || $l[2]) {
32 $prefix = "$useinstalled/include" if $useinstalled;
33 $libfound = 1;
34 push @libs, $libspec;
35 }
08461774 36}
37if (!$libfound && -d "$devkit/libfcgi" && -d "$devkit/include") {
38 # devkit
39 if (grep { ! -f "$devkit/include/$_" } @dist3
40 or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
41 {
42 warn "This appears to be a FastCGI devkit distribution, " .
43 "but one or more FastCGI library files are missing. \n" .
44 "Please check the integrity of the distribution.\n";
45 exit -1;
c737f293 46 }
08461774 47
48 my $extrarules = join "\n",
49 map { $b = $_; $b =~ s/\.c$//; my $s="$devkit/libfcgi/$b.c";
50 "$b\$(OBJ_EXT): $s\n\t".
51 '$(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) '."$s\n"; }
52 @dist2;
53 eval 'package MY; sub postamble { $extrarules; }';
54 $prefix = $devkit;
1b64d24d 55}
56
08461774 57
1b64d24d 58$sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
e12d4fb3 59push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
92079298 60$inc = '-I.' unless $libfound;
61$inc .= " -I$prefix/include" if $prefix;
1b64d24d 62
0074e702 63push(@extras, CAPI => 'TRUE')
64 if ($] >= 5.005 and $^O eq 'MSWin32'
65 and $Config{archname} =~ /-object\b/i);
66
67push(@extras,
68 ABSTRACT => 'Fast CGI module',
1e48c05a 69 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)'
08461774 70) if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
1e48c05a 71
f8d0fe1d 72push @extras, META_MERGE => {
d9085765 73 'meta-spec' => { version => 2 },
74 dynamic_config => 0,
f8d0fe1d 75 resources => {
d9085765 76 repository => {
77 # r/w: catagits@git.shadowcat.co.uk:fcgi2.git
78 url => 'git://git.shadowcat.co.uk/catagits/fcgi2.git',
79 web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/fcgi2.git',
80 type => 'git',
81 },
82 bugtracker => {
83 mailto => 'bug-FCGI@rt.cpan.org',
84 web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=FCGI',
85 },
f8d0fe1d 86 },
87} if $ExtUtils::MakeMaker::VERSION >= 6.46;
88
0a90482a 89push(@extras,
90 MIN_PERL_VERSION => '5.006',
91) if $ExtUtils::MakeMaker::VERSION >= 6.48;
92
93# not strictly necessary as everything is in core...
94#push(@extras,
95# CONFIGURE_REQUIRES => {
96# ...
97# },
98#) if $ExtUtils::MakeMaker::VERSION >= 6.51_03;
99
08461774 100if ("$sys" eq "win32") {
101 push @libs, ":nosearch -lws2_32";
102 push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
0833402a 103}
1e48c05a 104
08461774 105push @extras,
106 'LIBS' => [ "@libs" ],
107 'OBJECT' => "@o",
108 'INC' => $inc;
109
1b64d24d 110# See lib/ExtUtils/MakeMaker.pm for details of how to influence
111# the contents of the Makefile that is written.
00cbdd93 112
113# Work around bug in previous versions of MakeMaker
d81643d2 114WriteMakefile(
1e48c05a 115 'NAME' => 'FCGI',
f1bd23d5 116 'VERSION_FROM' => 'FCGI.pm',
1e48c05a 117 'dist' => {
118 'COMPRESS' => 'gzip -9f',
119 'SUFFIX' => 'gz',
120 'PREOP' => '$(CP) '.join(' ',
121 map {"../$_"} @dist1,
122 (map {"libfcgi/$_"} @dist2),
123 map {"include/$_"} @dist3).' $(DISTVNAME);'.
124 '$(CP) MANIFEST MANIFEST.old;'.
93981a50 125 '$(ECHO) '. join('\\\n',@dist1,@dist2,@dist3) .
1e48c05a 126 '>> $(DISTVNAME)/MANIFEST',
127 'POSTOP' =>
128 '$(MV) MANIFEST.old MANIFEST',
129 },
7c19e836 130 'clean' => { FILES => 'config.cache fcgi_config.h fcgi_config.h.in' .
131 ' FCGI.c aclocal.m4 autom4te.cache config.log config.status' .
132 ' FCGI.cfg' },
133 'realclean' => { FILES => 'configure MANIFEST.SKIP.bak MANIFEST.bak Makefile.old' },
1e48c05a 134 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
043e7beb 135 PREREQ_PM => {'XSLoader' => '0'},
0074e702 136 @extras,
d81643d2 137);
1b64d24d 138
08461774 139exit if -f 'fcgi_config.h' or $libfound;
1b64d24d 140
141# CPAN and no installed lib found
142if ($sys eq "win32") {
143 # configure will almost certainly not run on a normal NT install,
144 # use the pregenerated configuration file
145
146 print "Using prebuilt fcgi_config.h file for Windows\n";
147 unlink("fcgi_config.h");
18c10cb1 148 my $confdir = $prefix ? "$prefix/include/" : '';
aff18d25 149 die $! unless copy("${confdir}fcgi_config_x86.h","fcgi_config.h");
1b64d24d 150} else {
151 print "Running ./configure for you\n";
6ef7789b 152 print "Please read configure.readme for information on how to run it yourself\n";
1b64d24d 153
154 $ENV{'CC'} = $Config{'cc'};
a4c097db 155 if ( $^O eq 'android' && !$ENV{'TMPDIR'} ) {
156 # See http://stackoverflow.com/a/15417261
157 require File::Spec;
158 $ENV{'TMPDIR'} = File::Spec->tmpdir();
159 }
d4b5dccc 160 system("$Config{sh} configure");
1b64d24d 161}
1e48c05a 162