summaryrefslogtreecommitdiffstats
path: root/dmakegen
diff options
context:
space:
mode:
Diffstat (limited to 'dmakegen')
-rwxr-xr-xdmakegen43
1 files changed, 26 insertions, 17 deletions
diff --git a/dmakegen b/dmakegen
index b6b13b3..8ae88f0 100755
--- a/dmakegen
+++ b/dmakegen
@@ -29,9 +29,8 @@ while ( defined($line = <DMAKEROOT>) ) {
# Empty line, do nothing
} elsif ( $line =~ /^GENERIC:\s*/ ) {
foreach $generic ( split(/\s+/, $') ) {
- $Generics{$'} = [];
+ $Generics{$generic} = [];
}
- push(Generics, split(/\s+/, $'));
} elsif ( $line =~ /^DEFAULT:\s*/ ) {
$Default = $';
} else {
@@ -55,6 +54,8 @@ while ( defined($dir = pop(@dirlist)) ) {
open(DMAKEFRAG, "> ${dir}/Dmakefrag") or die "$0: Cannot create ${dir}/Dmakefrag: $!\n";
push(@dmakefrags, "${dir}/Dmakefrag");
+ $pat = 0; # Not currently processing a pattern rule
+
$nline = 0; $err = 0;
while ( defined($line = <DMAKEFILE>) ) {
chomp $line; $nline++;
@@ -75,7 +76,9 @@ while ( defined($dir = pop(@dirlist)) ) {
if ( $line eq '' ) {
# Do nothing
} elsif ( $line =~ /^SUBDIRS:\s*/ ) {
- push(@dirlist, split(/\s+/, $'));
+ foreach $subdir ( split(/\s+/, $') ) {
+ push(@dirlist, "${dir}/${subdir}");
+ }
} elsif ( $line =~ /^\.([^.:]+):\s*(.*)$/ ) {
# Rule of the form .c:
$suffix = $1;
@@ -86,7 +89,8 @@ while ( defined($dir = pop(@dirlist)) ) {
print DMAKEFRAG " ${dir}/${dep}";
}
}
- print "\n";
+ print DMAKEFRAG "\n";
+ $pat = 1;
} elsif ( $line =~ /^\.([^.:])\.([^.:]+):\s*(.*)$/ ) {
# Rule of the form .c.o:
$suff1 = $1;
@@ -98,29 +102,38 @@ while ( defined($dir = pop(@dirlist)) ) {
print DMAKEFRAG " ${dir}/${dep}";
}
}
- print "\n";
- } elsif ( $line =~ /^(\S|\S.*\S)\s*:\s*(\S|\S.*\S)\s*$/ ) {
+ print DMAKEFRAG "\n";
+ $pat = 1;
+ } elsif ( $line =~ /^(\S|\S.*\S)\s*:\s*(|\S|\S.*\S)\s*$/ ) {
# Rule of the form foo .. : bar
$lhs = $1;
$rhs = $2;
+ $tt = '';
+ $pat = 0;
if ( $lhs ne '' ) {
foreach $targ ( split(/\s+/, $lhs) ) {
if ( defined($Generics{$targ}) ) {
push(@{$Generics{$targ}}, "${dir}/${targ}");
print DMAKEFRAG ".PHONY: ${dir}/${targ}\n";
+ } elsif ( $targ = /%/ ) {
+ $pat = 1;
}
- print DMAKEFRAG " ${dir}/${targ}";
+ $tt .= "${dir}/${targ} ";
}
}
- print DMAKEFRAG " : ";
+ print DMAKEFRAG $tt, ":";
if ( $rhs ne '' ) {
foreach $deps ( split(/\s+/, $rhs) ) {
print DMAKEFRAG " ${dir}/${deps}";
}
}
- print "\n";
+ print DMAKEFRAG "\n";
} elsif ( $line =~ /^(\s+)(\S.*)$/ ) {
- print DMAKEFRAG "$1cd \"${dir}\" && $2\n";
+ if ( $pat ) {
+ print DMAKEFRAG $line, "\n";
+ } else {
+ print DMAKEFRAG "$1cd \"${dir}\" && $2\n";
+ }
} else {
# Handle stuff like local variables here
}
@@ -134,23 +147,19 @@ while ( defined($dir = pop(@dirlist)) ) {
#
open(MAKEFILE, "> Makefile") or die "$0: Could not create Makefile\n";
-print MAKEFILE ".default: ${Default}\n\n";
+print MAKEFILE "Default: ${Default}\n\n";
print MAKEFILE "Makefile:\n\tdmakegen\n\n";
foreach $gen ( keys(%Generics) ) {
print MAKEFILE ".PHONY: ${gen}\n";
- print MAKEFILE "${gen}: ";
- foreach $subtarg ( @{$Generics{$gen}} ) {
- print MAKEFILE $subtarg, ' ';
- }
- print MAKEFILE "\n";
+ print MAKEFILE "${gen}: ", join(' ', @{$Generics{$gen}}), "\n";
}
# Must be done in reverse order (leaf node directories
# before the associated branch node.)
while ( defined($frag = pop(@dmakefrags)) ) {
- print "-include ${frag}\n";
+ print MAKEFILE "-include ${frag}\n";
}
close(MAKEFILE);