Backport the syncfiles script to the nasm-2.03.x branch
authorH. Peter Anvin <hpa@zytor.com>
Mon, 16 Jun 2008 22:55:19 +0000 (15:55 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 16 Jun 2008 22:55:19 +0000 (15:55 -0700)
This is a maintenance tool only, it doesn't change the code in any
way.  However, it makes it a lot less likely that we'll have a release
go out with a broken Makefile.

Makefile.in
Mkfiles/msvc.mak
Mkfiles/netware.mak
Mkfiles/openwcom.mak
Mkfiles/owlinux.mak
syncfiles.pl [new file with mode: 0755]

index c7d380b..645c947 100644 (file)
@@ -58,6 +58,7 @@ X               = @EXEEXT@
 .1.man:
        $(NROFF) -man $< > $@
 
+#-- Begin File Lists --#
 NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
        assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
        outform.$(O) output/outbin.$(O) \
@@ -71,6 +72,7 @@ NASM =        nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
 
 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
        insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
+#-- End File Lists --#
 
 all: nasm$(X) ndisasm$(X) nasm.man ndisasm.man
        cd rdoff && $(MAKE) all
@@ -223,6 +225,7 @@ splint:
 # it's expected to be invoked manually.
 #
 alldeps: perlreq
+       $(PERL) syncfiles.pl Makefile.in Mkfiles/*.mak
        $(PERL) mkdep.pl -M Makefile.in Mkfiles/*.mak -- \
                . output lib
        ./config.status
index 6707f54..d1654e5 100644 (file)
@@ -32,6 +32,8 @@ X               = .exe
 .c.obj:
        $(CC) /c $(ALL_CFLAGS) /Fo$@ $<
 
+#-- Begin File Lists --#
+# Edit in Makefile.in, not here!
 NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
        assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
        outform.$(O) output/outbin.$(O) \
@@ -45,6 +47,7 @@ NASM =        nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
 
 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
        insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
+#-- End File Lists --#
 
 all: nasm$(X) ndisasm$(X)
        rem cd rdoff && $(MAKE) all
index 8b786a7..90ab7a1 100644 (file)
@@ -1,4 +1,4 @@
-# -* makefile -*- GNU Makefile for NetWare target
+# -*- makefile -*- GNU Makefile for NetWare target
 
 PROOT=.
 OBJDIR=release
@@ -28,19 +28,22 @@ LDFLAGS+=-s
 
 O = o
 
-NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
-       assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
-       outform.$(O) output/outbin.$(O) \
-       output/outaout.$(O) output/outcoff.$(O) \
-       output/outelf32.$(O) output/outelf64.$(O) \
-       output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
-       output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
-       preproc.$(O) quote.$(O) pptok.$(O) macros.$(O) \
-       listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) \
-       regvals.$(O) regflags.$(O)
-
-NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
-       insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
+#-- Begin File Lists --#
+# Edit in Makefile.in, not here!
+NASM = nasm.o nasmlib.o float.o insnsa.o insnsb.o \
+       assemble.o labels.o hashtbl.o crc64.o parser.o \
+       outform.o outbin.o \
+       outaout.o outcoff.o \
+       outelf32.o outelf64.o \
+       outobj.o outas86.o outrdf2.o \
+       outdbg.o outieee.o outmacho.o \
+       preproc.o quote.o pptok.o macros.o \
+       listing.o eval.o exprlib.o stdscan.o tokhash.o \
+       regvals.o regflags.o
+
+NDISASM = ndisasm.o disasm.o sync.o nasmlib.o \
+       insnsd.o insnsb.o insnsn.o regs.o regdis.o
+#-- End File Lists --#
 
 NASM_OBJ = $(addprefix $(OBJDIR)/,$(notdir $(NASM))) $(EOLIST)
 NDIS_OBJ = $(addprefix $(OBJDIR)/,$(notdir $(NDISASM))) $(EOLIST)
index eb9183c..9fada2a 100644 (file)
@@ -44,6 +44,8 @@ X               = .exe
        $(CC) -c $(ALL_CFLAGS) -fo=$^@ $[@
 
 # Note: wcl386 is broken if forward slashes are used as path separators.
+#-- Begin File Lists --#
+# Edit in Makefile.in, not here!
 NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) &
        assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) &
        outform.$(O) output\outbin.$(O) &
@@ -57,6 +59,7 @@ NASM =        nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) &
 
 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) &
        insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
+#-- End File Lists --#
 
 what:  .SYMBOLIC
        @echo Please build "dos", "win32" or "os2"
index ab44fbb..5b233e6 100644 (file)
@@ -55,6 +55,8 @@ X               = .exe
 .c.$(O):
        $(CC) -c $(ALL_CFLAGS) -fo=$@ $<
 
+#-- Begin File Lists --#
+# Edit in Makefile.in, not here!
 NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
        assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
        outform.$(O) output/outbin.$(O) \
@@ -68,6 +70,7 @@ NASM =        nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
 
 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
        insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
+#-- End File Lists --#
 
 what:
        @echo 'Please build "dos", "win32" or "os2"'
diff --git a/syncfiles.pl b/syncfiles.pl
new file mode 100755 (executable)
index 0000000..9596923
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/bin/perl
+#
+# Sync the output file list between Makefiles
+# Use the mkdep.pl parameters to get the filename syntax
+#
+# The first file is the source file; the other ones target.
+#
+%def_hints = ('object-ending' => '.o',
+             'path-separator' => '/',
+             'continuation' => "\\");
+
+sub do_transform($$) {
+    my($l, $h) = @_;
+    my($ps) = $$h{'path-separator'};
+
+    $l =~ s/\x01/$$h{'object-ending'}/g;
+    $l =~ s/\x03/$$h{'continuation'}/g;
+
+    if ($ps eq '') {
+       # Remove the path separator and the preceeding directory
+       $l =~ s/[^\s\=]*\x02//g;
+    } else {
+       # Convert the path separator
+       $l =~ s/\x02/$ps/g;
+    }
+
+    return $l;
+}
+
+@file_list = ();
+
+$first = 1;
+$first_file = $ARGV[0];
+die unless (defined($first_file));
+
+foreach $file (@ARGV) {
+    open(FILE, "< $file\0") or die;
+
+    # First, read the syntax hints
+    %hints = %def_hints;
+    while (defined($line = <FILE>)) {
+       if ( $line =~ /^\s*\#\s*@([a-z0-9-]+):\s*\"([^\"]*)\"/ ) {
+           $hints{$1} = $2;
+       }
+    }
+
+    # Read and process the file
+    seek(FILE,0,0);
+    @lines = ();
+    $processing = 0;
+    while (defined($line = <FILE>)) {
+       chomp $line;
+       if ($processing) {
+           if ($line eq '#-- End File Lists --#') {
+               push(@lines, $line."\n");
+               $processing = 0;
+           } elsif ($first) {
+               my $xl = $line;
+               my $oe = "\Q$hints{'object-ending'}";
+               my $ps = "\Q$hints{'path-separator'}";
+               my $cn = "\Q$hints{'continuation'}";
+
+               $xl =~ s/${oe}(\s|$)/\x01$1/g;
+               $xl =~ s/${ps}/\x02/g;
+               $xl =~ s/${cn}$/\x03/;
+               push(@file_list, $xl);
+               push(@lines, $line);
+           }
+       } else {
+           push(@lines, $line."\n");
+           if ($line eq '#-- Begin File Lists --#') {
+               $processing = 1;
+               if (!$first) {
+                   push(@lines, "# Edit in $first_file, not here!\n");
+                   foreach $l (@file_list) {
+                       push(@lines, do_transform($l, \%hints)."\n");
+                   }
+               }
+           }
+       }
+    }
+    close(FILE);
+
+    # Write the file back out
+    if (!$first) {
+       open(FILE, "> $file\0") or die;
+       print FILE @lines;
+       close(FILE);
+    }
+
+    undef @lines;
+    $first = 0;
+}