# -*- makefile -*-
# SPDX-License-Identifier: BSD-2-Clause
# Copyright 1996-2025 The NASM Authors - All Rights Reserved

# Auto-configuring Makefile for the Netwide Assembler.

@SET_MAKE@

PACKAGE_NAME    = @PACKAGE_NAME@
PACKAGE_TARNAME = @PACKAGE_TARNAME@

top_srcdir	= @top_srcdir@
srcdir		= @srcdir@
objdir		= @builddir@
VPATH		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
mandir		= @mandir@
datarootdir	= @datarootdir@
datadir		= @datadir@
pkgdatadir      = $(datadir)/$(PACKAGE_TARNAME)
docdir          = @docdir@
htmldir         = @htmldir@
pdfdir          = @pdfdir@
psdir           = @psdir@

CC		= @CC@
CFLAGS		= @CFLAGS@
CPPFLAGS	= @CPPFLAGS@
ZLIBINC         = @ZLIBINC@
BUILD_CFLAGS	= $(CPPFLAGS) $(CFLAGS) @DEFS@
INTERNAL_CFLAGS = -I$(srcdir) -I$(objdir) \
		  -I$(srcdir)/include -I$(objdir)/include \
		  -I$(srcdir)/x86 -I$(objdir)/x86 \
		  -I$(srcdir)/asm -I$(objdir)/asm \
		  -I$(srcdir)/disasm -I$(objdir)/disasm \
		  -I$(srcdir)/output -I$(objdir)/output \
		  $(ZLIBINC)
EXTRA_CFLAGS    =
ALL_CFLAGS	= $(BUILD_CFLAGS) $(INTERNAL_CFLAGS) $(EXTRA_CFLAGS)
LDFLAGS		= @LDFLAGS@
EXTRA_LDFLAGS   =
ALL_LDFLAGS     = $(ALL_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS)
LIBS		= @LIBS@

ZLIB		= @ZLIB@
ZLIBINC		= @ZLIBINC@

AR		= @AR@
RANLIB		= @RANLIB@
STRIP		= @STRIP@

tools		= $(top_srcdir)/tools

PERL		= perl
PERLFLAGS	= -I$(top_srcdir)/perllib -I$(srcdir)
RUNPERL         = $(PERL) $(PERLFLAGS)

EMPTY		= : >
SIDE		= @: Generated by side effect

PYTHON3		= @PYTHON3@
GREP		= grep

INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@

# Optional tools
NROFF		= @NROFF@
ASCIIDOC	= @ASCIIDOC@
XMLTO		= @XMLTO@
MAKENSIS	= @MAKENSIS@
XZ              = @XZ@
WINDRES         = @WINDRES@

# Optional targets
MANPAGES        = @MANPAGES@
NSIS            = @NSIS@

MKDIR_P		= @MKDIR_P@
RM_F		= rm -f
RM_RF		= rm -rf
LN_S		= @LN_S@
FIND		= find

# Binary suffixes
O		= @OBJEXT@
X		= @EXEEXT@
A		= @LIBEXT@

# Debug stuff
ifeq ($(TRACE),1)
	CFLAGS += -DNASM_TRACE
endif

# Don't delete intermediate files
.SECONDARY:

# Delete files on error
.DELETE_ON_ERROR:

.SUFFIXES:
.SUFFIXES: $(X) .$(O) .$(A) .xml .1 .c .i .s .txt .time

# Use to mark phony targets in global lists
PHONY =

.PHONY: all doc misc install clean distclean cleaner spotless test
.PHONY: install_doc everything install_everything strip perlreq warnings
.PHONY: dist tags TAGS nothing manpages nsis editors travis

.c.$(O):
	$(CC) -c $(ALL_CFLAGS) -o $@ $<

.c.s:
	$(CC) -S $(ALL_CFLAGS) -o $@ $<

.c.i:
	$(CC) -E $(ALL_CFLAGS) -o $@ $<

.txt.xml:
	$(ASCIIDOC) -b docbook -d manpage -o $@ $<

.xml.1:
	$(XMLTO) man --skip-validation $< 2>/dev/null

MANIFEST = @MANIFEST@

#-- Begin File Lists --#
NASM    = asm/nasm.$(O)
NDISASM = disasm/ndisasm.$(O)

