From 205512f3c07c60b6a8493a464f4aa61b08886ca5 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 1 Oct 2025 13:15:34 -0700 Subject: [PATCH] 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) --- Makefile.in | 7 ++++--- Mkfiles/msvc.mak | 17 ++++++++++------- Mkfiles/openwcom.mak | 17 ++++++++++++----- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Makefile.in b/Makefile.in index a861f719..3c5be883 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,6 +47,7 @@ PERLFLAGS = -I$(top_srcdir)/perllib -I$(srcdir) RUNPERL = $(PERL) $(PERLFLAGS) EMPTY = : > +SIDE = @: Generated by side effect PYTHON3 = python3 @@ -360,7 +361,7 @@ asm/warnings_c.h.time: asm/warnings.pl asm/warnings.time $(EMPTY) 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 $(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 include/warnings.h: include/warnings.h.time - @: Side effect + $(SIDE) doc/warnings.src.time: asm/warnings.pl asm/warnings.time $(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 doc/warnings.src : doc/warnings.src.time - @: Side effect + $(SIDE) # Assembler token hash asm/tokhash.c: x86/insns.xda x86/insnsn.c asm/tokens.dat asm/tokhash.pl \ diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index 086bd81f..6f9a8f06 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -21,10 +21,10 @@ mandir = $(prefix)/man MANIFEST_FLAGS = /manifest:embed /manifestfile:$(MANIFEST) !IF "$(DEBUG)" == "1" -OPTFLAGS = /Od /Zi +OPTFLAGS = /Od LDFLAGS = /debug !ELSE -CFLAGS = /O2 /Zi +OPTFLAGS = /O2 # /OPT:REF and /OPT:ICF two undo /DEBUG harm LDFLAGS = /debug /opt:ref /opt:icf !ENDIF @@ -33,6 +33,7 @@ CC = cl AR = lib ARFLAGS = /nologo +CFLAGS = $(OPTFLAGS) /Zi /nologo /std:c11 /bigobj BUILD_CFLAGS = $(CFLAGS) /W2 INTERNAL_CFLAGS = /I$(srcdir) /I. \ /I$(srcdir)/include /I./include \ @@ -52,8 +53,10 @@ RUNPERL = $(PERL) $(PERLFLAGS) MAKENSIS = makensis -RM_F = -del /f -LN_S = copy +RM_F = -del /s /f /q +LN_S = copy /y +EMPTY = copy /y nul: +SIDE = @rem Created by side effect # Binary suffixes O = obj @@ -308,7 +311,7 @@ asm\warnings_c.h.time: asm\warnings.pl asm\warnings.time $(EMPTY) 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 $(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 include\warnings.h: include\warnings.h.time - @: Side effect + $(SIDE) doc\warnings.src.time: asm\warnings.pl asm\warnings.time $(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 doc\warnings.src : doc\warnings.src.time - @: Side effect + $(SIDE) # Assembler token hash asm\tokhash.c: x86\insns.xda x86\insnsn.c asm\tokens.dat asm\tokhash.pl \ diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 22b70aa9..d27412cf 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -28,12 +28,19 @@ PERL = perl PERLFLAGS = -I$(srcdir)\perllib -I$(srcdir) 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 # Binary suffixes O = obj +A = lib X = .exe # 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" # in this list! .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 .c : $(VPATH) @@ -319,7 +326,7 @@ asm\warnings_c.h.time: asm\warnings.pl asm\warnings.time $(EMPTY) 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 $(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 include\warnings.h: include\warnings.h.time - @: Side effect + $(SIDE) doc\warnings.src.time: asm\warnings.pl asm\warnings.time $(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 doc\warnings.src : doc\warnings.src.time - @: Side effect + $(SIDE) # Assembler token hash asm\tokhash.c: x86\insns.xda x86\insnsn.c asm\tokens.dat asm\tokhash.pl &