# - special-define objects (foo.o[PREPROCSYMBOL]) are not
# supported in the mac or vcproj makefiles.
+use warnings;
use IO::Handle;
use Cwd;
@allobjs = (); # all object file names
readinput: while (1) {
+ $in = $filestack[$#filestack];
while (not defined ($_ = <$in>)) {
- close $in;
+ close $filestack[$#filestack];
+ pop @filestack;
last readinput if 0 == scalar @filestack;
- $in = pop @filestack;
+ $in = $filestack[$#filestack];
}
-
chomp;
- split;
+ @_ = split;
- # Skip comments (unless the comments belong, for example because
- # they're part of a diversion).
- next if /^\s*#/ and !defined $divert;
+ # If we're gathering help text, keep doing so.
+ if (defined $divert) {
+ if ((defined $_[0]) && $_[0] eq "!end") {
+ $divert = undef;
+ } else {
+ ${$divert} .= "$_\n";
+ }
+ next;
+ }
+ # Skip comments and blank lines.
+ next if /^\s*#/ or scalar @_ == 0;
if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
- if ($_[0] eq "!end") { $divert = undef; next; }
if ($_[0] eq "!name") { $project_name = $_[1]; next; }
if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
open $f, "<$file" or die "unable to open include file '$file'\n";
push @filestack, $f;
}
- $in = $filestack[$#filestack];
next;
}
- # If we're gathering help text, keep doing so.
- if (defined $divert) { ${$divert} .= "$_\n"; next; }
- # Ignore blank lines.
- next if scalar @_ == 0;
# Now we have an ordinary line. See if it's an = line, a : line
# or a + line.
foreach $i (@prognames) {
($prog, $type) = split ",", $i;
# Strip duplicate object names.
- $prev = undef;
+ $prev = '';
@list = grep { $status = ($prev ne $_); $prev=$_; $status }
sort @{$programs{$i}};
$programs{$i} = [@list];
while (scalar @scanlist > 0) {
$file = shift @scanlist;
next if defined $further{$file}; # skip if we've already done it
- $resource = ($file =~ /\.rc$/ ? 1 : 0);
$further{$file} = [];
$dirfile = &findfile($file);
open IN, "$dirfile" or die "unable to open source file $file\n";
while (scalar @scanlist > 0) {
$file = shift @scanlist;
foreach $j (@{$further{$file}}) {
- if ($dep{$j} != 1) {
+ if (!$dep{$j}) {
$dep{$j} = 1;
push @{$depends{$i}}, $j;
push @scanlist, $j;
sub dirpfx {
my ($path) = shift @_;
my ($sep) = shift @_;
- my $ret = "", $i;
+ my $ret = "";
+ my $i;
while (($i = index $path, $sep) >= 0) {
$path = substr $path, ($i + length $sep);
$ret .= "..$sep";
my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
my @ret;
my ($i, $x, $y);
+ ($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
@ret = ();
foreach $ii (@{$programs{$prog}}) {
$i = $objname{$ii};
sub splitline {
my ($line, $width, $splitchar) = @_;
- my ($result, $len);
+ my $result = "";
+ my $len;
$len = (defined $width ? $width : 76);
$splitchar = (defined $splitchar ? $splitchar : '\\');
while (length $line > $len) {
sub deps {
my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
my ($i, $x, $y);
- my @deps, @ret;
+ my @deps;
+ my @ret;
@ret = ();
$depchar ||= ':';
foreach $ii (sort keys %depends) {
print "\n\n";
foreach $p (&prognames("G:C")) {
($prog, $type) = split ",", $p;
- $objstr = &objects($p, "X.obj", "X.res", undef);
+ $objstr = &objects($p, "X.obj", "X.res", undef);
print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
my $ap = ($type eq "G") ? "-aa" : "-ap";
print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n";
"MAKEFILE = Makefile.vc\n".
"\n".
"# C compilation flags\n".
- "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401\n".
+ "CFLAGS = /nologo /W3 /O1 /D_WINDOWS /D_WIN32_WINDOWS=0x401 /DWINVER=0x401 /I.\n".
"LFLAGS = /incremental:no /fixed\n".
"\n";
print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C"));
"\n".
"# You can define this path to point at your tools if you need to\n".
"# TOOLPATH = /opt/gcc/bin\n".
- "CC = \$(TOOLPATH)cc\n".
+ "CC := \$(TOOLPATH)\$(CC)\n".
"# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
"# (depending on what works on your system) if you want to enforce\n".
"# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n".
"# to 1.2 if it isn't found.\n".
"GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
"\n".
- &splitline("CFLAGS = -O2 -Wall -Werror -ansi -pedantic -g " .
+ &splitline("CFLAGS := -O2 -Wall -Werror -ansi -pedantic -g " .
(join " ", map {"-I$dirpfx$_"} @srcdirs) .
- " `\$(GTK_CONFIG) --cflags`")."\n".
- "XLDFLAGS = `\$(GTK_CONFIG) --libs`\n".
- "ULDFLAGS =#\n".
+ " `\$(GTK_CONFIG) --cflags` \$(CFLAGS)")."\n".
+ "XLIBS = `\$(GTK_CONFIG) --libs`\n".
+ "ULIBS =#\n".
"INSTALL=install\n",
"INSTALL_PROGRAM=\$(INSTALL)\n",
"INSTALL_DATA=\$(INSTALL)\n",
$objstr = &objects($p, "X.o", undef, undef);
print &splitline($prog . ": " . $objstr), "\n";
$libstr = &objects($p, undef, undef, "-lX");
- print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
- $objstr . " $libstr", 69), "\n\n";
+ print &splitline("\t\$(CC) -o \$@ $objstr $libstr \$(${type}LIBS)", 69),
+ "\n\n";
}
foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
$objstr =~ s/gtk\.o/nestedvm\.o/g;
print &splitline($prog . ".mips: " . $objstr), "\n";
$libstr = &objects($p, undef, undef, "-lX");
- print &splitline("\t\$(CC)" . $mw . " \$(${type}LDFLAGS) -o \$@ " .
+ print &splitline("\t\$(CC) \$(${type}LDFLAGS) -o \$@ " .
$objstr . " $libstr -lm", 69), "\n\n";
}
foreach $d (&deps("X.o", undef, $dirpfx, "/")) {