Run "make alldeps" to update dependencies
[platform/upstream/nasm.git] / Mkfiles / openwcom.mak
1 # -*- makefile -*-
2 #
3 # Makefile for building NASM using OpenWatcom
4 # cross-compile on a DOS/Win32/OS2/Linux platform host
5 #
6
7 top_srcdir  = .
8 srcdir      = .
9 VPATH       = .;$(srcdir)/output;$(srcdir)/lib
10 prefix      = C:\Program Files\NASM
11 exec_prefix = $(prefix)
12 bindir      = $(prefix)\bin
13 mandir      = $(prefix)\man
14
15 CC      = *wcl386
16 DEBUG       =
17 CFLAGS      = -zq -6 -ox -wx -ze -fpi $(DEBUG)
18 BUILD_CFLAGS    = $(CFLAGS) $(%TARGET_CFLAGS)
19 INTERNAL_CFLAGS = -I$(srcdir) -I. -DHAVE_CONFIG_H
20 ALL_CFLAGS  = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
21 LD      = *wlink
22 LDEBUG      =
23 LDFLAGS     = op quiet $(%TARGET_LFLAGS) $(LDEBUG)
24 LIBS        =
25 PERL        = perl -I$(srcdir)/perllib
26
27 STRIP       = wstrip
28
29 # Binary suffixes
30 O               = obj
31 X               = .exe
32
33 # WMAKE errors out if a suffix is declared more than once, including
34 # its own built-in declarations.  Thus, we need to explicitly clear the list
35 # first.  Also, WMAKE only allows implicit rules that point "to the left"
36 # in this list!
37 .SUFFIXES:
38 .SUFFIXES: .man .1 .$(O) .i .c
39
40 # Needed to find C files anywhere but in the current directory
41 .c : $(VPATH)
42
43 .c.$(O):
44     @set INCLUDE=
45     $(CC) -c $(ALL_CFLAGS) -fo=$^@ $[@
46
47 #-- Begin File Lists --#
48 # Edit in Makefile.in, not here!
49 NASM =  nasm.$(O) nasmlib.$(O) ver.$(O) &
50         raa.$(O) saa.$(O) rbtree.$(O) &
51         float.$(O) insnsa.$(O) insnsb.$(O) &
52         directiv.$(O) &
53         assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) &
54         output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) &
55         output/nullout.$(O) &
56         output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) &
57         output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) &
58         output/outelfx32.$(O) &
59         output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) &
60         output/outdbg.$(O) output/outieee.$(O) output/outmac32.$(O) &
61         output/outmac64.$(O) preproc.$(O) quote.$(O) pptok.$(O) &
62         macros.$(O) listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) &
63         strfunc.$(O) tokhash.$(O) regvals.$(O) regflags.$(O) &
64         ilog2.$(O) &
65         lib/strlcpy.$(O) &
66         preproc-nop.$(O)
67
68 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) &
69         insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
70 #-- End File Lists --#
71
72 what:   .SYMBOLIC
73     @echo Please build "dos", "win32", "os2" or "linux386"
74
75 dos:    .SYMBOLIC
76     @set TARGET_CFLAGS=-bt=DOS -I"$(%WATCOM)/h"
77     @set TARGET_LFLAGS=sys causeway
78     @%make all
79
80 win32:  .SYMBOLIC
81     @set TARGET_CFLAGS=-bt=NT -I"$(%WATCOM)/h" -I"$(%WATCOM)/h/nt"
82     @set TARGET_LFLAGS=sys nt
83     @%make all
84
85 os2:    .SYMBOLIC
86     @set TARGET_CFLAGS=-bt=OS2 -I"$(%WATCOM)/h" -I"$(%WATCOM)/h/os2"
87     @set TARGET_LFLAGS=sys os2v2
88     @%make all
89
90 linux386:   .SYMBOLIC
91     @set TARGET_CFLAGS=-bt=LINUX -I"$(%WATCOM)/lh"
92     @set TARGET_LFLAGS=sys linux
93     @%make all
94
95 all: config.h perlreq nasm$(X) ndisasm$(X) .SYMBOLIC
96 #   cd rdoff && $(MAKE) all
97
98 nasm$(X): $(NASM)
99     $(LD) $(LDFLAGS) name nasm$(X) file {$(NASM)} $(LIBS)
100
101 ndisasm$(X): $(NDISASM)
102     $(LD) $(LDFLAGS) name ndisasm$(X) file {$(NDISASM)} $(LIBS)
103
104 # These source files are automagically generated from a single
105 # instruction-table file by a Perl script. They're distributed,
106 # though, so it isn't necessary to have Perl just to recompile NASM
107 # from the distribution.
108
109 insnsb.c: insns.dat insns.pl
110     $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat
111 insnsa.c: insns.dat insns.pl
112     $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat
113 insnsd.c: insns.dat insns.pl
114     $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat
115 insnsi.h: insns.dat insns.pl
116     $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat
117 insnsn.c: insns.dat insns.pl
118     $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat
119
120 # These files contains all the standard macros that are derived from
121 # the version number.
122 version.h: version version.pl
123     $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
124
125 version.mac: version version.pl
126     $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
127
128 # This source file is generated from the standard macros file
129 # `standard.mac' by another Perl script. Again, it's part of the
130 # standard distribution.
131
132 macros.c: macros.pl standard.mac version.mac macros/*.mac output/*.mac
133     $(PERL) $<
134
135 # These source files are generated from regs.dat by yet another
136 # perl script.
137 regs.c: regs.dat regs.pl
138     $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c
139 regflags.c: regs.dat regs.pl
140     $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
141 regdis.c: regs.dat regs.pl
142     $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
143 regdis.h: regs.dat regs.pl
144     $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h
145 regvals.c: regs.dat regs.pl
146     $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
147 regs.h: regs.dat regs.pl
148     $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h
149
150 # Assembler token hash
151 tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
152     $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat &
153         $(srcdir)/tokens.dat > tokhash.c
154
155 # Assembler token metadata
156 tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
157     $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat &
158         $(srcdir)/tokens.dat > tokens.h
159
160 # Preprocessor token hash
161 pptok.h: pptok.dat pptok.pl perllib/phash.ph
162     $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h
163 pptok.c: pptok.dat pptok.pl perllib/phash.ph
164     $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c
165 pptok.ph: pptok.dat pptok.pl perllib/phash.ph
166     $(PERL) $(srcdir)/pptok.pl ph $(srcdir)/pptok.dat pptok.ph
167
168 # Directives hash
169 directiv.h: directiv.dat directiv.pl perllib/phash.ph
170     $(PERL) $(srcdir)/directiv.pl h $(srcdir)/directiv.dat directiv.h
171 directiv.c: directiv.dat directiv.pl perllib/phash.ph
172     $(PERL) $(srcdir)/directiv.pl c $(srcdir)/directiv.dat directiv.c
173
174 # This target generates all files that require perl.
175 # This allows easier generation of distribution (see dist target).
176 PERLREQ = pptok.ph macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c &
177       regs.c regs.h regflags.c regdis.c regdis.h regvals.c &
178       tokhash.c tokens.h pptok.h pptok.c &
179       directiv.c directiv.h &
180       version.h version.mac
181 perlreq: $(PERLREQ) .SYMBOLIC
182
183 clean: .SYMBOLIC
184     rm -f *.$(O) *.s *.i
185     rm -f lib/*.$(O) lib/*.s lib/*.i
186     rm -f output/*.$(O) output/*.s output/*.i
187     rm -f config.h config.log config.status
188     rm -f nasm$(X) ndisasm$(X)
189 #   cd rdoff && $(MAKE) clean
190
191 distclean: clean .SYMBOLIC
192     rm -f config.h config.log config.status
193     rm -f Makefile *~ *.bak *.lst *.bin
194     rm -f output/*~ output/*.bak
195     rm -f test/*.lst test/*.bin test/*.$(O) test/*.bin
196 #   -del /s autom4te*.cache
197 #   cd rdoff && $(MAKE) distclean
198
199 cleaner: clean .SYMBOLIC
200     rm -f $(PERLREQ)
201     rm -f *.man
202     rm -f nasm.spec
203 #   cd doc && $(MAKE) clean
204
205 spotless: distclean cleaner .SYMBOLIC
206     rm -f doc/Makefile doc/*~ doc/*.bak
207
208 strip: .SYMBOLIC
209     $(STRIP) *.exe
210
211 rdf:
212 #   cd rdoff && $(MAKE)
213
214 doc:
215 #   cd doc && $(MAKE) all
216
217 everything: all doc rdf
218
219 config.h: Mkfiles/openwcom.mak
220     @echo Creating $@
221     @%create $@
222     @%append $@ $#define HAVE_DECL_STRCASECMP 1
223     @%append $@ $#define HAVE_DECL_STRICMP 1
224     @%append $@ $#define HAVE_DECL_STRLCPY 1
225     @%append $@ $#define HAVE_DECL_STRNCASECMP 1
226     @%append $@ $#define HAVE_DECL_STRNICMP 1
227     @%append $@ $#define HAVE_INTTYPES_H 1
228     @%append $@ $#define HAVE_LIMITS_H 1
229     @%append $@ $#define HAVE_MEMORY_H 1
230     @%append $@ $#define HAVE_SNPRINTF 1
231     @%append $@ $#define HAVE_STDBOOL_H 1
232     @%append $@ $#define HAVE_STDINT_H 1
233     @%append $@ $#define HAVE_STDLIB_H 1
234     @%append $@ $#define HAVE_STRCASECMP 1
235     @%append $@ $#define HAVE_STRCSPN 1
236     @%append $@ $#define HAVE_STRICMP 1
237     @%append $@ $#define HAVE_STRINGS_H 1
238     @%append $@ $#define HAVE_STRING_H 1
239     @%append $@ $#define HAVE_STRLCPY 1
240     @%append $@ $#define HAVE_STRNCASECMP 1
241     @%append $@ $#define HAVE_STRNICMP 1
242     @%append $@ $#define HAVE_STRSPN 1
243     @%append $@ $#define HAVE_SYS_STAT_H 1
244     @%append $@ $#define HAVE_SYS_TYPES_H 1
245     @%append $@ $#define HAVE_UNISTD_H 1
246     @%append $@ $#define HAVE_VSNPRINTF 1
247     @%append $@ $#define STDC_HEADERS 1
248
249 #
250 # This build dependencies in *ALL* makefiles.  Partially for that reason,
251 # it's expected to be invoked manually.
252 #
253 alldeps: perlreq .SYMBOLIC
254     $(PERL) syncfiles.pl Makefile.in Mkfiles/openwcom.mak
255     $(PERL) mkdep.pl -M Makefile.in Mkfiles/openwcom.mak -- . output lib
256
257 #-- Magic hints to mkdep.pl --#
258 # @object-ending: ".$(O)"
259 # @path-separator: "/"
260 # @exclude: ""
261 # @continuation: "&"
262 #-- Everything below is generated by mkdep.pl - do not edit --#
263 assemble.$(O): assemble.c assemble.h compiler.h config.h directiv.h insns.h &
264  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h &
265  tokens.h
266 crc64.$(O): crc64.c compiler.h config.h nasmlib.h
267 directiv.$(O): directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
268  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
269 disasm.$(O): disasm.c compiler.h config.h directiv.h disasm.h insns.h &
270  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regdis.h regs.h &
271  sync.h tables.h tokens.h
272 eval.$(O): eval.c compiler.h config.h directiv.h eval.h float.h insnsi.h &
273  labels.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
274 exprlib.$(O): exprlib.c compiler.h config.h directiv.h insnsi.h nasm.h &
275  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
276 float.$(O): float.c compiler.h config.h directiv.h float.h insnsi.h nasm.h &
277  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
278 hashtbl.$(O): hashtbl.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
279  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
280 ilog2.$(O): ilog2.c compiler.h config.h nasmlib.h
281 insnsa.$(O): insnsa.c compiler.h config.h directiv.h insns.h insnsi.h nasm.h &
282  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
283 insnsb.$(O): insnsb.c compiler.h config.h directiv.h insns.h insnsi.h nasm.h &
284  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
285 insnsd.$(O): insnsd.c compiler.h config.h directiv.h insns.h insnsi.h nasm.h &
286  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
287 insnsn.$(O): insnsn.c compiler.h config.h insnsi.h tables.h
288 labels.$(O): labels.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
289  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
290 lib/snprintf.$(O): lib/snprintf.c compiler.h config.h nasmlib.h
291 lib/strlcpy.$(O): lib/strlcpy.c compiler.h config.h
292 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h config.h nasmlib.h
293 listing.$(O): listing.c compiler.h config.h directiv.h insnsi.h listing.h &
294  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
295 macros.$(O): macros.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
296  nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h &
297  tables.h
298 nasm.$(O): nasm.c assemble.h compiler.h config.h directiv.h eval.h float.h &
299  insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h opflags.h &
300  output/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h &
301  tables.h tokens.h
302 nasmlib.$(O): nasmlib.c compiler.h config.h directiv.h insns.h insnsi.h &
303  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h tokens.h
304 ndisasm.$(O): ndisasm.c compiler.h config.h directiv.h disasm.h insns.h &
305  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h sync.h &
306  tables.h tokens.h
307 output/nulldbg.$(O): output/nulldbg.c compiler.h config.h directiv.h &
308  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
309 output/nullout.$(O): output/nullout.c compiler.h config.h directiv.h &
310  insnsi.h nasm.h nasmlib.h opflags.h output/outlib.h pptok.h preproc.h &
311  regs.h tables.h
312 output/outaout.$(O): output/outaout.c compiler.h config.h directiv.h eval.h &
313  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
314  pptok.h preproc.h raa.h regs.h saa.h stdscan.h tables.h
315 output/outas86.$(O): output/outas86.c compiler.h config.h directiv.h &
316  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
317  pptok.h preproc.h raa.h regs.h saa.h tables.h
318 output/outbin.$(O): output/outbin.c compiler.h config.h directiv.h eval.h &
319  insnsi.h labels.h nasm.h nasmlib.h opflags.h output/outform.h &
320  output/outlib.h pptok.h preproc.h regs.h saa.h stdscan.h tables.h
321 output/outcoff.$(O): output/outcoff.c compiler.h config.h directiv.h eval.h &
322  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
323  output/pecoff.h pptok.h preproc.h raa.h regs.h saa.h tables.h
324 output/outdbg.$(O): output/outdbg.c compiler.h config.h directiv.h insnsi.h &
325  nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h &
326  tables.h
327 output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h insnsi.h &
328  nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h output/outelf.h &
329  output/outform.h pptok.h preproc.h regs.h tables.h
330 output/outelf32.$(O): output/outelf32.c compiler.h config.h directiv.h &
331  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
332  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
333  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h
334 output/outelf64.$(O): output/outelf64.c compiler.h config.h directiv.h &
335  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
336  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
337  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h
338 output/outelfx32.$(O): output/outelfx32.c compiler.h config.h directiv.h &
339  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
340  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
341  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h
342 output/outform.$(O): output/outform.c compiler.h config.h directiv.h &
343  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h &
344  regs.h tables.h
345 output/outieee.$(O): output/outieee.c compiler.h config.h directiv.h &
346  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
347  pptok.h preproc.h regs.h tables.h
348 output/outlib.$(O): output/outlib.c compiler.h config.h directiv.h insnsi.h &
349  nasm.h nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h &
350  tables.h
351 output/outmac32.$(O): output/outmac32.c compiler.h config.h directiv.h &
352  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
353  pptok.h preproc.h raa.h regs.h saa.h tables.h
354 output/outmac64.$(O): output/outmac64.c compiler.h config.h directiv.h &
355  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
356  pptok.h preproc.h raa.h regs.h saa.h tables.h
357 output/outobj.$(O): output/outobj.c compiler.h config.h directiv.h eval.h &
358  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
359  pptok.h preproc.h regs.h stdscan.h tables.h
360 output/outrdf2.$(O): output/outrdf2.c compiler.h config.h directiv.h &
361  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
362  pptok.h preproc.h rdoff/rdoff.h regs.h saa.h tables.h
363 parser.$(O): parser.c compiler.h config.h directiv.h eval.h float.h insns.h &
364  insnsi.h nasm.h nasmlib.h opflags.h parser.h pptok.h preproc.h regs.h &
365  stdscan.h tables.h tokens.h
366 pptok.$(O): pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h &
367  preproc.h
368 preproc-nop.$(O): preproc-nop.c compiler.h config.h directiv.h insnsi.h &
369  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
370 preproc.$(O): preproc.c compiler.h config.h directiv.h eval.h hashtbl.h &
371  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h &
372  stdscan.h tables.h tokens.h
373 quote.$(O): quote.c compiler.h config.h nasmlib.h quote.h
374 raa.$(O): raa.c compiler.h config.h nasmlib.h raa.h
375 rbtree.$(O): rbtree.c compiler.h config.h rbtree.h
376 regdis.$(O): regdis.c regdis.h regs.h
377 regflags.$(O): regflags.c compiler.h config.h directiv.h insnsi.h nasm.h &
378  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
379 regs.$(O): regs.c compiler.h config.h insnsi.h tables.h
380 regvals.$(O): regvals.c compiler.h config.h insnsi.h tables.h
381 saa.$(O): saa.c compiler.h config.h nasmlib.h saa.h
382 stdscan.$(O): stdscan.c compiler.h config.h directiv.h insns.h insnsi.h &
383  nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h &
384  tables.h tokens.h
385 strfunc.$(O): strfunc.c compiler.h config.h directiv.h insnsi.h nasm.h &
386  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
387 sync.$(O): sync.c compiler.h config.h nasmlib.h sync.h
388 tokhash.$(O): tokhash.c compiler.h config.h directiv.h hashtbl.h insns.h &
389  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h &
390  tokens.h
391 ver.$(O): ver.c compiler.h config.h directiv.h insnsi.h nasm.h nasmlib.h &
392  opflags.h pptok.h preproc.h regs.h tables.h version.h