Source

perl-XML-LibXML / Makefile.PL

ma...@9ae0c189-c… 7f5ccab 




ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… 7f5ccab 




ph...@9ae0c189-c… d063313 





ph...@9ae0c189-c… 7a583ce 
ph...@9ae0c189-c… d063313 

ph...@9ae0c189-c… 7a583ce 
ma...@9ae0c189-c… 7f5ccab 






ph...@9ae0c189-c… 8513b0f 
ph...@9ae0c189-c… 3a3e157 
ph...@9ae0c189-c… d069086 
ph...@9ae0c189-c… 8513b0f 



ma...@9ae0c189-c… 7f5ccab 
ph...@9ae0c189-c… e59e8c7 
ph...@9ae0c189-c… f41b7cc 
ph...@9ae0c189-c… e59e8c7 




ph...@9ae0c189-c… f41b7cc 
ph...@9ae0c189-c… e59e8c7 



















ph...@9ae0c189-c… f41b7cc 
ph...@9ae0c189-c… e59e8c7 
ma...@9ae0c189-c… 7f5ccab 






ph...@9ae0c189-c… e59e8c7 
ph...@9ae0c189-c… 431bb77 

ph...@9ae0c189-c… a289060 

ph...@9ae0c189-c… 431bb77 










ph...@9ae0c189-c… a289060 

ph...@9ae0c189-c… 431bb77 






ma...@9ae0c189-c… 7f5ccab 

ph...@9ae0c189-c… e59e8c7 
ma...@9ae0c189-c… 7f5ccab 
ph...@9ae0c189-c… d063313 


ma...@9ae0c189-c… 7f5ccab 


ph...@9ae0c189-c… d063313 








ma...@9ae0c189-c… 7f5ccab 


ph...@9ae0c189-c… f41b7cc 




ma...@9ae0c189-c… 7f5ccab 

ph...@9ae0c189-c… e59e8c7 
ma...@9ae0c189-c… 7f5ccab 



ph...@9ae0c189-c… 7051277 
ma...@9ae0c189-c… 7f5ccab 




ma...@9ae0c189-c… 6d2a366 









ma...@9ae0c189-c… 7f5ccab 


ph...@9ae0c189-c… 7051277 
ma...@9ae0c189-c… 7f5ccab 
ph...@9ae0c189-c… 7051277 
ph...@9ae0c189-c… a289060 


ma...@9ae0c189-c… 7f5ccab 
ma...@9ae0c189-c… 4243349 
ma...@9ae0c189-c… 7f5ccab 


ma...@9ae0c189-c… 6d2a366 







ph...@9ae0c189-c… d069086 
ph...@9ae0c189-c… ffeffa7 
ma...@9ae0c189-c… 6d2a366 






ma...@9ae0c189-c… e3634d0 







ph...@9ae0c189-c… a289060 
ma...@9ae0c189-c… e3634d0 






ma...@9ae0c189-c… 7f5ccab 




ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… b01da26 
ma...@9ae0c189-c… f08c141 

ma...@9ae0c189-c… b01da26 

ma...@9ae0c189-c… 6d2a366 











ma...@9ae0c189-c… 7f5ccab 











ma...@9ae0c189-c… b01da26 




















ma...@9ae0c189-c… 7f5ccab 










ma...@9ae0c189-c… 6d2a366 

ma...@9ae0c189-c… 7f5ccab 





















ma...@9ae0c189-c… 6d2a366 

ma...@9ae0c189-c… 7f5ccab 













ma...@9ae0c189-c… f08c141 





ma...@9ae0c189-c… b01da26 

ma...@9ae0c189-c… f08c141 











ma...@9ae0c189-c… 7f5ccab 
ma...@9ae0c189-c… f08c141 






ma...@9ae0c189-c… 7f5ccab 
ma...@9ae0c189-c… b01da26 
ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… b01da26 


ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… b01da26 




ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… b01da26 
ma...@9ae0c189-c… f08c141 






ma...@9ae0c189-c… b01da26 

ma...@9ae0c189-c… f08c141 





ma...@9ae0c189-c… 3de52f3 

ph...@9ae0c189-c… 7051277 




ma...@9ae0c189-c… 3de52f3 
ph...@9ae0c189-c… f41b7cc 
ma...@9ae0c189-c… 7f5ccab 

ma...@9ae0c189-c… b01da26 
ma...@9ae0c189-c… 7f5ccab 


ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… b01da26 

