3 # Makefile for building NASM using Microsoft Visual C++ and NMAKE.
4 # Tested on Microsoft Visual C++ 2005 Express Edition.
6 # Make sure to put the appropriate directories in your PATH, in
7 # the case of MSVC++ 2005, they are ...\VC\bin and ...\Common7\IDE.
9 # This is typically done by opening the Visual Studio Command Prompt.
16 prefix = "C:\Program Files\NASM"
17 exec_prefix = $(prefix)
18 bindir = $(prefix)/bin
19 mandir = $(prefix)/man
26 LDFLAGS
= /DEBUG
/OPT
:REF
/OPT
:ICF
# (latter two undoes /DEBUG harm)
31 CFLAGS
= $(CFLAGS
) /W2
32 BUILD_CFLAGS
= $(CFLAGS
)
33 INTERNAL_CFLAGS
= /I
$(srcdir) /I. \
34 /I
$(srcdir)/include /I.
/include \
35 /I
$(srcdir)/x86
/I.
/x86 \
36 /I
$(srcdir)/asm
/I.
/asm \
37 /I
$(srcdir)/disasm
/I.
/disasm \
38 /I
$(srcdir)/output
/I.
/output
39 ALL_CFLAGS
= $(BUILD_CFLAGS
) $(INTERNAL_CFLAGS
)
40 LDFLAGS
= /link
$(LINKFLAGS
) /SUBSYSTEM
:CONSOLE
/RELEASE
44 PERLFLAGS
= -I
$(srcdir)/perllib
-I
$(srcdir)
45 RUNPERL
= $(PERL
) $(PERLFLAGS
)
57 .SUFFIXES
: $(X
) .
$(A
) .
$(O
) .c .i .s
.1 .man
60 $(CC
) /c
$(ALL_CFLAGS
) /Fo
$@
$<
62 #-- Begin File Lists --#
63 # Edit in Makefile.in, not here!
65 NDISASM
= disasm
\ndisasm.
$(O
)
67 LIBOBJ
= stdlib\snprintf.
$(O
) stdlib
\vsnprintf.
$(O
) stdlib\strlcpy.
$(O
) \
68 stdlib\strnlen.
$(O
) stdlib\strrchrnul.
$(O
) \
71 nasmlib
\alloc.
$(O
) nasmlib
\asprintf.
$(O
) nasmlib\errfile.
$(O
) \
72 nasmlib\crc64.
$(O
) nasmlib\md5c.
$(O
) \
73 nasmlib\string.
$(O
) nasmlib
\nctype.
$(O
) \
74 nasmlib
\file.
$(O
) nasmlib\mmap.
$(O
) nasmlib\ilog2.
$(O
) \
75 nasmlib
\realpath.
$(O
) nasmlib\path.
$(O
) \
76 nasmlib
\filename.
$(O
) nasmlib
\rlimit.
$(O
) \
77 nasmlib\zerobuf.
$(O
) nasmlib
\readnum.
$(O
) nasmlib
\bsi.
$(O
) \
78 nasmlib
\rbtree.
$(O
) nasmlib\hashtbl.
$(O
) \
79 nasmlib
\raa.
$(O
) nasmlib\saa.
$(O
) \
80 nasmlib\strlist.
$(O
) \
81 nasmlib\perfhash.
$(O
) nasmlib
\badenum.
$(O
) \
85 x86\insnsa.
$(O
) x86\insnsb.
$(O
) x86\insnsd.
$(O
) x86\insnsn.
$(O
) \
86 x86
\regs.
$(O
) x86
\regvals.
$(O
) x86
\regflags.
$(O
) x86
\regdis.
$(O
) \
87 x86\disp8.
$(O
) x86\iflag.
$(O
) \
89 asm\error.
$(O
) asm\warnings.
$(O
) \
91 asm\directiv.
$(O
) asm\directbl.
$(O
) \
93 asm
\assemble.
$(O
) asm\labels.
$(O
) asm\parser.
$(O
) \
94 asm\preproc.
$(O
) asm\quote.
$(O
) asm\pptok.
$(O
) \
95 asm\listing.
$(O
) asm\eval.
$(O
) asm\exprlib.
$(O
) asm\exprdump.
$(O
) \
97 asm\strfunc.
$(O
) asm
\tokhash.
$(O
) \
99 asm\preproc-nop.
$(O
) \
104 output\outform.
$(O
) output\outlib.
$(O
) output\legacy.
$(O
) \
105 output
\nulldbg.
$(O
) output
\nullout.
$(O
) \
106 output\outbin.
$(O
) output\outaout.
$(O
) output\outcoff.
$(O
) \
108 output\outobj.
$(O
) output\outas86.
$(O
) output\outrdf2.
$(O
) \
109 output\outdbg.
$(O
) output\outieee.
$(O
) output\outmacho.
$(O
) \
110 output\codeview.
$(O
) \
112 disasm\disasm.
$(O
) disasm\sync.
$(O
)
114 SUBDIRS
= stdlib nasmlib output asm disasm x86 common macros
115 XSUBDIRS
= test doc nsis rdoff
116 DEPDIRS
= .
include config x86 rdoff
$(SUBDIRS
)
117 #-- End File Lists --#
119 NASMLIB
= libnasm.
$(A
)
121 all: nasm
$(X
) ndisasm
$(X
) rdf
123 nasm
$(X
): $(NASM
) $(NASMLIB
)
124 $(CC
) /Fe
$@
$(NASM
) $(LDFLAGS
) $(NASMLIB
) $(LIBS
)
126 ndisasm
$(X
): $(NDISASM
) $(NASMLIB
)
127 $(CC
) /Fe
$@
$(NDISASM
) $(LDFLAGS
) $(NASMLIB
) $(LIBS
)
129 $(NASMLIB
): $(LIBOBJ
)
130 $(AR
) $(ARFLAGS
) /OUT
:$@
$**
132 #-- Begin Generated File Rules --#
133 # Edit in Makefile.in, not here!
135 # These source files are automagically generated from data files using
136 # Perl scripts. They're distributed, though, so it isn't necessary to
137 # have Perl just to recompile NASM from the distribution.
139 # Perl-generated source files
140 PERLREQ
= x86\insnsb.c x86\insnsa.c x86\insnsd.c x86\insnsi.h x86\insnsn.c \
141 x86
\regs.c x86
\regs.h x86
\regflags.c x86
\regdis.c x86
\regdis.h \
142 x86
\regvals.c asm
\tokhash.c asm
\tokens.h asm\pptok.h asm\pptok.c \
143 x86\iflag.c x86\iflaggen.h \
145 asm\pptok.ph asm\directbl.c asm\directiv.h \
146 asm\warnings.c
include\warnings.h \
147 version.h version.mac version.mak nsis
\version.nsh
149 INSDEP
= x86\insns.dat x86\insns.pl x86\insns-iflags.ph x86\iflags.ph
151 x86\iflag.c
: $(INSDEP
)
152 $(RUNPERL
) $(srcdir)\x86\insns.pl
-fc \
153 $(srcdir)\x86\insns.dat x86\iflag.c
154 x86\iflaggen.h
: $(INSDEP
)
155 $(RUNPERL
) $(srcdir)\x86\insns.pl
-fh \
156 $(srcdir)\x86\insns.dat x86\iflaggen.h
157 x86\insnsb.c
: $(INSDEP
)
158 $(RUNPERL
) $(srcdir)\x86\insns.pl
-b \
159 $(srcdir)\x86\insns.dat x86\insnsb.c
160 x86\insnsa.c
: $(INSDEP
)
161 $(RUNPERL
) $(srcdir)\x86\insns.pl
-a \
162 $(srcdir)\x86\insns.dat x86\insnsa.c
163 x86\insnsd.c
: $(INSDEP
)
164 $(RUNPERL
) $(srcdir)\x86\insns.pl
-d \
165 $(srcdir)\x86\insns.dat x86\insnsd.c
166 x86\insnsi.h
: $(INSDEP
)
167 $(RUNPERL
) $(srcdir)\x86\insns.pl
-i \
168 $(srcdir)\x86\insns.dat x86\insnsi.h
169 x86\insnsn.c
: $(INSDEP
)
170 $(RUNPERL
) $(srcdir)\x86\insns.pl
-n \
171 $(srcdir)\x86\insns.dat x86\insnsn.c
173 # These files contains all the standard macros that are derived from
174 # the version number.
175 version.h
: version version.pl
176 $(RUNPERL
) $(srcdir)\version.pl h
< $(srcdir)\version
> version.h
177 version.mac
: version version.pl
178 $(RUNPERL
) $(srcdir)\version.pl mac
< $(srcdir)\version
> version.mac
179 version.sed
: version version.pl
180 $(RUNPERL
) $(srcdir)\version.pl sed
< $(srcdir)\version
> version.sed
181 version.mak
: version version.pl
182 $(RUNPERL
) $(srcdir)\version.pl make
< $(srcdir)\version
> version.mak
183 nsis
\version.nsh
: version version.pl
184 $(RUNPERL
) $(srcdir)\version.pl nsis
< $(srcdir)\version
> nsis
\version.nsh
186 # This source file is generated from the standard macros file
187 # `standard.mac' by another Perl script. Again, it's part of the
188 # standard distribution.
189 macros\macros.c
: macros\macros.pl asm\pptok.ph version.mac \
190 $(srcdir)\macros\
*.mac
$(srcdir)\output\
*.mac
191 $(RUNPERL
) $(srcdir)\macros\macros.pl version.mac \
192 $(srcdir)\macros\
*.mac
$(srcdir)\output\
*.mac
194 # These source files are generated from regs.dat by yet another
196 x86
\regs.c
: x86
\regs.dat x86
\regs.pl
197 $(RUNPERL
) $(srcdir)\x86\regs.pl c \
198 $(srcdir)\x86\regs.dat
> x86
\regs.c
199 x86
\regflags.c
: x86
\regs.dat x86
\regs.pl
200 $(RUNPERL
) $(srcdir)\x86\regs.pl
fc \
201 $(srcdir)\x86\regs.dat
> x86
\regflags.c
202 x86
\regdis.c
: x86
\regs.dat x86
\regs.pl
203 $(RUNPERL
) $(srcdir)\x86\regs.pl dc \
204 $(srcdir)\x86\regs.dat
> x86
\regdis.c
205 x86
\regdis.h
: x86
\regs.dat x86
\regs.pl
206 $(RUNPERL
) $(srcdir)\x86\regs.pl dh \
207 $(srcdir)\x86\regs.dat
> x86
\regdis.h
208 x86
\regvals.c
: x86
\regs.dat x86
\regs.pl
209 $(RUNPERL
) $(srcdir)\x86\regs.pl vc \
210 $(srcdir)\x86\regs.dat
> x86
\regvals.c
211 x86
\regs.h
: x86
\regs.dat x86
\regs.pl
212 $(RUNPERL
) $(srcdir)\x86\regs.pl h \
213 $(srcdir)\x86\regs.dat
> x86
\regs.h
215 # Extract warnings from source code. Since this depends on
216 # ALL the source files, this is only done on demand.
217 WARNFILES
= asm\warnings.c
include\warnings.h doc\warnings.src
223 asm\warnings.c
: asm\warnings.pl
224 $(RUNPERL
) $(srcdir)\asm\warnings.pl c asm\warnings.c
$(srcdir)
226 include\warnings.h
: asm\warnings.pl
227 $(RUNPERL
) $(srcdir)\asm\warnings.pl h
include\warnings.h
$(srcdir)
229 doc\warnings.src
: asm\warnings.pl
230 $(RUNPERL
) $(srcdir)\asm\warnings.pl doc doc\warnings.src
$(srcdir)
232 # Assembler token hash
233 asm
\tokhash.c
: x86\insns.dat x86
\regs.dat asm
\tokens.dat asm
\tokhash.pl \
235 $(RUNPERL
) $(srcdir)\asm
\tokhash.pl c \
236 $(srcdir)\x86\insns.dat
$(srcdir)\x86\regs.dat \
237 $(srcdir)\asm
\tokens.dat
> asm
\tokhash.c
239 # Assembler token metadata
240 asm
\tokens.h
: x86\insns.dat x86
\regs.dat asm
\tokens.dat asm
\tokhash.pl \
242 $(RUNPERL
) $(srcdir)\asm
\tokhash.pl h \
243 $(srcdir)\x86\insns.dat
$(srcdir)\x86\regs.dat \
244 $(srcdir)\asm
\tokens.dat
> asm
\tokens.h
246 # Preprocessor token hash
247 asm\pptok.h
: asm\pptok.dat asm\pptok.pl perllib\phash.ph
248 $(RUNPERL
) $(srcdir)\asm\pptok.pl h \
249 $(srcdir)\asm\pptok.dat asm\pptok.h
250 asm\pptok.c
: asm\pptok.dat asm\pptok.pl perllib\phash.ph
251 $(RUNPERL
) $(srcdir)\asm\pptok.pl c \
252 $(srcdir)\asm\pptok.dat asm\pptok.c
253 asm\pptok.ph
: asm\pptok.dat asm\pptok.pl perllib\phash.ph
254 $(RUNPERL
) $(srcdir)\asm\pptok.pl ph \
255 $(srcdir)\asm\pptok.dat asm\pptok.ph
258 asm\directiv.h
: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
259 $(RUNPERL
) $(srcdir)\nasmlib\perfhash.pl h \
260 $(srcdir)\asm\directiv.dat asm\directiv.h
261 asm\directbl.c
: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
262 $(RUNPERL
) $(srcdir)\nasmlib\perfhash.pl c \
263 $(srcdir)\asm\directiv.dat asm\directbl.c
265 #-- End Generated File Rules --#
269 # This rule is only used for RDOFF
271 $(CC
) /Fe
$@
$< $(LDFLAGS
) $(RDFLIB
) $(NASMLIB
) $(LIBS
)
276 #-- Begin RDOFF Shared Rules --#
277 # Edit in Makefile.in, not here!
279 RDFLIBOBJ
= rdoff
\rdoff.
$(O
) rdoff
\rdfload.
$(O
) rdoff\symtab.
$(O
) \
280 rdoff\collectn.
$(O
) rdoff
\rdlib.
$(O
) rdoff\segtab.
$(O
) \
283 RDFPROGS
= rdoff
\rdfdump
$(X
) rdoff\ldrdf
$(X
) rdoff
\rdx
$(X
) rdoff
\rdflib
$(X
) \
285 RDF2BINLINKS
= rdoff
\rdf
2com
$(X
) rdoff
\rdf
2ith
$(X
) \
286 rdoff
\rdf
2ihx
$(X
) rdoff
\rdf
2srec
$(X
)
288 RDFLIB
= rdoff\librdoff.
$(A
)
289 RDFLIBS
= $(RDFLIB
) $(NASMLIB
)
291 rdoff
\rdfdump
$(X
): rdoff
\rdfdump.
$(O
) $(RDFLIBS
)
292 rdoff\ldrdf
$(X
): rdoff\ldrdf.
$(O
) $(RDFLIBS
)
293 rdoff
\rdx
$(X
): rdoff
\rdx.
$(O
) $(RDFLIBS
)
294 rdoff
\rdflib
$(X
): rdoff
\rdflib.
$(O
) $(RDFLIBS
)
295 rdoff
\rdf
2bin
$(X
): rdoff
\rdf
2bin.
$(O
) $(RDFLIBS
)
296 rdoff
\rdf
2com
$(X
): rdoff
\rdf
2bin
$(X
)
297 $(RM_F
) rdoff
\rdf
2com
$(X
)
298 $(RDFLN
) $(RDFLNPFX
)rdf2bin
$(X
) $(RDFLNPFX
)rdf2com
$(X
)
299 rdoff
\rdf
2ith
$(X
): rdoff
\rdf
2bin
$(X
)
300 $(RM_F
) rdoff
\rdf
2ith
$(X
)
301 $(RDFLN
) $(RDFLNPFX
)rdf2bin
$(X
) $(RDFLNPFX
)rdf2ith
$(X
)
302 rdoff
\rdf
2ihx
$(X
): rdoff
\rdf
2bin
$(X
)
303 $(RM_F
) rdoff
\rdf
2ihx
$(X
)
304 $(RDFLN
) $(RDFLNPFX
)rdf2bin
$(X
) $(RDFLNPFX
)rdf2ihx
$(X
)
305 rdoff
\rdf
2srec
$(X
): rdoff
\rdf
2bin
$(X
)
306 $(RM_F
) rdoff
\rdf
2srec
$(X
)
307 $(RDFLN
) $(RDFLNPFX
)rdf2bin
$(X
) $(RDFLNPFX
)rdf2srec
$(X
)
309 #-- End RDOFF Shared Rules --#
311 rdf
: $(RDFPROGS
) $(RDF2BINLINKS
)
313 $(RDFLIB
): $(RDFLIBOBJ
)
314 $(AR
) $(ARFLAGS
) /OUT
:$@
$**
316 #-- Begin NSIS Rules --#
317 # Edit in Makefile.in, not here!
319 nsis
\arch.nsh
: nsis\getpearch.pl nasm
$(X
)
320 $(PERL
) $(srcdir)\nsis\getpearch.pl nasm
$(X
) > nsis
\arch.nsh
322 # Should only be done after "make everything".
323 # The use of redirection here keeps makensis from moving the cwd to the
325 nsis
: nsis
\nasm.nsi nsis
\arch.nsh nsis
\version.nsh
326 $(MAKENSIS
) -Dsrcdir
="$(srcdir)" -Dobjdir
="$(objdir)" - < nsis
\nasm.nsi
328 #-- End NSIS Rules --#
335 -del
/f
$(NASMLIB
) $(RDFLIB
)
343 -del
/f config.status
356 -del
/f
/s autom4te
*.cache
357 rem cd rdoff
&& $(MAKE
) distclean
363 rem cd doc
&& $(MAKE
) clean
365 spotless
: distclean cleaner
372 # Abuse doc/Makefile.in to build nasmdoc.pdf only
374 cd doc
&& $(MAKE
) /f Makefile.in
srcdir=. top_srcdir
=.. \
375 PERL
=$(PERL
) PDFOPT
= nasmdoc.pdf
377 everything
: all docs nsis
380 # Does this version of this file have external dependencies? This definition
381 # will be automatically updated by mkdep.pl as needed.
383 EXTERNAL_DEPENDENCIES
= 1
386 # Generate dependency information for this Makefile only.
387 # If this Makefile has external dependency information, then
388 # the dependency information will remain external, so it doesn't
389 # pollute the git logs.
391 msvc.dep
: $(PERLREQ
) tools\mkdep.pl
392 $(RUNPERL
) tools\mkdep.pl
-M Mkfiles\msvc.mak
-- $(DEPDIRS
)
396 # Include and/or generate msvc.dep as needed. This is too complex to
397 # use the include-command feature, but we can open-code it here.
399 !IF
$(EXTERNAL_DEPENDENCIES
) == 1 && $(MKDEP
) == 0
402 !ELSEIF
[$(MAKE
) /c MKDEP
=1 /f Mkfiles\msvc.mak msvc.dep
] == 0
405 !ERROR Unable to rebuild dependencies file msvc.dep
409 #-- Magic hints to mkdep.pl --#
410 # @object-ending: ".$(O)"
411 # @path-separator: "\"
412 # @exclude: "config\config.h"
413 # @external: "msvc.dep"
415 #-- Everything below is generated by mkdep.pl - do not edit --#