test: nasm-t -- Update multisection
[nasm.git] / Mkfiles / msvc.mak
blob9c7d60e0f751c2816654229dc9eea8d214e824f9
1 # -*- makefile -*-
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.
12 top_srcdir = .
13 srcdir = .
14 objdir = .
15 VPATH = .
16 prefix = "C:\Program Files\NASM"
17 exec_prefix = $(prefix)
18 bindir = $(prefix)/bin
19 mandir = $(prefix)/man
21 !IF "$(DEBUG)" == "1"
22 CFLAGS = /Od /Zi
23 LDFLAGS = /DEBUG
24 !ELSE
25 CFLAGS = /O2 /Zi
26 LDFLAGS = /DEBUG /OPT:REF /OPT:ICF # (latter two undoes /DEBUG harm)
27 !ENDIF
29 CC = cl
30 AR = lib
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
41 LIBS =
43 PERL = perl
44 PERLFLAGS = -I$(srcdir)/perllib -I$(srcdir)
45 RUNPERL = $(PERL) $(PERLFLAGS)
47 MAKENSIS = makensis
49 RM_F = -del /f
50 LN_S = copy
52 # Binary suffixes
53 O = obj
54 A = lib
55 X = .exe
56 .SUFFIXES:
57 .SUFFIXES: $(X) .$(A) .$(O) .c .i .s .1 .man
59 .c.obj:
60 $(CC) /c $(ALL_CFLAGS) /Fo$@ $<
62 #-- Begin File Lists --#
63 # Edit in Makefile.in, not here!
64 NASM = asm\nasm.$(O)
65 NDISASM = disasm\ndisasm.$(O)
67 LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \
68 stdlib\strnlen.$(O) stdlib\strrchrnul.$(O) \
70 nasmlib\ver.$(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) \
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) \
83 common\common.$(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) \
90 asm\float.$(O) \
91 asm\directiv.$(O) asm\directbl.$(O) \
92 asm\pragma.$(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) \
96 asm\stdscan.$(O) \
97 asm\strfunc.$(O) asm\tokhash.$(O) \
98 asm\segalloc.$(O) \
99 asm\preproc-nop.$(O) \
100 asm\rdstrnum.$(O) \
101 asm\srcfile.$(O) \
102 macros\macros.$(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) \
107 output\outelf.$(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 \
144 macros\macros.c \
145 asm\pptok.ph asm\directbl.c asm\directiv.h \
146 version.h version.mac version.mak nsis\version.nsh
148 INSDEP = x86\insns.dat x86\insns.pl x86\insns-iflags.ph
150 x86\iflag.c: $(INSDEP)
151 $(RUNPERL) $(srcdir)\x86\insns.pl -fc \
152 $(srcdir)\x86\insns.dat x86\iflag.c
153 x86\iflaggen.h: $(INSDEP)
154 $(RUNPERL) $(srcdir)\x86\insns.pl -fh \
155 $(srcdir)\x86\insns.dat x86\iflaggen.h
156 x86\insnsb.c: $(INSDEP)
157 $(RUNPERL) $(srcdir)\x86\insns.pl -b \
158 $(srcdir)\x86\insns.dat x86\insnsb.c
159 x86\insnsa.c: $(INSDEP)
160 $(RUNPERL) $(srcdir)\x86\insns.pl -a \
161 $(srcdir)\x86\insns.dat x86\insnsa.c
162 x86\insnsd.c: $(INSDEP)
163 $(RUNPERL) $(srcdir)\x86\insns.pl -d \
164 $(srcdir)\x86\insns.dat x86\insnsd.c
165 x86\insnsi.h: $(INSDEP)
166 $(RUNPERL) $(srcdir)\x86\insns.pl -i \
167 $(srcdir)\x86\insns.dat x86\insnsi.h
168 x86\insnsn.c: $(INSDEP)
169 $(RUNPERL) $(srcdir)\x86\insns.pl -n \
170 $(srcdir)\x86\insns.dat x86\insnsn.c
172 # These files contains all the standard macros that are derived from
173 # the version number.
174 version.h: version version.pl
175 $(RUNPERL) $(srcdir)\version.pl h < $(srcdir)\version > version.h
176 version.mac: version version.pl
177 $(RUNPERL) $(srcdir)\version.pl mac < $(srcdir)\version > version.mac
178 version.sed: version version.pl
179 $(RUNPERL) $(srcdir)\version.pl sed < $(srcdir)\version > version.sed
180 version.mak: version version.pl
181 $(RUNPERL) $(srcdir)\version.pl make < $(srcdir)\version > version.mak
182 nsis\version.nsh: version version.pl
183 $(RUNPERL) $(srcdir)\version.pl nsis < $(srcdir)\version > nsis\version.nsh
185 # This source file is generated from the standard macros file
186 # `standard.mac' by another Perl script. Again, it's part of the
187 # standard distribution.
188 macros\macros.c: macros\macros.pl asm\pptok.ph version.mac \
189 $(srcdir)\macros\*.mac $(srcdir)\output\*.mac
190 $(RUNPERL) $(srcdir)\macros\macros.pl version.mac \
191 $(srcdir)\macros\*.mac $(srcdir)\output\*.mac
193 # These source files are generated from regs.dat by yet another
194 # perl script.
195 x86\regs.c: x86\regs.dat x86\regs.pl
196 $(RUNPERL) $(srcdir)\x86\regs.pl c \
197 $(srcdir)\x86\regs.dat > x86\regs.c
198 x86\regflags.c: x86\regs.dat x86\regs.pl
199 $(RUNPERL) $(srcdir)\x86\regs.pl fc \
200 $(srcdir)\x86\regs.dat > x86\regflags.c
201 x86\regdis.c: x86\regs.dat x86\regs.pl
202 $(RUNPERL) $(srcdir)\x86\regs.pl dc \
203 $(srcdir)\x86\regs.dat > x86\regdis.c
204 x86\regdis.h: x86\regs.dat x86\regs.pl
205 $(RUNPERL) $(srcdir)\x86\regs.pl dh \
206 $(srcdir)\x86\regs.dat > x86\regdis.h
207 x86\regvals.c: x86\regs.dat x86\regs.pl
208 $(RUNPERL) $(srcdir)\x86\regs.pl vc \
209 $(srcdir)\x86\regs.dat > x86\regvals.c
210 x86\regs.h: x86\regs.dat x86\regs.pl
211 $(RUNPERL) $(srcdir)\x86\regs.pl h \
212 $(srcdir)\x86\regs.dat > x86\regs.h
214 # Assembler token hash
215 asm\tokhash.c: x86\insns.dat x86\regs.dat asm\tokens.dat asm\tokhash.pl \
216 perllib\phash.ph
217 $(RUNPERL) $(srcdir)\asm\tokhash.pl c \
218 $(srcdir)\x86\insns.dat $(srcdir)\x86\regs.dat \
219 $(srcdir)\asm\tokens.dat > asm\tokhash.c
221 # Assembler token metadata
222 asm\tokens.h: x86\insns.dat x86\regs.dat asm\tokens.dat asm\tokhash.pl \
223 perllib\phash.ph
224 $(RUNPERL) $(srcdir)\asm\tokhash.pl h \
225 $(srcdir)\x86\insns.dat $(srcdir)\x86\regs.dat \
226 $(srcdir)\asm\tokens.dat > asm\tokens.h
228 # Preprocessor token hash
229 asm\pptok.h: asm\pptok.dat asm\pptok.pl perllib\phash.ph
230 $(RUNPERL) $(srcdir)\asm\pptok.pl h \
231 $(srcdir)\asm\pptok.dat asm\pptok.h
232 asm\pptok.c: asm\pptok.dat asm\pptok.pl perllib\phash.ph
233 $(RUNPERL) $(srcdir)\asm\pptok.pl c \
234 $(srcdir)\asm\pptok.dat asm\pptok.c
235 asm\pptok.ph: asm\pptok.dat asm\pptok.pl perllib\phash.ph
236 $(RUNPERL) $(srcdir)\asm\pptok.pl ph \
237 $(srcdir)\asm\pptok.dat asm\pptok.ph
239 # Directives hash
240 asm\directiv.h: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
241 $(RUNPERL) $(srcdir)\nasmlib\perfhash.pl h \
242 $(srcdir)\asm\directiv.dat asm\directiv.h
243 asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
244 $(RUNPERL) $(srcdir)\nasmlib\perfhash.pl c \
245 $(srcdir)\asm\directiv.dat asm\directbl.c
247 #-- End Generated File Rules --#
249 perlreq: $(PERLREQ)
251 # This rule is only used for RDOFF
252 .obj.exe:
253 $(CC) /Fe$@ $< $(LDFLAGS) $(RDFLIB) $(NASMLIB) $(LIBS)
255 RDFLN = copy
256 RDFLNPFX = rdoff^\
258 #-- Begin RDOFF Shared Rules --#
259 # Edit in Makefile.in, not here!
261 RDFLIBOBJ = rdoff\rdoff.$(O) rdoff\rdfload.$(O) rdoff\symtab.$(O) \
262 rdoff\collectn.$(O) rdoff\rdlib.$(O) rdoff\segtab.$(O) \
263 rdoff\hash.$(O)
265 RDFPROGS = rdoff\rdfdump$(X) rdoff\ldrdf$(X) rdoff\rdx$(X) rdoff\rdflib$(X) \
266 rdoff\rdf2bin$(X)
267 RDF2BINLINKS = rdoff\rdf2com$(X) rdoff\rdf2ith$(X) \
268 rdoff\rdf2ihx$(X) rdoff\rdf2srec$(X)
270 RDFLIB = rdoff\librdoff.$(A)
271 RDFLIBS = $(RDFLIB) $(NASMLIB)
273 rdoff\rdfdump$(X): rdoff\rdfdump.$(O) $(RDFLIBS)
274 rdoff\ldrdf$(X): rdoff\ldrdf.$(O) $(RDFLIBS)
275 rdoff\rdx$(X): rdoff\rdx.$(O) $(RDFLIBS)
276 rdoff\rdflib$(X): rdoff\rdflib.$(O) $(RDFLIBS)
277 rdoff\rdf2bin$(X): rdoff\rdf2bin.$(O) $(RDFLIBS)
278 rdoff\rdf2com$(X): rdoff\rdf2bin$(X)
279 $(RM_F) rdoff\rdf2com$(X)
280 $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2com$(X)
281 rdoff\rdf2ith$(X): rdoff\rdf2bin$(X)
282 $(RM_F) rdoff\rdf2ith$(X)
283 $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ith$(X)
284 rdoff\rdf2ihx$(X): rdoff\rdf2bin$(X)
285 $(RM_F) rdoff\rdf2ihx$(X)
286 $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ihx$(X)
287 rdoff\rdf2srec$(X): rdoff\rdf2bin$(X)
288 $(RM_F) rdoff\rdf2srec$(X)
289 $(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2srec$(X)
291 #-- End RDOFF Shared Rules --#
293 rdf: $(RDFPROGS) $(RDF2BINLINKS)
295 $(RDFLIB): $(RDFLIBOBJ)
296 $(AR) $(ARFLAGS) /OUT:$@ $**
298 #-- Begin NSIS Rules --#
299 # Edit in Makefile.in, not here!
301 # NSIS is not built except by explicit request, as it only applies to
302 # Windows platforms
303 nsis\arch.nsh: nsis\getpearch.pl nasm$(X)
304 $(PERL) $(srcdir)\nsis\getpearch.pl nasm$(X) > nsis\arch.nsh
306 # Should only be done after "make everything".
307 # The use of redirection here keeps makensis from moving the cwd to the
308 # source directory.
309 nsis: nsis\nasm.nsi nsis\arch.nsh nsis\version.nsh
310 $(MAKENSIS) -Dsrcdir="$(srcdir)" -Dobjdir="$(objdir)" - < nsis\nasm.nsi
312 #-- End NSIS Rules --#
314 clean:
315 -del /f /s *.$(O)
316 -del /f /s *.pdb
317 -del /f /s *.s
318 -del /f /s *.i
319 -del /f $(NASMLIB) $(RDFLIB)
320 -del /f nasm$(X)
321 -del /f ndisasm$(X)
322 -del /f rdoff\*$(X)
324 distclean: clean
325 -del /f config.h
326 -del /f config.log
327 -del /f config.status
328 -del /f Makefile
329 -del /f /s *~
330 -del /f /s *.bak
331 -del /f /s *.lst
332 -del /f /s *.bin
333 -del /f /s *.dep
334 -del /f output\*~
335 -del /f output\*.bak
336 -del /f test\*.lst
337 -del /f test\*.bin
338 -del /f test\*.$(O)
339 -del /f test\*.bin
340 -del /f/s autom4te*.cache
341 rem cd rdoff && $(MAKE) distclean
343 cleaner: clean
344 -del /f $(PERLREQ)
345 -del /f *.man
346 -del /f nasm.spec
347 rem cd doc && $(MAKE) clean
349 spotless: distclean cleaner
350 -del /f doc\Makefile
351 -del doc\*~
352 -del doc\*.bak
354 strip:
356 # Abuse doc/Makefile.in to build nasmdoc.pdf only
357 docs:
358 cd doc && $(MAKE) /f Makefile.in srcdir=. top_srcdir=.. \
359 PERL=$(PERL) PDFOPT= nasmdoc.pdf
361 everything: all docs nsis
364 # Does this version of this file have external dependencies? This definition
365 # will be automatically updated by mkdep.pl as needed.
367 EXTERNAL_DEPENDENCIES = 1
370 # Generate dependency information for this Makefile only.
371 # If this Makefile has external dependency information, then
372 # the dependency information will remain external, so it doesn't
373 # pollute the git logs.
375 msvc.dep: $(PERLREQ) tools\mkdep.pl
376 $(RUNPERL) tools\mkdep.pl -M Mkfiles\msvc.mak -- $(DEPDIRS)
378 dep: msvc.dep
380 # Include and/or generate msvc.dep as needed. This is too complex to
381 # use the include-command feature, but we can open-code it here.
382 MKDEP=0
383 !IF $(EXTERNAL_DEPENDENCIES) == 1 && $(MKDEP) == 0
384 !IF EXISTS(msvc.dep)
385 !INCLUDE msvc.dep
386 !ELSEIF [$(MAKE) /c MKDEP=1 /f Mkfiles\msvc.mak msvc.dep] == 0
387 !INCLUDE msvc.dep
388 !ELSE
389 !ERROR Unable to rebuild dependencies file msvc.dep
390 !ENDIF
391 !ENDIF
393 #-- Magic hints to mkdep.pl --#
394 # @object-ending: ".$(O)"
395 # @path-separator: "\"
396 # @exclude: "config\config.h"
397 # @external: "msvc.dep"
398 # @selfrule: "1"
399 #-- Everything below is generated by mkdep.pl - do not edit --#