ma...@9ae0c189-c… 7f5ccab 



ma...@9ae0c189-c… f08c141 


ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… 7f5ccab 

ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… 3de52f3 
ma...@9ae0c189-c… 6d2a366 
ph...@9ae0c189-c… 7051277 
ma...@9ae0c189-c… 6d2a366 

ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… 7f5ccab 

ma...@9ae0c189-c… 6d2a366 
ph...@9ae0c189-c… 7051277 
ma...@9ae0c189-c… 6d2a366 

ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… 6d2a366 




ph...@9ae0c189-c… 7051277 
ma...@9ae0c189-c… f08c141 
ma...@9ae0c189-c… 6d2a366 

ma...@9ae0c189-c… 7f5ccab 

ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… 7f5ccab 



ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… 7f5ccab 


ma...@9ae0c189-c… 6d2a366 
ma...@9ae0c189-c… 7f5ccab 

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# $Id$

use ExtUtils::MakeMaker;
use Config;
use Symbol;
use File::Spec;

$|=0;

my %config;


# maybe i am doing something wrong here, but on my system parse_fh()
# refuses to work correctly with libxml2 versions below 2.4.25 :|
# (without even a code change at that level)
# someone else should run tests with this package, since i can't 
# trigger this problem. 
my ( $lib_major, $lib_minor, $lib_patch ) = (2, 4, 20);
# uncomment for release?
# my ( $lib_major, $lib_minor, $lib_patch ) = (2, 4, 25);

while($_ = shift) {
    my ($key, $val) = split(/=/, $_, 2);
    $config{$key} = $val;
}

my $DEBUG = delete $config{DEBUG};

# $config{DEFINE} .= " -DXS_WARNINGS";

if ( $] >= 5.006 ) {
    warn "enable native perl UTF8\n";
    $config{DEFINE} .= " -DHAVE_UTF8";
}

# get libs and inc from gnome-config

unless ( $is_Win32 ) {
    eval {
        my $xml2cfg = "xml2-config";
        if ( defined $ENV{XMLPREFIX} ) {
            $xml2cfg = $ENV{XMLPREFIX} . '/bin/' . $xml2cfg;
        }

        print "running xml2-config... ";
        my $ver = backtick("$xml2cfg --version");
        my ($major, $minor, $point) = $ver =~ /(\d+).(\d+)\.(\d+)/g;
        die "VERSION $major.$minor.$point" unless $major > $lib_major
          || ($major == $lib_major && $minor > $lib_minor)
            || ($major == $lib_major && $minor == $lib_minor && $point >= $lib_patch);
        $config{LIBS} ||= backtick("$xml2cfg --libs");
        $config{INC}  ||= backtick("$xml2cfg --cflags");
        print "ok\n";
    };
    if ($@) {
        print "failed\n";
        if ($@ =~ /^VERSION/) {
            die "XML::LibXML needs libxml2 version $lib_major.$lib_minor.$lib_patch or higher (found $@)\n";
        }
        warn "*** ", $@ if $DEBUG;
        warn "using fallback values for LIBS and INC\n";
        # backtick fails if gnome-config didn't exist...
        $config{LIBS} = '-L/usr/local/lib -L/usr/lib -lxml2 -lz -lm';
        $config{INC} = '-I/usr/local/include -I/usr/include';

        print <<OPT;
options:
  LIBS='$config{LIBS}'
  INC='$config{INC}'
If this is wrong, Re-run as:
  \$ $^X Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include'

OPT
    }

    # test for libgdome
    my ( $g_major, $g_minor, $g_patch ) = (0, 7, 3);

    eval {
        print "running gdome-config...";
        my $ver = backtick("gdome-config --version");
        ($major, $minor, $point) = $ver =~ /(\d+).(\d+)\.(\d+)/g;
        die "VERSION " unless $major > $g_major
             || ($major == $g_major && $minor > $g_minor)
             || ($major == $g_major && $minor == $g_minor && $point >= $g_patch) ;
            print "ok\n";
            print "make use of GDOME support\n";
            print "NOTE: You will still have to install XML::GDOME to make\n";
            print "      use of this feature\n";
            $config{LIBS} = backtick("gdome-config --libs");
            $config{INC}  = backtick("gdome-config --cflags");
            $config{DEFINE} .= " -DXML_LIBXML_GDOME_SUPPORT";
    };
    if ($@) {
       print "failed\n";
       print "GDOME support is optional and is not required for running\n";
       print "this package\n";
   }
}


