Run "make alldeps" to update dependencies
[platform/upstream/nasm.git] / Mkfiles / owlinux.mak
1 # -*- makefile -*-
2 #
3 # Makefile for cross-compiling NASM from Linux
4 # to DOS, Win32 or OS/2 using OpenWatcom.
5 #
6 # Please see http://bugzilla.openwatcom.org/show_bug.cgi?id=751
7 # for some caveats in using OpenWatcom as a cross-compiler
8 # from Linux, in particular:
9 #
10 # > Second and more importantly, the makefile needs to ensure that the
11 # > proper headers are included. This is normally not a problem when
12 # > building on DOS, Windows, or OS/2, as they share the same C
13 # > library headers. But when cross-compiling from (or to) Linux, it
14 # > is crucial.
15 # >
16 # > This may be accomplished by setting the INCLUDE env var in the
17 # > makefile, or setting OS2_INCLUDE, DOS_INCLUDE, NT_INCLUDE env vars
18 # > *and* making sure that the proper -bt switch is used, or passing a
19 # > switch like -I"$(%WATCOM)/h". The last variant is probably the
20 # > easiest to implement and least likely to break.
21 #
22
23 top_srcdir      = .
24 srcdir          = .
25 prefix          = C:/Program Files/NASM
26 exec_prefix     = $(prefix)
27 bindir          = $(prefix)/bin
28 mandir          = $(prefix)/man
29
30 CC              = wcl386
31 DEBUG           =
32 CFLAGS          = -6 -ox -wx -ze -fpi $(DEBUG)
33 BUILD_CFLAGS    = $(CFLAGS) $(TARGET_FLAGS) # -I$(srcdir)/inttypes
34 INTERNAL_CFLAGS = -I$(srcdir) -I. \
35                   -DHAVE_SNPRINTF -DHAVE_VSNPRINTF
36 ALL_CFLAGS      = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
37 LD              = $(CC)
38 LDFLAGS         = $(ALL_CFLAGS)
39 LIBS            =
40 PERL            = perl -I$(srcdir)/perllib
41
42 STRIP           = wstrip
43
44 # Binary suffixes
45 O               = obj
46 X               = .exe
47
48 # WMAKE errors out if a suffix is declared more than once, including
49 # its own built-in declarations.  Thus, we need to explicitly clear the list
50 # first.  Also, WMAKE only allows implicit rules that point "to the left"
51 # in this list!
52 .SUFFIXES:
53 .SUFFIXES: .man .1 .$(O) .i .c
54
55 .c.$(O):
56         $(CC) -c $(ALL_CFLAGS) -fo=$@ $<
57
58 #-- Begin File Lists --#
59 # Edit in Makefile.in, not here!
60 NASM =  nasm.$(O) nasmlib.$(O) ver.$(O) \
61         raa.$(O) saa.$(O) rbtree.$(O) \
62         float.$(O) insnsa.$(O) insnsb.$(O) \
63         directiv.$(O) \
64         assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
65         output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \
66         output/nullout.$(O) \
67         output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
68         output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \
69         output/outelfx32.$(O) \
70         output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
71         output/outdbg.$(O) output/outieee.$(O) output/outmac32.$(O) \
72         output/outmac64.$(O) preproc.$(O) quote.$(O) pptok.$(O) \
73         macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \
74         strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) \
75         ilog2.$(O) \
76         lib/strlcpy.$(O) \
77         preproc-nop.$(O)
78
79 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
80         insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
81 #-- End File Lists --#
82
83 what:
84         @echo 'Please build "dos", "win32" or "os2"'
85
86 dos:
87         $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=DOS -l=DOS4G'
88
89 win32:
90         $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=NT  -l=NT'
91
92 os2:
93         $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=OS2 -l=OS2V2'
94
95 all: nasm$(X) ndisasm$(X)
96
97 nasm$(X): $(NASM)
98         $(LD) $(LDFLAGS) -fe=nasm$(X) $(NASM) $(LIBS)
99
100 ndisasm$(X): $(NDISASM)
101         $(LD) $(LDFLAGS) -fe=ndisasm$(X) $(NDISASM) $(LIBS)
102
103 # These source files are automagically generated from a single
104 # instruction-table file by a Perl script. They're distributed,
105 # though, so it isn't necessary to have Perl just to recompile NASM
106 # from the distribution.
107
108 insnsb.c: insns.dat insns.pl
109         $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat
110 insnsa.c: insns.dat insns.pl
111         $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat
112 insnsd.c: insns.dat insns.pl
113         $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat
114 insnsi.h: insns.dat insns.pl
115         $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat
116 insnsn.c: insns.dat insns.pl
117         $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat
118
119 # These files contains all the standard macros that are derived from
120 # the version number.
121 version.h: version version.pl
122         $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
123
124 version.mac: version version.pl
125         $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
126
127 # This source file is generated from the standard macros file
128 # `standard.mac' by another Perl script. Again, it's part of the
129 # standard distribution.
130
131 macros.c: macros.pl standard.mac version.mac
132         $(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac
133
134 # These source files are generated from regs.dat by yet another
135 # perl script.
136 regs.c: regs.dat regs.pl
137         $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c
138 regflags.c: regs.dat regs.pl
139         $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
140 regdis.c: regs.dat regs.pl
141         $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
142 regdis.h: regs.dat regs.pl
143         $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h
144 regvals.c: regs.dat regs.pl
145         $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
146 regs.h: regs.dat regs.pl
147         $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h
148
149 # Assembler token hash
150 tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
151         $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \
152                 $(srcdir)/tokens.dat > tokhash.c
153
154 # Assembler token metadata
155 tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
156         $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \
157                 $(srcdir)/tokens.dat > tokens.h
158
159 # Preprocessor token hash
160 pptok.h: pptok.dat pptok.pl perllib/phash.ph
161         $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h
162 pptok.c: pptok.dat pptok.pl perllib/phash.ph
163         $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c
164
165 # This target generates all files that require perl.
166 # This allows easier generation of distribution (see dist target).
167 PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
168           regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
169           tokhash.c tokens.h pptok.h pptok.c \
170           version.h version.mac
171 perlreq: $(PERLREQ)
172
173 clean:
174         -rm -f *.$(O)
175         -rm -f *.s
176         -rm -f *.i
177         -rm -f lib/*.$(O)
178         -rm -f lib/*.s
179         -rm -f lib/*.i
180         -rm -f output/*.$(O)
181         -rm -f output/*.s
182         -rm -f output/*.i
183         -rm -f nasm$(X)
184         -rm -f ndisasm$(X)
185         # cd rdoff && $(MAKE) clean
186
187 distclean: clean .SYMBOLIC
188         -rm -f config.h
189         -rm -f config.log
190         -rm -f config.status
191         -rm -f Makefile
192         -rm -f *~
193         -rm -f *.bak
194         -rm -f *.lst
195         -rm -f *.bin
196         -rm -f output/*~
197         -rm -f output/*.bak
198         -rm -f test/*.lst
199         -rm -f test/*.bin
200         -rm -f test/*.$(O)
201         -rm -f test/*.bin
202         -rm -f/s autom4te*.cache
203         # cd rdoff && $(MAKE) distclean
204
205 cleaner: clean .SYMBOLIC
206         -rm -f $(PERLREQ)
207         -rm -f *.man
208         -rm -f nasm.spec
209         # cd doc && $(MAKE) clean
210
211 spotless: distclean cleaner .SYMBOLIC
212         -rm -f doc/Makefile
213         -rm -f doc/*~
214         -rm -f doc/*.bak
215
216 strip:
217         $(STRIP) *.exe
218
219 rdf:
220         # cd rdoff && $(MAKE)
221
222 doc:
223         # cd doc && $(MAKE) all
224
225 everything: all doc rdf
226
227 #-- Magic hints to mkdep.pl --#
228 # @object-ending: ".$(O)"
229 # @path-separator: "/"
230 # @exclude: "config.h"
231 # @continuation: "\"
232 #-- Everything below is generated by mkdep.pl - do not edit --#
233 assemble.$(O): assemble.c assemble.h compiler.h directiv.h insns.h insnsi.h \
234  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
235 crc64.$(O): crc64.c compiler.h nasmlib.h
236 directiv.$(O): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
237  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
238 disasm.$(O): disasm.c compiler.h directiv.h disasm.h insns.h insnsi.h nasm.h \
239  nasmlib.h opflags.h pptok.h preproc.h regdis.h regs.h sync.h tables.h \
240  tokens.h
241 eval.$(O): eval.c compiler.h directiv.h eval.h float.h insnsi.h labels.h \
242  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
243 exprlib.$(O): exprlib.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h \
244  opflags.h pptok.h preproc.h regs.h tables.h
245 float.$(O): float.c compiler.h directiv.h float.h insnsi.h nasm.h nasmlib.h \
246  opflags.h pptok.h preproc.h regs.h tables.h
247 hashtbl.$(O): hashtbl.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
248  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
249 ilog2.$(O): ilog2.c compiler.h nasmlib.h
250 insnsa.$(O): insnsa.c compiler.h directiv.h insns.h insnsi.h nasm.h \
251  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
252 insnsb.$(O): insnsb.c compiler.h directiv.h insns.h insnsi.h nasm.h \
253  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
254 insnsd.$(O): insnsd.c compiler.h directiv.h insns.h insnsi.h nasm.h \
255  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
256 insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
257 labels.$(O): labels.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
258  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
259 lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
260 lib/strlcpy.$(O): lib/strlcpy.c compiler.h
261 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
262 listing.$(O): listing.c compiler.h directiv.h insnsi.h listing.h nasm.h \
263  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
264 macros.$(O): macros.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
265  nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h tables.h
266 nasm.$(O): nasm.c assemble.h compiler.h directiv.h eval.h float.h insns.h \
267  insnsi.h labels.h listing.h nasm.h nasmlib.h opflags.h output/outform.h \
268  parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h tables.h tokens.h
269 nasmlib.$(O): nasmlib.c compiler.h directiv.h insns.h insnsi.h nasm.h \
270  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
271 ndisasm.$(O): ndisasm.c compiler.h directiv.h disasm.h insns.h insnsi.h \
272  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h sync.h tables.h \
273  tokens.h
274 output/nulldbg.$(O): output/nulldbg.c compiler.h directiv.h insnsi.h nasm.h \
275  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
276 output/nullout.$(O): output/nullout.c compiler.h directiv.h insnsi.h nasm.h \
277  nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h tables.h
278 output/outaout.$(O): output/outaout.c compiler.h directiv.h eval.h insnsi.h \
279  nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
280  preproc.h raa.h regs.h saa.h stdscan.h tables.h
281 output/outas86.$(O): output/outas86.c compiler.h directiv.h insnsi.h nasm.h \
282  nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h preproc.h \
283  raa.h regs.h saa.h tables.h
284 output/outbin.$(O): output/outbin.c compiler.h directiv.h eval.h insnsi.h \
285  labels.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \
286  pptok.h preproc.h regs.h saa.h stdscan.h tables.h
287 output/outcoff.$(O): output/outcoff.c compiler.h directiv.h eval.h insnsi.h \
288  nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h output/pecoff.h \
289  pptok.h preproc.h raa.h regs.h saa.h tables.h
290 output/outdbg.$(O): output/outdbg.c compiler.h directiv.h insnsi.h nasm.h \
291  nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h tables.h
292 output/outelf.$(O): output/outelf.c compiler.h directiv.h insnsi.h nasm.h \
293  nasmlib.h opflags.h output/dwarf.h output/elf.h output/outelf.h \
294  output/outform.h pptok.h preproc.h regs.h tables.h
295 output/outelf32.$(O): output/outelf32.c compiler.h directiv.h eval.h \
296  insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
297  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
298  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h
299 output/outelf64.$(O): output/outelf64.c compiler.h directiv.h eval.h \
300  insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
301  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
302  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h
303 output/outelfx32.$(O): output/outelfx32.c compiler.h directiv.h eval.h \
304  insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h \
305  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \
306  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h
307 output/outform.$(O): output/outform.c compiler.h directiv.h insnsi.h nasm.h \
308  nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h tables.h
309 output/outieee.$(O): output/outieee.c compiler.h directiv.h insnsi.h nasm.h \
310  nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h preproc.h \
311  regs.h tables.h
312 output/outlib.$(O): output/outlib.c compiler.h directiv.h insnsi.h nasm.h \
313  nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h tables.h
314 output/outmac32.$(O): output/outmac32.c compiler.h directiv.h eval.h \
315  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \
316  pptok.h preproc.h raa.h regs.h saa.h tables.h
317 output/outmac64.$(O): output/outmac64.c compiler.h directiv.h insnsi.h \
318  nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
319  preproc.h raa.h regs.h saa.h tables.h
320 output/outobj.$(O): output/outobj.c compiler.h directiv.h eval.h insnsi.h \
321  nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
322  preproc.h regs.h stdscan.h tables.h
323 output/outrdf2.$(O): output/outrdf2.c compiler.h directiv.h insnsi.h nasm.h \
324  nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h preproc.h \
325  rdoff/rdoff.h regs.h saa.h tables.h
326 parser.$(O): parser.c compiler.h directiv.h eval.h float.h insns.h insnsi.h \
327  nasm.h nasmlib.h opflags.h parser.h pptok.h preproc.h regs.h stdscan.h \
328  tables.h tokens.h
329 pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
330 preproc-nop.$(O): preproc-nop.c compiler.h directiv.h insnsi.h nasm.h \
331  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
332 preproc.$(O): preproc.c compiler.h directiv.h eval.h hashtbl.h insnsi.h \
333  nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h \
334  tables.h tokens.h
335 quote.$(O): quote.c compiler.h nasmlib.h quote.h
336 raa.$(O): raa.c compiler.h nasmlib.h raa.h
337 rbtree.$(O): rbtree.c compiler.h rbtree.h
338 regdis.$(O): regdis.c regdis.h regs.h
339 regflags.$(O): regflags.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h \
340  opflags.h pptok.h preproc.h regs.h tables.h
341 regs.$(O): regs.c compiler.h insnsi.h tables.h
342 regvals.$(O): regvals.c compiler.h insnsi.h tables.h
343 saa.$(O): saa.c compiler.h nasmlib.h saa.h
344 stdscan.$(O): stdscan.c compiler.h directiv.h insns.h insnsi.h nasm.h \
345  nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h tables.h \
346  tokens.h
347 strfunc.$(O): strfunc.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h \
348  opflags.h pptok.h preproc.h regs.h tables.h
349 sync.$(O): sync.c compiler.h nasmlib.h sync.h
350 tokhash.$(O): tokhash.c compiler.h directiv.h hashtbl.h insns.h insnsi.h \
351  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
352 ver.$(O): ver.c compiler.h directiv.h insnsi.h nasm.h nasmlib.h opflags.h \
353  pptok.h preproc.h regs.h tables.h version.h