Don't fclose() the output in the backend
[nasm.git] / Mkfiles / owlinux.mak
blobbda449ece4409f73b1c559db1d21bf0b300175e6
1 # -*- makefile -*-
3 # Makefile for cross-compiling NASM from Linux
4 # to DOS, Win32 or OS/2 using OpenWatcom.
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:
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.
23 top_srcdir = .
24 srcdir = .
25 prefix = C:/Program Files/NASM
26 exec_prefix = $(prefix)
27 bindir = $(prefix)/bin
28 mandir = $(prefix)/man
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
42 STRIP = wstrip
44 # Binary suffixes
45 O = obj
46 X = .exe
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
55 .c.$(O):
56 $(CC) -c $(ALL_CFLAGS) -fo=$@ $<
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 directives.$(O) \
64 assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
65 output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \
66 output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
67 output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \
68 output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
69 output/outdbg.$(O) output/outieee.$(O) output/outmacho32.$(O) \
70 output/outmacho64.$(O) preproc.$(O) quote.$(O) pptok.$(O) \
71 macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) \
72 strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O)
74 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
75 insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
76 #-- End File Lists --#
78 what:
79 @echo 'Please build "dos", "win32" or "os2"'
81 dos:
82 $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=DOS -l=DOS4G'
84 win32:
85 $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=NT -l=NT'
87 os2:
88 $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=OS2 -l=OS2V2'
90 all: nasm$(X) ndisasm$(X)
92 nasm$(X): $(NASM)
93 $(LD) $(LDFLAGS) -fe=nasm$(X) $(NASM) $(LIBS)
95 ndisasm$(X): $(NDISASM)
96 $(LD) $(LDFLAGS) -fe=ndisasm$(X) $(NDISASM) $(LIBS)
98 # These source files are automagically generated from a single
99 # instruction-table file by a Perl script. They're distributed,
100 # though, so it isn't necessary to have Perl just to recompile NASM
101 # from the distribution.
103 insnsb.c: insns.dat insns.pl
104 $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat
105 insnsa.c: insns.dat insns.pl
106 $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat
107 insnsd.c: insns.dat insns.pl
108 $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat
109 insnsi.h: insns.dat insns.pl
110 $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat
111 insnsn.c: insns.dat insns.pl
112 $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat
114 # These files contains all the standard macros that are derived from
115 # the version number.
116 version.h: version version.pl
117 $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
119 version.mac: version version.pl
120 $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
122 # This source file is generated from the standard macros file
123 # `standard.mac' by another Perl script. Again, it's part of the
124 # standard distribution.
126 macros.c: macros.pl standard.mac version.mac
127 $(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac
129 # These source files are generated from regs.dat by yet another
130 # perl script.
131 regs.c: regs.dat regs.pl
132 $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c
133 regflags.c: regs.dat regs.pl
134 $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
135 regdis.c: regs.dat regs.pl
136 $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
137 regdis.h: regs.dat regs.pl
138 $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h
139 regvals.c: regs.dat regs.pl
140 $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
141 regs.h: regs.dat regs.pl
142 $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h
144 # Assembler token hash
145 tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
146 $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \
147 $(srcdir)/tokens.dat > tokhash.c
149 # Assembler token metadata
150 tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
151 $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \
152 $(srcdir)/tokens.dat > tokens.h
154 # Preprocessor token hash
155 pptok.h: pptok.dat pptok.pl perllib/phash.ph
156 $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h
157 pptok.c: pptok.dat pptok.pl perllib/phash.ph
158 $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c
160 # This target generates all files that require perl.
161 # This allows easier generation of distribution (see dist target).
162 PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
163 regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
164 tokhash.c tokens.h pptok.h pptok.c \
165 version.h version.mac
166 perlreq: $(PERLREQ)
168 clean:
169 -rm -f *.$(O)
170 -rm -f *.s
171 -rm -f *.i
172 -rm -f output/*.$(O)
173 -rm -f output/*.s
174 -rm -f output/*.i
175 -rm -f nasm$(X)
176 -rm -f ndisasm$(X)
177 # cd rdoff && $(MAKE) clean
179 distclean: clean .SYMBOLIC
180 -rm -f config.h
181 -rm -f config.log
182 -rm -f config.status
183 -rm -f Makefile
184 -rm -f *~
185 -rm -f *.bak
186 -rm -f *.lst
187 -rm -f *.bin
188 -rm -f output/*~
189 -rm -f output/*.bak
190 -rm -f test/*.lst
191 -rm -f test/*.bin
192 -rm -f test/*.$(O)
193 -rm -f test/*.bin
194 -rm -f/s autom4te*.cache
195 # cd rdoff && $(MAKE) distclean
197 cleaner: clean .SYMBOLIC
198 -rm -f $(PERLREQ)
199 -rm -f *.man
200 -rm -f nasm.spec
201 # cd doc && $(MAKE) clean
203 spotless: distclean cleaner .SYMBOLIC
204 -rm -f doc/Makefile
205 -rm -f doc/*~
206 -rm -f doc/*.bak
208 strip:
209 $(STRIP) *.exe
211 rdf:
212 # cd rdoff && $(MAKE)
214 doc:
215 # cd doc && $(MAKE) all
217 everything: all doc rdf
219 #-- Magic hints to mkdep.pl --#
220 # @object-ending: ".$(O)"
221 # @path-separator: "/"
222 # @exclude: "config.h"
223 # @continuation: "\"
224 #-- Everything below is generated by mkdep.pl - do not edit --#
225 assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
226 nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h
227 crc64.$(O): crc64.c compiler.h nasmlib.h
228 directives.$(O): directives.c compiler.h directives.h hashtbl.h insnsi.h \
229 nasm.h nasmlib.h pptok.h preproc.h regs.h
230 disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h \
231 pptok.h preproc.h regdis.h regs.h sync.h tables.h tokens.h
232 eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
233 nasmlib.h pptok.h preproc.h regs.h
234 exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
235 preproc.h regs.h
236 float.$(O): float.c compiler.h float.h insnsi.h nasm.h nasmlib.h pptok.h \
237 preproc.h regs.h
238 hashtbl.$(O): hashtbl.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
239 pptok.h preproc.h regs.h
240 insnsa.$(O): insnsa.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
241 preproc.h regs.h tokens.h
242 insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
243 preproc.h regs.h tokens.h
244 insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
245 preproc.h regs.h tokens.h
246 insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
247 labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h pptok.h \
248 preproc.h regs.h
249 lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
250 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
251 listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
252 pptok.h preproc.h regs.h
253 macros.$(O): macros.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
254 output/outform.h pptok.h preproc.h regs.h tables.h
255 nasm.$(O): nasm.c assemble.h compiler.h directives.h eval.h float.h insns.h \
256 insnsi.h labels.h listing.h nasm.h nasmlib.h output/outform.h parser.h \
257 pptok.h preproc.h raa.h regs.h saa.h stdscan.h tokens.h
258 nasmlib.$(O): nasmlib.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
259 preproc.h regs.h tokens.h
260 ndisasm.$(O): ndisasm.c compiler.h disasm.h insns.h insnsi.h nasm.h \
261 nasmlib.h pptok.h preproc.h regs.h sync.h tokens.h
262 output/nulldbg.$(O): output/nulldbg.c compiler.h insnsi.h nasm.h nasmlib.h \
263 pptok.h preproc.h regs.h
264 output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
265 output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h \
266 stdscan.h
267 output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
268 output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
269 output/outbin.$(O): output/outbin.c compiler.h eval.h insnsi.h labels.h \
270 nasm.h nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h regs.h \
271 saa.h stdscan.h
272 output/outcoff.$(O): output/outcoff.c compiler.h insnsi.h nasm.h nasmlib.h \
273 output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h saa.h
274 output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
275 output/outform.h pptok.h preproc.h regs.h
276 output/outelf.$(O): output/outelf.c compiler.h insnsi.h nasm.h nasmlib.h \
277 output/dwarf.h output/elfcommon.h output/outelf.h output/outform.h pptok.h \
278 preproc.h regs.h
279 output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
280 output/dwarf.h output/elf32.h output/elfcommon.h output/outelf.h \
281 output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
282 saa.h stdscan.h
283 output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
284 output/dwarf.h output/elf64.h output/elfcommon.h output/outelf.h \
285 output/outform.h output/outlib.h pptok.h preproc.h raa.h rbtree.h regs.h \
286 saa.h stdscan.h
287 output/outexe.$(O): output/outexe.c compiler.h insnsi.h nasm.h nasmlib.h \
288 output/outform.h pptok.h preproc.h regs.h
289 output/outform.$(O): output/outform.c compiler.h insnsi.h nasm.h nasmlib.h \
290 output/outform.h pptok.h preproc.h regs.h
291 output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
292 output/outform.h output/outlib.h pptok.h preproc.h regs.h
293 output/outlib.$(O): output/outlib.c compiler.h insnsi.h nasm.h nasmlib.h \
294 output/outlib.h pptok.h preproc.h regs.h
295 output/outmacho32.$(O): output/outmacho32.c compiler.h insnsi.h nasm.h \
296 nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h \
297 saa.h
298 output/outmacho64.$(O): output/outmacho64.c compiler.h insnsi.h nasm.h \
299 nasmlib.h output/outform.h output/outlib.h pptok.h preproc.h raa.h regs.h \
300 saa.h
301 output/outobj.$(O): output/outobj.c compiler.h insnsi.h nasm.h nasmlib.h \
302 output/outform.h output/outlib.h pptok.h preproc.h regs.h stdscan.h
303 output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
304 output/outform.h pptok.h preproc.h regs.h
305 output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
306 output/outform.h output/outlib.h pptok.h preproc.h rdoff/rdoff.h regs.h \
307 saa.h
308 parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
309 parser.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
310 pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
311 preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
312 pptok.h preproc.h quote.h regs.h stdscan.h tables.h tokens.h
313 quote.$(O): quote.c compiler.h nasmlib.h quote.h
314 raa.$(O): raa.c compiler.h nasmlib.h raa.h
315 rbtree.$(O): rbtree.c compiler.h rbtree.h
316 regdis.$(O): regdis.c regdis.h regs.h
317 regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
318 preproc.h regs.h tables.h
319 regs.$(O): regs.c compiler.h insnsi.h tables.h
320 regvals.$(O): regvals.c compiler.h insnsi.h tables.h
321 saa.$(O): saa.c compiler.h nasmlib.h saa.h
322 stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h pptok.h \
323 preproc.h quote.h regs.h stdscan.h tokens.h
324 strfunc.$(O): strfunc.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h \
325 preproc.h regs.h
326 sync.$(O): sync.c compiler.h nasmlib.h sync.h
327 tokhash.$(O): tokhash.c compiler.h hashtbl.h insns.h insnsi.h nasm.h \
328 nasmlib.h pptok.h preproc.h regs.h tokens.h
329 ver.$(O): ver.c compiler.h insnsi.h nasm.h nasmlib.h pptok.h preproc.h \
330 regs.h version.h