if ($config{LIBS} !~ /\-lxml2\b/) {
    # in this case we are not able to run xml2-config. therefore we need to
    # expand the libz as well.
    $config{LIBS} .= $is_Win32 ? ' -llibxml2 -lzlib' : ' -lxml2 -lz';
}

if ($config{LIBS} !~ /\-lz\b/) {
    # note if libxml2 has not -lz within its cflags, we should not use
    # it! We should trust libxml2 and assume libz is not available on the
    # current system (this is ofcourse not true with win32 systems.
    # $config{LIBS} .= $is_Win32 ? ' -lzlib' :' -lz';
    if ( $config{DEBUG} ) {
        warn "zlib was not configured\n";
        warn "set zlib\n" if $is_Win32;
    }
    $config{LIBS} .= $is_Win32 ? ' -lzlib' :'';
}

if ($config{LIBS} !~ /\-lm\b/) {
    $config{LIBS} .= $is_Win32 ? '' :' -lm';
}

if ( $config{DEBUG} ) {
    warn "win32 compile\n" if $is_Win32;
}

unless (have_library("xml2") or have_library("libxml2")) {
    die <<DEATH;
libxml2 not found
Try setting LIBS and INC values on the command line
Or get libxml2 from 
  http://xmlsoft.org/
If you install via RPMs, make sure you also install the -devel
RPMs, as this is where the headers (.h files) are.
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
    'AUTHOR'    => 'Christian Glahn',
    'ABSTRACT'  => 'Interface to Gnome libxml2 xml parsing and DOM library',
    'PREREQ_PM' => { 'XML::SAX' => '0.11',
                     'XML::NamespaceSupport' => '1.07',
                     'XML::LibXML::Common' => 0,
                   },
    'OBJECT'    => '$(O_FILES)', # add the DOM extensions to libxml2
    'dist'      => { PREOP => "$^X -Iblib/arch -Iblib/lib example/xml2pod.pl" },
    %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/XML/LibXML/
\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;
}

sub MY::install {
    package MY;
    my $script = shift->SUPER::install(@_);
    $script =~ s/install :: (.*)$/install :: $1 install_sax_driver/m;
    $script .= <<"INSTALL";

install_sax_driver :
\t\@\$(PERL) -MXML::SAX -e "XML::SAX->add_parser(q(XML::LibXML::SAX::Parser))->save_parsers()"
\t\@\$(PERL) -MXML::SAX -e "XML::SAX->add_parser(q(XML::LibXML::SAX))->save_parsers()"
 
INSTALL
 
    return $script;
}


###################################################################
# Functions
#  - these should really be in MakeMaker... But &shrug;
###################################################################

use Config;
use Cwd;
use Symbol;
use File::Spec;

use vars qw/$DEVNULL $is_Win32/;

BEGIN {
    $is_Win32 = ($^O =~ /Win32/);
    if ($is_Win32) {
        $DEVNULL = 'DEVNULL';
    }
    else {
        $DEVNULL = eval { File::Spec->devnull };
        if ($@) { $DEVNULL = '/dev/null' }
    }
}

sub rm_f {
    my @files = @_;
    my @realfiles;
    foreach (@files) {
        push @realfiles, glob($_);
    }
    if (@realfiles) {
        chmod(0777, @realfiles);
        unlink(@realfiles);
    }
}

sub rm_fr {
    my @files = @_;
    my @realfiles;
    foreach (@files) {
        push @realfiles, glob($_);
    }
    foreach my $file (@realfiles) {
        if (-d $file) {
            # warn("$file is a directory\n");
            rm_fr("$file/*");
            rm_fr("$file/.exists");
            rmdir($file) || die "Couldn't remove $file: $!";
        }
        else {
            # warn("removing $file\n");
            chmod(0777, $file);
            unlink($file);
        }
    }
}

sub xsystem {
    my $command = shift;
    if ($DEBUG) {
        print $command, "\n";
        if (system($command) != 0) {
            die "system call to '$command' failed";
        }
        return 1;
    }
    open(OLDOUT, ">&STDOUT");
    open(OLDERR, ">&STDERR");
    open(STDOUT, ">$DEVNULL");
    open(STDERR, ">$DEVNULL");
    my $retval = system($command);
    open(STDOUT, ">&OLDOUT");
    open(STDERR, ">&OLDERR");
    if ($retval != 0) {
        die "system call to '$command' failed";
    }
    return 1;
}

