From 0b99b28c02f9b50cb94a50e146df76e42b69603e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 23 Dec 2024 13:24:14 +0100 Subject: [PATCH] build: fix for broken MSVC and Open Watcom makefiles fix recursive call to make for MSVC and Open Watcom do make files more consistent - add NULLCMD macro - add WARNFILESX macro as template for extensions substitution - use EMPTY macro everywhere - use RM_F and RM_RF everywhere for deletion --- Makefile.in | 27 ++++++------ Mkfiles/msvc.mak | 100 ++++++++++++++++++++++--------------------- Mkfiles/openwcom.mak | 90 +++++++++++++++++++------------------- 3 files changed, 112 insertions(+), 105 deletions(-) diff --git a/Makefile.in b/Makefile.in index 99768153..fd9969c9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,6 +44,7 @@ PERLFLAGS = -I$(top_srcdir)/perllib -I$(srcdir) RUNPERL = $(PERL) $(PERLFLAGS) EMPTY = : > +NULLCMD = @: PYTHON3 = python3 @@ -91,6 +92,7 @@ endif .PHONY: all doc install clean distclean cleaner spotless test .PHONY: install_doc everything install_everything strip perlreq dist tags TAGS .PHONY: nothing manpages nsis +.PHONY: warnings .c.$(O): $(CC) -c $(ALL_CFLAGS) -o $@ $< @@ -164,13 +166,15 @@ LIBOBJ_NW = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ disasm/disasm.$(O) disasm/sync.$(O) # Warnings depend on all source files, so handle them separately -WARNOBJ = asm/warnings.$(O) -WARNFILES = asm/warnings_c.h include/warnings.h doc/warnings.src +WARNOBJ = asm/warnings.$(O) +WARNFILESX = asm/warnings_c.h.x include/warnings.h.x doc/warnings.src.x LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ) ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW) ALLOBJ = $(PROGOBJ) $(LIBOBJ) +WARNSRCS = $(LIBOBJ_NW:.$(O)=.c) asm/nasm.c + SUBDIRS = stdlib nasmlib include config output asm disasm x86 \ common macros XSUBDIRS = test doc nsis win @@ -196,10 +200,6 @@ nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB) ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB) $(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $^ $(LIBS) -# These are specific to certain Makefile syntaxes... -WARNTIMES = $(WARNFILES:=.time) -WARNSRCS = $(LIBOBJ_NW:.$(O)=.c) asm/nasm.c - #-- Begin Generated File Rules --# # These source files are automagically generated from data files using @@ -214,7 +214,7 @@ PERLREQ_CLEANABLE = \ x86/iflag.c x86/iflaggen.h \ macros/macros.c \ asm/pptok.ph asm/directbl.c asm/directiv.h \ - $(WARNFILES) \ + $(WARNFILESX:.x=) \ misc/nasmtok.el \ version.h version.mac version.mak nsis/version.nsh @@ -297,35 +297,34 @@ x86/regs.h: x86/regs.dat x86/regs.pl # reasonable, but doesn't update the time stamp if the files aren't # changed, to avoid rebuilding everything every time. Track the actual # dependency by the empty file asm/warnings.time. -.PHONY: warnings warnings: dirs - $(RM_F) $(WARNFILES) $(WARNTIMES) asm/warnings.time + $(RM_F) $(WARNFILESX:.x=) $(WARNFILESX:.x=.time) asm/warnings.time $(MAKE) asm/warnings.time asm/warnings.time: $(WARNSRCS) asm/warnings.pl $(EMPTY) asm/warnings.time - $(MAKE) $(WARNTIMES) + $(MAKE) $(WARNFILESX:.x=.time) asm/warnings_c.h.time: asm/warnings.pl asm/warnings.time $(RUNPERL) $(srcdir)/asm/warnings.pl c asm/warnings_c.h $(srcdir) $(EMPTY) asm/warnings_c.h.time asm/warnings_c.h: asm/warnings_c.h.time - @: Side effect + $(NULLCMD) Side effect include/warnings.h.time: asm/warnings.pl asm/warnings.time $(RUNPERL) $(srcdir)/asm/warnings.pl h include/warnings.h $(srcdir) $(EMPTY) include/warnings.h.time include/warnings.h: include/warnings.h.time - @: Side effect + $(NULLCMD) Side effect doc/warnings.src.time: asm/warnings.pl asm/warnings.time $(RUNPERL) $(srcdir)/asm/warnings.pl doc doc/warnings.src $(srcdir) $(EMPTY) doc/warnings.src.time doc/warnings.src : doc/warnings.src.time - @: Side effect + $(NULLCMD) Side effect # Assembler token hash asm/tokhash.c: x86/insns.dat x86/insnsn.c asm/tokens.dat asm/tokhash.pl \ @@ -363,7 +362,7 @@ asm/directbl.c: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph # Emacs token files misc/nasmtok.el: misc/emacstbl.pl asm/tokhash.c asm/pptok.c \ asm/directiv.dat version - $(RUNPERL) $< $@ "$(srcdir)" "$(objdir)" + $(RUNPERL) $(srcdir)/misc/emacstbl.pl $@ "$(srcdir)" "$(objdir)" #-- End Generated File Rules --# diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index 49678935..9bac7c94 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -49,7 +49,11 @@ RUNPERL = $(PERL) $(PERLFLAGS) MAKENSIS = makensis +EMPTY = echo > +NULLCMD = REM + RM_F = -del /f +RM_RF = -del /f/s LN_S = copy # Binary suffixes @@ -120,13 +124,16 @@ LIBOBJ_NW = stdlib\snprintf.obj stdlib\vsnprintf.obj stdlib\strlcpy.obj \ disasm\disasm.obj disasm\sync.obj # Warnings depend on all source files, so handle them separately -WARNOBJ = asm\warnings.obj -WARNFILES = asm\warnings_c.h include\warnings.h doc\warnings.src +WARNOBJ = asm\warnings.obj +WARNFILESX = asm\warnings_c.h.x include\warnings.h.x doc\warnings.src.x LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ) ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW) ALLOBJ = $(PROGOBJ) $(LIBOBJ) +# These are specific to certain Makefile syntaxes... +WARNSRCS = $(LIBOBJ_NW:.obj=.c) + SUBDIRS = stdlib nasmlib include config output asm disasm x86 \ common macros XSUBDIRS = test doc nsis win @@ -146,10 +153,6 @@ ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB) $(NASMLIB): $(LIBOBJ) $(AR) $(ARFLAGS) /OUT:$@ $** -# These are specific to certain Makefile syntaxes... -WARNTIMES = $(patsubst %,%.time,$(WARNFILES)) -WARNSRCS = $(patsubst %.obj,%.c,$(LIBOBJ_NW)) - #-- Begin Generated File Rules --# # Edit in Makefile.in, not here! @@ -165,7 +168,7 @@ PERLREQ_CLEANABLE = \ x86\iflag.c x86\iflaggen.h \ macros\macros.c \ asm\pptok.ph asm\directbl.c asm\directiv.h \ - $(WARNFILES) \ + $(WARNFILESX:.x=) \ misc\nasmtok.el \ version.h version.mac version.mak nsis\version.nsh @@ -175,9 +178,11 @@ PERLREQ = config\unconfig.h $(PERLREQ_CLEANABLE) INSDEP = x86\insns.dat x86\insns.pl x86\insns-iflags.ph x86\iflags.ph -config\unconfig.h: config\config.h.in autoconf\unconfig.pl - $(RUNPERL) '$(srcdir)'\autoconf\unconfig.pl \ - '$(srcdir)' config\config.h.in config\unconfig.h +!IF EXISTS($(srcdir)\config\config.h.in) +config\unconfig.h: autoconf\unconfig.pl config\config.h.in + $(RUNPERL) $(srcdir)\autoconf\unconfig.pl \ + $(srcdir) config\config.h.in config\unconfig.h +!ENDIF x86\iflag.c: $(INSDEP) $(RUNPERL) $(srcdir)\x86\insns.pl -fc \ @@ -248,35 +253,34 @@ x86\regs.h: x86\regs.dat x86\regs.pl # reasonable, but doesn't update the time stamp if the files aren't # changed, to avoid rebuilding everything every time. Track the actual # dependency by the empty file asm\warnings.time. -.PHONY: warnings warnings: dirs - $(RM_F) $(WARNFILES) $(WARNTIMES) asm\warnings.time - $(MAKE) asm\warnings.time + $(RM_F) $(WARNFILESX:.x=) $(WARNFILESX:.x=.time) asm\warnings.time + $(MAKE) -f mkfiles\msvc.mak asm\warnings.time asm\warnings.time: $(WARNSRCS) asm\warnings.pl $(EMPTY) asm\warnings.time - $(MAKE) $(WARNTIMES) + $(MAKE) -f mkfiles\msvc.mak $(WARNFILESX:.x=.time) asm\warnings_c.h.time: asm\warnings.pl asm\warnings.time $(RUNPERL) $(srcdir)\asm\warnings.pl c asm\warnings_c.h $(srcdir) $(EMPTY) asm\warnings_c.h.time asm\warnings_c.h: asm\warnings_c.h.time - @: Side effect + $(NULLCMD) Side effect include\warnings.h.time: asm\warnings.pl asm\warnings.time $(RUNPERL) $(srcdir)\asm\warnings.pl h include\warnings.h $(srcdir) $(EMPTY) include\warnings.h.time include\warnings.h: include\warnings.h.time - @: Side effect + $(NULLCMD) Side effect doc\warnings.src.time: asm\warnings.pl asm\warnings.time $(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src $(srcdir) $(EMPTY) doc\warnings.src.time doc\warnings.src : doc\warnings.src.time - @: Side effect + $(NULLCMD) Side effect # Assembler token hash asm\tokhash.c: x86\insns.dat x86\insnsn.c asm\tokens.dat asm\tokhash.pl \ @@ -314,7 +318,7 @@ asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph # Emacs token files misc\nasmtok.el: misc\emacstbl.pl asm\tokhash.c asm\pptok.c \ asm\directiv.dat version - $(RUNPERL) $< $@ "$(srcdir)" "$(objdir)" + $(RUNPERL) $(srcdir)\misc\emacstbl.pl $@ "$(srcdir)" "$(objdir)" #-- End Generated File Rules --# @@ -335,42 +339,42 @@ nsis: nsis\nasm.nsi nsis\arch.nsh nsis\version.nsh #-- End NSIS Rules --# clean: - -del /f /s *.obj - -del /f /s *.pdb - -del /f /s *.s - -del /f /s *.i - -del /f $(NASMLIB) $(RDFLIB) - -del /f nasm$(X) - -del /f ndisasm$(X) + $(RM_RF) *.obj + $(RM_RF) *.pdb + $(RM_RF) *.s + $(RM_RF) *.i + $(RM_F) $(NASMLIB) $(RDFLIB) + $(RM_F) nasm$(X) + $(RM_F) ndisasm$(X) distclean: clean - -del /f config.h - -del /f config.log - -del /f config.status - -del /f Makefile - -del /f /s *~ - -del /f /s *.bak - -del /f /s *.lst - -del /f /s *.bin - -del /f /s *.dep - -del /f output\*~ - -del /f output\*.bak - -del /f test\*.lst - -del /f test\*.bin - -del /f test\*.obj - -del /f test\*.bin - -del /f/s autom4te*.cache + $(RM_F) config.h + $(RM_F) config.log + $(RM_F) config.status + $(RM_F) Makefile + $(RM_RF) *~ + $(RM_RF) *.bak + $(RM_RF) *.lst + $(RM_RF) *.bin + $(RM_RF) *.dep + $(RM_F) output\*~ + $(RM_F) output\*.bak + $(RM_F) test\*.lst + $(RM_F) test\*.bin + $(RM_F) test\*.obj + $(RM_F) test\*.bin + $(RM_RF) autom4te*.cache cleaner: clean - -del /f $(PERLREQ) - -del /f *.man - -del /f nasm.spec + $(RM_F) $(PERLREQ) + $(RM_F) *.man + $(RM_F) nasm.spec rem cd doc && $(MAKE) clean spotless: distclean cleaner - -del /f doc\Makefile - -del doc\*~ - -del doc\*.bak + $(RM_F) doc\Makefile + $(RM_F) doc\*~ + $(RM_F) doc\*.bak strip: @@ -394,7 +398,7 @@ EXTERNAL_DEPENDENCIES = 1 # pollute the git logs. # msvc.dep: $(PERLREQ) tools\mkdep.pl - $(RUNPERL) tools\mkdep.pl -M Mkfiles\msvc.mak -- $(DEPDIRS) + $(RUNPERL) $(srcdir)\tools\mkdep.pl -M Mkfiles\msvc.mak -- $(DEPDIRS) dep: msvc.dep diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 91c606be..4798ac38 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -6,6 +6,7 @@ top_srcdir = . srcdir = . +objdir = . VPATH = $(srcdir)\asm;$(srcdir)\x86;asm;x86;$(srcdir)\macros;macros;$(srcdir)\output;$(srcdir)\lib;$(srcdir)\common;$(srcdir)\stdlib;$(srcdir)\nasmlib;$(srcdir)\disasm prefix = C:\Program Files\NASM exec_prefix = $(prefix) @@ -28,10 +29,13 @@ PERL = perl PERLFLAGS = -I$(srcdir)\perllib -I$(srcdir) RUNPERL = $(PERL) $(PERLFLAGS) -EMPTY = $(RUNPERL) -e "" +EMPTY = %create +NULLCMD = %null MAKENSIS = makensis +RM_F = rm -f + # Binary suffixes O = obj X = .exe @@ -108,13 +112,17 @@ LIBOBJ_NW = stdlib\snprintf.obj stdlib\vsnprintf.obj stdlib\strlcpy.obj & disasm\disasm.obj disasm\sync.obj # Warnings depend on all source files, so handle them separately -WARNOBJ = asm\warnings.obj -WARNFILES = asm\warnings_c.h include\warnings.h doc\warnings.src +WARNOBJ = asm\warnings.obj +WARNFILESX = asm\warnings_c.h.x include\warnings.h.x doc\warnings.src.x LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ) ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW) ALLOBJ = $(PROGOBJ) $(LIBOBJ) +# These are specific to certain Makefile syntaxes (what are they +# actually supposed to look like for wmake?) +WARNSRCS = $(LIBOBJ_NW:.obj=.c) + SUBDIRS = stdlib nasmlib include config output asm disasm x86 & common macros XSUBDIRS = test doc nsis win @@ -158,11 +166,6 @@ ndisasm$(X): $(NDISASM) $(LIBOBJ) nasm.lib: $(LIBOBJ) wlib -q -b -n $@ $(LIBOBJ) -# These are specific to certain Makefile syntaxes (what are they -# actually supposed to look like for wmake?) -WARNTIMES = $(WARNFILES:=.time) -WARNSRCS = $(LIBOBJ_NW:.obj=.c) - #-- Begin Generated File Rules --# # Edit in Makefile.in, not here! @@ -178,7 +181,7 @@ PERLREQ_CLEANABLE = & x86\iflag.c x86\iflaggen.h & macros\macros.c & asm\pptok.ph asm\directbl.c asm\directiv.h & - $(WARNFILES) & + $(WARNFILESX:.x=) & misc\nasmtok.el & version.h version.mac version.mak nsis\version.nsh @@ -188,9 +191,11 @@ PERLREQ = config\unconfig.h $(PERLREQ_CLEANABLE) INSDEP = x86\insns.dat x86\insns.pl x86\insns-iflags.ph x86\iflags.ph -config\unconfig.h: config\config.h.in autoconf\unconfig.pl - $(RUNPERL) '$(srcdir)'\autoconf\unconfig.pl & - '$(srcdir)' config\config.h.in config\unconfig.h +!if exists($(srcdir)\config\config.h.in) +config\unconfig.h: autoconf\unconfig.pl config\config.h.in + $(RUNPERL) $(srcdir)\autoconf\unconfig.pl & + $(srcdir) config\config.h.in config\unconfig.h +!endif x86\iflag.c: $(INSDEP) $(RUNPERL) $(srcdir)\x86\insns.pl -fc & @@ -261,35 +266,34 @@ x86\regs.h: x86\regs.dat x86\regs.pl # reasonable, but doesn't update the time stamp if the files aren't # changed, to avoid rebuilding everything every time. Track the actual # dependency by the empty file asm\warnings.time. -.PHONY: warnings -warnings: dirs - $(RM_F) $(WARNFILES) $(WARNTIMES) asm\warnings.time - $(MAKE) asm\warnings.time +warnings: dirs .SYMBOLIC + $(RM_F) $(WARNFILESX:.x=) $(WARNFILESX:.x=.time) asm\warnings.time + $(MAKE) -f mkfiles\openwcom.mak asm\warnings.time asm\warnings.time: $(WARNSRCS) asm\warnings.pl $(EMPTY) asm\warnings.time - $(MAKE) $(WARNTIMES) + $(MAKE) -f mkfiles\openwcom.mak $(WARNFILESX:.x=.time) asm\warnings_c.h.time: asm\warnings.pl asm\warnings.time $(RUNPERL) $(srcdir)\asm\warnings.pl c asm\warnings_c.h $(srcdir) $(EMPTY) asm\warnings_c.h.time asm\warnings_c.h: asm\warnings_c.h.time - @: Side effect + $(NULLCMD) Side effect include\warnings.h.time: asm\warnings.pl asm\warnings.time $(RUNPERL) $(srcdir)\asm\warnings.pl h include\warnings.h $(srcdir) $(EMPTY) include\warnings.h.time include\warnings.h: include\warnings.h.time - @: Side effect + $(NULLCMD) Side effect doc\warnings.src.time: asm\warnings.pl asm\warnings.time $(RUNPERL) $(srcdir)\asm\warnings.pl doc doc\warnings.src $(srcdir) $(EMPTY) doc\warnings.src.time doc\warnings.src : doc\warnings.src.time - @: Side effect + $(NULLCMD) Side effect # Assembler token hash asm\tokhash.c: x86\insns.dat x86\insnsn.c asm\tokens.dat asm\tokhash.pl & @@ -327,7 +331,7 @@ asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph # Emacs token files misc\nasmtok.el: misc\emacstbl.pl asm\tokhash.c asm\pptok.c & asm\directiv.dat version - $(RUNPERL) $< $@ "$(srcdir)" "$(objdir)" + $(RUNPERL) $(srcdir)\misc\emacstbl.pl $@ "$(srcdir)" "$(objdir)" #-- End Generated File Rules --# @@ -348,33 +352,33 @@ nsis: nsis\nasm.nsi nsis\arch.nsh nsis\version.nsh #-- End NSIS Rules --# clean: .SYMBOLIC - rm -f *.obj *.s *.i - rm -f asm\*.obj asm\*.s asm\*.i - rm -f x86\*.obj x86\*.s x86\*.i - rm -f lib\*.obj lib\*.s lib\*.i - rm -f macros\*.obj macros\*.s macros\*.i - rm -f output\*.obj output\*.s output\*.i - rm -f common\*.obj common\*.s common\*.i - rm -f stdlib\*.obj stdlib\*.s stdlib\*.i - rm -f nasmlib\*.obj nasmlib\*.s nasmlib\*.i - rm -f disasm\*.obj disasm\*.s disasm\*.i - rm -f config.h config.log config.status - rm -f nasm$(X) ndisasm$(X) $(NASMLIB) + $(RM_F) *.obj *.s *.i *.err + $(RM_F) asm\*.obj asm\*.s asm\*.i asm\*.err + $(RM_F) x86\*.obj x86\*.s x86\*.i x86\*.err + $(RM_F) lib\*.obj lib\*.s lib\*.i lib\*.err + $(RM_F) macros\*.obj macros\*.s macros\*.i macros\*.err + $(RM_F) output\*.obj output\*.s output\*.i output\*.err + $(RM_F) common\*.obj common\*.s common\*.i common\*.err + $(RM_F) stdlib\*.obj stdlib\*.s stdlib\*.i stdlib\*.err + $(RM_F) nasmlib\*.obj nasmlib\*.s nasmlib\*.i nasmlib\*.err + $(RM_F) disasm\*.obj disasm\*.s disasm\*.i disasm\*.err + $(RM_F) config.h config.log config.status + $(RM_F) nasm$(X) ndisasm$(X) $(NASMLIB) distclean: clean .SYMBOLIC - rm -f config.h config.log config.status - rm -f Makefile *~ *.bak *.lst *.bin - rm -f output\*~ output\*.bak - rm -f test\*.lst test\*.bin test\*.obj test\*.bin + $(RM_F) config.h config.log config.status + $(RM_F) Makefile *~ *.bak *.lst *.bin + $(RM_F) output\*~ output\*.bak + $(RM_F) test\*.lst test\*.bin test\*.obj test\*.bin cleaner: clean .SYMBOLIC - rm -f $(PERLREQ) - rm -f *.man - rm -f nasm.spec + $(RM_F) $(PERLREQ) + $(RM_F) *.man + $(RM_F) nasm.spec # cd doc && $(MAKE) clean spotless: distclean cleaner .SYMBOLIC - rm -f doc\Makefile doc\*~ doc\*.bak + $(RM_F) doc\Makefile doc\*~ doc\*.bak strip: .SYMBOLIC $(STRIP) *.exe @@ -389,8 +393,8 @@ everything: all doc # it's expected to be invoked manually. # alldeps: perlreq .SYMBOLIC - $(PERL) syncfiles.pl Makefile.in Mkfiles\openwcom.mak - $(PERL) mkdep.pl -M Makefile.in Mkfiles\openwcom.mak -- . output lib + $(PERL) $(srcdir)\tools\syncfiles.pl Makefile.in Mkfiles\openwcom.mak + $(PERL) $(srcdir)\tools\mkdep.pl -M Makefile.in Mkfiles\openwcom.mak -- . output lib #-- Magic hints to mkdep.pl --# # @object-ending: ".obj"