msvc.mak: avoid infinite recursion on msvc.dep
[nasm.git] / Mkfiles / msvc.mak
bloba29a869e39d5a207b1259741aff1afe2b61a8594
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: .c .i .s .$(O) .$(A) .exe .1 .man
59 .c.obj:
60 $(CC) /c $(ALL_CFLAGS) /Fo$@ $<
62 # This rule is only used for rdoff
63 .obj.exe:
64 $(CC) $(ALL_CFLAGS) /Fe$@ $< $(LDFLAGS) $(RDFLIB) $(NASMLIB) $(LIBS)
66 #-- Begin File Lists --#
67 # Edit in Makefile.in, not here!
68 NASM = asm\nasm.$(O)
69 NDISASM = disasm\ndisasm.$(O)
71 LIBOBJ = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \
72 stdlib\strnlen.$(O) \
73 nasmlib\ver.$(O) \
74 nasmlib\crc64.$(O) nasmlib\malloc.$(O) \
75 nasmlib\md5c.$(O) nasmlib\string.$(O) \
76 nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \
77 nasmlib\realpath.$(O) nasmlib\path.$(O) \
78 nasmlib\filename.$(O) nasmlib\srcfile.$(O) \
79 nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) \
80 nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) \
81 nasmlib\raa.$(O) nasmlib\saa.$(O) \
82 nasmlib\strlist.$(O) \
83 nasmlib\perfhash.$(O) nasmlib\badenum.$(O) \
84 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) \
102 macros\macros.$(O) \
104 output\outform.$(O) output\outlib.$(O) output\legacy.$(O) \
105 output\strtbl.$(O) \
106 output\nulldbg.$(O) output\nullout.$(O) \
107 output\outbin.$(O) output\outaout.$(O) output\outcoff.$(O) \
108 output\outelf.$(O) \
109 output\outobj.$(O) output\outas86.$(O) output\outrdf2.$(O) \
110 output\outdbg.$(O) output\outieee.$(O) output\outmacho.$(O) \
111 output\codeview.$(O) \
113 disasm\disasm.$(O) disasm\sync.$(O)
115 SUBDIRS = stdlib nasmlib output asm disasm x86 common macros
116 XSUBDIRS = test doc nsis rdoff
117 DEPDIRS = . include config x86 rdoff $(SUBDIRS)
118 #-- End File Lists --#
120 NASMLIB = libnasm.$(A)
122 all: nasm$(X) ndisasm$(X) rdf
124 nasm$(X): $(NASM) $(NASMLIB)
125 $(CC) /Fe$@ $(NASM) $(LDFLAGS) $(NASMLIB) $(LIBS)
127 ndisasm$(X): $(NDISASM) $(NASMLIB)
128 $(CC) /Fe$@ $(NDISASM) $(LDFLAGS) $(NASMLIB) $(LIBS)
130 $(NASMLIB): $(LIBOBJ)
131 $(AR) $(ARFLAGS) /OUT:$@ $**
133 #-- Begin Generated File Rules --#
134 # Edit in Makefile.in, not here!
136 # These source files are automagically generated from data files using
137 # Perl scripts. They're distributed, though, so it isn't necessary to
138 # have Perl just to recompile NASM from the distribution.
140 # Perl-generated source files
141 PERLREQ = x86\insnsb.c x86\insnsa.c x86\insnsd.c x86\insnsi.h x86\insnsn.c \
142 x86\regs.c x86\regs.h x86\regflags.c x86\regdis.c x86\regdis.h \
143 x86\regvals.c asm\tokhash.c asm\tokens.h asm\pptok.h asm\pptok.c \
144 x86\iflag.c x86\iflaggen.h \
145 macros\macros.c \
146 asm\pptok.ph asm\directbl.c asm\directiv.h \
147 version.h version.mac version.mak nsis\version.nsh
149 INSDEP = x86\insns.dat x86\insns.pl x86\insns-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
195 # perl script.
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 # Assembler token hash
216 asm\tokhash.c: x86\insns.dat x86\regs.dat asm\tokens.dat asm\tokhash.pl \
217 perllib\phash.ph
218 $(RUNPERL) $(srcdir)\asm\tokhash.pl c \
219 $(srcdir)\x86\insns.dat $(srcdir)\x86\regs.dat \
220 $(srcdir)\asm\tokens.dat > asm\tokhash.c
222 # Assembler token metadata
223 asm\tokens.h: x86\insns.dat x86\regs.dat asm\tokens.dat asm\tokhash.pl \
224 perllib\phash.ph
225 $(RUNPERL) $(srcdir)\asm\tokhash.pl h \
226 $(srcdir)\x86\insns.dat $(srcdir)\x86\regs.dat \
227 $(srcdir)\asm\tokens.dat > asm\tokens.h
229 # Preprocessor token hash
230 asm\pptok.h: asm\pptok.dat asm\pptok.pl perllib\phash.ph
231 $(RUNPERL) $(srcdir)\asm\pptok.pl h \
232 $(srcdir)\asm\pptok.dat asm\pptok.h
233 asm\pptok.c: asm\pptok.dat asm\pptok.pl perllib\phash.ph
234 $(RUNPERL) $(srcdir)\asm\pptok.pl c \
235 $(srcdir)\asm\pptok.dat asm\pptok.c
236 asm\pptok.ph: asm\pptok.dat asm\pptok.pl perllib\phash.ph
237 $(RUNPERL) $(srcdir)\asm\pptok.pl ph \
238 $(srcdir)\asm\pptok.dat asm\pptok.ph
240 # Directives hash
241 asm\directiv.h: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
242 $(RUNPERL) $(srcdir)\nasmlib\perfhash.pl h \
243 $(srcdir)\asm\directiv.dat asm\directiv.h
244 asm\directbl.c: asm\directiv.dat nasmlib\perfhash.pl perllib\phash.ph
245 $(RUNPERL) $(srcdir)\nasmlib\perfhash.pl c \
246 $(srcdir)\asm\directiv.dat asm\directbl.c
248 #-- End Generated File Rules --#
250 perlreq: $(PERLREQ)
252 #-- Begin RDOFF Shared Rules --#
253 # Edit in Makefile.in, not here!
255 RDFLIBOBJ = rdoff\rdoff.$(O) rdoff\rdfload.$(O) rdoff\symtab.$(O) \
256 rdoff\collectn.$(O) rdoff\rdlib.$(O) rdoff\segtab.$(O) \
257 rdoff\hash.$(O)
259 RDFPROGS = rdoff\rdfdump$(X) rdoff\ldrdf$(X) rdoff\rdx$(X) rdoff\rdflib$(X) \
260 rdoff\rdf2bin$(X)
261 RDF2BINLINKS = rdoff\rdf2com$(X) rdoff\rdf2ith$(X) \
262 rdoff\rdf2ihx$(X) rdoff\rdf2srec$(X)
264 RDFLIB = rdoff\librdoff.$(A)
265 RDFLIBS = $(RDFLIB) $(NASMLIB)
267 # This rule is only used for rdoff, to allow common rules
268 MAKERDF = $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS)
270 rdoff\rdfdump$(X): rdoff\rdfdump.$(O) $(RDFLIBS)
271 $(MAKERDF)
272 rdoff\ldrdf$(X): rdoff\ldrdf.$(O) $(RDFLIBS)
273 $(MAKERDF)
274 rdoff\rdx$(X): rdoff\rdx.$(O) $(RDFLIBS)
275 $(MAKERDF)
276 rdoff\rdflib$(X): rdoff\rdflib.$(O) $(RDFLIBS)
277 $(MAKERDF)
278 rdoff\rdf2bin$(X): rdoff\rdf2bin.$(O) $(RDFLIBS)
279 $(MAKERDF)
280 rdoff\rdf2com$(X): rdoff\rdf2bin$(X)
281 $(RM_F) rdoff\rdf2com$(X)
282 cd rdoff && $(LN_S) rdf2bin$(X) rdf2com$(X)
283 rdoff\rdf2ith$(X): rdoff\rdf2bin$(X)
284 $(RM_F) rdoff\rdf2ith$(X)
285 cd rdoff && $(LN_S) rdf2bin$(X) rdf2ith$(X)
286 rdoff\rdf2ihx$(X): rdoff\rdf2bin$(X)
287 $(RM_F) rdoff\rdf2ihx$(X)
288 cd rdoff && $(LN_S) rdf2bin$(X) rdf2ihx$(X)
289 rdoff\rdf2srec$(X): rdoff\rdf2bin$(X)
290 $(RM_F) rdoff\rdf2srec$(X)
291 cd rdoff && $(LN_S) rdf2bin$(X) rdf2srec$(X)
293 #-- End RDOFF Shared Rules --#
295 rdf: $(RDFPROGS) $(RDF2BINLINKS)
297 $(RDFLIB): $(RDFLIBOBJ)
298 $(AR) $(ARFLAGS) /OUT:$@ $**
300 #-- Begin NSIS Rules --#
301 # Edit in Makefile.in, not here!
303 # NSIS is not built except by explicit request, as it only applies to
304 # Windows platforms
305 nsis\arch.nsh: nsis\getpearch.pl nasm$(X)
306 $(PERL) $(srcdir)\nsis\getpearch.pl nasm$(X) > nsis\arch.nsh
308 # Should only be done after "make everything".
309 # The use of redirection here keeps makensis from moving the cwd to the
310 # source directory.
311 nsis: nsis\nasm.nsi nsis\arch.nsh nsis\version.nsh
312 $(MAKENSIS) -Dsrcdir="$(srcdir)" -Dobjdir="$(objdir)" - < nsis\nasm.nsi
314 #-- End NSIS Rules --#
316 clean:
317 -del /f /s *.$(O)
318 -del /f /s *.pdb
319 -del /f /s *.s
320 -del /f /s *.i
321 -del /f $(NASMLIB) $(RDFLIB)
322 -del /f nasm$(X)
323 -del /f ndisasm$(X)
324 -del /f rdoff\*$(X)
326 distclean: clean
327 -del /f config.h
328 -del /f config.log
329 -del /f config.status
330 -del /f Makefile
331 -del /f /s *~
332 -del /f /s *.bak
333 -del /f /s *.lst
334 -del /f /s *.bin
335 -del /f /s *.dep
336 -del /f output\*~
337 -del /f output\*.bak
338 -del /f test\*.lst
339 -del /f test\*.bin
340 -del /f test\*.$(O)
341 -del /f test\*.bin
342 -del /f/s autom4te*.cache
343 rem cd rdoff && $(MAKE) distclean
345 cleaner: clean
346 -del /f $(PERLREQ)
347 -del /f *.man
348 -del /f nasm.spec
349 rem cd doc && $(MAKE) clean
351 spotless: distclean cleaner
352 -del /f doc\Makefile
353 -del doc\*~
354 -del doc\*.bak
356 strip:
358 # Abuse doc/Makefile.in to build nasmdoc.pdf only
359 docs:
360 cd doc && $(MAKE) /f Makefile.in srcdir=. top_srcdir=.. \
361 PERL=$(PERL) PDFOPT= nasmdoc.pdf
363 everything: all docs nsis
366 # Does this version of this file have external dependencies? This definition
367 # will be automatically updated by mkdep.pl as needed.
369 EXTERNAL_DEPENDENCIES = 1
372 # Generate dependency information for this Makefile only.
373 # If this Makefile has external dependency information, then
374 # the dependency information will remain external, so it doesn't
375 # pollute the git logs.
377 msvc.dep: $(PERLREQ) tools\mkdep.pl
378 $(RUNPERL) tools\mkdep.pl -M Mkfiles\msvc.mak -- $(DEPDIRS)
380 dep: msvc.dep
382 # Include and/or generate msvc.dep as needed. This is too complex to
383 # use the include-command feature, but we can open-code it here.
384 !IF $(EXTERNAL_DEPENDENCIES) == 1
385 !IF [$(MAKE) /c MKDEP=1 /f Mkfiles\msvc.mak msvc.dep] == 0
386 !INCLUDE msvc.dep
387 !ELSEIFNDEF MKDEP
388 !ERROR Unable to rebuild dependencies file msvc.dep
389 !ENDIF
390 !ENDIF
392 #-- Magic hints to mkdep.pl --#
393 # @object-ending: ".$(O)"
394 # @path-separator: "\"
395 # @exclude: "config/config.h"
396 # @external: "msvc.dep"
397 # @selfrule: "1"
398 #-- Everything below is generated by mkdep.pl - do not edit --#