sub backtick {
    my $command = shift;
    if ($DEBUG) {
        print $command, "\n";
        my $results = `$command`;
        chomp $results;
        if ($? != 0) {
            die "backticks call to '$command' failed";
        }
        return $results;
    }
    open(OLDOUT, ">&STDOUT");
    open(OLDERR, ">&STDERR");
    open(STDOUT, ">$DEVNULL");
    open(STDERR, ">$DEVNULL");
    my $results = `$command`;
    my $retval = $?;
    open(STDOUT, ">&OLDOUT");
    open(STDERR, ">&OLDERR");
    if ($retval != 0) {
        die "backticks call to '$command' failed";
    }
    chomp $results;
    return $results;
}

sub try_link0 {
    my ($src, $opt) = @_;
    my $cfile = gensym();
    # local $config{LIBS};
    # $config{LIBS} .= $opt;
    unless (mkdir(".testlink", 0777)) {
        rm_fr(".testlink");
        mkdir(".testlink", 0777) || die "Cannot create .testlink dir: $!";
    }
    chdir(".testlink");
    open($cfile, ">Conftest.xs") || die "Cannot write to file Conftest.xs: $!";
print $cfile <<EOT;
#ifdef __cplusplus
extern "C" {
#endif
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#ifdef __cplusplus
}
#endif

EOT
    print $cfile $src;
    print $cfile <<EOT;

MODULE = Conftest          PACKAGE = Conftest

PROTOTYPES: DISABLE

EOT
    close($cfile);
    open($cfile, ">Conftest.pm") || die "Cannot write to file Conftest.pm: $!";
    print $cfile <<'EOT';
package Conftest;
$VERSION = 1.0;
require DynaLoader;
@ISA = ('DynaLoader');
bootstrap Conftest $VERSION;
1;
EOT
    close($cfile);
    open($cfile, ">Makefile.PL") || die "Cannot write to file Makefile.PL: $!";
    print $cfile <<'EOT';
use ExtUtils::MakeMaker;
my %config;
while($_ = shift @ARGV) {
    my ($k, $v) = split /=/, $_, 2;
    warn("$k = $v\n");
    $config{$k} = $v;
}
WriteMakefile(NAME => "Conftest", VERSION_FROM => "Conftest.pm", %config);
EOT
    close($cfile);
    open($cfile, ">test.pl") || die "Cannot write to file test.pl: $!";
    print $cfile <<EOT;
use Test; BEGIN { plan tests => 1; } END { ok(\$loaded) }
use Conftest; \$loaded++;
EOT
    close($cfile);
    my $quote = $is_Win32 ? '"' : "'";
    xsystem("$^X Makefile.PL " . join(' ', map { "${quote}$_=$config{$_}${quote}" } keys %config));

    # I am not shure if OTHERLDFLAGS is really required - at least the
    # libraries to include do not belong here!
    # I would assume a user to set OTHERLDFLAGS in the %config if they are
    # really required. if done so, we don't have to pass them here ...
    xsystem("$Config{make} test ${quote}OTHERLDFLAGS=${opt}${quote}");
} # end try_link0

sub try_link {
    my $start_dir = cwd();
    my $result = eval {
        try_link0(@_);
    };
    warn $@ if $DEBUG && $@;
    chdir($start_dir);
    rm_fr(".testlink");
    return $result;
}

sub have_library {
    my ($lib, $func) = (@_, "blank");
    printf("checking for %s() in -l%s... ", $func, $lib) if $func ne "blank";
    printf("looking for -l%s... ", $lib) if $func eq "blank";

    my $result;
    if ($func) {
        my $libs = $is_Win32 ? " $lib.lib  " : "-l$lib";
#        my $libs = "-l$lib";
        if ($is_Win32) {
            $result = try_link(<<"SRC", undef);
#include <windows.h>
#include <winsock.h>
blank() { return 0; }
int t() { ${func}(); return 0; }
SRC
            unless ($result) {
                $result = try_link(<<"SRC", undef);
#include <windows.h>
#include <winsock.h>
blank() { return 0; }
int t() { void ((*p)()); p = (void ((*)()))${func}; return 0; }
SRC
            }
        }
        else {
            $result = try_link(<<"SRC", undef);
blank() { 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;
}