0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00

Makefile: a few more portability improvements

Define macros for generating an empty file and for a dummy (side
effect) target.

Tweak MSVC compiler options.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin
2025-10-01 13:15:34 -07:00
parent a54a902f4e
commit 205512f3c0
3 changed files with 26 additions and 15 deletions

View File

@@ -47,6 +47,7 @@ PERLFLAGS = -I$(top_srcdir)/perllib -I$(srcdir)
RUNPERL = $(PERL) $(PERLFLAGS) RUNPERL = $(PERL) $(PERLFLAGS)
EMPTY = : > EMPTY = : >
SIDE = @: Generated by side effect
PYTHON3 = python3 PYTHON3 = python3
@@ -360,7 +361,7 @@ asm/warnings_c.h.time: asm/warnings.pl asm/warnings.time
$(EMPTY) asm/warnings_c.h.time $(EMPTY) asm/warnings_c.h.time
asm/warnings_c.h: asm/warnings_c.h.time asm/warnings_c.h: asm/warnings_c.h.time
@: Side effect $(SIDE)
include/warnings.h.time: asm/warnings.pl asm/warnings.time include/warnings.h.time: asm/warnings.pl asm/warnings.time
$(RUNPERL) $(srcdir)/asm/warnings.pl h include/warnings.h \ $(RUNPERL) $(srcdir)/asm/warnings.pl h include/warnings.h \
@@ -368,7 +369,7 @@ include/warnings.h.time: asm/warnings.pl asm/warnings.time
$(EMPTY) include/warnings.h.time $(EMPTY) include/warnings.h.time
include/warnings.h: include/warnings.h.time include/warnings.h: include/warnings.h.time
@: Side effect $(SIDE)
doc/warnings.src.time: asm/warnings.pl asm/warnings.time doc/warnings.src.time: asm/warnings.pl asm/warnings.time
$(RUNPERL) $(srcdir)/asm/warnings.pl doc doc/warnings.src \ $(RUNPERL) $(srcdir)/asm/warnings.pl doc doc/warnings.src \
@@ -376,7 +377,7 @@ doc/warnings.src.time: asm/warnings.pl asm/warnings.time
$(EMPTY) doc/warnings.src.time $(EMPTY) doc/warnings.src.time
doc/warnings.src : doc/warnings.src.time doc/warnings.src : doc/warnings.src.time
@: Side effect $(SIDE)
# Assembler token hash # Assembler token hash
asm/tokhash.c: x86/insns.xda x86/insnsn.c asm/tokens.dat asm/tokhash.pl \ asm/tokhash.c: x86/insns.xda x86/insnsn.c asm/tokens.dat asm/tokhash.pl \

View File

