IsFastCGI
[catagits/fcgi2.git] / perl / Makefile.PL
CommitLineData
9915cd6d 1# $Id: Makefile.PL,v 1.5 2000/11/01 14:27:49 skimo Exp $
1b64d24d 2
3use ExtUtils::MakeMaker;
4use IO::File;
5use Config;
6use Cwd 'cwd';
7
8@h1 = qw(fastcgi.h fcgiapp.h fcgiappmisc.h fcgimisc.h fcgios.h);
9@h = (@h1, 'fcgi_config.h');
10@o = qw(FCGI.o);
11@dist1 = qw(LICENSE.TERMS acconfig.h);
12@dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
13@dist3 = (@h1, qw(fcgi_config.h.in fcgi_config_x86.h));
14
15$devkit = cwd() . "/..";
16
17if (-d "$devkit/libfcgi/" && -f "$devkit/libfcgi/libfcgi.a"
18 && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h))
19{
20 # devkit
21 $prefix = $devkit;
22 push @libs, "-L$devkit/libfcgi -lfcgi";
23}
24else {
25 # CPAN
26 for $dir ("/usr", "/usr/local") {
27 if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a"
28 && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h))
29 {
30 print "Found fcgi library and include files in $dir\n";
31 print "Will be using that instead of included files\n";
32 print "Edit Makefile.PL if you don't like it\n";
33
34 $prefix = $dir;
35 push @libs, "-L$dir/lib -lfcgi";
36 last;
37 }
38 }
39}
40
41$sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
42push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
43$inc = $prefix ? "-I$prefix/include" : '-I.';
44
0074e702 45push(@extras, CAPI => 'TRUE')
46 if ($] >= 5.005 and $^O eq 'MSWin32'
47 and $Config{archname} =~ /-object\b/i);
48
49push(@extras,
50 ABSTRACT => 'Fast CGI module',
51 AUTHOR => 'Sven Verdoolaege (skimo@kotnet.org)')
52 if ($ExtUtils::MakeMaker::VERSION >= 5.4301);
53
1b64d24d 54# See lib/ExtUtils/MakeMaker.pm for details of how to influence
55# the contents of the Makefile that is written.
56WriteMakefile(
57 'NAME' => 'FCGI',
58 'VERSION_FROM' => 'FCGI.pm',
59 'LIBS' => [ @libs ],
60 'OBJECT' => "@o",
61 'INC' => $inc,
62 'dist' => { 'COMPRESS' => 'gzip -9f',
63 'SUFFIX' => 'gz',
64 'PREOP' => '$(CP) '.join(' ',
65 map {"../$_"} @dist1,
66 (map {"libfcgi/$_"} @dist2),
67 map {"include/$_"} @dist3).' $(DISTVNAME);'.
68 '$(CP) MANIFEST MANIFEST.old;'.
69 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
70 '>> $(DISTVNAME)/MANIFEST',
71 'POSTOP' =>
72 '$(MV) MANIFEST.old MANIFEST',
73 },
74 'clean' => { FILES => 'config.cache fcgi_config.h' },
34bfd355 75 'PL_FILES' => { 'echo.PL' => 'echo.fpl',
9915cd6d 76 'remote.PL' => 'remote.fpl',
34bfd355 77 'threaded.PL' => 'threaded.fpl',
78 'FCGI.PL' => 'FCGI.xs',
79 },
0074e702 80 @extras,
1b64d24d 81);
82
83exit if -f 'fcgi_config.h' or $prefix;
84
85# CPAN and no installed lib found
86if ($sys eq "win32") {
87 # configure will almost certainly not run on a normal NT install,
88 # use the pregenerated configuration file
89
90 print "Using prebuilt fcgi_config.h file for Windows\n";
91 unlink("fcgi_config.h");
92 die $! unless rename("fcgi_config_x86.h","fcgi_config.h");
93
94 # Win build system also can't deal with existence of FCGI.xs or absence of
95 # FCGI.c
96 unlink("FCGI.xs");
97 open(F, ">FCGI.c"); close(F);
98 $now = time; $before = $now - 600;
99 utime $before, $before, "FCGI.c";
100 utime $now, $now, "FCGI.PL";
101
102} else {
103 print "Running ./configure for you\n";
6ef7789b 104 print "Please read configure.readme for information on how to run it yourself\n";
1b64d24d 105
106 $ENV{'CC'} = $Config{'cc'};
107 system("./configure");
108}