@@ -43,6 +43,8 @@ PERL = perl
4343PERLFLAGS = -I$(top_srcdir ) /perllib -I$(srcdir )
4444RUNPERL = $(PERL ) $(PERLFLAGS )
4545
46+ EMPTY = : >
47+
4648PYTHON3 = python3
4749
4850INSTALL = @INSTALL@
@@ -55,6 +57,7 @@ ASCIIDOC = @ASCIIDOC@
5557XMLTO = @XMLTO@
5658MAKENSIS = @MAKENSIS@
5759XZ = @XZ@
60+ WINDRES = @WINDRES@
5861
5962# Optional targets
6063MANPAGES = @MANPAGES@
@@ -76,6 +79,12 @@ ifeq ($(TRACE),1)
7679 CFLAGS += -DNASM_TRACE
7780endif
7881
82+ # Don't delete intermediate files
83+ .SECONDARY :
84+
85+ # Delete files on error
86+ .DELETE_ON_ERROR :
87+
7988.SUFFIXES :
8089.SUFFIXES : $(X ) .$(O ) .$(A ) .xml .1 .c .i .s .txt .time
8190
98107.xml.1 :
99108 $(XMLTO ) man --skip-validation $< 2> /dev/null
100109
110+ MANIFEST = @MANIFEST@
111+
101112# -- Begin File Lists --#
102113NASM = asm/nasm.$(O )
103114NDISASM = disasm/ndisasm.$(O )
@@ -115,7 +126,8 @@ LIBOBJ_NW = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
115126 nasmlib/file.$(O ) nasmlib/mmap.$(O ) nasmlib/ilog2.$(O ) \
116127 nasmlib/realpath.$(O ) nasmlib/path.$(O ) \
117128 nasmlib/filename.$(O ) nasmlib/rlimit.$(O ) \
118- nasmlib/zerobuf.$(O ) nasmlib/readnum.$(O ) nasmlib/bsi.$(O ) \
129+ nasmlib/readnum.$(O ) nasmlib/numstr.$(O ) \
130+ nasmlib/zerobuf.$(O ) nasmlib/bsi.$(O ) \
119131 nasmlib/rbtree.$(O ) nasmlib/hashtbl.$(O ) \
120132 nasmlib/raa.$(O ) nasmlib/saa.$(O ) \
121133 nasmlib/strlist.$(O ) \
@@ -153,14 +165,16 @@ LIBOBJ_NW = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
153165
154166# Warnings depend on all source files, so handle them separately
155167WARNOBJ = asm/warnings.$(O )
168+ WARNFILES = asm/warnings_c.h include/warnings.h doc/warnings.src
156169
157170LIBOBJ = $(LIBOBJ_NW ) $(WARNOBJ )
158171ALLOBJ_NW = $(PROGOBJ ) $(LIBOBJ_NW )
159172ALLOBJ = $(PROGOBJ ) $(LIBOBJ )
160173
161- SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
162- XSUBDIRS = test doc nsis
163- DEPDIRS = . include config x86 $(SUBDIRS )
174+ SUBDIRS = stdlib nasmlib include config output asm disasm x86 \
175+ common macros
176+ XSUBDIRS = test doc nsis win
177+ DEPDIRS = . $(SUBDIRS )
164178# -- End File Lists --#
165179
166180all : dirs
@@ -176,11 +190,15 @@ $(NASMLIB): $(LIBOBJ)
176190 $(AR ) cq $(NASMLIB ) $(LIBOBJ )
177191 $(RANLIB ) $(NASMLIB )
178192
179- nasm$(X ) : $(NASM ) $(NASMLIB )
180- $(CC ) $(ALL_LDFLAGS ) -o nasm$(X ) $( NASM ) $( NASMLIB ) $(LIBS )
193+ nasm$(X ) : $(NASM ) $(MANIFEST ) $( NASMLIB )
194+ $(CC ) $(ALL_LDFLAGS ) -o nasm$(X ) $^ $(LIBS )
181195
182- ndisasm$(X ) : $(NDISASM ) $(NASMLIB )
183- $(CC ) $(ALL_LDFLAGS ) -o ndisasm$(X ) $(NDISASM ) $(NASMLIB ) $(LIBS )
196+ ndisasm$(X ) : $(NDISASM ) $(MANIFEST ) $(NASMLIB )
197+ $(CC ) $(ALL_LDFLAGS ) -o ndisasm$(X ) $^ $(LIBS )
198+
199+ # These are specific to certain Makefile syntaxes...
200+ WARNTIMES = $(WARNFILES:=.time )
201+ WARNSRCS = $(LIBOBJ_NW:.$(O ) =.c ) asm/nasm.c
184202
185203# -- Begin Generated File Rules --#
186204
@@ -189,7 +207,7 @@ ndisasm$(X): $(NDISASM) $(NASMLIB)
189207# have Perl just to recompile NASM from the distribution.
190208
191209# Perl-generated source files
192- PERLREQ = config/unconfig.h \
210+ PERLREQ_CLEANABLE = \
193211 x86/insnsb.c x86/insnsa.c x86/insnsd.c x86/insnsi.h x86/insnsn.c \
194212 x86/regs.c x86/regs.h x86/regflags.c x86/regdis.c x86/regdis.h \
195213 x86/regvals.c asm/tokhash.c asm/tokens.h asm/pptok.h asm/pptok.c \
@@ -200,10 +218,14 @@ PERLREQ = config/unconfig.h \
200218 misc/nasmtok.el \
201219 version.h version.mac version.mak nsis/version.nsh
202220
221+ # Special hack to keep config/unconfig.h from getting deleted
222+ # by "make spotless"...
223+ PERLREQ = config/unconfig.h $(PERLREQ_CLEANABLE )
224+
203225INSDEP = x86/insns.dat x86/insns.pl x86/insns-iflags.ph x86/iflags.ph
204226
205- config/unconfig.h : config/config.h.in
206- $(RUNPERL ) $( tools ) /unconfig.pl \
227+ config/unconfig.h : config/config.h.in autoconf/unconfig.pl
228+ $(RUNPERL ) ' $(srcdir) ' /autoconf /unconfig.pl \
207229 ' $(srcdir)' config/config.h.in config/unconfig.h
208230
209231x86/iflag.c : $(INSDEP )
@@ -275,33 +297,32 @@ x86/regs.h: x86/regs.dat x86/regs.pl
275297# reasonable, but doesn't update the time stamp if the files aren't
276298# changed, to avoid rebuilding everything every time. Track the actual
277299# dependency by the empty file asm/warnings.time.
278- WARNFILES = asm/warnings_c.h include/warnings.h doc/warnings.src
279-
280- warnings :
281- $(RM_F ) $(WARNFILES ) $(WARNFILES:=.time )
300+ .PHONY : warnings
301+ warnings : dirs
302+ $(RM_F ) $(WARNFILES ) $(WARNTIMES ) asm/warnings.time
282303 $(MAKE ) asm/warnings.time
283304
284- asm/warnings.time : $(ALLOBJ_NW:. $( O ) =.c )
285- : > asm/warnings.time
286- $(MAKE ) $(WARNFILES:=.time )
305+ asm/warnings.time : $(WARNSRCS ) asm/warnings.pl
306+ $( EMPTY ) asm/warnings.time
307+ $(MAKE ) $(WARNTIMES )
287308
288309asm/warnings_c.h.time : asm/warnings.pl asm/warnings.time
289310 $(RUNPERL ) $(srcdir ) /asm/warnings.pl c asm/warnings_c.h $(srcdir )
290- : > asm/warnings_c.h.time
311+ $( EMPTY ) asm/warnings_c.h.time
291312
292313asm/warnings_c.h : asm/warnings_c.h.time
293314 @: Side effect
294315
295316include/warnings.h.time : asm/warnings.pl asm/warnings.time
296317 $(RUNPERL ) $(srcdir ) /asm/warnings.pl h include/warnings.h $(srcdir )
297- : > include/warnings.h.time
318+ $( EMPTY ) include/warnings.h.time
298319
299320include/warnings.h : include/warnings.h.time
300321 @: Side effect
301322
302323doc/warnings.src.time : asm/warnings.pl asm/warnings.time
303324 $(RUNPERL ) $(srcdir ) /asm/warnings.pl doc doc/warnings.src $(srcdir )
304- : > doc/warnings.src.time
325+ $( EMPTY ) doc/warnings.src.time
305326
306327doc/warnings.src : doc/warnings.src.time
307328 @: Side effect
@@ -346,7 +367,8 @@ misc/nasmtok.el: misc/emacstbl.pl asm/tokhash.c asm/pptok.c \
346367
347368# -- End Generated File Rules --#
348369
349- perlreq : $(PERLREQ )
370+ perlreq : dirs
371+ $(MAKE ) $(PERLREQ )
350372
351373# -- Begin NSIS Rules --#
352374
@@ -361,6 +383,11 @@ nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
361383
362384# -- End NSIS Rules --#
363385
386+ # Windows embedded manifest
387+ MANIFEST_RC = win/manifest.rc
388+ win/manifest.$(O ) : win/manifest.xml $(MANIFEST_RC )
389+ $(WINDRES ) -I. -Iwin -DMANIFEST_FILE=' \"$<\"' -i $(MANIFEST_RC ) -o $@
390+
364391# Generated manpages, also pregenerated for distribution
365392manpages : nasm.1 ndisasm.1
366393
@@ -388,16 +415,16 @@ distclean: clean
388415 done
389416 $(RM_F ) test/* .$(O )
390417 $(RM_F ) * .dep
418+ -sh autoconf/clean.sh || sh ' $(srcdir)' /autoconf/clean.sh
391419
392- cleaner : clean
393- $(RM_F ) $(PERLREQ ) * .1 nasm.spec
420+ cleaner :
421+ $(RM_F ) $(PERLREQ_CL ) * .1 nasm.spec
394422 $(MAKE ) -C doc clean
395- $(RM_F ) * .dep * /* .time
396-
397- makefile-clean :
398- ./autogen.sh
423+ $(MAKE ) distclean
424+ $(RM_F ) * /* .time
399425
400- spotless : distclean cleaner makefile-clean
426+ spotless : cleaner
427+ $(RM_F ) configure autoconf/aclocal.m4 autoconf/clean.sh
401428
402429strip :
403430 $(STRIP ) --strip-unneeded $(PROGS )
@@ -433,23 +460,22 @@ everything: always_everything
433460install_everything : everything install install_doc
434461
435462dist :
436- $(MAKE ) distclean
437463 $(MAKE ) alldeps
438- $(MAKE ) perlreq manpages spec $(MANPAGES )
464+ $(MAKE ) perlreq warnings spec $(MANPAGES )
465+ $(MAKE ) distclean
439466 ./autogen.sh
440467
441468tar : dist
442- tar -cv --exclude CVS -C .. -f - | \
443- $(XZ ) -9e > \
444- ../nasm-` cat version` -` date +%Y%m%d` .tar.xz ` basename \` pwd\` `
469+ tar -cv --exclude CVS --exclude .git -C .. -f - ` basename \` pwd\` ` | \
470+ $(XZ ) -9e > ../nasm-` cat version` -` date +%Y%m%d` .tar.xz
445471
446472spec : nasm.spec
447473
448474ALLPERLSRC := $(shell find $(srcdir ) -type f -name '* .p[lh]')
449475
450476perlbreq.si : $(ALLPERLSRC )
451- sed -n -r -e ' s/^[[:space:]]*use[[:space:]]+([^[:space:];]+ ).*$$/BuildRequires: perl(\1)/p' $(ALLPERLSRC ) | \
452- sed -r -e ' /perl\((strict|warnings| Win32.*)\)/d' | \
477+ sed -n -r -e ' s/^[[:space:]]*use[[:space:]]+([[:upper:]][ ^[:space:];]* ).*$$/BuildRequires: perl(\1)/p' $(ALLPERLSRC ) | \
478+ sed -r -e ' /perl\((Win32.*)\)/d' | \
453479 sort | uniq > perlbreq.si
454480
455481nasm.spec : nasm.spec.in nasm.spec.sed version.sed perlbreq.si
@@ -508,8 +534,9 @@ EXTERNAL_DEPENDENCIES = 1
508534# the dependency information will remain external, so it doesn't
509535# pollute the git logs.
510536#
511- Makefile.dep : $(PERLREQ ) $(tools ) /mkdep.pl config.status
512- $(RUNPERL ) $(tools ) /mkdep.pl -M Makefile.in -- $(DEPDIRS )
537+ Makefile.dep : $(tools ) /mkdep.pl config.status $(PERLREQ )
538+ $(RUNPERL ) $(tools ) /mkdep.pl -s ' $(top_srcdir)' \
539+ -M $(srcdir ) /Makefile.in -- $(DEPDIRS )
513540
514541dep : Makefile.dep
515542
0 commit comments