~ubuntu-branches/ubuntu/quantal/sgt-puzzles/quantal

« back to all changes in this revision

Viewing changes to mkfiles.pl

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2011-03-01 04:16:54 UTC
  • mfrom: (1.2.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20110301041654-949qy9qrroziy7vq
* New upstream version:
  - Add Range and Signpost puzzles
  - Use stock icons and conventional order for dialog buttons
  - Use Cairo for screen rendering
* Update German translation, thanks to Helge Kreutzmann
* Remove or update patches applied or partially applied upstream
* Use Debian source format 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#  - special-define objects (foo.o[PREPROCSYMBOL]) are not
18
18
#    supported in the mac or vcproj makefiles.
19
19
 
 
20
use warnings;
20
21
use IO::Handle;
21
22
use Cwd;
22
23
 
49
50
@allobjs = (); # all object file names
50
51
 
51
52
readinput: while (1) {
 
53
  $in = $filestack[$#filestack];
52
54
  while (not defined ($_ = <$in>)) {
53
 
    close $in;
 
55
    close $filestack[$#filestack];
 
56
    pop @filestack;
54
57
    last readinput if 0 == scalar @filestack;
55
 
    $in = pop @filestack;
 
58
    $in = $filestack[$#filestack];
56
59
  }
57
 
 
58
60
  chomp;
59
 
  split;
 
61
  @_ = split;
60
62
 
61
 
  # Skip comments (unless the comments belong, for example because
62
 
  # they're part of a diversion).
63
 
  next if /^\s*#/ and !defined $divert;
 
63
  # If we're gathering help text, keep doing so.
 
64
  if (defined $divert) {
 
65
      if ((defined $_[0]) && $_[0] eq "!end") {
 
66
          $divert = undef;
 
67
      } else {
 
68
          ${$divert} .= "$_\n";
 
69
      }
 
70
      next;
 
71
  }
 
72
  # Skip comments and blank lines.
 
73
  next if /^\s*#/ or scalar @_ == 0;
64
74
 
65
75
  if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
66
 
  if ($_[0] eq "!end") { $divert = undef; next; }
67
76
  if ($_[0] eq "!name") { $project_name = $_[1]; next; }
68
77
  if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
69
78
  if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
87
96
          open $f, "<$file" or die "unable to open include file '$file'\n";
88
97
          push @filestack, $f;
89
98
      }
90
 
      $in = $filestack[$#filestack];
91
99
      next;
92
100
  }
93
 
  # If we're gathering help text, keep doing so.
94
 
  if (defined $divert) { ${$divert} .= "$_\n"; next; }
95
 
  # Ignore blank lines.
96
 
  next if scalar @_ == 0;
97
101
 
98
102
  # Now we have an ordinary line. See if it's an = line, a : line
99
103
  # or a + line.
206
210
foreach $i (@prognames) {
207
211
  ($prog, $type) = split ",", $i;
208
212
  # Strip duplicate object names.
209
 
  $prev = undef;
 
213
  $prev = '';
210
214
  @list = grep { $status = ($prev ne $_); $prev=$_; $status }
211
215
          sort @{$programs{$i}};
212
216
  $programs{$i} = [@list];
238
242
while (scalar @scanlist > 0) {
239
243
  $file = shift @scanlist;
240
244
  next if defined $further{$file}; # skip if we've already done it
241
 
  $resource = ($file =~ /\.rc$/ ? 1 : 0);
242
245
  $further{$file} = [];
243
246
  $dirfile = &findfile($file);
244
247
  open IN, "$dirfile" or die "unable to open source file $file\n";
267
270
  while (scalar @scanlist > 0) {
268
271
    $file = shift @scanlist;
269
272
    foreach $j (@{$further{$file}}) {
270
 
      if ($dep{$j} != 1) {
 
273
      if (!$dep{$j}) {
271
274
        $dep{$j} = 1;
272
275
        push @{$depends{$i}}, $j;
273
276
        push @scanlist, $j;
296
299
sub dirpfx {
297
300
    my ($path) = shift @_;
298
301
    my ($sep) = shift @_;
299
 
    my $ret = "", $i;
 
302
    my $ret = "";
 
303
    my $i;
300
304
    while (($i = index $path, $sep) >= 0) {
301
305
        $path = substr $path, ($i + length $sep);
302
306
        $ret .= "..$sep";
350
354
  my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
351
355
  my @ret;
352
356
  my ($i, $x, $y);
 
357
  ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
353
358
  @ret = ();
354
359
  foreach $ii (@{$programs{$prog}}) {
355
360
    $i = $objname{$ii};
384
389
 
385
390
sub splitline {
386
391
  my ($line, $width, $splitchar) = @_;
387
 
  my ($result, $len);
 
392
  my $result = "";
 
393
  my $len;
388
394
  $len = (defined $width ? $width : 76);
389
395
  $splitchar = (defined $splitchar ? $splitchar : '\\');
390
396
  while (length $line > $len) {
400
406
sub deps {
401
407
  my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
402
408
  my ($i, $x, $y);
403
 
  my @deps, @ret;
 
409
  my @deps;
 
410
  my @ret;
404
411
  @ret = ();
405
412
  $depchar ||= ':';
406
413
  foreach $ii (sort keys %depends) {
572
579
    print "\n\n";
573
580
    foreach $p (&prognames("G:C")) {
574
581
      ($prog, $type) = split ",", $p;
575
 
      $objstr = &objects($p, "X.obj", "X.res", undef);
 
582
      $objstr =  &objects($p, "X.obj", "X.res", undef);
576
583
      print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
577
584
      my $ap = ($type eq "G") ? "-aa" : "-ap";
578
585
      print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
1116
1123
    "INSTALL=install\n",
1117
1124
    "INSTALL_PROGRAM=\$(INSTALL)\n",
1118
1125
    "INSTALL_DATA=\$(INSTALL)\n",
1119
 
    "prefix=/usr/local\n",
 
1126
    "prefix=/usr\n",
1120
1127
    "exec_prefix=\$(prefix)\n",
1121
1128
    "bindir=\$(exec_prefix)/bin\n",
 
1129
    "libdir=\$(exec_prefix)/lib\n",
1122
1130
    "gamesdir=\$(exec_prefix)/games\n",
1123
 
    "mandir=\$(prefix)/man\n",
 
1131
    "sharedir=\$(prefix)/share\n",
 
1132
    "mandir=\$(sharedir)/man\n",
1124
1133
    "man1dir=\$(mandir)/man1\n",
 
1134
    "CFLAGS += -DSHAREDIR=\"\\\"\$(sharedir)\\\"\"\n",
1125
1135
    "\n";
1126
1136
    print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U"));
1127
1137
    print "\n\n";