add config.*
[catagits/fcgi2.git] / perl / Makefile.PL
index 7783a42..e749f38 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.PL,v 1.12 2001/08/27 19:53:58 robs Exp $
+# $Id: Makefile.PL,v 1.25 2001/09/21 16:14:11 skimo Exp $
 
 use ExtUtils::MakeMaker;
 use IO::File;
@@ -9,47 +9,58 @@ use Getopt::Long;
 @h1 = qw(fastcgi.h fcgiapp.h fcgimisc.h fcgios.h);
 @h = (@h1, 'fcgi_config.h');
 @o = qw(FCGI.o);
-@dist1 = qw(LICENSE.TERMS acconfig.h);
+@dist1 = qw(LICENSE.TERMS configure configure.in install.sh missing
+            config.sub config.guess ltmain.sh);
 @dist2 = qw(fcgiapp.c os_unix.c os_win32.c);
 @dist3 = (@h1, qw(fcgi_config.h.in fcgi_config_x86.h));
 
 GetOptions ("pure-perl!" => \$pure);
-$pure = 
-    (prompt("Do you want to use the pure perl implementation", "no") =~ /^y/) 
-    ? "1" : "0" unless defined $pure;
+$pure = "0" unless defined $pure;
 open(CFG,">FCGI.cfg");
 print CFG "\$pure = $pure;1;\n";
 close CFG;
 
-$devkit = cwd() . "/..";
-
-if (-d "$devkit/libfcgi/" 
-    && -d "$devkit/include" && !grep {!-f "$devkit/include/$_"} (@h)) 
-{
-    unless (-f "$devkit/libfcgi/libfcgi.a") {
-       warn "Please compile the library before attempting " .
-             "to compile the perl module.\n";
-       exit -1;
-    }
-    # devkit
-    $prefix = $devkit;
-    push @libs, "-L$devkit/libfcgi -lfcgi";
-} 
-else {
-    # CPAN  
-    for $dir ("/usr", "/usr/local") {
-        if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a" 
-               && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h)) 
-        {
-            print "Found fcgi library and include files in $dir\n";
-            print "Will be using that instead of included files\n";
-            print "Edit Makefile.PL if you don't like it\n";
-            
-            $prefix = $dir;
-            push @libs, "-L$dir/lib -lfcgi"; 
-            last;
-        }
-    }
+if (! $pure) {
+       my $cwd = cwd();
+       my $devkit = "$cwd/..";
+
+       if (-d "$devkit/libfcgi" && -d "$devkit/include") {
+               # devkit
+               if (grep { ! -f "$devkit/include/$_" } @dist3 
+                       or grep { ! -f "$devkit/libfcgi/$_" } @dist2)
+               {
+                       warn "This appears to be a FastCGI devkit distribution, " .
+                                "but one or more FastCGI library files are missing. \n" .
+                                "Please check the integrity of the distribution.\n";
+                       exit -1;
+               }
+
+               # Copy the C lib files down to ensure a compatible build.
+               print "Copying C library files from the devkit distribution\n";
+           use File::Copy qw(copy);
+
+               # TODO: stop or save if a local file has been modified
+               foreach (@dist1, @dist2, @dist3) { unlink };
+               foreach (@dist1) { copy("$devkit/$_", ".") || die $! };
+               foreach (@dist2) { copy("$devkit/libfcgi/$_", ".") || die $! };
+               foreach (@dist3) { copy("$devkit/include/$_", ".") || die $! };
+       }
+       else {
+           # CPAN  
+           for $dir ("/usr", "/usr/local") {
+               if (-d "$dir/lib/" && -f "$dir/lib/libfcgi.a" 
+                       && -d "$dir/include" && !grep {!-f "$dir/include/$_"} (@h)) 
+               {
+                   print "Found fcgi library and include files in $dir\n";
+                   print "Will be using those instead of the included files\n";
+                   print "Edit Makefile.PL if you don't like it\n";
+                   
+                   $prefix = $dir;
+                   push @libs, "-L$dir/lib -lfcgi"; 
+                   last;
+               }
+           }
+       }
 }
 
 $sys = $^O eq 'MSWin32' ? 'win32' : 'unix';
@@ -75,6 +86,14 @@ if ($pure) {
     push @extras,
        LINKTYPE => ' ';
 } else {
+
+       if ("$sys" eq "win32") {
+               @libs = (scalar @libs)
+                       ? map { "$_ :nosearch -lws2_32" } @libs 
+                       : (':nosearch -lws2_32');
+               push @extras, 'DEFINE' => '-DDLLAPI=__declspec(dllexport)';
+       }
+
     push @extras,
        'LIBS'  => [ @libs ],
        'OBJECT'        => "@o",
@@ -90,7 +109,7 @@ WriteMakefile(NAME => 'FCGI')
 
 $mm = MM->new({
     'NAME'             => 'FCGI',
-    'VERSION_FROM'     => 'FCGI.PL',
+    'VERSION_FROM'     => 'version.pm',
     'dist'             => { 'COMPRESS' => 'gzip -9f', 
                             'SUFFIX' => 'gz',
                             'PREOP' => '$(CP) '.join(' ',
@@ -126,18 +145,16 @@ if ($sys eq "win32") {
     unlink("fcgi_config.h");
     die $! unless copy("fcgi_config_x86.h","fcgi_config.h");
 
-    # Win build system also can't deal with existence of FCGI.xs or absence of
-    # FCGI.c
+    # Win can't deal with existence of FCGI.xs or absence of FCGI.c
     unlink("FCGI.xs");
     open(F, ">FCGI.c"); close(F);
     $now = time; $before = $now - 600;
     utime $before, $before, "FCGI.c";
     utime $now, $now, "FCGI.PL";
-
 } else {
     print "Running ./configure for you\n";
     print "Please read configure.readme for information on how to run it yourself\n";
 
     $ENV{'CC'} = $Config{'cc'};
-    system("./configure");
+    system("$Config{sh} configure");
 }