Moved examples to eg/
[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
08461774 17GetOptions ("use-installed:s" => \$useinstalled);
0833402a 18
e12d4fb3 19$libfound = 0;
c737f293 20@libs = ();
e12d4fb3 21
08461774 22my $cwd = cwd();
23my $devkit = "$cwd/..";
e12d4fb3 24
08461774 25if (defined $useinstalled) {
1e48c05a 26 require ExtUtils::Liblist;
27 my $libspec = $useinstalled ? "-L$useinstalled/lib " : "";
28 $libspec .= "-lfcgi";
29 my @l = MM->ext($libspec);
30 if ($l[0] || $l[1] || $l[2]) {
31 $prefix = "$useinstalled/include" if $useinstalled;
32 $libfound = 1;
33 push @libs, $libspec;
34 }
08461774 35}
36if (!$libfound && -d "$devkit/libfcgi" && -d "$devkit/include") {
37 # devkit
38 if (grep { ! -f "$devkit/include/$_" } @dist3
39 or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
40 {
41 warn "This appears to be a FastCGI devkit distribution, " .
42 "but one or more FastCGI library files are missing. \n" .
43 "Please check the integrity of the distribution.\n";
44 exit -1;
c737f293 45 }
08461774 46
47 my $extrarules = join "\n",
48 map { $b = $_; $b =~ s/\.c$//; my $s="$devkit/libfcgi/$b.c";
49 "$b\$(OBJ_EXT): $s\n\t".
50 '$(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) '."$s\n"; }
51 @dist2;
52 eval 'package MY; sub postamble { $extrarules; }';
53 $prefix = $devkit;
1b64d24d 54}
55
08461774 56
1b64d24d 57$sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
e12d4fb3 58push @o, "fcgiapp.o", "os_$sys.o" unless $libfound;
92079298 59$inc = '-I.' unless $libfound;
60$inc .= " -I$prefix/include" if $prefix;
1b64d24d 61
0074e702 62push(@extras, CAPI => 'TRUE')
63 if ($] >= 5.005 and $^O eq 'MSWin32'
64 and $Config{archname} =~ /-object\b/i);
65
66push(@extras,
67 ABSTRACT => 'Fast CGI module',
1e48c05a 68 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)'
08461774 69) if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
1e48c05a 70
f8d0fe1d 71push @extras, META_MERGE => {
72 resources => {
73 repository => 'git://git.shadowcat.co.uk/catagits/fcgi2.git',
74 },
75} if $ExtUtils::MakeMaker::VERSION >= 6.46;
76
08461774 77if ("$sys" eq "win32") {
78 push @libs, ":nosearch -lws2_32";
79 push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
0833402a 80}
1e48c05a 81
08461774 82push @extras,
83 'LIBS' => [ "@libs" ],
84 'OBJECT' => "@o",
85 'INC' => $inc;
86
1b64d24d 87# See lib/ExtUtils/MakeMaker.pm for details of how to influence
88# the contents of the Makefile that is written.
00cbdd93 89
90# Work around bug in previous versions of MakeMaker
d81643d2 91WriteMakefile(
1e48c05a 92 'NAME' => 'FCGI',
f1bd23d5 93 'VERSION_FROM' => 'FCGI.pm',
1e48c05a 94 'dist' => {
95 'COMPRESS' => 'gzip -9f',
96 'SUFFIX' => 'gz',
97 'PREOP' => '$(CP) '.join(' ',
98 map {"../$_"} @dist1,
99 (map {"libfcgi/$_"} @dist2),
100 map {"include/$_"} @dist3).' $(DISTVNAME);'.
101 '$(CP) MANIFEST MANIFEST.old;'.
93981a50 102 '$(ECHO) '. join('\\\n',@dist1,@dist2,@dist3) .
1e48c05a 103 '>> $(DISTVNAME)/MANIFEST',
104 'POSTOP' =>
105 '$(MV) MANIFEST.old MANIFEST',
106 },
107 'clean' => { FILES => 'config.cache fcgi_config.h' .
b3029f84 108 ' FCGI.c ' },
1e48c05a 109 PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
0074e702 110 @extras,
d81643d2 111);
1b64d24d 112
08461774 113exit if -f 'fcgi_config.h' or $libfound;
1b64d24d 114
115# CPAN and no installed lib found
116if ($sys eq "win32") {
117 # configure will almost certainly not run on a normal NT install,
118 # use the pregenerated configuration file
119
120 print "Using prebuilt fcgi_config.h file for Windows\n";
121 unlink("fcgi_config.h");
18c10cb1 122 my $confdir = $prefix ? "$prefix/include/" : '';
aff18d25 123 die $! unless copy("${confdir}fcgi_config_x86.h","fcgi_config.h");
1b64d24d 124} else {
125 print "Running ./configure for you\n";
6ef7789b 126 print "Please read configure.readme for information on how to run it yourself\n";
1b64d24d 127
128 $ENV{'CC'} = $Config{'cc'};
d4b5dccc 129 system("$Config{sh} configure");
1b64d24d 130}
1e48c05a 131