Remove references to files that have been removed from the kit.
[catagits/fcgi2.git] / perl / Makefile.PL
1 # $Id: Makefile.PL,v 1.12 2001/08/27 19:53:58 robs Exp $
2
3 use ExtUtils::MakeMaker;
4 use IO::File;
5 use Config;
6 use Cwd 'cwd';
7 use Getopt::Long;
8
9 @h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
10 @h = (@h1, 'fcgi_config.h');
11 @o = qw(FCGI.o);
12 @dist1 = qw(LICENSE.TERMS acconfig.h);
13 @dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
14 @dist3 = (@h1, qw(fcgi_config.h.in fcgi_config_x86.h));
15
16 GetOptions ("pure-perl!" => \$pure);
17 $pure = 
18     (prompt("Do you want to use the pure perl implementation", "no") =~ /^y/) 
19     ? "1" : "0" unless defined $pure;
20 open(CFG,">FCGI.cfg");
21 print CFG "\$pure = $pure;1;\n";
22 close CFG;
23
24 $devkit = cwd() . "/..";
25
26 if (-d "$devkit/libfcgi/" 
27     && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h)) 
28 {
29     unless (-f "$devkit/libfcgi/libfcgi.a") {
30         warn "Please compile the library before attempting " .
31               "to compile the perl module.\n";
32         exit -1;
33     }
34     # devkit
35     $prefix = $devkit;
36     push @libs, "-L$devkit/libfcgi -lfcgi";
37
38 else {
39     # CPAN  
40     for $dir ("/usr", "/usr/local") {
41         if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a" 
42                 && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h)) 
43         {
44             print "Found fcgi library and include files in $dir\n";
45             print "Will be using that instead of included files\n";
46             print "Edit Makefile.PL if you don't like it\n";
47             
48             $prefix = $dir;
49             push @libs, "-L$dir/lib -lfcgi"; 
50             last;
51         }
52     }
53 }
54
55 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
56 push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
57 $inc = $prefix ? "-I$prefix/include" : '-I.';
58
59 push(@extras, CAPI => 'TRUE')
60      if ($] >= 5.005 and $^O eq 'MSWin32'
61         and $Config{archname} =~ /-object\b/i);
62
63 push(@extras,
64     ABSTRACT => 'Fast CGI module',
65     AUTHOR   => 'Sven Verdoolaege (skimo@kotnet.org)')
66         if ($ExtUtils::MakeMaker::VERSION >= 5.4301); 
67
68 $plfiles = { 'echo.PL' => 'echo.fpl', 
69              'remote.PL' => 'remote.fpl',
70              'threaded.PL' => 'threaded.fpl',
71              'FCGI.PL' => 'FCGI.pm',
72            };
73 $plfiles->{'FCGI.XL'} = 'FCGI.xs' unless $pure;
74 if ($pure) {
75     push @extras,
76         LINKTYPE => ' ';
77 } else {
78     push @extras,
79         'LIBS'  => [ @libs ],
80         'OBJECT'        => "@o",
81         'INC'   => $inc;
82 }
83         
84 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
85 # the contents of the Makefile that is written.
86
87 # Work around bug in previous versions of MakeMaker
88 WriteMakefile(NAME => 'FCGI') 
89     if $ExtUtils::MakeMaker::VERSION <= 5.4302;
90
91 $mm = MM->new({
92     'NAME'              => 'FCGI',
93     'VERSION_FROM'      => 'FCGI.PL',
94     'dist'              => { 'COMPRESS' => 'gzip -9f', 
95                              'SUFFIX' => 'gz',
96                              'PREOP' => '$(CP) '.join(' ',
97                                 map {"../$_"} @dist1,
98                                 (map {"libfcgi/$_"} @dist2),
99                                 map {"include/$_"} @dist3).' $(DISTVNAME);'.
100                                 '$(CP) MANIFEST MANIFEST.old;'.
101                                 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
102                                 '>> $(DISTVNAME)/MANIFEST',
103                               'POSTOP' => 
104                                 '$(MV) MANIFEST.old MANIFEST',
105                             },
106     'clean'             => { FILES => 'config.cache fcgi_config.h' . 
107                                       ' FCGI.xs FCGI.c FCGI.cfg ' .
108                                       (join ' ', values %$plfiles)},
109     'PL_FILES'          => $plfiles,
110     PM                  => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'},
111     @extras,
112 });
113 # don't install oldinterface pod
114 delete $mm->{MAN3PODS}{oldinterface.pod};
115 $mm->flush;
116
117 exit if -f 'fcgi_config.h' or $prefix or $pure;
118
119 # CPAN and no installed lib found
120 if ($sys eq "win32") {
121     # configure will almost certainly not run on a normal NT install,
122     # use the pregenerated configuration file
123
124     use File::Copy qw(copy);
125     print "Using prebuilt fcgi_config.h file for Windows\n";
126     unlink("fcgi_config.h");
127     die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
128
129     # Win build system also can't deal with existence of FCGI.xs or absence of
130     # FCGI.c
131     unlink("FCGI.xs");
132     open(F, ">FCGI.c"); close(F);
133     $now = time; $before = $now - 600;
134     utime $before, $before, "FCGI.c";
135     utime $now, $now, "FCGI.PL";
136
137 } else {
138     print "Running ./configure for you\n";
139     print "Please read configure.readme for information on how to run it yourself\n";
140
141     $ENV{'CC'} = $Config{'cc'};
142     system("./configure");
143 }