summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2018-06-18 13:50:25 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2018-06-18 13:54:43 -0700
commit5d8193367e638092f35f5e54128795329f42a746 (patch)
treeda09ed568973f3f311ffb1b6bd959e93180885ca
parentef4e5e209fd1ad9e2ffff9112a66bb2b73225d8f (diff)
downloadnasm-5d8193367e638092f35f5e54128795329f42a746.tar.gz
MSVC: fix dependency generation and building RDOFF under MSVC
1. The mkdep.pl program didn't handle excluded dependencies correctly, causing it to error out due to config/config.h not existing. 2. NMAKE is sensitive to the order suffixes appear in .SUFFIXES, causing it to try to use the builtin rule .c.exe instead of .c.obj -> .obj.exe. 3. NMAKE doesn't handle the && operator between commands. 4. The !ifdef jungle around dependency generation was wrong. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--Makefile.in33
-rw-r--r--Mkfiles/msvc.mak39
-rwxr-xr-xtools/mkdep.pl16
3 files changed, 41 insertions, 47 deletions
diff --git a/Makefile.in b/Makefile.in
index 9a8e2def..0943f39e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -50,7 +50,7 @@ XMLTO = @XMLTO@
MAKENSIS = makensis
-MKDIR = mkdir
+MKDIR = mkdir -p
RM_F = rm -f
RM_RF = rm -rf
LN_S = @LN_S@
@@ -277,6 +277,13 @@ asm/directbl.c: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph
perlreq: $(PERLREQ)
+# This rule is only used for RDOFF
+.$(O)$(X):
+ $(CC) $(ALL_CFLAGS) -o $@ $< $(LDFLAGS) $(RDFLIB) $(NASMLIB) $(LIBS)
+
+RDFLN = cd rdoff && ln -s
+RDFLNPFX =
+
#-- Begin RDOFF Shared Rules --#
RDFLIBOBJ = rdoff/rdoff.$(O) rdoff/rdfload.$(O) rdoff/symtab.$(O) \
@@ -291,31 +298,23 @@ RDF2BINLINKS = rdoff/rdf2com$(X) rdoff/rdf2ith$(X) \
RDFLIB = rdoff/librdoff.$(A)
RDFLIBS = $(RDFLIB) $(NASMLIB)
-# This rule is only used for rdoff, to allow common rules
-MAKERDF = $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS)
-
rdoff/rdfdump$(X): rdoff/rdfdump.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff/ldrdf$(X): rdoff/ldrdf.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff/rdx$(X): rdoff/rdx.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff/rdflib$(X): rdoff/rdflib.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff/rdf2bin$(X): rdoff/rdf2bin.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff/rdf2com$(X): rdoff/rdf2bin$(X)
$(RM_F) rdoff/rdf2com$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2com$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2com$(X)
rdoff/rdf2ith$(X): rdoff/rdf2bin$(X)
$(RM_F) rdoff/rdf2ith$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2ith$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ith$(X)
rdoff/rdf2ihx$(X): rdoff/rdf2bin$(X)
$(RM_F) rdoff/rdf2ihx$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2ihx$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ihx$(X)
rdoff/rdf2srec$(X): rdoff/rdf2bin$(X)
$(RM_F) rdoff/rdf2srec$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2srec$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2srec$(X)
#-- End RDOFF Shared Rules --#
@@ -345,10 +344,10 @@ nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
manpages: nasm.1 ndisasm.1
install: nasm$(X) ndisasm$(X)
- $(MKDIR) -p $(DESTDIR)$(bindir)
+ $(MKDIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) nasm$(X) $(DESTDIR)$(bindir)/nasm$(X)
$(INSTALL_PROGRAM) ndisasm$(X) $(DESTDIR)$(bindir)/ndisasm$(X)
- $(MKDIR) -p $(DESTDIR)$(mandir)/man1
+ $(MKDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) $(srcdir)/nasm.1 $(DESTDIR)$(mandir)/man1/nasm.1
$(INSTALL_DATA) $(srcdir)/ndisasm.1 $(DESTDIR)$(mandir)/man1/ndisasm.1
@@ -397,7 +396,7 @@ cscope:
cscope -b -f cscope.out
rdf_install install_rdf install_rdoff:
- $(MKDIR) -p $(DESTDIR)$(bindir)
+ $(MKDIR) $(DESTDIR)$(bindir)
for f in $(RDFPROGS); do \
$(INSTALL_PROGRAM) "$$f" '$(DESTDIR)$(bindir)'/ ; \
done
@@ -406,7 +405,7 @@ rdf_install install_rdf install_rdoff:
bn=`basename "$$f"` && $(RM_F) "$$bn" && \
$(LN_S) rdf2bin$(X) "$$bn" ; \
done
- $(MKDIR) -p $(DESTDIR)$(mandir)/man1
+ $(MKDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) $(srcdir)/rdoff/*.1 $(DESTDIR)$(mandir)/man1/
doc:
diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak
index 430fa2d3..9aec80fc 100644
--- a/Mkfiles/msvc.mak
+++ b/Mkfiles/msvc.mak
@@ -46,7 +46,7 @@ RUNPERL = $(PERL) $(PERLFLAGS)
MAKENSIS = makensis
-RM_F = del /f
+RM_F = -del /f
LN_S = copy
# Binary suffixes
@@ -54,15 +54,11 @@ O = obj
A = lib
X = .exe
.SUFFIXES:
-.SUFFIXES: .c .i .s .$(O) .$(A) .exe .1 .man
+.SUFFIXES: $(X) .$(A) .$(O) .c .i .s .1 .man
.c.obj:
$(CC) /c $(ALL_CFLAGS) /Fo$@ $<
-# This rule is only used for rdoff
-.obj.exe:
- $(CC) $(ALL_CFLAGS) /Fe$@ $< $(LDFLAGS) $(RDFLIB) $(NASMLIB) $(LIBS)
-
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = asm\nasm.$(O)
@@ -252,6 +248,13 @@ asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
perlreq: $(PERLREQ)
+# This rule is only used for RDOFF
+.obj.exe:
+ $(CC) /Fe$@ $< $(LDFLAGS) $(RDFLIB) $(NASMLIB) $(LIBS)
+
+RDFLN = copy
+RDFLNPFX = rdoff^\
+
#-- Begin RDOFF Shared Rules --#
# Edit in Makefile.in, not here!
@@ -267,31 +270,23 @@ RDF2BINLINKS = rdoff\rdf2com$(X) rdoff\rdf2ith$(X) \
RDFLIB = rdoff\librdoff.$(A)
RDFLIBS = $(RDFLIB) $(NASMLIB)
-# This rule is only used for rdoff, to allow common rules
-MAKERDF = $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS)
-
rdoff\rdfdump$(X): rdoff\rdfdump.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff\ldrdf$(X): rdoff\ldrdf.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff\rdx$(X): rdoff\rdx.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff\rdflib$(X): rdoff\rdflib.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff\rdf2bin$(X): rdoff\rdf2bin.$(O) $(RDFLIBS)
- $(MAKERDF)
rdoff\rdf2com$(X): rdoff\rdf2bin$(X)
$(RM_F) rdoff\rdf2com$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2com$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2com$(X)
rdoff\rdf2ith$(X): rdoff\rdf2bin$(X)
$(RM_F) rdoff\rdf2ith$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2ith$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ith$(X)
rdoff\rdf2ihx$(X): rdoff\rdf2bin$(X)
$(RM_F) rdoff\rdf2ihx$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2ihx$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ihx$(X)
rdoff\rdf2srec$(X): rdoff\rdf2bin$(X)
$(RM_F) rdoff\rdf2srec$(X)
- cd rdoff && $(LN_S) rdf2bin$(X) rdf2srec$(X)
+ $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2srec$(X)
#-- End RDOFF Shared Rules --#
@@ -384,21 +379,21 @@ dep: msvc.dep
# Include and/or generate msvc.dep as needed. This is too complex to
# use the include-command feature, but we can open-code it here.
-!IF $(EXTERNAL_DEPENDENCIES) == 1
-!IFDEF MKDEP
+MKDEP=0
+!IF $(EXTERNAL_DEPENDENCIES) == 1 && $(MKDEP) == 0
!IF EXISTS(msvc.dep)
!INCLUDE msvc.dep
-!ENDIF
!ELSEIF [$(MAKE) /c MKDEP=1 /f Mkfiles\msvc.mak msvc.dep] == 0
!INCLUDE msvc.dep
!ELSE
!ERROR Unable to rebuild dependencies file msvc.dep
!ENDIF
+!ENDIF
#-- Magic hints to mkdep.pl --#
# @object-ending: ".$(O)"
# @path-separator: "\"
-# @exclude: "config/config.h"
+# @exclude: "config\config.h"
# @external: "msvc.dep"
# @selfrule: "1"
#-- Everything below is generated by mkdep.pl - do not edit --#
diff --git a/tools/mkdep.pl b/tools/mkdep.pl
index e84cc358..8c89f39a 100755
--- a/tools/mkdep.pl
+++ b/tools/mkdep.pl
@@ -51,6 +51,9 @@ $barrier = "#-- Everything below is generated by mkdep.pl - do not edit --#\n";
# This converts from filenames to full pathnames for our dependencies
%dep_path = {};
+# List of files that cannot be found; these *must* be excluded
+@must_exclude = ();
+
#
# Scan files for dependencies
#
@@ -70,7 +73,8 @@ sub scandeps($) {
if ( $line =~ /^\s*\#\s*include\s+\"(.*)\"\s*$/ ) {
my $nf = $1;
if (!defined($dep_path{$nf})) {
- die "$0: cannot determine path for dependency: $file -> $nf\n";
+ push(@must_exclude, $nf);
+ next;
}
$nf = $dep_path{$nf};
$mdeps{$nf}++;
@@ -138,7 +142,7 @@ sub _insert_deps($$) {
my $selfrule = 0;
my $do_external = 0;
my $maxline = 78; # Seems like a reasonable default
- my @exclude = (); # Don't exclude anything
+ my %exclude = (); # Don't exclude anything
my @genhdrs = ();
my $external = undef;
my $raw_output = 0;
@@ -165,7 +169,7 @@ sub _insert_deps($$) {
} elsif ( $parm eq 'continuation' ) {
$cont = $val;
} elsif ( $parm eq 'exclude' ) {
- @exclude = split(/\,/, $val);
+ $excludes{$val}++;
} elsif ( $parm eq 'include-command' ) {
$include_command = $val;
} elsif ( $parm eq 'external' ) {
@@ -201,10 +205,6 @@ sub _insert_deps($$) {
}
my $e;
- my %do_exclude = ();
- foreach $e (@exclude) {
- $do_exclude{$e} = 1;
- }
foreach my $dfile ($external, sort(keys(%deps)) ) {
my $ofile;
@@ -222,7 +222,7 @@ sub _insert_deps($$) {
my $len = length($ofile);
print $out $ofile;
foreach my $dep (@deps) {
- unless ($do_exclude{$dep}) {
+ unless ($excludes{$dep}) {
my $str = convert_file($dep, $sep);
my $sl = length($str)+1;
if ( $len+$sl > $maxline-2 ) {