6707f5460d0c9d02d31ef0212a75c0444a4069d6
[platform/upstream/nasm.git] / Mkfiles / msvc.mak
1 # -*- makefile -*-
2 #
3 # Makefile for building NASM using Microsoft Visual C++ and NMAKE.
4 # Tested on Microsoft Visual C++ 2005 Express Edition.
5 #
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.
8
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
16
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
25
26 # Binary suffixes
27 O               = obj
28 X               = .exe
29
30 .SUFFIXES: .c .i .s .$(O) .1 .man
31
32 .c.obj:
33         $(CC) /c $(ALL_CFLAGS) /Fo$@ $<
34
35 NASM =  nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
36         assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
37         outform.$(O) output/outbin.$(O) \
38         output/outaout.$(O) output/outcoff.$(O) \
39         output/outelf32.$(O) output/outelf64.$(O) \
40         output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
41         output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
42         preproc.$(O) quote.$(O) pptok.$(O) macros.$(O) \
43         listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) \
44         regvals.$(O) regflags.$(O)
45
46 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
47         insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
48
49 all: nasm$(X) ndisasm$(X)
50         rem cd rdoff && $(MAKE) all
51
52 nasm$(X): $(NASM)
53         $(CC) $(LDFLAGS) /Fenasm$(X) $(NASM) $(LIBS)
54
55 ndisasm$(X): $(NDISASM)
56         $(CC) $(LDFLAGS) /Fendisasm$(X) $(NDISASM) $(LIBS)
57
58 # These source files are automagically generated from a single
59 # instruction-table file by a Perl script. They're distributed,
60 # though, so it isn't necessary to have Perl just to recompile NASM
61 # from the distribution.
62
63 insnsb.c: insns.dat insns.pl
64         $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat
65 insnsa.c: insns.dat insns.pl
66         $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat
67 insnsd.c: insns.dat insns.pl
68         $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat
69 insnsi.h: insns.dat insns.pl
70         $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat
71 insnsn.c: insns.dat insns.pl
72         $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat
73
74 # These files contains all the standard macros that are derived from
75 # the version number.
76 version.h: version version.pl
77         $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
78
79 version.mac: version version.pl
80         $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
81
82 # This source file is generated from the standard macros file
83 # `standard.mac' by another Perl script. Again, it's part of the
84 # standard distribution.
85
86 macros.c: macros.pl standard.mac version.mac
87         $(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac
88
89 # These source files are generated from regs.dat by yet another
90 # perl script.
91 regs.c: regs.dat regs.pl
92         $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c
93 regflags.c: regs.dat regs.pl
94         $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
95 regdis.c: regs.dat regs.pl
96         $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
97 regvals.c: regs.dat regs.pl
98         $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
99 regs.h: regs.dat regs.pl
100         $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h
101
102 # Assembler token hash
103 tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
104         $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \
105                 $(srcdir)/tokens.dat > tokhash.c
106
107 # Assembler token metadata
108 tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
109         $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \
110                 $(srcdir)/tokens.dat > tokens.h
111
112 # Preprocessor token hash
113 pptok.h: pptok.dat pptok.pl perllib/phash.ph
114         $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h
115 pptok.c: pptok.dat pptok.pl perllib/phash.ph
116         $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c
117
118 # This target generates all files that require perl.
119 # This allows easier generation of distribution (see dist target).
120 PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
121           regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \
122           version.h version.mac pptok.h pptok.c
123 perlreq: $(PERLREQ)
124
125 clean:
126         -del /f *.$(O)
127         -del /f *.s
128         -del /f *.i
129         -del /f output\*.$(O)
130         -del /f output\*.s
131         -del /f output\*.i
132         -del /f nasm$(X)
133         -del /f ndisasm$(X)
134         rem cd rdoff && $(MAKE) clean
135
136 distclean: clean
137         -del /f config.h
138         -del /f config.log
139         -del /f config.status
140         -del /f Makefile
141         -del /f *~
142         -del /f *.bak
143         -del /f *.lst
144         -del /f *.bin
145         -del /f output\*~
146         -del /f output\*.bak
147         -del /f test\*.lst
148         -del /f test\*.bin
149         -del /f test\*.$(O)
150         -del /f test\*.bin
151         -del /f/s autom4te*.cache
152         rem cd rdoff && $(MAKE) distclean
153
154 cleaner: clean
155         -del /f $(PERLREQ)
156         -del /f *.man
157         -del /f nasm.spec
158         rem cd doc && $(MAKE) clean
159
160 spotless: distclean cleaner
161         -del /f doc\Makefile
162         -del doc\*~
163         -del doc\*.bak
164
165 strip:
166
167 rdf:
168         # cd rdoff && $(MAKE)
169
170 doc:
171         # cd doc && $(MAKE) all
172
173 everything: all doc rdf
174
175 #-- Magic hints to mkdep.pl --#
176 # @object-ending: ".$(O)"
177 # @path-separator: "/"
178 # @exclude: "config.h"
179 #-- Everything below is generated by mkdep.pl - do not edit --#
180 assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
181  nasmlib.h regs.h tables.h tokens.h version.h
182 crc64.$(O): crc64.c compiler.h
183 disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h \
184  regdis.h regs.h sync.h tables.h tokens.h version.h
185 eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
186  nasmlib.h regs.h version.h
187 exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
188  version.h
189 float.$(O): float.c compiler.h float.h insnsi.h nasm.h nasmlib.h regs.h \
190  version.h
191 hashtbl.$(O): hashtbl.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
192  regs.h version.h
193 insnsa.$(O): insnsa.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
194  tokens.h version.h
195 insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
196  tokens.h version.h
197 insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
198  tokens.h version.h
199 insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
200 labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h regs.h \
201  version.h
202 lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
203 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
204 listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
205  regs.h version.h
206 macros.$(O): macros.c compiler.h insnsi.h tables.h
207 nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h \
208  labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h preproc.h \
209  regs.h stdscan.h tokens.h version.h
210 nasmlib.$(O): nasmlib.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
211  tokens.h version.h
212 ndisasm.$(O): ndisasm.c compiler.h disasm.h insns.h insnsi.h nasm.h \
213  nasmlib.h regs.h sync.h tokens.h version.h
214 outform.$(O): outform.c compiler.h insnsi.h nasm.h nasmlib.h outform.h \
215  regs.h version.h
216 output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
217  outform.h regs.h stdscan.h version.h
218 output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
219  outform.h regs.h version.h
220 output/outbin.$(O): output/outbin.c compiler.h eval.h insnsi.h labels.h \
221  nasm.h nasmlib.h outform.h regs.h stdscan.h version.h
222 output/outcoff.$(O): output/outcoff.c compiler.h insnsi.h nasm.h nasmlib.h \
223  outform.h regs.h version.h
224 output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
225  outform.h regs.h version.h
226 output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
227  outform.h regs.h stdscan.h version.h wsaa.h
228 output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
229  outform.h regs.h stdscan.h version.h wsaa.h
230 output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
231  outform.h regs.h version.h
232 output/outmacho.$(O): output/outmacho.c compiler.h insnsi.h nasm.h nasmlib.h \
233  outform.h regs.h version.h
234 output/outobj.$(O): output/outobj.c compiler.h insnsi.h nasm.h nasmlib.h \
235  outform.h regs.h stdscan.h version.h
236 output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
237  outform.h regs.h version.h
238 output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
239  outform.h rdoff/rdoff.h regs.h version.h
240 parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
241  parser.h regs.h stdscan.h tables.h tokens.h version.h
242 pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
243 preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
244  pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h version.h
245 quote.$(O): quote.c compiler.h nasmlib.h quote.h
246 regdis.$(O): regdis.c regdis.h regs.h
247 regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
248  tables.h version.h
249 regs.$(O): regs.c compiler.h insnsi.h tables.h
250 regvals.$(O): regvals.c compiler.h insnsi.h tables.h
251 stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h quote.h \
252  regs.h stdscan.h tokens.h version.h
253 sync.$(O): sync.c compiler.h nasmlib.h sync.h
254 tokhash.$(O): tokhash.c compiler.h hashtbl.h insns.h insnsi.h nasm.h \
255  nasmlib.h regs.h tokens.h version.h