~ubuntu-branches/ubuntu/trusty/libalien-sdl-perl/trusty

« back to all changes in this revision

Viewing changes to inc/My/Builder.pm

  • Committer: Package Import Robot
  • Author(s): gregor herrmann, gregor herrmann, Salvatore Bonaccorso
  • Date: 2013-05-13 22:06:58 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130513220658-r3ahjiqiftr1c9v8
Tags: 1.440-1
* Team upload.

[ gregor herrmann ]
* debian/control: update {versioned,alternative} (build) dependencies.
* Adjust build and runtime dependencies to allow other OpenGL
  implementations. Thanks to Jerome Vouillon for the bug report.
  (Closes: #695027)
* debian/rules: make override more dh-ish.
* debian/control: remove unused ${perl:Depends} from libalien-sdl-dev-
  perl.

[ Salvatore Bonaccorso ]
* Change Vcs-Git to canonical URI (git://anonscm.debian.org)
* Change search.cpan.org based URIs to metacpan.org based URIs

[ gregor herrmann ]
* New upstream release.
  Fixes "fatal error with perl 5.18: SDL.h'tempfile' can't be called as
  a method at /usr/share/perl5/Alien/SDL.pm line 243."
  (Closes: #708082)
* debian/copyright: switch formatting to Copyright-Format 1.0.
* Bump debhelper compatibility level to 8.
* Set Standards-Version to 3.9.4 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
use Text::Patch;
18
18
use Config;
19
19
 
 
20
$SIG{__WARN__} = sub {
 
21
        my $thing =  join('', @_);
 
22
        $thing    =~ s|(://.+:).+(\@.+)|$1******$2|;
 
23
        warn $thing;
 
24
        return 1;
 
25
};
 
26
 
20
27
sub ACTION_build {
21
28
  my $self = shift;
22
29
  # as we want to wipe 'sharedir' during 'Build clean' we has
37
44
{
38
45
 my $self = shift;
39
46
 my $sharedir = '';
40
 
 
 
47
 
41
48
 $sharedir = eval {File::ShareDir::dist_dir('Alien-SDL')} || '';
42
49
 
43
50
 if ( -d $sharedir )
84
91
    if($bp->{buildtype} eq 'use_config_script') {
85
92
      $self->config_data('script', $bp->{script});
86
93
      # include path trick - adding couple of addititonal locations
 
94
      $self->set_ld_config($build_out);
87
95
      $self->config_data('additional_cflags', '-I' . $self->get_path($bp->{prefix} . '/include/smpeg') . ' '.
88
96
                                              '-I' . $self->get_path($bp->{prefix} . '/include') . ' ' .
89
97
                                              $self->get_additional_cflags);
95
103
      $self->clean_dir($build_out);
96
104
      $self->extract_binaries($download, $build_out);
97
105
      $self->set_config_data($build_out);
 
106
      $self->set_ld_config($build_out);
98
107
    }
99
108
    elsif($bp->{buildtype} eq 'build_from_sources' ) {
100
109
      # all the following functions die on error, no need to test ret values
103
112
      $self->clean_dir($build_out);
104
113
      $self->build_binaries($build_out, $build_src);
105
114
      $self->set_config_data($build_out);
 
115
      $self->set_ld_config($build_out);
106
116
    }
107
117
 
108
118
    # mark sucessfully finished build
118
128
  die "###ERROR### _fetch_file undefined sha1sum\n" unless $sha1sum;
119
129
 
120
130
  # setting http_proxy environment var if we are within CPAN and this information is available
121
 
  unless($ENV{http_proxy} && $ENV{PERL5_CPAN_IS_RUNNING}) {
 
131
  if(!$ENV{http_proxy} && $ENV{PERL5_CPAN_IS_RUNNING}) {
122
132
    if(eval('require CPAN::Config; 1') && $CPAN::Config->{http_proxy}) {
123
133
      $ENV{http_proxy} = $CPAN::Config->{http_proxy};
124
134
      if($CPAN::Config->{proxy_user} && $CPAN::Config->{proxy_pass} && $CPAN::Config->{http_proxy} !~ m|//.+:.+@|) {
178
188
  # fix hardcoded prefix path in bin/sdl-config
179
189
  my ($version, $prefix, $incdir, $libdir) = find_SDL_dir(rel2abs($build_out));
180
190
  sed_inplace("$prefix/bin/sdl-config", 's/^prefix=.*/prefix=\''.quotemeta($prefix).'\'/');
 
191
  if( $^O eq 'MSWin32' && $My::Utility::cc eq 'cl' ) {
 
192
    cp( catfile('patches', 'SDL_config_win32.h'), catfile($incdir, 'SDL', 'SDL_config.h') );
 
193
  }
181
194
}
182
195
 
183
196
sub extract_sources {
228
241
  $self->config_data('share_subdir', abs2rel($prefix, rel2abs('sharedir')));
229
242
 
230
243
  # set defaults
231
 
  my $cfg = {
232
 
    # defaults
233
 
    version     => $version,
234
 
    prefix      => '@PrEfIx@',
235
 
    libs        => '-L' . $self->get_path('@PrEfIx@/lib') . ' -lSDLmain -lSDL',
236
 
    cflags      => '-I' . $self->get_path('@PrEfIx@/include/SDL') . ' -D_GNU_SOURCE=1 -Dmain=SDL_main',
237
 
    shared_libs => [ ],
238
 
  };
 
244
  my $L   = $My::Utility::cc eq 'cl'
 
245
          ? '/LIBPATH:'
 
246
          : '-L';
 
247
  my $cfg = $self->config_data('config') || {};
 
248
 
 
249
  # defaults
 
250
  $cfg->{version}        = $version;
 
251
  $cfg->{prefix}         = '@PrEfIx@';
 
252
  $cfg->{libs}           = $L . $self->get_path('@PrEfIx@/lib') . ' -lSDLmain -lSDL';
 
253
  $cfg->{cflags}         = '-I' . $self->get_path('@PrEfIx@/include/SDL') . ' -D_GNU_SOURCE=1 -Dmain=SDL_main';
 
254
  $cfg->{ld_shared_libs} = [ ];
239
255
 
240
256
  # overwrite values available via sdl-config
241
 
  my $bp = $self->config_data('build_prefix') || $prefix;
 
257
  my $bp      = $self->config_data('build_prefix') || $prefix;
242
258
  my $devnull = File::Spec->devnull();
243
 
  my $script = rel2abs("$prefix/bin/sdl-config");
 
259
  my $script  = $self->escape_path( rel2abs("$prefix/bin/sdl-config") );
244
260
  foreach my $p (qw(version prefix libs cflags)) {
245
261
    my $o=`$script --$p 2>$devnull`;
246
262
    if ($o) {
250
266
    }
251
267
  }
252
268
 
 
269
  # write config
 
270
  $self->config_data('additional_cflags', '-I' . $self->get_path('@PrEfIx@/include') . ' ' .
 
271
                                          '-I' . $self->get_path('@PrEfIx@/include/smpeg') . ' ' .
 
272
                                          $self->get_additional_cflags);
 
273
  $self->config_data('additional_libs', $self->get_additional_libs);
 
274
  $self->config_data('config', $cfg);
 
275
}
 
276
 
 
277
sub set_ld_config {
 
278
  my( $self, $build_out ) = @_;
 
279
  my ($version, $prefix, $incdir, $libdir) = find_SDL_dir(rel2abs($build_out));
 
280
  my $cfg   = $self->config_data('config') || {};
253
281
  my $dlext = get_dlext();
254
282
  # find ld_shared_libs and create symlinks if necessary
255
283
  my $symlink_exists = eval { symlink("",""); 1 };
256
 
  if($symlink_exists)
257
 
  {
 
284
  if($symlink_exists) {
258
285
    my @shlibs_ = find_file($build_out, qr/\.$dlext[\d\.]+$/);
259
286
    foreach my $full (@shlibs_){
260
287
      $full =~ qr/(.*\.$dlext)[\d\.]+$/;
265
292
 
266
293
  # find and set ld_shared_libs
267
294
  my @shlibs = find_file($build_out, qr/\.$dlext$/);
268
 
  my $p = rel2abs($prefix);
269
 
  $_ =~ s/^\Q$prefix\E/\@PrEfIx\@/ foreach (@shlibs);
270
 
  $cfg->{ld_shared_libs} = [ @shlibs ];
 
295
#  my $p      = rel2abs($prefix);
 
296
  $_         =~ s/^\Q$prefix\E/\@PrEfIx\@/ foreach (@shlibs);
271
297
 
272
298
  # set ld_paths and ld_shlib_map
273
299
  my %tmp = ();
280
306
      $shlib_map{smpeg} = $full unless $shlib_map{smpeg};
281
307
    }
282
308
    elsif ($f =~ /^(lib)?(png12)/) {
283
 
      $shlib_map{png12} = $full unless $shlib_map{png12};
 
309
      $shlib_map{png12} = $full unless $shlib_map{png12}; # what if it isnt png12?
284
310
    }
285
 
    elsif ($f =~ /^(lib)?(tiff|jpeg|png)[^a-zA-Z]/) {
 
311
    elsif ($f =~ /^(lib)?(intl|z|tiff|jpeg|png|ogg|vorbis|vorbisfile|freetype|FLAC|mikmod)[^a-zA-Z]/) {
286
312
      $shlib_map{$2} = $full unless $shlib_map{$2};
287
313
    }
288
314
    elsif ($f =~ /^(lib)?(SDL_[a-zA-Z]{2,8})[^a-zA-Z0-9]/) {
294
320
      $shlib_map{SDL} = $full unless $shlib_map{SDL};
295
321
    }
296
322
  };
297
 
  $cfg->{ld_paths} = [ keys %tmp ];
298
 
  $cfg->{ld_shlib_map} = \%shlib_map;
299
 
 
300
 
  # write config
301
 
  $self->config_data('additional_cflags', '-I' . $self->get_path('@PrEfIx@/include') . ' ' .
302
 
                                          '-I' . $self->get_path('@PrEfIx@/include/smpeg') . ' ' .
303
 
                                          $self->get_additional_cflags);
304
 
  $self->config_data('additional_libs', $self->get_additional_libs);
 
323
 
 
324
  $cfg->{ld_shared_libs} = [ @shlibs ];
 
325
  $cfg->{ld_paths}       = [ keys %tmp ];
 
326
  $cfg->{ld_shlib_map}   = \%shlib_map;
 
327
 
 
328
  my $have_libs = $self->notes('have_libs');
 
329
  for(qw(pthread  z jpeg tiff png ogg vorbis vorbisfile freetype
 
330
         pangoft2 pango gobject gmodule glib fontconfig expat )) {
 
331
    if( !$shlib_map{$_} && $have_libs->{$_}->[0] ) {
 
332
      next unless defined $have_libs->{$_}->[1];
 
333
      push @{ $cfg->{ld_shared_libs} }, $have_libs->{$_}->[1];
 
334
      $shlib_map{$_} = $have_libs->{$_}->[1];
 
335
    }
 
336
  }
 
337
 
305
338
  $self->config_data('config', $cfg);
306
339
}
307
340
 
343
376
  }
344
377
}
345
378
 
 
379
sub escape_path {
 
380
  # this needs to be overriden in My::Builder::<platform>
 
381
  my( $self, $path ) = @_;
 
382
  return $path;
 
383
}
 
384
 
346
385
sub check_build_done_marker {
347
386
  my $self = shift;
348
387
  return (-e 'build_done');
369
408
  binmode($fh);
370
409
  $sha1->addfile($fh);
371
410
  close($fh);
372
 
  return ($sha1->hexdigest eq $sha1sum) ? 1 : 0
 
411
  my $_sha1sum = $sha1->hexdigest;
 
412
  warn "###WARN## checksum for file $file is $_sha1sum but we expect $sha1sum\n" if $_sha1sum ne $sha1sum;
 
413
  return ($_sha1sum eq $sha1sum) ? 1 : 0
373
414
}
374
415
 
375
416
sub patch_get_affected_files {