preproc.c: fix %?/%?? support and address memory leaks
[nasm.git] / Mkfiles / msvc.mak
blobf0aeaa9faa0591183dfc76ea41b316477d1f8b02
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 top_srcdir = .
10 srcdir = .
11 VPATH = .
12 prefix = C:\Program Files\NASM
13 exec_prefix = $(prefix)
14 bindir = $(prefix)/bin
15 mandir = $(prefix)/man
17 CC = cl
18 CFLAGS = /O2 /Ox /Oy /W2
19 BUILD_CFLAGS = $(CFLAGS) /I$(srcdir)/inttypes
20 INTERNAL_CFLAGS = /I$(srcdir) /I. /DHAVE__SNPRINTF /DHAVE__VSNPRINTF
21 ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
22 LDFLAGS =
23 LIBS =
24 PERL = perl -I$(srcdir)/perllib
26 # Binary suffixes
27 O = obj
28 X = .exe
30 .SUFFIXES: .c .i .s .$(O) .1 .man
32 .c.obj:
33 $(CC) /c $(ALL_CFLAGS) /Fo$@ $<
35 #-- Begin File Lists --#
36 # Edit in Makefile.in, not here!
37 NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
38 raa.$(O) saa.$(O) rbtree.$(O) \
39 float.$(O) insnsa.$(O) insnsb.$(O) \
40 directiv.$(O) \
41 assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
42 output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \
43 output/nullout.$(O) \
44 output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
45 output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \
46 output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
47 output/outdbg.$(O) output/outieee.$(O) output/outmac32.$(O) \
48 output/outmac64.$(O) preproc.$(O) quote.$(O) pptok.$(O) \
49 macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \
50 strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) \
51 ilog2.$(O) \
52 lib/strlcpy.$(O)
54 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
55 insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
56 #-- End File Lists --#
58 all: nasm$(X) ndisasm$(X)
59 rem cd rdoff && $(MAKE) all
61 nasm$(X): $(NASM)
62 $(CC) $(LDFLAGS) /Fenasm$(X) $(NASM) $(LIBS)
64 ndisasm$(X): $(NDISASM)
65 $(CC) $(LDFLAGS) /Fendisasm$(X) $(NDISASM) $(LIBS)
67 # These source files are automagically generated from a single
68 # instruction-table file by a Perl script. They're distributed,
69 # though, so it isn't necessary to have Perl just to recompile NASM
70 # from the distribution.
72 insnsb.c: insns.dat insns.pl
73 $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat
74 insnsa.c: insns.dat insns.pl
75 $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat
76 insnsd.c: insns.dat insns.pl
77 $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat
78 insnsi.h: insns.dat insns.pl
79 $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat
80 insnsn.c: insns.dat insns.pl
81 $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat
83 # These files contains all the standard macros that are derived from
84 # the version number.
85 version.h: version version.pl
86 $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
88 version.mac: version version.pl
89 $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
91 # This source file is generated from the standard macros file
92 # `standard.mac' by another Perl script. Again, it's part of the
93 # standard distribution.
95 macros.c: macros.pl standard.mac version.mac
96 $(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac
98 # These source files are generated from regs.dat by yet another
99 # perl script.
100 regs.c: regs.dat regs.pl
101 $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c
102 regflags.c: regs.dat regs.pl
103 $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
104 regdis.c: regs.dat regs.pl
105 $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
106 regvals.c: regs.dat regs.pl
107 $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
108 regs.h: regs.dat regs.pl
109 $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h
111 # Assembler token hash
112 tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
113 $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \
114 $(srcdir)/tokens.dat > tokhash.c
116 # Assembler token metadata
117 tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
118 $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \
119 $(srcdir)/tokens.dat > tokens.h
121 # Preprocessor token hash
122 pptok.h: pptok.dat pptok.pl perllib/phash.ph
123 $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h
124 pptok.c: pptok.dat pptok.pl perllib/phash.ph
125 $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c
127 # This target generates all files that require perl.
128 # This allows easier generation of distribution (see dist target).
129 PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
130 regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \
131 version.h version.mac pptok.h pptok.c
132 perlreq: $(PERLREQ)
134 clean:
135 -del /f *.$(O)
136 -del /f *.s
137 -del /f *.i
138 -del /f lib\*.$(O)
139 -del /f lib\*.s
140 -del /f lib\*.i
141 -del /f output\*.$(O)
142 -del /f output\*.s
143 -del /f output\*.i
144 -del /f nasm$(X)
145 -del /f ndisasm$(X)
146 rem cd rdoff && $(MAKE) clean
148 distclean: clean
149 -del /f config.h
150 -del /f config.log
151 -del /f config.status
152 -del /f Makefile
153 -del /f *~
154 -del /f *.bak
155 -del /f *.lst
156 -del /f *.bin
157 -del /f output\*~
158 -del /f output\*.bak
159 -del /f test\*.lst
160 -del /f test\*.bin
161 -del /f test\*.$(O)
162 -del /f test\*.bin
163 -del /f/s autom4te*.cache
164 rem cd rdoff && $(MAKE) distclean
166 cleaner: clean
167 -del /f $(PERLREQ)
168 -del /f *.man
169 -del /f nasm.spec
170 rem cd doc && $(MAKE) clean
172 spotless: distclean cleaner
173 -del /f doc\Makefile
174 -del doc\*~
175 -del doc\*.bak
177 strip:
179 rdf:
180 # cd rdoff && $(MAKE)
182 doc:
183 # cd doc && $(MAKE) all
185 everything: all doc rdf
187 #-- Magic hints to mkdep.pl --#
188 # @object-ending: ".$(O)"
189 # @path-separator: "/"
190 # @exclude: "config.h"
191 #-- Everything below is generated by mkdep.pl - do not edit --#
192 assemble.$(O): assemble.c assemble.h compiler.h directiv.h insns.h insnsi.h \
193 nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
194 crc64.$(O): crc64.c compiler.h nasmlib.h
195 directiv.$(O): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
196 nasmlib.h opflags.h pptok.h preproc.h regs.h
197 disasm.$(O): disasm.c compiler.h directiv.h disasm.h insns.h insnsi.h nasm.h \
198 nasmlib.h opflags.h pptok.h preproc.h regdis.h regs.h sync.h tables.h \
199 tokens.h
200 eval.$(O): eval.c compiler.h directiv.h eval.h float.h insnsi.h labels.h \
201 nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
202 exprlib.$(O): exprlib.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h \
203 opflags.h pptok.h preproc.h regs.h
204 float.$(O): float.c compiler.h directiv.h float.h insnsi.h nasm.h nasmlib.h \
205 opflags.h pptok.h preproc.h regs.h
206 hashtbl.$(O): hashtbl.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
207 nasmlib.h opflags.h pptok.h preproc.h regs.h
208 ilog2.$(O): ilog2.c compiler.h nasmlib.h
209 insnsa.$(O): insnsa.c compiler.h directiv.h insns.h insnsi.h nasm.h \
210 nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
211 insnsb.$(O): insnsb.c compiler.h directiv.h insns.h insnsi.h nasm.h \
212 nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
213 insnsd.$(O): insnsd.c compiler.h directiv.h insns.h insnsi.h nasm.h \
214 nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
215 insnsn.$(O): insnsn.c compiler.h insnsi.h opflags.h tables.h
216 labels.$(O): labels.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
217 nasmlib.h opflags.h pptok.h preproc.h regs.h
218 lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
219 lib/strlcpy.$(O): lib/strlcpy.c compiler.h
220 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
221 listing.$(O): listing.c compiler.h directiv.h insnsi.h listing.h nasm.h \
222 nasmlib.h opflags.h pptok.h preproc.h regs.h
223 macros.$(O): macros.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
224 nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h tables.h
225 nasm.$(O): nasm.c assemble.h compiler.h directiv.h eval.h float.h insns.h \
226 insnsi.h labels.h listing.h nasm.h nasmlib.h opflags.h output/outform.h \
227 parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
228 nasmlib.$(O): nasmlib.c compiler.h directiv.h insns.h insnsi.h nasm.h \
229 nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
230 ndisasm.$(O): ndisasm.c compiler.h directiv.h disasm.h insns.h insnsi.h \
231 nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h sync.h tokens.h
232 output/nulldbg.$(O): output/nulldbg.c compiler.h directiv.h insnsi.h nasm.h \
233 nasmlib.h opflags.h pptok.h preproc.h regs.h
234 output/nullout.$(O): output/nullout.c compiler.h directiv.h insnsi.h nasm.h \
235 nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h
236 output/outaout.$(O): output/outaout.c compiler.h directiv.h eval.h insnsi.h \
237 nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
238 preproc.h raa.h regs.h saa.h stdscan.h
239 output/outas86.$(O): output/outas86.c compiler.h directiv.h insnsi.h nasm.h \
240 nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h preproc.h \
241 raa.h regs.h saa.h
242 output/outbin.$(O): output/outbin.c compiler.h directiv.h eval.h insnsi.h \
243 labels.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \
244 pptok.h preproc.h regs.h saa.h stdscan.h
245 output/outcoff.$(O): output/outcoff.c compiler.h directiv.h eval.h insnsi.h \
246 nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h output/pecoff.h \
247 pptok.h preproc.h raa.h regs.h saa.h
248 output/outdbg.$(O): output/outdbg.c compiler.h directiv.h insnsi.h nasm.h \
249 nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h
250 output/outelf.$(O): output/outelf.c compiler.h directiv.h insnsi.h nasm.h \
251 nasmlib.h opflags.h output/dwarf.h output/elf.h output/outelf.h \
252 output/outform.h pptok.h preproc.h regs.h
253 output/outelf32.$(O): output/outelf32.c compiler.h directiv.h eval.h \
254 insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
255 output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
256 preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
257 output/outelf64.$(O): output/outelf64.c compiler.h directiv.h eval.h \
258 insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
259 output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
260 preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
261 output/outform.$(O): output/outform.c compiler.h directiv.h insnsi.h nasm.h \
262 nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h
263 output/outieee.$(O): output/outieee.c compiler.h directiv.h insnsi.h nasm.h \
264 nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h preproc.h \
265 regs.h
266 output/outlib.$(O): output/outlib.c compiler.h directiv.h insnsi.h nasm.h \
267 nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h
268 output/outmac32.$(O): output/outmac32.c compiler.h directiv.h eval.h \
269 insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \
270 pptok.h preproc.h raa.h regs.h saa.h
271 output/outmac64.$(O): output/outmac64.c compiler.h directiv.h insnsi.h \
272 nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
273 preproc.h raa.h regs.h saa.h
274 output/outobj.$(O): output/outobj.c compiler.h directiv.h eval.h insnsi.h \
275 nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
276 preproc.h regs.h stdscan.h
277 output/outrdf2.$(O): output/outrdf2.c compiler.h directiv.h insnsi.h nasm.h \
278 nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h preproc.h \
279 rdoff/rdoff.h regs.h saa.h
280 parser.$(O): parser.c compiler.h directiv.h eval.h float.h insns.h insnsi.h \
281 nasm.h nasmlib.h opflags.h parser.h pptok.h preproc.h regs.h stdscan.h \
282 tables.h tokens.h
283 pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
284 preproc.$(O): preproc.c compiler.h directiv.h eval.h hashtbl.h insnsi.h \
285 nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h \
286 tables.h tokens.h
287 quote.$(O): quote.c compiler.h nasmlib.h quote.h
288 raa.$(O): raa.c compiler.h nasmlib.h raa.h
289 rbtree.$(O): rbtree.c compiler.h rbtree.h
290 regdis.$(O): regdis.c regdis.h regs.h
291 regflags.$(O): regflags.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h \
292 opflags.h pptok.h preproc.h regs.h tables.h
293 regs.$(O): regs.c compiler.h insnsi.h opflags.h tables.h
294 regvals.$(O): regvals.c compiler.h insnsi.h opflags.h tables.h
295 saa.$(O): saa.c compiler.h nasmlib.h saa.h
296 stdscan.$(O): stdscan.c compiler.h directiv.h insns.h insnsi.h nasm.h \
297 nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h tokens.h
298 strfunc.$(O): strfunc.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h \
299 opflags.h pptok.h preproc.h regs.h
300 sync.$(O): sync.c compiler.h nasmlib.h sync.h
301 tokhash.$(O): tokhash.c compiler.h directiv.h hashtbl.h insns.h insnsi.h \
302 nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
303 ver.$(O): ver.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h opflags.h \
304 pptok.h preproc.h regs.h version.h