change repository metadata to reference the github mirror
[catagits/fcgi2.git] / perl / Makefile.PL
1 # $Id: Makefile.PL,v 1.33 2002/12/15 19:40:19 skimo Exp $
2
3 use 5.006;
4 use ExtUtils::MakeMaker;
5 use IO::File;
6 use Config;
7 use Cwd 'cwd';
8 use Getopt::Long;
9 use File::Copy qw(copy);
10
11 @h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
12 @h = (@h1, 'fcgi_config.h');
13 @o = qw(FCGI.o);
14 @dist1 = qw(LICENSE.TERMS);
15 @dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
16 @dist3 = (@h1, qw(fcgi_config_x86.h));
17
18 GetOptions ("use-installed:s" => \$useinstalled);
19
20 $libfound = 0;
21 @libs = ();
22
23 my $cwd = cwd();
24 my $devkit = "$cwd/..";
25
26 if (defined $useinstalled) {
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     }
36 }
37 if (!$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;
46     }
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;
55 }
56
57
58 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
59 push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
60 $inc = '-I.' unless $libfound;
61 $inc .= " -I$prefix/include" if $prefix;
62
63 push(@extras, CAPI => 'TRUE')
64      if ($] >= 5.005 and $^O eq 'MSWin32'
65         and $Config{archname} =~ /-object\b/i);
66
67 push(@extras,
68     ABSTRACT => 'Fast CGI module',
69     AUTHOR   => 'Sven Verdoolaege (skimo@kotnet.org)'
70 ) if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
71
72 push @extras, META_MERGE => {
73     'meta-spec' => { version => 2 },
74     dynamic_config => 0,
75     resources => {
76         repository => {
77             # this is the real repository
78             # r/w: catagits@git.shadowcat.co.uk:fcgi2.git
79             # r/o: git://git.shadowcat.co.uk/catagits/fcgi2.git
80             # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/fcgi2.git
81             # this is a mirror, but can receive pull requests
82             url => 'https://github.com/perl-catalyst/FCGI.git',
83             web => 'https://github.com/perl-catalyst/FCGI',
84             type => 'git',
85         },
86         bugtracker => {
87             mailto => 'bug-FCGI@rt.cpan.org',
88             web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=FCGI',
89         },
90     },
91 } if $ExtUtils::MakeMaker::VERSION >= 6.46;
92
93 push(@extras,
94     MIN_PERL_VERSION => '5.006',
95 ) if $ExtUtils::MakeMaker::VERSION >= 6.48;
96
97 # not strictly necessary as everything is in core...
98 #push(@extras,
99 #    CONFIGURE_REQUIRES => {
100 #        ...
101 #    },
102 #) if $ExtUtils::MakeMaker::VERSION >= 6.51_03;
103
104 if ("$sys" eq "win32") {
105     push @libs, ":nosearch -lws2_32";
106     push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
107 }
108
109 push @extras,
110     'LIBS'    => [ "@libs" ],
111     'OBJECT'    => "@o",
112     'INC'    => $inc;
113
114 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
115 # the contents of the Makefile that is written.
116
117 # Work around bug in previous versions of MakeMaker
118 WriteMakefile(
119     'NAME'        => 'FCGI',
120     'VERSION_FROM'    => 'FCGI.pm',
121     'dist' => {
122         'COMPRESS' => 'gzip -9f',
123         'SUFFIX' => 'gz',
124         'PREOP' => '$(CP) '.join(' ',
125             map {"../$_"} @dist1,
126             (map {"libfcgi/$_"} @dist2),
127             map {"include/$_"} @dist3).' $(DISTVNAME);'.
128                 '$(CP) MANIFEST MANIFEST.old;'.
129                 '$(ECHO) '. join('\\\n',@dist1,@dist2,@dist3) .
130                 '>> $(DISTVNAME)/MANIFEST',
131                   'POSTOP' => 
132                 '$(MV) MANIFEST.old MANIFEST',
133     },
134     'clean'        => { FILES => 'config.cache fcgi_config.h fcgi_config.h.in' .
135                       ' FCGI.c aclocal.m4 autom4te.cache config.log config.status' .
136                       ' FCGI.cfg' },
137     'realclean'    => { FILES => 'configure MANIFEST.SKIP.bak MANIFEST.bak Makefile.old' },
138     PM            => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
139     PREREQ_PM     => {'XSLoader' => '0'},
140     @extras,
141 );
142
143 exit if -f 'fcgi_config.h' or $libfound;
144
145 # CPAN and no installed lib found
146 if ($sys eq "win32") {
147     # configure will almost certainly not run on a normal NT install,
148     # use the pregenerated configuration file
149
150     print "Using prebuilt fcgi_config.h file for Windows\n";
151     unlink("fcgi_config.h");
152     my $confdir = $prefix ? "$prefix/include/" : '';
153     die $! unless copy("${confdir}fcgi_config_x86.h","fcgi_config.h");
154 } else {
155     print "Running ./configure for you\n";
156     print "Please read configure.readme for information on how to run it yourself\n";
157
158     $ENV{'CC'} = $Config{'cc'};
159     if ( $^O eq 'android' && !$ENV{'TMPDIR'} ) {
160         # See http://stackoverflow.com/a/15417261
161         require File::Spec;
162         $ENV{'TMPDIR'} = File::Spec->tmpdir();
163     }
164     system("$Config{sh} configure");
165 }
166