Rename Perl -> perl (gotta move all the files).
[catagits/fcgi2.git] / perl / Makefile.PL
1 # $Id: Makefile.PL,v 1.1 1999/02/13 05:26:44 roberts Exp $
2
3 use ExtUtils::MakeMaker;
4 use IO::File;
5 use Config;
6 use 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
17 if (-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
24 else {
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';
42 push @o, "fcgiapp.o", "os_$sys.o" unless $prefix;
43 $inc = $prefix ? "-I$prefix/include" : '-I.';
44
45 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
46 # the contents of the Makefile that is written.
47 WriteMakefile(
48     'NAME'              => 'FCGI',
49     'VERSION_FROM'      => 'FCGI.pm',
50     'LIBS'              => [ @libs ],
51     'OBJECT'    => "@o",
52     'INC'               => $inc,
53     'dist'              => { 'COMPRESS' => 'gzip -9f', 
54                              'SUFFIX' => 'gz',
55                              'PREOP' => '$(CP) '.join(' ',
56                                 map {"../$_"} @dist1,
57                                 (map {"libfcgi/$_"} @dist2),
58                                 map {"include/$_"} @dist3).' $(DISTVNAME);'.
59                                 '$(CP) MANIFEST MANIFEST.old;'.
60                                 'echo -e '. join('\\\n',@dist1,@dist2,@dist3) .
61                                 '>> $(DISTVNAME)/MANIFEST',
62                               'POSTOP' => 
63                                 '$(MV) MANIFEST.old MANIFEST',
64                             },
65     'clean'             => { FILES => 'config.cache fcgi_config.h' },
66     'PL_FILES'  => { 'echo.PL' => 'echo.fpl', 'FCGI.PL' => 'FCGI.xs' },
67 );
68
69 exit if -f 'fcgi_config.h' or $prefix;
70
71 # CPAN and no installed lib found
72 if ($sys eq "win32") {
73     # configure will almost certainly not run on a normal NT install,
74     # use the pregenerated configuration file
75
76     print "Using prebuilt fcgi_config.h file for Windows\n";
77     unlink("fcgi_config.h");
78     die $! unless rename("fcgi_config_x86.h","fcgi_config.h");
79
80     # Win build system also can't deal with existence of FCGI.xs or absence of
81     # FCGI.c
82     unlink("FCGI.xs");
83     open(F, ">FCGI.c"); close(F);
84     $now = time; $before = $now - 600;
85     utime $before, $before, "FCGI.c";
86     utime $now, $now, "FCGI.PL";
87
88 } else {
89     print "Running ./configure for you\n";
90     print "Please read INSTALL for information on how to run it yourself\n";
91
92     $ENV{'CC'} = $Config{'cc'};
93     system("./configure");
94 }