msvc.mak: Build fixes, updates and improvements.

* Added missing rules for creating a library out of LIBOBJ
   and using it when linking.
 * Updated the clean rule and PRELREQ list.
 * Always build with debug info as it ends up in external PDB files
   anyway and doesn't really impact binary size.
 * Added /RELEASE to the LDFLAGS so the linker checksums the headers and
   the binary can be signed.

Signed-off-by: Knut St. Osmundsen<bird-nasm@anduin.net>
Reviewed-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Knut St. Osmundsen 2016-04-21 09:13:19 +03:00 committed by Cyrill Gorcunov
parent b156bc8c61
commit 6fd298418b
2 changed files with 29 additions and 7 deletions

3
.gitignore vendored
View File

@ -1,6 +1,8 @@
*.a
*.bin *.bin
*.dbg *.dbg
*.exe *.exe
*.lib
*.lst *.lst
*.o *.o
*.o64 *.o64
@ -8,6 +10,7 @@
*.obj64 *.obj64
*.orig *.orig
*.out *.out
*.pdb
*.rej *.rej
*.xml *.xml
*.swp *.swp

View File

@ -21,22 +21,25 @@ mandir = $(prefix)/man
CFLAGS = /Od /Zi CFLAGS = /Od /Zi
LDFLAGS = /DEBUG LDFLAGS = /DEBUG
!ELSE !ELSE
CFLAGS = /O2 CFLAGS = /O2 /Zi
LDFLAGS = /DEBUG /OPT:REF /OPT:ICF # (latter two undoes /DEBUG harm)
!ENDIF !ENDIF
CC = cl CC = cl
LD = link LD = link
AR = lib
CFLAGS = $(CFLAGS) /W2 CFLAGS = $(CFLAGS) /W2
BUILD_CFLAGS = $(CFLAGS) /I$(srcdir)/inttypes BUILD_CFLAGS = $(CFLAGS) /I$(srcdir)/inttypes
INTERNAL_CFLAGS = /I$(srcdir) /I. \ INTERNAL_CFLAGS = /I$(srcdir) /I. \
/DHAVE__SNPRINTF /DHAVE__VSNPRINTF /DHAVE__FULLPATH /DHAVE__SNPRINTF /DHAVE__VSNPRINTF /DHAVE__FULLPATH
ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS) ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /RELEASE
LIBS = LIBS =
PERL = perl -I$(srcdir)/perllib PERL = perl -I$(srcdir)/perllib
# Binary suffixes # Binary suffixes
O = obj O = obj
L = lib
X = .exe X = .exe
.SUFFIXES: .c .i .s .$(O) .1 .man .SUFFIXES: .c .i .s .$(O) .1 .man
@ -79,11 +82,14 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
all: nasm$(X) ndisasm$(X) all: nasm$(X) ndisasm$(X)
rem cd rdoff && $(MAKE) all rem cd rdoff && $(MAKE) all
nasm$(X): $(NASM) nasm$(X): $(NASM) nasm.$(L)
$(LD) $(LDFLAGS) /OUT:nasm$(X) $(NASM) $(LIBS) $(LD) $(LDFLAGS) /OUT:nasm$(X) $(NASM) $(LIBS) nasm.$(L)
ndisasm$(X): $(NDISASM) ndisasm$(X): $(NDISASM) nasm.$(L)
$(LD) $(LDFLAGS) /OUT:ndisasm$(X) $(NDISASM) $(LIBS) $(LD) $(LDFLAGS) /OUT:ndisasm$(X) $(NDISASM) $(LIBS) nasm.$(L)
nasm.$(L): $(LIBOBJ)
$(AR) $(ARFLAGS) /OUT:$@ $**
# These source files are automagically generated from a single # These source files are automagically generated from a single
# instruction-table file by a Perl script. They're distributed, # instruction-table file by a Perl script. They're distributed,
@ -169,19 +175,32 @@ directiv.c: directiv.dat directiv.pl perllib/phash.ph
# This allows easier generation of distribution (see dist target). # This allows easier generation of distribution (see dist target).
PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \ PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \ regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \
version.h version.mac pptok.h pptok.c iflag.c iflag.h version.h version.mac pptok.h pptok.c iflag.c iflaggen.h \
directiv.c directiv.h pptok.ph regdis.h
perlreq: $(PERLREQ) perlreq: $(PERLREQ)
clean: clean:
-del /f *.$(O) -del /f *.$(O)
-del /f *.pdb
-del /f *.s -del /f *.s
-del /f *.i -del /f *.i
-del /f lib\*.$(O) -del /f lib\*.$(O)
-del /f lib\*.pdb
-del /f lib\*.s -del /f lib\*.s
-del /f lib\*.i -del /f lib\*.i
-del /f output\*.$(O) -del /f output\*.$(O)
-del /f output\*.pdb
-del /f output\*.s -del /f output\*.s
-del /f output\*.i -del /f output\*.i
-del /f nasmlib\*.$(O)
-del /f nasmlib\*.pdb
-del /f nasmlib\*.s
-del /f nasmlib\*.i
-del /f stdlib\*.$(O)
-del /f stdlib\*.pdb
-del /f stdlib\*.s
-del /f stdlib\*.i
-del /f nasm.$(L)
-del /f nasm$(X) -del /f nasm$(X)
-del /f ndisasm$(X) -del /f ndisasm$(X)
rem cd rdoff && $(MAKE) clean rem cd rdoff && $(MAKE) clean