Generate a byte array instead of using strings for the byte codes
[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 NASM =  nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) assemble.$(O) \
59         labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
60         outform.$(O) output/outbin.$(O) \
61         output/outaout.$(O) output/outcoff.$(O) \
62         output/outelf32.$(O) output/outelf64.$(O) \
63         output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
64         output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
65         preproc.$(O) pptok.$(O) \
66         listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O)
67
68 NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) insnsd.$(O)
69
70 what:
71         @echo 'Please build "dos", "win32" or "os2"'
72
73 dos:
74         $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=DOS -l=DOS4G'
75
76 win32:
77         $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=NT  -l=NT'
78
79 os2:
80         $(MAKE) -f $(MAKEFILE_LIST) all TARGET_FLAGS='-bt=OS2 -l=OS2V2'
81
82 all: nasm$(X) ndisasm$(X)
83
84 nasm$(X): $(NASM)
85         $(LD) $(LDFLAGS) -fe=nasm$(X) $(NASM) $(LIBS)
86
87 ndisasm$(X): $(NDISASM)
88         $(LD) $(LDFLAGS) -fe=ndisasm$(X) $(NDISASM) $(LIBS)
89
90 # These source files are automagically generated from a single
91 # instruction-table file by a Perl script. They're distributed,
92 # though, so it isn't necessary to have Perl just to recompile NASM
93 # from the distribution.
94
95 insnsb.c: insns.dat insns.pl
96         $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat
97 insnsa.c: insns.dat insns.pl
98         $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat
99 insnsd.c: insns.dat insns.pl
100         $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat
101 insnsi.h: insns.dat insns.pl
102         $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat
103 insnsn.c: insns.dat insns.pl
104         $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat
105
106 # These files contains all the standard macros that are derived from
107 # the version number.
108 version.h: version version.pl
109         $(PERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
110
111 version.mac: version version.pl
112         $(PERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
113
114 # This source file is generated from the standard macros file
115 # `standard.mac' by another Perl script. Again, it's part of the
116 # standard distribution.
117
118 macros.c: macros.pl standard.mac version.mac
119         $(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac
120
121 # These source files are generated from regs.dat by yet another
122 # perl script.
123 regs.c: regs.dat regs.pl
124         $(PERL) $(srcdir)/regs.pl c $(srcdir)/regs.dat > regs.c
125 regflags.c: regs.dat regs.pl
126         $(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
127 regdis.c: regs.dat regs.pl
128         $(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
129 regvals.c: regs.dat regs.pl
130         $(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
131 regs.h: regs.dat regs.pl
132         $(PERL) $(srcdir)/regs.pl h $(srcdir)/regs.dat > regs.h
133
134 # Assembler token hash
135 tokhash.c: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
136         $(PERL) $(srcdir)/tokhash.pl c $(srcdir)/insns.dat $(srcdir)/regs.dat \
137                 $(srcdir)/tokens.dat > tokhash.c
138
139 # Assembler token metadata
140 tokens.h: insns.dat regs.dat tokens.dat tokhash.pl perllib/phash.ph
141         $(PERL) $(srcdir)/tokhash.pl h $(srcdir)/insns.dat $(srcdir)/regs.dat \
142                 $(srcdir)/tokens.dat > tokens.h
143
144 # Preprocessor token hash
145 pptok.h: pptok.dat pptok.pl perllib/phash.ph
146         $(PERL) $(srcdir)/pptok.pl h $(srcdir)/pptok.dat pptok.h
147 pptok.c: pptok.dat pptok.pl perllib/phash.ph
148         $(PERL) $(srcdir)/pptok.pl c $(srcdir)/pptok.dat pptok.c
149
150 # This target generates all files that require perl.
151 # This allows easier generation of distribution (see dist target).
152 PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
153           regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \
154           version.h version.mac pptok.h pptok.c
155 perlreq: $(PERLREQ)
156
157 clean:
158         -rm -f *.$(O)
159         -rm -f *.s
160         -rm -f *.i
161         -rm -f output/*.$(O)
162         -rm -f output/*.s
163         -rm -f output/*.i
164         -rm -f nasm$(X)
165         -rm -f ndisasm$(X)
166         # cd rdoff && $(MAKE) clean
167
168 distclean: clean .SYMBOLIC
169         -rm -f config.h
170         -rm -f config.log
171         -rm -f config.status
172         -rm -f Makefile
173         -rm -f *~
174         -rm -f *.bak
175         -rm -f *.lst
176         -rm -f *.bin
177         -rm -f output/*~
178         -rm -f output/*.bak
179         -rm -f test/*.lst
180         -rm -f test/*.bin
181         -rm -f test/*.$(O)
182         -rm -f test/*.bin
183         -rm -f/s autom4te*.cache
184         # cd rdoff && $(MAKE) distclean
185
186 cleaner: clean .SYMBOLIC
187         -rm -f $(PERLREQ)
188         -rm -f *.man
189         -rm -f nasm.spec
190         # cd doc && $(MAKE) clean
191
192 spotless: distclean cleaner .SYMBOLIC
193         -rm -f doc/Makefile
194         -rm -f doc/*~
195         -rm -f doc/*.bak
196
197 strip:
198         $(STRIP) *.exe
199
200 rdf:
201         # cd rdoff && $(MAKE)
202
203 doc:
204         # cd doc && $(MAKE) all
205
206 everything: all doc rdf
207
208 #-- Magic hints to mkdep.pl --#
209 # @object-ending: ".$(O)"
210 # @path-separator: "/"
211 # @exclude: "config.h"
212 # @continuation: "\"
213 #-- Everything below is generated by mkdep.pl - do not edit --#
214 assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
215  nasmlib.h pptok.h preproc.h regflags.c regs.h regvals.c tokens.h version.h
216 crc64.$(O): crc64.c compiler.h
217 disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h insnsn.c names.c \
218  nasm.h nasmlib.h regdis.c regs.c regs.h sync.h tokens.h version.h
219 eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
220  nasmlib.h regs.h version.h
221 exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
222  version.h
223 float.$(O): float.c compiler.h float.h insnsi.h nasm.h nasmlib.h regs.h \
224  version.h
225 hashtbl.$(O): hashtbl.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
226  regs.h version.h
227 insnsa.$(O): insnsa.c compiler.h insns.h insnsb.c insnsi.h nasm.h nasmlib.h \
228  regs.h tokens.h version.h
229 insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
230  tokens.h version.h
231 insnsd.$(O): insnsd.c compiler.h insns.h insnsb.c insnsi.h nasm.h nasmlib.h \
232  regs.h tokens.h version.h
233 insnsn.$(O): insnsn.c
234 labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h regs.h \
235  version.h
236 lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
237 lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
238 listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
239  regs.h version.h
240 macros.$(O): macros.c compiler.h
241 names.$(O): names.c compiler.h insnsn.c regs.c
242 nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h \
243  labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h preproc.h \
244  regs.h stdscan.h tokens.h version.h
245 nasmlib.$(O): nasmlib.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
246  tokens.h version.h
247 ndisasm.$(O): ndisasm.c compiler.h disasm.h insns.h insnsi.h nasm.h \
248  nasmlib.h regs.h sync.h tokens.h version.h
249 outform.$(O): outform.c compiler.h insnsi.h nasm.h nasmlib.h outform.h \
250  regs.h version.h
251 output/outaout.$(O): output/outaout.c compiler.h insnsi.h nasm.h nasmlib.h \
252  outform.h regs.h stdscan.h version.h
253 output/outas86.$(O): output/outas86.c compiler.h insnsi.h nasm.h nasmlib.h \
254  outform.h regs.h version.h
255 output/outbin.$(O): output/outbin.c compiler.h eval.h insnsi.h labels.h \
256  nasm.h nasmlib.h outform.h regs.h stdscan.h version.h
257 output/outcoff.$(O): output/outcoff.c compiler.h insnsi.h nasm.h nasmlib.h \
258  outform.h regs.h version.h
259 output/outdbg.$(O): output/outdbg.c compiler.h insnsi.h nasm.h nasmlib.h \
260  outform.h regs.h version.h
261 output/outelf32.$(O): output/outelf32.c compiler.h insnsi.h nasm.h nasmlib.h \
262  outform.h regs.h stdscan.h version.h wsaa.h
263 output/outelf64.$(O): output/outelf64.c compiler.h insnsi.h nasm.h nasmlib.h \
264  outform.h regs.h stdscan.h version.h wsaa.h
265 output/outieee.$(O): output/outieee.c compiler.h insnsi.h nasm.h nasmlib.h \
266  outform.h regs.h version.h
267 output/outmacho.$(O): output/outmacho.c compiler.h insnsi.h nasm.h nasmlib.h \
268  outform.h regs.h version.h
269 output/outobj.$(O): output/outobj.c compiler.h insnsi.h nasm.h nasmlib.h \
270  outform.h regs.h stdscan.h version.h
271 output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
272  outform.h regs.h version.h
273 output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
274  outform.h rdoff/rdoff.h regs.h version.h
275 parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
276  parser.h regflags.c regs.h stdscan.h tokens.h version.h
277 pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
278 preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h macros.c nasm.h \
279  nasmlib.h pptok.h preproc.h regs.h stdscan.h tokens.h version.h
280 regdis.$(O): regdis.c
281 regflags.$(O): regflags.c
282 regs.$(O): regs.c compiler.h
283 regvals.$(O): regvals.c
284 stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
285  stdscan.h tokens.h version.h
286 sync.$(O): sync.c compiler.h nasmlib.h sync.h
287 tokhash.$(O): tokhash.c compiler.h hashtbl.h insns.h insnsi.h nasm.h \
288  nasmlib.h regs.h tokens.h version.h