PROGOBJ = $(NASM) $(NDISASM)
PROGS   = nasm$(X) ndisasm$(X)

# Files dependent on warnings.dat
WARNOBJ   = asm/warnings.$(O)
WARNFILES = asm/warnings_c.h include/warnings.h doc/warnings.src

OUTPUTOBJ = \
	output/outform.$(O) output/outlib.$(O) \
	output/nulldbg.$(O) output/nullout.$(O) \
	output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
	output/outelf.$(O) \
	output/outobj.$(O) output/outas86.$(O) \
	output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
	output/codeview.$(O)

# The source files for these objects are scanned for warnings
LIBOBJ_W = \
	nasmlib/readnum.$(O) \
	\
	asm/error.$(O) \
	asm/floats.$(O) \
	asm/directiv.$(O) \
	asm/pragma.$(O) \
	asm/assemble.$(O) asm/labels.$(O) asm/parser.$(O) \
	asm/preproc.$(O) asm/quote.$(O) \
	asm/listing.$(O) asm/eval.$(O) asm/exprlib.$(O) asm/exprdump.$(O) \
	asm/stdscan.$(O) \
	asm/getbool.$(O) \
	asm/strfunc.$(O) \
	asm/segalloc.$(O) \
	asm/rdstrnum.$(O) \
	asm/srcfile.$(O) \
	\
	$(OUTPUTOBJ)

# The source files for these objects are NOT scanned for warnings;
# normally this will include all generated files.
# It is entirely possible that it may be necessary to move some of these
# files to LIBOBJ_W, notably $(OUTPUTOBJ)
LIBOBJ_NW = \
	stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
	stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \
	\
	asm/directbl.$(O) \
	asm/pptok.$(O) \
	asm/tokhash.$(O) \
	asm/uncompress.$(O) \
	\
	macros/macros.$(O) \
	\
	nasmlib/ver.$(O) \
	nasmlib/alloc.$(O) nasmlib/asprintf.$(O) \
	nasmlib/crc32b.$(O) nasmlib/crc64.$(O) nasmlib/md5c.$(O) \
	nasmlib/string.$(O) nasmlib/nctype.$(O) \
	nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \
	nasmlib/realpath.$(O) nasmlib/path.$(O) \
	nasmlib/filename.$(O) nasmlib/rlimit.$(O) \
	nasmlib/numstr.$(O) \
	nasmlib/zerobuf.$(O) nasmlib/bsi.$(O) \
	nasmlib/rbtree.$(O) nasmlib/hashtbl.$(O) \
	nasmlib/raa.$(O) nasmlib/saa.$(O) \
	nasmlib/strlist.$(O) \
	nasmlib/perfhash.$(O) nasmlib/badenum.$(O) \
	\
	common/common.$(O) \
	\
	x86/insnsa.$(O) x86/insnsb.$(O) x86/insnsn.$(O) \
	x86/regs.$(O) x86/regvals.$(O) x86/regflags.$(O) \
	x86/iflag.$(O) \
	\
	$(WARNOBJ)

# Objects which are only used for the disassembler
LIBOBJ_DIS = \
	disasm/disasm.$(O) disasm/sync.$(O) disasm/prefix.$(O) \
	\
	x86/insnsd.$(O) x86/regdis.$(O)

# Objects for the local copy of zlib. The variable ZLIB is set to
# $(ZLIBOBJ) if the internal version of zlib should be used.
ZLIBOBJ = \
	zlib/adler32.$(O) \
	zlib/crc32.$(O) \
	zlib/infback.$(O) \
	zlib/inffast.$(O) \
	zlib/inflate.$(O) \
	zlib/inftrees.$(O) \
	zlib/zutil.$(O)

LIBOBJ    = $(LIBOBJ_W) $(LIBOBJ_NW) $(ZLIB)
ALLOBJ_W  = $(NASM) $(LIBOBJ_W)
ALLOBJ    = $(PROGOBJ) $(LIBOBJ)
SUBDIRS  = stdlib nasmlib include config output asm disasm x86 \
	   common zlib macros misc
XSUBDIRS = nsis win test doc editors
DEPDIRS  = . $(SUBDIRS)