@@ -21,10 +21,10 @@ mandir = $(prefix)/man
MANIFEST_FLAGS = /manifest:embed /manifestfile:$(MANIFEST) MANIFEST_FLAGS = /manifest:embed /manifestfile:$(MANIFEST)
!IF "$(DEBUG)" == "1" !IF "$(DEBUG)" == "1"
OPTFLAGS = /Od /Zi OPTFLAGS = /Od
LDFLAGS = /debug LDFLAGS = /debug
!ELSE !ELSE
CFLAGS = /O2 /Zi OPTFLAGS = /O2
# /OPT:REF and /OPT:ICF two undo /DEBUG harm # /OPT:REF and /OPT:ICF two undo /DEBUG harm
LDFLAGS = /debug /opt:ref /opt:icf LDFLAGS = /debug /opt:ref /opt:icf
!ENDIF !ENDIF
@@ -33,6 +33,7 @@ CC = cl
AR = lib AR = lib
ARFLAGS = /nologo ARFLAGS = /nologo
CFLAGS = $(OPTFLAGS) /Zi /nologo /std:c11 /bigobj
BUILD_CFLAGS = $(CFLAGS) /W2 BUILD_CFLAGS = $(CFLAGS) /W2
INTERNAL_CFLAGS = /I$(srcdir) /I. \ INTERNAL_CFLAGS = /I$(srcdir) /I. \
/I$(srcdir)/include /I./include \ /I$(srcdir)/include /I./include \
@@ -52,8 +53,10 @@ RUNPERL = $(PERL) $(PERLFLAGS)
MAKENSIS = makensis MAKENSIS = makensis
RM_F = -del /f RM_F = -del /s /f /q
LN_S = copy LN_S = copy /y
EMPTY = copy /y nul:
SIDE = @rem Created by side effect
# Binary suffixes # Binary suffixes
O = obj O = obj
@@ -308,7 +311,7 @@ asm\warnings_c.h.time: asm\warnings.pl asm\warnings.time
$(EMPTY) asm\warnings_c.h.time $(EMPTY) asm\warnings_c.h.time
asm\warnings_c.h: asm\warnings_c.h.time asm\warnings_c.h: asm\warnings_c.h.time
@: Side effect $(SIDE)
include\warnings.h.time: asm\warnings.pl asm\warnings.time include\warnings.h.time: asm\warnings.pl asm\warnings.time
$(RUNPERL) $(srcdir)\asm\warnings.pl h include\warnings.h \ $(RUNPERL) $(srcdir)\asm\warnings.pl h include\warnings.h \
@@ -316,7 +319,7 @@ include\warnings.h.time: asm\warnings.pl asm\warnings.time
$(EMPTY) include\warnings.h.time $(EMPTY) include\warnings.h.time
include\warnings.h: include\warnings.h.time include\warnings.h: include\warnings.h.time
@: Side effect $(SIDE)
doc\warnings.src.time: asm\warnings.pl asm\warnings.time doc\warnings.src.time: asm\warnings.pl asm\warnings.time
$(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src \ $(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src \
@@ -324,7 +327,7 @@ doc\warnings.src.time: asm\warnings.pl asm\warnings.time
$(EMPTY) doc\warnings.src.time $(EMPTY) doc\warnings.src.time
doc\warnings.src : doc\warnings.src.time doc\warnings.src : doc\warnings.src.time
@: Side effect $(SIDE)
# Assembler token hash # Assembler token hash
asm\tokhash.c: x86\insns.xda x86\insnsn.c asm\tokens.dat asm\tokhash.pl \ asm\tokhash.c: x86\insns.xda x86\insnsn.c asm\tokens.dat asm\tokhash.pl \

View File

@@ -28,12 +28,19 @@ PERL = perl
PERLFLAGS = -I$(srcdir)\perllib -I$(srcdir) PERLFLAGS = -I$(srcdir)\perllib -I$(srcdir)
RUNPERL = $(PERL) $(PERLFLAGS) RUNPERL = $(PERL) $(PERLFLAGS)
EMPTY = $(RUNPERL) -e "" .BEFORE
set COPYCMD=/y
RM_F = -del /f
LN_S = copy
EMPTY = copy nul:
SIDE = @rem Created by side effect
MAKENSIS = makensis MAKENSIS = makensis
# Binary suffixes # Binary suffixes
O = obj O = obj
A = lib
X = .exe X = .exe
# WMAKE errors out if a suffix is declared more than once, including # WMAKE errors out if a suffix is declared more than once, including
@@ -41,7 +48,7 @@ X = .exe
# first. Also, WMAKE only allows implicit rules that point "to the left" # first. Also, WMAKE only allows implicit rules that point "to the left"
# in this list! # in this list!
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .man .1 .obj .i .c .SUFFIXES: .man .1 .obj .i .c .lib .exe
# Needed to find C files anywhere but in the current directory # Needed to find C files anywhere but in the current directory
.c : $(VPATH) .c : $(VPATH)
@@ -319,7 +326,7 @@ asm\warnings_c.h.time: asm\warnings.pl asm\warnings.time
$(EMPTY) asm\warnings_c.h.time $(EMPTY) asm\warnings_c.h.time
asm\warnings_c.h: asm\warnings_c.h.time asm\warnings_c.h: asm\warnings_c.h.time
@: Side effect $(SIDE)
include\warnings.h.time: asm\warnings.pl asm\warnings.time include\warnings.h.time: asm\warnings.pl asm\warnings.time
$(RUNPERL) $(srcdir)\asm\warnings.pl h include\warnings.h & $(RUNPERL) $(srcdir)\asm\warnings.pl h include\warnings.h &
@@ -327,7 +334,7 @@ include\warnings.h.time: asm\warnings.pl asm\warnings.time
$(EMPTY) include\warnings.h.time $(EMPTY) include\warnings.h.time
include\warnings.h: include\warnings.h.time include\warnings.h: include\warnings.h.time
@: Side effect $(SIDE)
doc\warnings.src.time: asm\warnings.pl asm\warnings.time doc\warnings.src.time: asm\warnings.pl asm\warnings.time
$(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src & $(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src &
@@ -335,7 +342,7 @@ doc\warnings.src.time: asm\warnings.pl asm\warnings.time
$(EMPTY) doc\warnings.src.time $(EMPTY) doc\warnings.src.time
doc\warnings.src : doc\warnings.src.time doc\warnings.src : doc\warnings.src.time
@: Side effect $(SIDE)
# Assembler token hash # Assembler token hash
asm\tokhash.c: x86\insns.xda x86\insnsn.c asm\tokens.dat asm\tokhash.pl & asm\tokhash.c: x86\insns.xda x86\insnsn.c asm\tokens.dat asm\tokhash.pl &