backend: add support for x32 ELF
[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
67 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) &
68         insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
69 #-- End File Lists --#
70
71 what:   .SYMBOLIC
72     @echo Please build "dos", "win32", "os2" or "linux386"
73
74 dos:    .SYMBOLIC
75     @set TARGET_CFLAGS=-bt=DOS -I"$(%WATCOM)/h"
76     @set TARGET_LFLAGS=sys causeway
77     @%make all
78
79 win32:  .SYMBOLIC
80     @set TARGET_CFLAGS=-bt=NT -I"$(%WATCOM)/h" -I"$(%WATCOM)/h/nt"
81     @set TARGET_LFLAGS=sys nt
82     @%make all
83
84 os2:    .SYMBOLIC
85     @set TARGET_CFLAGS=-bt=OS2 -I"$(%WATCOM)/h" -I"$(%WATCOM)/h/os2"
86     @set TARGET_LFLAGS=sys os2v2
87     @%make all
88
89 linux386:   .SYMBOLIC
90     @set TARGET_CFLAGS=-bt=LINUX -I"$(%WATCOM)/lh"
91     @set TARGET_LFLAGS=sys linux
92     @%make all
93
94 all: config.h perlreq nasm$(X) ndisasm$(X) .SYMBOLIC
95 #   cd rdoff && $(MAKE) all
96
97 nasm$(X): $(NASM)
98     $(LD) $(LDFLAGS) name nasm$(X) file {$(NASM)} $(LIBS)
99
100 ndisasm$(X): $(NDISASM)
101     $(LD) $(LDFLAGS) name ndisasm$(X) file {$(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 macros/*.mac output/*.mac
132     $(PERL) $<
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 pptok.ph: pptok.dat pptok.pl perllib/phash.ph
165     $(PERL) $(srcdir)/pptok.pl ph $(srcdir)/pptok.dat pptok.ph
166
167 # Directives hash
168 directiv.h: directiv.dat directiv.pl perllib/phash.ph
169     $(PERL) $(srcdir)/directiv.pl h $(srcdir)/directiv.dat directiv.h
170 directiv.c: directiv.dat directiv.pl perllib/phash.ph
171     $(PERL) $(srcdir)/directiv.pl c $(srcdir)/directiv.dat directiv.c
172
173 # This target generates all files that require perl.
174 # This allows easier generation of distribution (see dist target).
175 PERLREQ = pptok.ph macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c &
176       regs.c regs.h regflags.c regdis.c regdis.h regvals.c &
177       tokhash.c tokens.h pptok.h pptok.c &
178       directiv.c directiv.h &
179       version.h version.mac
180 perlreq: $(PERLREQ) .SYMBOLIC
181
182 clean: .SYMBOLIC
183     rm -f *.$(O) *.s *.i
184     rm -f lib/*.$(O) lib/*.s lib/*.i
185     rm -f output/*.$(O) output/*.s output/*.i
186     rm -f config.h config.log config.status
187     rm -f nasm$(X) ndisasm$(X)
188 #   cd rdoff && $(MAKE) clean
189
190 distclean: clean .SYMBOLIC
191     rm -f config.h config.log config.status
192     rm -f Makefile *~ *.bak *.lst *.bin
193     rm -f output/*~ output/*.bak
194     rm -f test/*.lst test/*.bin test/*.$(O) test/*.bin
195 #   -del /s autom4te*.cache
196 #   cd rdoff && $(MAKE) distclean
197
198 cleaner: clean .SYMBOLIC
199     rm -f $(PERLREQ)
200     rm -f *.man
201     rm -f nasm.spec
202 #   cd doc && $(MAKE) clean
203
204 spotless: distclean cleaner .SYMBOLIC
205     rm -f doc/Makefile doc/*~ doc/*.bak
206
207 strip: .SYMBOLIC
208     $(STRIP) *.exe
209
210 rdf:
211 #   cd rdoff && $(MAKE)
212
213 doc:
214 #   cd doc && $(MAKE) all
215
216 everything: all doc rdf
217
218 config.h: Mkfiles/openwcom.mak
219     @echo Creating $@
220     @%create $@
221     @%append $@ $#define HAVE_DECL_STRCASECMP 1
222     @%append $@ $#define HAVE_DECL_STRICMP 1
223     @%append $@ $#define HAVE_DECL_STRLCPY 1
224     @%append $@ $#define HAVE_DECL_STRNCASECMP 1
225     @%append $@ $#define HAVE_DECL_STRNICMP 1
226     @%append $@ $#define HAVE_INTTYPES_H 1
227     @%append $@ $#define HAVE_LIMITS_H 1
228     @%append $@ $#define HAVE_MEMORY_H 1
229     @%append $@ $#define HAVE_SNPRINTF 1
230     @%append $@ $#define HAVE_STDBOOL_H 1
231     @%append $@ $#define HAVE_STDINT_H 1
232     @%append $@ $#define HAVE_STDLIB_H 1
233     @%append $@ $#define HAVE_STRCASECMP 1
234     @%append $@ $#define HAVE_STRCSPN 1
235     @%append $@ $#define HAVE_STRICMP 1
236     @%append $@ $#define HAVE_STRINGS_H 1
237     @%append $@ $#define HAVE_STRING_H 1
238     @%append $@ $#define HAVE_STRLCPY 1
239     @%append $@ $#define HAVE_STRNCASECMP 1
240     @%append $@ $#define HAVE_STRNICMP 1
241     @%append $@ $#define HAVE_STRSPN 1
242     @%append $@ $#define HAVE_SYS_STAT_H 1
243     @%append $@ $#define HAVE_SYS_TYPES_H 1
244     @%append $@ $#define HAVE_UNISTD_H 1
245     @%append $@ $#define HAVE_VSNPRINTF 1
246     @%append $@ $#define STDC_HEADERS 1
247
248 #
249 # This build dependencies in *ALL* makefiles.  Partially for that reason,
250 # it's expected to be invoked manually.
251 #
252 alldeps: perlreq .SYMBOLIC
253     $(PERL) syncfiles.pl Makefile.in Mkfiles/openwcom.mak
254     $(PERL) mkdep.pl -M Makefile.in Mkfiles/openwcom.mak -- . output lib
255
256 #-- Magic hints to mkdep.pl --#
257 # @object-ending: ".$(O)"
258 # @path-separator: "/"
259 # @exclude: ""
260 # @continuation: "&"
261 #-- Everything below is generated by mkdep.pl - do not edit --#
262 assemble.$(O): assemble.c assemble.h compiler.h config.h directiv.h insns.h &
263  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h &
264  tokens.h
265 crc64.$(O): crc64.c compiler.h config.h nasmlib.h
266 directiv.$(O): directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
267  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
268 disasm.$(O): disasm.c compiler.h config.h directiv.h disasm.h insns.h &
269  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regdis.h regs.h &
270  sync.h tables.h tokens.h
271 eval.$(O): eval.c compiler.h config.h directiv.h eval.h float.h insnsi.h &
272  labels.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
273 exprlib.$(O): exprlib.c compiler.h config.h directiv.h insnsi.h nasm.h &
274  nasmlib.h opflags.h pptok.h preproc.h regs.h
275 float.$(O): float.c compiler.h config.h directiv.h float.h insnsi.h nasm.h &
276  nasmlib.h opflags.h pptok.h preproc.h regs.h
277 hashtbl.$(O): hashtbl.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
278  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
279 ilog2.$(O): ilog2.c compiler.h config.h nasmlib.h
280 insnsa.$(O): insnsa.c compiler.h config.h directiv.h insns.h insnsi.h nasm.h &
281  nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
282 insnsb.$(O): insnsb.c compiler.h config.h directiv.h insns.h insnsi.h nasm.h &
283  nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
284 insnsd.$(O): insnsd.c compiler.h config.h directiv.h insns.h insnsi.h nasm.h &
285  nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
286 insnsn.$(O): insnsn.c compiler.h config.h insnsi.h opflags.h tables.h
287 labels.$(O): labels.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
288  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
289 lib/snprintf.$(O): lib/snprintf.c compiler.h config.h nasmlib.h
290 lib/strlcpy.$(O): lib/strlcpy.c compiler.h config.h
291 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h config.h nasmlib.h
292 listing.$(O): listing.c compiler.h config.h directiv.h insnsi.h listing.h &
293  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
294 macros.$(O): macros.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
295  nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h &
296  tables.h
297 nasm.$(O): nasm.c assemble.h compiler.h config.h directiv.h eval.h float.h &
298  insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h opflags.h &
299  output/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h &
300  tokens.h
301 nasmlib.$(O): nasmlib.c compiler.h config.h directiv.h insns.h insnsi.h &
302  nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
303 ndisasm.$(O): ndisasm.c compiler.h config.h directiv.h disasm.h insns.h &
304  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h sync.h &
305  tokens.h
306 output/nulldbg.$(O): output/nulldbg.c compiler.h config.h directiv.h &
307  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h
308 output/nullout.$(O): output/nullout.c compiler.h config.h directiv.h &
309  insnsi.h nasm.h nasmlib.h opflags.h output/outlib.h pptok.h preproc.h &
310  regs.h
311 output/outaout.$(O): output/outaout.c compiler.h config.h directiv.h eval.h &
312  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
313  pptok.h preproc.h raa.h regs.h saa.h stdscan.h
314 output/outas86.$(O): output/outas86.c compiler.h config.h directiv.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
317 output/outbin.$(O): output/outbin.c compiler.h config.h directiv.h eval.h &
318  insnsi.h labels.h nasm.h nasmlib.h opflags.h output/outform.h &
319  output/outlib.h pptok.h preproc.h regs.h saa.h stdscan.h
320 output/outcoff.$(O): output/outcoff.c compiler.h config.h directiv.h eval.h &
321  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
322  output/pecoff.h pptok.h preproc.h raa.h regs.h saa.h
323 output/outdbg.$(O): output/outdbg.c compiler.h config.h directiv.h insnsi.h &
324  nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h
325 output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h insnsi.h &
326  nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h output/outelf.h &
327  output/outform.h pptok.h preproc.h regs.h
328 output/outelf32.$(O): output/outelf32.c compiler.h config.h directiv.h &
329  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
330  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
331  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
332 output/outelf64.$(O): output/outelf64.c compiler.h config.h directiv.h &
333  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
334  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
335  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
336 output/outelfx32.$(O): output/outelfx32.c compiler.h config.h directiv.h &
337  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/dwarf.h output/elf.h &
338  output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h &
339  preproc.h raa.h rbtree.h regs.h saa.h stdscan.h
340 output/outform.$(O): output/outform.c compiler.h config.h directiv.h &
341  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h &
342  regs.h
343 output/outieee.$(O): output/outieee.c compiler.h config.h directiv.h &
344  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
345  pptok.h preproc.h regs.h
346 output/outlib.$(O): output/outlib.c compiler.h config.h directiv.h insnsi.h &
347  nasm.h nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h
348 output/outmac32.$(O): output/outmac32.c compiler.h config.h directiv.h &
349  eval.h insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
350  pptok.h preproc.h raa.h regs.h saa.h
351 output/outmac64.$(O): output/outmac64.c compiler.h config.h directiv.h &
352  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
354 output/outobj.$(O): output/outobj.c compiler.h config.h directiv.h eval.h &
355  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
356  pptok.h preproc.h regs.h stdscan.h
357 output/outrdf2.$(O): output/outrdf2.c compiler.h config.h directiv.h &
358  insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
359  pptok.h preproc.h rdoff/rdoff.h regs.h saa.h
360 parser.$(O): parser.c compiler.h config.h directiv.h eval.h float.h insns.h &
361  insnsi.h nasm.h nasmlib.h opflags.h parser.h pptok.h preproc.h regs.h &
362  stdscan.h tables.h tokens.h
363 pptok.$(O): pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h &
364  preproc.h
365 preproc.$(O): preproc.c compiler.h config.h directiv.h eval.h hashtbl.h &
366  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h &
367  stdscan.h tables.h tokens.h
368 quote.$(O): quote.c compiler.h config.h nasmlib.h quote.h
369 raa.$(O): raa.c compiler.h config.h nasmlib.h raa.h
370 rbtree.$(O): rbtree.c compiler.h config.h rbtree.h
371 regdis.$(O): regdis.c regdis.h regs.h
372 regflags.$(O): regflags.c compiler.h config.h directiv.h insnsi.h nasm.h &
373  nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
374 regs.$(O): regs.c compiler.h config.h insnsi.h opflags.h tables.h
375 regvals.$(O): regvals.c compiler.h config.h insnsi.h opflags.h tables.h
376 saa.$(O): saa.c compiler.h config.h nasmlib.h saa.h
377 stdscan.$(O): stdscan.c compiler.h config.h directiv.h insns.h insnsi.h &
378  nasm.h nasmlib.h opflags.h pptok.h preproc.h quote.h regs.h stdscan.h &
379  tokens.h
380 strfunc.$(O): strfunc.c compiler.h config.h directiv.h insnsi.h nasm.h &
381  nasmlib.h opflags.h pptok.h preproc.h regs.h
382 sync.$(O): sync.c compiler.h config.h nasmlib.h sync.h
383 tokhash.$(O): tokhash.c compiler.h config.h directiv.h hashtbl.h insns.h &
384  insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tokens.h
385 ver.$(O): ver.c compiler.h config.h directiv.h insnsi.h nasm.h nasmlib.h &
386  opflags.h pptok.h preproc.h regs.h version.h