EDITORS  = editors/nasmtok.el editors/nasmtok.json

#-- End File Lists --#

all: $(PROGS)

DIRS = dirs
$(DIRS):
	@$(MKDIR_P) $(SUBDIRS) $(XSUBDIRS)

NASMLIB = libnasm.$(A)
DISLIB  = libndis.$(A)

$(NASMLIB): $(LIBOBJ)
	$(RM_F) $(NASMLIB)
	$(AR) cq $(NASMLIB) $(LIBOBJ)
	$(RANLIB) $(NASMLIB)

$(DISLIB): $(LIBOBJ_DIS)
	$(RM_F) $(DISLIB)
	$(AR) cq $(DISLIB) $(LIBOBJ_DIS)
	$(RANLIB) $(DISLIB)

nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
	$(CC) $(ALL_LDFLAGS) -o $@ $(NASM) $(MANIFEST) \
		$(NASMLIB) $(LIBS)

ndisasm$(X): $(NDISASM) $(MANIFEST) $(DISLIB) $(NASMLIB)
	$(CC) $(ALL_LDFLAGS) -o $@ $(NDISASM) $(MANIFEST) \
		$(DISLIB) $(NASMLIB) $(LIBS)

# Make sure we have subdirectories set up...
$(LIBOBJ) $(LIBOBJ_DIS): $(DIRS)

#-- Begin Generated File Rules --#

# These source files are automagically generated from data files using
# Perl scripts. They're distributed, though, so it isn't necessary to
# have Perl just to recompile NASM from the distribution.

# Perl-generated source files
PERLREQ_CLEANABLE = \
	  x86/insnsb.c x86/insnsa.c x86/insnsd.c x86/insnsi.h x86/insnsn.c \
	  x86/regs.c x86/regs.h x86/regflags.c x86/regdis.c x86/regdis.h \
	  x86/regvals.c asm/tokhash.c asm/tokens.h asm/pptok.h asm/pptok.c \
	  x86/iflag.c x86/iflaggen.h \
	  macros/macros.c \
	  asm/pptok.ph asm/directbl.c asm/directiv.h \
	  $(WARNFILES) \
	  version.h version.mac version.mak nsis/version.nsh

PERLREQ = $(PERLREQ_CLEANABLE)

INSDEP = x86/insns.xda x86/insns.pl x86/insns-iflags.ph x86/iflags.ph

x86/insns.xda: x86/insns.dat x86/preinsns.pl $(DIRS)
	$(RUNPERL) $(srcdir)/x86/preinsns.pl $(srcdir)/x86/insns.dat $@

x86/iflag.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -fc \
		x86/insns.xda x86/iflag.c
x86/iflaggen.h: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -fh \
		x86/insns.xda x86/iflaggen.h
x86/insnsb.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -b \
		x86/insns.xda x86/insnsb.c
x86/insnsa.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -a \
		x86/insns.xda x86/insnsa.c
x86/insnsd.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -d \
		x86/insns.xda x86/insnsd.c
x86/insnsi.h: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -i \
		x86/insns.xda x86/insnsi.h
x86/insnsn.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -n \
		x86/insns.xda x86/insnsn.c

