Commits

Anonymous committed 6d2a366

Better doc building
Support building on Win32 (untested)

Comments (0)

Files changed (1)

 use ExtUtils::MakeMaker;
 use Config;
 use Symbol;
+use File::Spec;
 
 $|=0;
 
 
 }
 
-my $LINK = "$Config{ld} -o conftest $Config{ccflags} -I$Config{incpath} %s $Config{lddlflags} $Config{ldflags} conftest.c $Config{libs} %s %s";
-
 if ($config{LIBS} !~ /\-lxml2\b/) {
     $config{LIBS} .= ' -lxml2';
 }
 DEATH
 }
 
+print <<EOT;
+If you are building XML::LibXML from CVS, you may wish to run
+
+  \$ make docs
+
+before doing anything else. This will re-build the documentation
+from the XML file in examples/libxml.xml. This is *not* necessary
+if you are building from a CPAN distribution.
+EOT
+
 WriteMakefile(
     'NAME'	=> 'XML::LibXML',
     'VERSION_FROM' => 'LibXML.pm', # finds $VERSION
     %config,
 );
 
+sub MY::manifypods {
+    package MY;
+    my $str = shift->SUPER::manifypods(@_);
+#    warn $str;
+#    $str =~ s/^manifypods : pure_all (.*)$/manifypods : pure_all docs $1/m;
+    $str .= <<EOF;
+
+docs : pure_all
+\t\@$^X -Iblib/arch -Iblib/lib example/xml2pod.pl example/libxml.xml lib
+\t\@$^X -pi.old -e 's/a/a/' Makefile.PL
+\t\@echo "==> YOU MUST NOW RE-RUN $^X Makefile.PL <=="
+\t\@false
+
+EOF
+    return $str;
+}
+
 ###################################################################
 # Functions
 #  - these should really be in MakeMaker... But &shrug;
 ###################################################################
 
+use vars qw/$LINK $DEVNULL $CC $is_Win32/;
+
+BEGIN {
+    $is_Win32 = ($^O =~ /Win32/);
+    if ($is_Win32) {
+        $CC = "$Config{cc} -c $Config{ccflags} -I$Config{incpath} %s conftest.c ";
+        $LINK = "LINK $Config{ccdlflags} $Config{ldflags} conftest.obj $Config{libs} %s %s ";
+        $DEVNULL = 'DEVNULL';
+    }
+    else {
+        $LINK = "$Config{cc} $Config{ccdlflags} -o conftest $Config{ccflags} -I$Config{incpath} $Config{ldflags} %s %s conftest.c $Config{libs} %s";
+        $DEVNULL = eval { File::Spec->devnull };
+        if ($@) { $DEVNULL = '/dev/null' }
+    }
+}
+
 sub rm_f {
     my @files = @_;
     my @realfiles;
     }
     open(OLDOUT, ">&STDOUT");
     open(OLDERR, ">&STDERR");
-    open(STDOUT, ">/dev/null");
-    open(STDERR, ">/dev/null");
+    open(STDOUT, ">$DEVNULL");
+    open(STDERR, ">$DEVNULL");
     my $retval = system($command);
     open(STDOUT, ">&OLDOUT");
     open(STDERR, ">&OLDERR");
     }
     open(OLDOUT, ">&STDOUT");
     open(OLDERR, ">&STDERR");
-    open(STDOUT, ">/dev/null");
-    open(STDERR, ">/dev/null");
+    open(STDOUT, ">$DEVNULL");
+    open(STDERR, ">$DEVNULL");
     my $results = `$command`;
     my $retval = $?;
     open(STDOUT, ">&OLDOUT");
     open($cfile, ">conftest.c") || die "Cannot write to file conftest.c";
     print $cfile $src;
     close($cfile);
-    xsystem(sprintf($LINK, $config{INC}, $config{LIBS}, $opt));
+    if ($is_Win32) {
+        xsystem(sprintf($CC, $config{INC}));
+        xsystem(sprintf($LINK, $config{LIBS}, $opt));
+    }
+    else {
+        xsystem(sprintf($LINK, $config{INC}, $config{LIBS}, $opt));      
+    }
 }
 
 sub try_link {
     my $result = eval {
         try_link0(@_);
     };
-    my $err = $@;
+    warn $@ if $DEBUG && $@;
     rm_f("conftest*");
-    if ($err) {
-        die $err;
-    }
     return $result;
 }
 
 sub have_library {
     my ($lib, $func) = (@_, "main");
     printf("checking for %s() in -l%s... ", $func, $lib);
-    
+
     my $result;
     if ($func) {
-        my $libs = "-l$lib";
-        eval {
-        $result = try_link(<<"SRC", $libs);
+        my $libs = $is_Win32 ? " $lib.lib  " : "-l$lib";
+        if ($is_Win32) {
+            $result = try_link(<<"SRC", $libs);
+#include <windows.h>
+#include <winsock.h>
 int main() { return 0; }
 int t() { ${func}(); return 0; }
 SRC
-        };
-        if ($@) {
-            warn $@ if $DEBUG;
+            unless ($result) {
+                $result = try_link(<<"SRC", $libs);
+#include <windows.h>
+#include <winsock.h>
+int main() { return 0; }
+int t() { void ((*p)()); p = (void ((*)()))${func}; return 0; }
+SRC
+            }
+        }
+        else {
+
+            $result = try_link(<<"SRC", $libs);
+int main() { return 0; }
+int t() { ${func}(); return 0; }
+SRC
         }
     }
-    
+
     unless ($result) {
         print "no\n";
         return 0;
     }
-    
+
     if ($func ne "main") {
         $config{DEFINE} .= uc(" -Dhave_$func");
     }
-    
+
     print "yes\n";
     return 1;
 }