summaryrefslogtreecommitdiff
path: root/toolbin
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2018-12-17 11:18:07 +0000
committerRobin Watts <robin.watts@artifex.com>2019-01-07 19:42:24 +0000
commite91b67894a28c518b34e0daf75d79715c4aa16e4 (patch)
treee057e05b39777354949d3a2752a5743a86462604 /toolbin
parent763a5f4c3bf94cd7cc3d9fcdcde3d7cac4f38796 (diff)
downloadghostpdl-e91b67894a28c518b34e0daf75d79715c4aa16e4.tar.gz
Remove some blah_DEFINED cruft.
Now we properly "include what we use" let's sanitise the horrid blah_DEFINED ifdeffery (i.e. kill it where possible). Also, we update the .c dependencies in the base/psi makefiles to be correct. Unfortunately, this new correct set of dependencies causes nmake to soil itself and die with an out of memory error. After much experimentation, I've come to the conclusion that this is because it copes poorly with given the same file as a dependency multiple times. Sadly, our style of declaring dependencies in the following style: foo_h=$(BLAH)/foo.h $(std_h) bar_h=$(BLAH)/bar.h $(foo_h) $(std_h) baz_h=$(BLAH)/baz.h $(foo_h) $(std_h) means that a .obj file that depends on $(foo_h) $(bar_h) and $(baz_h) ends up depending on foo.h twice, and std.h three times. I have therefore changed the style of dependencies used to be more standard. We still define: foo_h=$(BLAH)/foo.h so each .obj file rule can depend on $(foo_h) etc as required, but the dependencies between each .h file are expressed in normal rules at the end of the file in a dedicated "# Dependencies" section that we can now autogenerate.
Diffstat (limited to 'toolbin')
-rwxr-xr-xtoolbin/checkdeps.pl4
-rw-r--r--toolbin/headercompile.pl84
2 files changed, 58 insertions, 30 deletions
diff --git a/toolbin/checkdeps.pl b/toolbin/checkdeps.pl
index 6cdbe7a48..98bacfb0e 100755
--- a/toolbin/checkdeps.pl
+++ b/toolbin/checkdeps.pl
@@ -37,11 +37,11 @@ sub read_makefile {
open(IN, "$dir/$file") or die "can't open $dir/$file";
LINE: while (<IN>) {
# Reassemble split lines
- chomp $_;
+ $_ =~ s/[\r\n]*$//;
my $line=$_;
while (substr($line,-1) eq "\\") {
my $nextline = <IN>;
- chomp $nextline;
+ $nextline =~ s/[\r\n]*$//;
substr($line,-1) = $nextline;
}
diff --git a/toolbin/headercompile.pl b/toolbin/headercompile.pl
index ea0ae3fca..2bff24756 100644
--- a/toolbin/headercompile.pl
+++ b/toolbin/headercompile.pl
@@ -103,6 +103,8 @@ sub pcompare($$)
readdeps("base");
readdeps("psi");
+readdeps("devices");
+readdeps("devices/vector");
print "Processing header dependencies...\n";
@@ -313,6 +315,25 @@ for (my $ui=$mx-1; $ui >= 0; $ui--) {
# print "\n";
#}
+sub prep($) {
+ my $f = shift;
+ if ($dirs{$f} eq "base") {
+ return "\$(GLSRC)";
+ } elsif ($dirs{$f} eq "psi") {
+ return "\$(PSSRC)";
+ } elsif ($dirs{$f} eq "gen") {
+ return "\$(GLGEN)";
+ } elsif ($dirs{$f} eq "jpeg") {
+ return "\$(JSRCDIR)\$(D)";
+ } elsif ($dirs{$f} eq "devices") {
+ return "\$(DEVSRC)";
+ } elsif ($dirs{$f} eq "devices/vector") {
+ return "\$(DEVVECSRC)";
+ } else {
+ return "";
+ }
+}
+
sub rewrite($$) {
my $i = shift;
my $m = shift;
@@ -321,30 +342,8 @@ sub rewrite($$) {
my $g = $f;
$g =~ s/\./_/;
- if ($dirs{$f} eq "base") {
- print "$g=\$(GLSRC)$f";
- } elsif ($dirs{$f} eq "psi") {
- print "$g=\$(PSSRC)$f";
- } elsif ($dirs{$f} eq "gen") {
- print "$g=\$(GLGEN)$f";
- } elsif ($dirs{$f} eq "jpeg") {
- print "$g=\$(JSRCDIR)\$(D)$f";
- } else {
- print "$g=$f";
- }
- for (my $uj=1; $uj < $mx; $uj++) {
- my $j = $order[$uj];
- if ($deparr[$i][$j] != 1) { next; }
- my $e = $num2fname[$j];
- if (!exists $dirs{$e}) {
- # Don't include things like sgidefs_h
- next;
- }
- my $d = $e;
-
- $e =~ s/\./_/;
- print " \$($e)";
- }
+ my $h = prep($f);
+ print "$g=$h$f";
if ($m) {
print " \$(MAKEFILE)";
}
@@ -371,13 +370,14 @@ sub write_dep($$)
$good[$i] = -2;
rewrite($i, $m);
- return 0;
+ return $i;
}
- return 1;
+ return 0;
}
sub rewrite_make($)
{
+ my @deplist = ();
my $f = shift;
print "$f:\n";
@@ -385,8 +385,11 @@ sub rewrite_make($)
open(F, "$f") || die "WTF?";
while (<F>) {
$_ =~ s/[\r\n]*$//;
+ if ($_ =~ m/^\# Dependencies:/) {
+ last;
+ }
if ($_ =~ m/^([a-z0-9_\-]+_h)=/) {
- my $f = $1;
+ my $f = $1;
# Gather up the line, allowing for continuations
if ($_ =~ m/\\$/) {
my $block = $_;
@@ -408,13 +411,33 @@ sub rewrite_make($)
if ($_ =~ m/\$\(MAKEFILE\)/) {
$makefile = 1;
}
- if (write_dep($f, $makefile)) {
+ my $i = write_dep($f, $makefile);
+ if ($i == 0) {
print "$_\n";
+ } else {
+ push @deplist, $i;
}
} else {
print "$_\n";
}
}
+ print "# Dependencies:\n";
+ foreach $i (@deplist) {
+ my $f = $num2fname[$i];
+ my $df = prep($f);
+ for (my $uj=1; $uj < $mx; $uj++) {
+ my $j = $order[$uj];
+ if ($deparr[$i][$j] == 0) { next; }
+ my $e = $num2fname[$j];
+ if (!exists $dirs{$e}) {
+ # Don't include things like sgidefs_h
+ next;
+ }
+ my $d = prep($e);
+
+ print "$df$f:$d$e\n";
+ }
+ }
print "-----\n";
}
@@ -422,8 +445,13 @@ rewrite_make("base/gs.mak");
rewrite_make("base/pcwin.mak");
rewrite_make("base/lib.mak");
rewrite_make("base/tiff.mak");
+rewrite_make("base/winlib.mak");
rewrite_make("psi/int.mak");
rewrite_make("psi/winint.mak");
+rewrite_make("devices/contrib.mak");
+rewrite_make("devices/devs.mak");
+rewrite_make("gpdl/pspcl6_gcc.mak");
+rewrite_make("pcl/pl/pl.mak");
# Now output the troubled ones.
print "\nThese references are questionable: (possibly they didn't compile?)\n";