2 # Auto-configuring Makefile for the Netwide Assembler.
4 # The Netwide Assembler is copyright (C) 1996 Simon Tatham and
5 # Julian Hall. All rights reserved. The software is
6 # redistributable under the license given in the file "LICENSE"
7 # distributed in the NASM archive.
11 top_srcdir
= @top_srcdir@
16 exec_prefix = @
exec_prefix@
19 datarootdir
= @datarootdir@
24 BUILD_CFLAGS
= $(CPPFLAGS
) $(CFLAGS
) @DEFS@
25 INTERNAL_CFLAGS
= -I
$(srcdir) -I
$(objdir
) \
26 -I
$(srcdir)/include -I
$(objdir
)/include \
27 -I
$(srcdir)/x86
-I
$(objdir
)/x86 \
28 -I
$(srcdir)/asm
-I
$(objdir
)/asm \
29 -I
$(srcdir)/disasm
-I
$(objdir
)/disasm \
30 -I
$(srcdir)/output
-I
$(objdir
)/output
31 ALL_CFLAGS
= $(BUILD_CFLAGS
) $(INTERNAL_CFLAGS
)
40 PERLFLAGS
= -I
$(srcdir)/perllib
-I
$(srcdir)
41 RUNPERL
= $(PERL
) $(PERLFLAGS
)
44 INSTALL_PROGRAM
= @INSTALL_PROGRAM@
45 INSTALL_DATA
= @INSTALL_DATA@
66 CFLAGS
+= -DNASM_TRACE
70 .SUFFIXES
: .c .i .s .
$(O
) .
$(A
) $(X
) .1 .txt .xml
72 .PHONY
: all doc rdf
install clean distclean cleaner spotless install_rdf
test
73 .PHONY
: install_doc everything install_everything
strip perlreq
dist tags TAGS
77 $(CC
) -c
$(ALL_CFLAGS
) $(ALL_CFLAGS
) -o
$@
$<
80 $(CC
) -S
$(ALL_CFLAGS
) $(ALL_CFLAGS
) -o
$@
$<
83 $(CC
) -E
$(ALL_CFLAGS
) $(ALL_CFLAGS
) -o
$@
$<
86 $(ASCIIDOC
) -b docbook
-d manpage
-o
$@
$<
89 $(XMLTO
) man
--skip-validation
$< 2>/dev
/null
91 #-- Begin File Lists --#
93 NDISASM
= disasm
/ndisasm.
$(O
)
95 LIBOBJ
= stdlib
/snprintf.
$(O
) stdlib
/vsnprintf.
$(O
) stdlib
/strlcpy.
$(O
) \
96 stdlib
/strnlen.
$(O
) stdlib
/strrchrnul.
$(O
) \
99 nasmlib
/crc64.
$(O
) nasmlib
/malloc.
$(O
) \
100 nasmlib
/md5c.
$(O
) nasmlib
/string.
$(O
) \
101 nasmlib
/file.
$(O
) nasmlib
/mmap.
$(O
) nasmlib
/ilog2.
$(O
) \
102 nasmlib
/realpath.
$(O
) nasmlib
/path.
$(O
) \
103 nasmlib
/filename.
$(O
) nasmlib
/srcfile.
$(O
) \
104 nasmlib
/zerobuf.
$(O
) nasmlib
/readnum.
$(O
) nasmlib
/bsi.
$(O
) \
105 nasmlib
/rbtree.
$(O
) nasmlib
/hashtbl.
$(O
) \
106 nasmlib
/raa.
$(O
) nasmlib
/saa.
$(O
) \
107 nasmlib
/strlist.
$(O
) \
108 nasmlib
/perfhash.
$(O
) nasmlib
/badenum.
$(O
) \
112 x86
/insnsa.
$(O
) x86
/insnsb.
$(O
) x86
/insnsd.
$(O
) x86
/insnsn.
$(O
) \
113 x86
/regs.
$(O
) x86
/regvals.
$(O
) x86
/regflags.
$(O
) x86
/regdis.
$(O
) \
114 x86
/disp8.
$(O
) x86
/iflag.
$(O
) \
118 asm
/directiv.
$(O
) asm
/directbl.
$(O
) \
120 asm
/assemble.
$(O
) asm
/labels.
$(O
) asm
/parser.
$(O
) \
121 asm
/preproc.
$(O
) asm
/quote.
$(O
) asm
/pptok.
$(O
) \
122 asm
/listing.
$(O
) asm
/eval.
$(O
) asm
/exprlib.
$(O
) asm
/exprdump.
$(O
) \
124 asm
/strfunc.
$(O
) asm
/tokhash.
$(O
) \
126 asm
/preproc-nop.
$(O
) \
131 output
/outform.
$(O
) output
/outlib.
$(O
) output
/legacy.
$(O
) \
133 output
/nulldbg.
$(O
) output
/nullout.
$(O
) \
134 output
/outbin.
$(O
) output
/outaout.
$(O
) output
/outcoff.
$(O
) \
136 output
/outobj.
$(O
) output
/outas86.
$(O
) output
/outrdf2.
$(O
) \
137 output
/outdbg.
$(O
) output
/outieee.
$(O
) output
/outmacho.
$(O
) \
138 output
/codeview.
$(O
) \
140 disasm
/disasm.
$(O
) disasm
/sync.
$(O
)
142 SUBDIRS
= stdlib nasmlib output asm disasm x86 common macros
143 XSUBDIRS
= test doc nsis rdoff
144 DEPDIRS
= .
include config x86 rdoff
$(SUBDIRS
)
145 #-- End File Lists --#
147 all: nasm
$(X
) ndisasm
$(X
) rdf
149 NASMLIB
= libnasm.
$(A
)
151 $(NASMLIB
): $(LIBOBJ
)
153 $(AR
) cq
$(NASMLIB
) $(LIBOBJ
)
156 nasm
$(X
): $(NASM
) $(NASMLIB
)
157 $(CC
) $(ALL_CFLAGS
) $(LDFLAGS
) -o nasm
$(X
) $(NASM
) $(NASMLIB
) $(LIBS
)
159 ndisasm
$(X
): $(NDISASM
) $(NASMLIB
)
160 $(CC
) $(ALL_CFLAGS
) $(LDFLAGS
) -o ndisasm
$(X
) $(NDISASM
) $(NASMLIB
) $(LIBS
)
162 #-- Begin Generated File Rules --#
164 # These source files are automagically generated from data files using
165 # Perl scripts. They're distributed, though, so it isn't necessary to
166 # have Perl just to recompile NASM from the distribution.
168 # Perl-generated source files
169 PERLREQ
= x86
/insnsb.c x86
/insnsa.c x86
/insnsd.c x86
/insnsi.h x86
/insnsn.c \
170 x86
/regs.c x86
/regs.h x86
/regflags.c x86
/regdis.c x86
/regdis.h \
171 x86
/regvals.c asm
/tokhash.c asm
/tokens.h asm
/pptok.h asm
/pptok.c \
172 x86
/iflag.c x86
/iflaggen.h \
174 asm
/pptok.ph asm
/directbl.c asm
/directiv.h \
175 version.h version.mac version.mak nsis
/version.nsh
177 INSDEP
= x86
/insns.dat x86
/insns.pl x86
/insns-iflags.ph
179 x86
/iflag.c
: $(INSDEP
)
180 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-fc \
181 $(srcdir)/x86
/insns.dat x86
/iflag.c
182 x86
/iflaggen.h
: $(INSDEP
)
183 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-fh \
184 $(srcdir)/x86
/insns.dat x86
/iflaggen.h
185 x86
/insnsb.c
: $(INSDEP
)
186 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-b \
187 $(srcdir)/x86
/insns.dat x86
/insnsb.c
188 x86
/insnsa.c
: $(INSDEP
)
189 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-a \
190 $(srcdir)/x86
/insns.dat x86
/insnsa.c
191 x86
/insnsd.c
: $(INSDEP
)
192 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-d \
193 $(srcdir)/x86
/insns.dat x86
/insnsd.c
194 x86
/insnsi.h
: $(INSDEP
)
195 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-i \
196 $(srcdir)/x86
/insns.dat x86
/insnsi.h
197 x86
/insnsn.c
: $(INSDEP
)
198 $(RUNPERL
) $(srcdir)/x86
/insns.pl
-n \
199 $(srcdir)/x86
/insns.dat x86
/insnsn.c
201 # These files contains all the standard macros that are derived from
202 # the version number.
203 version.h
: version version.pl
204 $(RUNPERL
) $(srcdir)/version.pl h
< $(srcdir)/version
> version.h
205 version.mac
: version version.pl
206 $(RUNPERL
) $(srcdir)/version.pl mac
< $(srcdir)/version
> version.mac
207 version.sed
: version version.pl
208 $(RUNPERL
) $(srcdir)/version.pl sed
< $(srcdir)/version
> version.sed
209 version.mak
: version version.pl
210 $(RUNPERL
) $(srcdir)/version.pl make
< $(srcdir)/version
> version.mak
211 nsis
/version.nsh
: version version.pl
212 $(RUNPERL
) $(srcdir)/version.pl nsis
< $(srcdir)/version
> nsis
/version.nsh
214 # This source file is generated from the standard macros file
215 # `standard.mac' by another Perl script. Again, it's part of the
216 # standard distribution.
217 macros
/macros.c
: macros
/macros.pl asm
/pptok.ph version.mac \
218 $(srcdir)/macros
/*.mac
$(srcdir)/output
/*.mac
219 $(RUNPERL
) $(srcdir)/macros
/macros.pl version.mac \
220 $(srcdir)/macros
/*.mac
$(srcdir)/output
/*.mac
222 # These source files are generated from regs.dat by yet another
224 x86
/regs.c
: x86
/regs.dat x86
/regs.pl
225 $(RUNPERL
) $(srcdir)/x86
/regs.pl c \
226 $(srcdir)/x86
/regs.dat
> x86
/regs.c
227 x86
/regflags.c
: x86
/regs.dat x86
/regs.pl
228 $(RUNPERL
) $(srcdir)/x86
/regs.pl
fc \
229 $(srcdir)/x86
/regs.dat
> x86
/regflags.c
230 x86
/regdis.c
: x86
/regs.dat x86
/regs.pl
231 $(RUNPERL
) $(srcdir)/x86
/regs.pl dc \
232 $(srcdir)/x86
/regs.dat
> x86
/regdis.c
233 x86
/regdis.h
: x86
/regs.dat x86
/regs.pl
234 $(RUNPERL
) $(srcdir)/x86
/regs.pl dh \
235 $(srcdir)/x86
/regs.dat
> x86
/regdis.h
236 x86
/regvals.c
: x86
/regs.dat x86
/regs.pl
237 $(RUNPERL
) $(srcdir)/x86
/regs.pl vc \
238 $(srcdir)/x86
/regs.dat
> x86
/regvals.c
239 x86
/regs.h
: x86
/regs.dat x86
/regs.pl
240 $(RUNPERL
) $(srcdir)/x86
/regs.pl h \
241 $(srcdir)/x86
/regs.dat
> x86
/regs.h
243 # Assembler token hash
244 asm
/tokhash.c
: x86
/insns.dat x86
/regs.dat asm
/tokens.dat asm
/tokhash.pl \
246 $(RUNPERL
) $(srcdir)/asm
/tokhash.pl c \
247 $(srcdir)/x86
/insns.dat
$(srcdir)/x86
/regs.dat \
248 $(srcdir)/asm
/tokens.dat
> asm
/tokhash.c
250 # Assembler token metadata
251 asm
/tokens.h
: x86
/insns.dat x86
/regs.dat asm
/tokens.dat asm
/tokhash.pl \
253 $(RUNPERL
) $(srcdir)/asm
/tokhash.pl h \
254 $(srcdir)/x86
/insns.dat
$(srcdir)/x86
/regs.dat \
255 $(srcdir)/asm
/tokens.dat
> asm
/tokens.h
257 # Preprocessor token hash
258 asm
/pptok.h
: asm
/pptok.dat asm
/pptok.pl perllib
/phash.ph
259 $(RUNPERL
) $(srcdir)/asm
/pptok.pl h \
260 $(srcdir)/asm
/pptok.dat asm
/pptok.h
261 asm
/pptok.c
: asm
/pptok.dat asm
/pptok.pl perllib
/phash.ph
262 $(RUNPERL
) $(srcdir)/asm
/pptok.pl c \
263 $(srcdir)/asm
/pptok.dat asm
/pptok.c
264 asm
/pptok.ph
: asm
/pptok.dat asm
/pptok.pl perllib
/phash.ph
265 $(RUNPERL
) $(srcdir)/asm
/pptok.pl ph \
266 $(srcdir)/asm
/pptok.dat asm
/pptok.ph
269 asm
/directiv.h
: asm
/directiv.dat nasmlib
/perfhash.pl perllib
/phash.ph
270 $(RUNPERL
) $(srcdir)/nasmlib
/perfhash.pl h \
271 $(srcdir)/asm
/directiv.dat asm
/directiv.h
272 asm
/directbl.c
: asm
/directiv.dat nasmlib
/perfhash.pl perllib
/phash.ph
273 $(RUNPERL
) $(srcdir)/nasmlib
/perfhash.pl c \
274 $(srcdir)/asm
/directiv.dat asm
/directbl.c
276 #-- End Generated File Rules --#
280 #-- Begin RDOFF Shared Rules --#
282 RDFLIBOBJ
= rdoff
/rdoff.
$(O
) rdoff
/rdfload.
$(O
) rdoff
/symtab.
$(O
) \
283 rdoff
/collectn.
$(O
) rdoff
/rdlib.
$(O
) rdoff
/segtab.
$(O
) \
286 RDFPROGS
= rdoff
/rdfdump
$(X
) rdoff
/ldrdf
$(X
) rdoff
/rdx
$(X
) rdoff
/rdflib
$(X
) \
288 RDF2BINLINKS
= rdoff
/rdf2com
$(X
) rdoff
/rdf2ith
$(X
) \
289 rdoff
/rdf2ihx
$(X
) rdoff
/rdf2srec
$(X
)
291 RDFLIB
= rdoff
/librdoff.
$(A
)
292 RDFLIBS
= $(RDFLIB
) $(NASMLIB
)
294 # This rule is only used for rdoff, to allow common rules
295 MAKERDF
= $(CC
) $(ALL_CFLAGS
) $(LDFLAGS
) -o
$@
$< $(RDFLIB
) $(NASMLIB
) $(LIBS
)
297 rdoff
/rdfdump
$(X
): rdoff
/rdfdump.
$(O
) $(RDFLIBS
)
299 rdoff
/ldrdf
$(X
): rdoff
/ldrdf.
$(O
) $(RDFLIBS
)
301 rdoff
/rdx
$(X
): rdoff
/rdx.
$(O
) $(RDFLIBS
)
303 rdoff
/rdflib
$(X
): rdoff
/rdflib.
$(O
) $(RDFLIBS
)
305 rdoff
/rdf2bin
$(X
): rdoff
/rdf2bin.
$(O
) $(RDFLIBS
)
307 rdoff
/rdf2com
$(X
): rdoff
/rdf2bin
$(X
)
308 $(RM_F
) rdoff
/rdf2com
$(X
)
309 cd rdoff
&& $(LN_S
) rdf2bin
$(X
) rdf2com
$(X
)
310 rdoff
/rdf2ith
$(X
): rdoff
/rdf2bin
$(X
)
311 $(RM_F
) rdoff
/rdf2ith
$(X
)
312 cd rdoff
&& $(LN_S
) rdf2bin
$(X
) rdf2ith
$(X
)
313 rdoff
/rdf2ihx
$(X
): rdoff
/rdf2bin
$(X
)
314 $(RM_F
) rdoff
/rdf2ihx
$(X
)
315 cd rdoff
&& $(LN_S
) rdf2bin
$(X
) rdf2ihx
$(X
)
316 rdoff
/rdf2srec
$(X
): rdoff
/rdf2bin
$(X
)
317 $(RM_F
) rdoff
/rdf2srec
$(X
)
318 cd rdoff
&& $(LN_S
) rdf2bin
$(X
) rdf2srec
$(X
)
320 #-- End RDOFF Shared Rules --#
322 rdf
: $(RDFPROGS
) $(RDF2BINLINKS
)
324 $(RDFLIB
): $(RDFLIBOBJ
)
326 $(AR
) cq
$(RDFLIB
) $(RDFLIBOBJ
)
329 #-- Begin NSIS Rules --#
331 # NSIS is not built except by explicit request, as it only applies to
333 nsis
/arch.nsh
: nsis
/getpearch.pl nasm
$(X
)
334 $(PERL
) $(srcdir)/nsis
/getpearch.pl nasm
$(X
) > nsis
/arch.nsh
336 # Should only be done after "make everything".
337 # The use of redirection here keeps makensis from moving the cwd to the
339 nsis
: nsis
/nasm.nsi nsis
/arch.nsh nsis
/version.nsh
340 $(MAKENSIS
) -Dsrcdir
="$(srcdir)" -Dobjdir
="$(objdir)" - < nsis
/nasm.nsi
342 #-- End NSIS Rules --#
344 # Generated manpages, also pregenerated for distribution
345 manpages
: nasm
.1 ndisasm
.1
347 install: nasm
$(X
) ndisasm
$(X
)
348 $(MKDIR
) -p
$(DESTDIR
)$(bindir)
349 $(INSTALL_PROGRAM
) nasm
$(X
) $(DESTDIR
)$(bindir)/nasm
$(X
)
350 $(INSTALL_PROGRAM
) ndisasm
$(X
) $(DESTDIR
)$(bindir)/ndisasm
$(X
)
351 $(MKDIR
) -p
$(DESTDIR
)$(mandir)/man1
352 $(INSTALL_DATA
) $(srcdir)/nasm
.1 $(DESTDIR
)$(mandir)/man1
/nasm
.1
353 $(INSTALL_DATA
) $(srcdir)/ndisasm
.1 $(DESTDIR
)$(mandir)/man1
/ndisasm
.1
356 for d in .
$(SUBDIRS
) $(XSUBDIRS
); do \
357 $(RM_F
) "$$d"/*.
$(O
) "$$d"/*.s
"$$d"/*.i
"$$d"/*.
$(A
) ; \
359 $(RM_F
) nasm
$(X
) ndisasm
$(X
)
360 $(RM_F
) nasm-
*-installer-
*.exe
362 $(RM_F
) nsis
/arch.nsh
364 $(RM_F
) $(RDFPROGS
) $(RDF2BINLINKS
)
367 $(RM_F
) config.log config.status config
/config.h
368 for d in .
$(SUBDIRS
) $(XSUBDIRS
); do \
369 $(RM_F
) "$$d"/*~
"$$d"/*.bak
"$$d"/*.lst
"$$d"/*.bin
; \
372 $(RM_RF
) autom4te
*.cache
373 $(RM_F
) Makefile
*.dep
376 $(RM_F
) $(PERLREQ
) *.1 nasm.spec
380 spotless
: distclean cleaner
384 $(STRIP
) --strip-unneeded nasm
$(X
) ndisasm
$(X
)
388 $(FIND
) .
-name
'*.[hcS]' -print | xargs etags
-a
392 $(FIND
) .
-name
'*.[hcS]' -print | xargs ctags
-a
395 $(RM_F
) cscope.out cscope.files
396 $(FIND
) .
-name
'*.[hcS]' -print > cscope.files
397 cscope
-b
-f cscope.out
399 rdf_install install_rdf install_rdoff
:
400 $(MKDIR
) -p
$(DESTDIR
)$(bindir)
401 for f in
$(RDFPROGS
); do \
402 $(INSTALL_PROGRAM
) "$$f" '$(DESTDIR)$(bindir)'/ ; \
404 cd
'$(DESTDIR)$(bindir)' && \
405 for f in
$(RDF2BINLINKS
); do \
406 bn
=`basename "$$f"` && $(RM_F
) "$$bn" && \
407 $(LN_S
) rdf2bin
$(X
) "$$bn" ; \
409 $(MKDIR
) -p
$(DESTDIR
)$(mandir)/man1
410 $(INSTALL_DATA
) $(srcdir)/rdoff
/*.1 $(DESTDIR
)$(mandir)/man1
/
415 doc_install install_doc
:
416 $(MAKE
) -C doc
install
418 everything
: all manpages doc rdf
420 install_everything
: everything
install install_doc install_rdf
424 $(MAKE
) spotless perlreq manpages spec
427 $(RM_RF
) .
/autom4te
*.cache
430 tar -cvj
--exclude CVS
-C ..
-f ..
/nasm-
`cat version`-`date +%Y%m%d`.
tar.bz2
`basename \`pwd\
``
434 ALLPERLSRC
:= $(shell find
$(srcdir) -type f
-name
'*.p[lh]')
436 perlbreq.si
: $(ALLPERLSRC
)
437 sed
-n
-r
-e
's/^[[:space:]]*use[[:space:]]+([^[:space:];]+).*$$/BuildRequires: perl(\1)/p' $(ALLPERLSRC
) | \
438 sed
-r
-e
'/perl\((strict|warnings|Win32.*)\)/d' | \
439 sort | uniq
> perlbreq.si ||
( rm -f perlbreq.si
; false
)
441 nasm.spec
: nasm.spec.in nasm.spec.sed version.sed perlbreq.si
442 sed
-f version.sed
-f nasm.spec.sed \
443 < nasm.spec.in
> nasm.spec ||
( rm -f nasm.spec
; false
)
449 cd
test && $(RUNPERL
) performtest.pl
--nasm
=..
/nasm
*.asm
452 cd
test && $(RUNPERL
) performtest.pl
--golden
--nasm
=..
/nasm
*.asm
455 # Rules to run autoreconf if necessary
457 configure
: configure.ac aclocal.m4
460 config.status
: configure
461 @if
[ ! -f config.status
]; then \
462 echo
"*** ERROR: Need to run configure!" 1>&2 ; \
465 sh config.status
--recheck
467 Makefile
: config.status Makefile.in doc
/Makefile.in
470 doc
/Makefile
: Makefile
472 config
/config.h
: config.status
475 # Does this version of this file have external dependencies? This definition
476 # will be automatically updated by mkdep.pl as needed.
478 EXTERNAL_DEPENDENCIES
= 1
481 # Generate dependency information for this Makefile only.
482 # If this Makefile has external dependency information, then
483 # the dependency information will remain external, so it doesn't
484 # pollute the git logs.
486 Makefile.dep
: $(PERLREQ
) tools
/mkdep.pl config.status
487 $(RUNPERL
) tools
/mkdep.pl
-M Makefile.in
-- $(DEPDIRS
)
492 # This build dependencies in *ALL* makefiles, and forces all
493 # dependencies to be inserted inline. For that reason, it should only
494 # be invoked manually or via "make dist". It should be run before
495 # creating release archives.
497 alldeps
: $(PERLREQ
) tools
/syncfiles.pl tools
/mkdep.pl
498 $(RUNPERL
) tools
/syncfiles.pl Makefile.in Mkfiles
/*.mak
499 $(RUNPERL
) tools
/mkdep.pl
-i
-M Makefile.in Mkfiles
/*.mak
-- \
502 if
[ -f config.status
]; then \
503 if
[ $(EXTERNAL_DEPENDENCIES
) -eq
1 ]; then \
504 sh config.status
--recheck
; \
509 # Strip internal dependency information from all Makefiles; this makes
510 # the output good for git checkin
511 cleandeps
: $(PERLREQ
) tools
/syncfiles.pl tools
/mkdep.pl
512 $(RUNPERL
) tools
/syncfiles.pl Makefile.in Mkfiles
/*.mak
513 $(RUNPERL
) tools
/mkdep.pl
-e
-M Makefile.in Mkfiles
/*.mak
-- \
516 if
[ -f config.status
]; then \
517 if
[ $(EXTERNAL_DEPENDENCIES
) -eq
0 ]; then \
518 sh config.status
--recheck
; \
523 #-- Magic hints to mkdep.pl --#
524 # @object-ending: ".$(O)"
525 # @path-separator: "/"
526 # @external: "Makefile.dep"
527 # @include-command: "-include"
529 #-- Everything below is generated by mkdep.pl - do not edit --#
530 -include Makefile.dep