# These files contains all the standard macros that are derived from
# the version number.
version.h: version version.pl
	$(RUNPERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
version.mac: version version.pl
	$(RUNPERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
version.sed: version version.pl
	$(RUNPERL) $(srcdir)/version.pl sed < $(srcdir)/version > version.sed
version.mak: version version.pl
	$(RUNPERL) $(srcdir)/version.pl make < $(srcdir)/version > version.mak
nsis/version.nsh: version version.pl $(DIRS)
	$(RUNPERL) $(srcdir)/version.pl nsis < $(srcdir)/version > nsis/version.nsh

# This source file is generated from the standard macros file
# `standard.mac' by another Perl script. Again, it's part of the
# standard distribution.
macros/macros.c: macros/macros.pl asm/pptok.ph version.mac \
	$(srcdir)/macros/*.mac $(srcdir)/output/*.mac
	$(RUNPERL) $(srcdir)/macros/macros.pl version.mac \
		$(srcdir)/macros/*.mac $(srcdir)/output/*.mac

# These source files are generated from regs.dat by yet another
# perl script.
x86/regs.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl c \
		$(srcdir)/x86/regs.dat > x86/regs.c
x86/regflags.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl fc \
		$(srcdir)/x86/regs.dat > x86/regflags.c
x86/regdis.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl dc \
		$(srcdir)/x86/regs.dat > x86/regdis.c
x86/regdis.h: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl dh \
		$(srcdir)/x86/regs.dat > x86/regdis.h
x86/regvals.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl vc \
		$(srcdir)/x86/regs.dat > x86/regvals.c
x86/regs.h: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl h \
		$(srcdir)/x86/regs.dat > x86/regs.h


# Assembler token hash
asm/tokhash.c: x86/insns.xda x86/insnsn.c asm/tokens.dat asm/tokhash.pl \
	perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/tokhash.pl c \
		x86/insnsn.c $(srcdir)/x86/regs.dat \
		$(srcdir)/asm/tokens.dat > asm/tokhash.c

# Assembler token metadata
asm/tokens.h: x86/insns.xda x86/insnsn.c asm/tokens.dat asm/tokhash.pl \
	perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/tokhash.pl h \
		x86/insnsn.c $(srcdir)/x86/regs.dat \
		$(srcdir)/asm/tokens.dat > asm/tokens.h

# Preprocessor token hash
asm/pptok.h: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl h \
		$(srcdir)/asm/pptok.dat asm/pptok.h
asm/pptok.c: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl c \
		$(srcdir)/asm/pptok.dat asm/pptok.c
asm/pptok.ph: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl ph \
		$(srcdir)/asm/pptok.dat asm/pptok.ph
doc/pptok.src: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl src \
		$(srcdir)/asm/pptok.dat doc/pptok.src

# Directives hash
asm/directiv.h: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/nasmlib/perfhash.pl h \
		$(srcdir)/asm/directiv.dat asm/directiv.h
asm/directbl.c: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/nasmlib/perfhash.pl c \
		$(srcdir)/asm/directiv.dat asm/directbl.c

# Editor token files
editors/nasmtok.el: editors/nasmtok.pl asm/tokhash.c asm/pptok.c \
		 asm/directiv.dat macros/macros.c editors/builtin.mac \
		 version.mak
	$(RUNPERL) $(srcdir)/editors/nasmtok.pl -el $@ $(srcdir) $(objdir)

editors/nasmtok.json: editors/nasmtok.pl asm/tokhash.c asm/pptok.c \
		 asm/directiv.dat macros/macros.c editors/builtin.mac \
		 version.mak
	$(RUNPERL) $(srcdir)/editors/nasmtok.pl -json $@ $(srcdir) $(objdir)

editors: $(EDITORS) $(PHONY)

asm/warnings_c.h: asm/warnings.pl asm/warnings.dat
	$(RUNPERL) $(srcdir)/asm/warnings.pl c asm/warnings_c.h \
		$(srcdir)/asm/warnings.dat

include/warnings.h: asm/warnings.pl asm/warnings.dat
	$(RUNPERL) $(srcdir)/asm/warnings.pl h include/warnings.h \
		$(srcdir)/asm/warnings.dat

doc/warnings.src: asm/warnings.pl asm/warnings.dat
	$(RUNPERL) $(srcdir)/asm/warnings.pl doc doc/warnings.src \
		$(srcdir)/asm/warnings.dat

$(PERLREQ): $(DIRS)

perlreq: $(PERLREQ) $(PHONY)

warnings: $(WARNFILES) $(PHONY)

#-- End Generated File Rules --#

#-- Begin NSIS Rules --#

nsis/arch.nsh: nsis/getpearch.pl nasm$(X) $(DIRS)
	$(PERL) $(srcdir)/nsis/getpearch.pl nasm$(X) > nsis/arch.nsh

# Should only be done after "make everything".
# The use of redirection here keeps makensis from moving the cwd to the
# source directory.
nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
	$(MAKENSIS) -Dsrcdir=$(srcdir) -Dobjdir=$(objdir) - \
		< $(srcdir)/nsis/nasm.nsi

#-- End NSIS Rules --#

# Windows embedded manifest
MANIFEST_RC = win/manifest.rc
win/manifest.$(O): win/manifest.xml $(MANIFEST_RC) $(DIRS)
	$(WINDRES) -I. -Iwin -DMANIFEST_FILE='\"$(srcdir)/manifest.xml\"' \
		-i $(MANIFEST_RC) -o $@

# Generated manpages, also pregenerated for distribution
manpages: nasm.1 ndisasm.1

install: $(PROGS)
	$(MKDIR_P) $(DESTDIR)$(bindir)
	$(INSTALL_PROGRAM) $(PROGS) $(DESTDIR)$(bindir)/
	$(MKDIR_P) $(DESTDIR)$(mandir)/man1
	$(INSTALL_DATA) $(srcdir)/nasm.1 $(DESTDIR)$(mandir)/man1/nasm.1
	$(INSTALL_DATA) $(srcdir)/ndisasm.1 $(DESTDIR)$(mandir)/man1/ndisasm.1

install_editors: $(EDITORS)
	$(MKDIR_P) $(DESTDIR)$(pkgdatadir)
	$(INSTALL_DATA) $(EDITORS) $(DESTDIR)$(pkgdatadir)

clean:
	for d in . $(SUBDIRS) $(XSUBDIRS); do \
		$(RM_F) "$$d"/*.$(O) "$$d"/*.s "$$d"/*.i "$$d"/*.$(A) ; \
	done
	$(RM_F) $(PROGS)
	$(RM_F) nasm-*-installer-*.exe
	$(RM_F) tags TAGS
	$(RM_F) nsis/arch.nsh
	$(RM_F) perlbreq.si

distclean: clean
	for d in . $(SUBDIRS) $(XSUBDIRS); do \
		$(RM_F) "$$d"/.\#* "$$d"/\#* "$$d"/*~ "$$d"/*.bak \
			"$$d"/*.lst "$$d"/*.bin "$$d"/*.dep ; \
	done
	$(RM_F) test/*.$(O)
	-$(SHELL) autoconf/clean.sh || $(SHELL) $(srcdir)/autoconf/clean.sh

cleaner:
	$(RM_F) $(PERLREQ_CLEANABLE) $(EDITORS) *.1 nasm.spec
	$(MAKE) -C doc clean
	$(MAKE) -C misc clean
	$(MAKE) distclean
	$(RM_F) */*.time

spotless: cleaner
	$(RM_F) configure autoconf/aclocal.m4 autoconf/clean.sh

strip:
	$(STRIP) --strip-unneeded $(PROGS)

TAGS:
	$(RM_F) TAGS
	$(FIND) . -name '*.[hcS]' -print | xargs etags -a

tags:
	$(RM_F) tags
	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a

cscope:
	$(RM_F) cscope.out cscope.files
	$(FIND) . -name '*.[hcS]' -print > cscope.files
	cscope -b -f cscope.out

doc: doc/warnings.src doc/perlbreq.src doc/pptok.src
	$(MAKE) -C doc all

doc_install install_doc install-doc:
	$(MAKE) -C doc install

.PHONY: misc
misc:
	$(MKDIR_P) misc
	$(MAKE) -C misc all

misc_install install_misc install-misc:
	$(MAKE) -C misc install

# Dummy target to prevent accidental invocation of the default "all" target
nothing:

always_everything: $(DIRS)
	$(MAKE) all doc

everything: always_everything
	$(MAKE) $(MANPAGES) $(NSIS) nothing

install_everything: everything install install_doc install_editors

editor_builtin: nasm$(X)
	$(SHELL) editors/dumpbuiltin.sh ./nasm$(X) > editors/builtin.mac

dist:
	$(MAKE) alldeps
	$(MAKE) perlreq spec
	$(MAKE) editor_builtin
	$(MAKE) editors $(MANPAGES)
	$(MAKE) distclean
	$(SHELL) autogen.sh --clearenv

tar: dist
	tar -cv --exclude CVS --exclude .git -C .. -f - `basename \`pwd\`` | \
		$(XZ) -9e > ../nasm-`cat version`-`date +%Y%m%d`.tar.xz

spec: nasm.spec

ALLPERLSRC := $(shell find $(srcdir) -type f -name '*.p[lh]')

perlbreq.si: $(ALLPERLSRC)
	sed -n -r -e 's/^[[:space:]]*use[[:space:]]+([[:upper:]][^[:space:];]*).*$$/BuildRequires: perl(\1)/p' $(ALLPERLSRC) | \
	sed -r -e '/perl\((Win32.*)\)/d' | \
	sort | uniq > perlbreq.si

doc/perlbreq.src: perlbreq.si $(DIRS)
	sed -n -r -e 's/^BuildRequires: perl\((.*)\)$$/\\c      \1/p' \
		< perlbreq.si > doc/perlbreq.src
	echo '\c      Win32 (if building on Windows only)' >> doc/perlbreq.src

nasm.spec: nasm.spec.in nasm.spec.sed version.sed perlbreq.si
	sed -f version.sed -f nasm.spec.sed \
	< nasm.spec.in > nasm.spec

splint:
	splint -weak *.c

.PHONY: test
test: $(PROGS)
	cd $(srcdir)/test && \
		$(RUNPERL) performtest.pl --nasm=../nasm$(X) *.asm

golden: $(PROGS)
	cd $(srcdir)/test && \
		$(RUNPERL) performtest.pl --golden --nasm=../nasm$(X) *.asm

#
# Travis tests
#
travis_version = travis/test/_version.stdout

$(travis_version): version
	printf 'NASM version %s compiled on ?\n' `cat version` > $@

travis: $(PROGS) $(travis_version)
	-$(PYTHON3) travis/nasm-t.py run --stop=n > travis.log
	@if $(GREP) FAIL travis.log; then exit 1; else \
		echo '=== All tests PASS ==='; fi

#
# Rules to run autogen if necessary
#
configure: configure.ac autoconf/aclocal.m4
	sh autogen.sh --recheck

config.status: configure
	@if [ ! -f config.status ]; then \
		echo "*** ERROR: Need to run configure!" 1>&2 ; \
		exit 1; \
	fi
	sh config.status --recheck

Makefile: config.status Makefile.in doc/Makefile.in
	sh config.status

doc/Makefile: Makefile

config/config.h: config.status


#
# Synchronize auxiliary Makefiles
#
syncfiles: $(tools)/syncfiles.pl
	$(RUNPERL) $(tools)/syncfiles.pl Makefile.in Mkfiles/*.mak

#
# Does this version of this file have external dependencies?  This definition
# will be automatically updated by mkdep.pl as needed.
#
EXTERNAL_DEPENDENCIES = 1

#
# Generate dependency information for this Makefile only.
# If this Makefile has external dependency information, then
# the dependency information will remain external, so it doesn't
# pollute the git logs.
#
Makefile.dep: $(tools)/mkdep.pl config.status $(PERLREQ)
	$(RUNPERL) $(tools)/mkdep.pl -s $(top_srcdir) \
		-M $(srcdir)/Makefile.in -- $(DEPDIRS)

dep: Makefile.dep
#
# This build dependencies in *ALL* makefiles, and forces all
# dependencies to be inserted inline.  For that reason, it should only
# be invoked manually or via "make dist".  It should be run before
# creating release archives.
#
alldeps: syncfiles $(PERLREQ) $(tools)/mkdep.pl
	$(RUNPERL) $(tools)/mkdep.pl -i -M Makefile.in Mkfiles/*.mak -- \
		$(DEPDIRS)
	$(RM_F) *.dep
	if [ -f config.status ]; then \
		sh config.status; \
	fi

# Strip internal dependency information from all Makefiles; this makes
# the output good for git checkin
cleandeps: syncfiles $(PERLREQ) $(tools)/mkdep.pl
	$(RUNPERL) $(tools)/mkdep.pl -e -M Makefile.in Mkfiles/*.mak -- \
		$(DEPDIRS)
	$(RM_F) *.dep
	if [ -f config.status ]; then \
		sh config.status; \
	fi

#
# Dummy rules that changes make behavior
# (at end to avoid confusing non-GNU makes)
#
.SECONDARY:

.DELETE_ON_ERROR:

#-- Magic hints to mkdep.pl --#
# @object-ending: ".$(O)"
# @path-separator: "/"
# @external: "Makefile.dep"
# @include-command: "include"
# @selfrule: "1"
#-- Everything below is generated by mkdep.pl - do not edit --#
include Makefile.dep
