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
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.
25 prefix = C
:/Program Files
/NASM
26 exec_prefix = $(prefix)
27 bindir = $(prefix)/bin
28 mandir = $(prefix)/man
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
)
38 LDFLAGS
= $(ALL_CFLAGS
)
40 PERL
= perl
-I
$(srcdir)/perllib
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"
53 .SUFFIXES
: .man
.1 .
$(O
) .i .c
56 $(CC
) -c
$(ALL_CFLAGS
) -fo
=$@
$<
58 #-- Begin File Lists --#
59 # Edit in Makefile.in, not here!
61 raa.
$(O
) saa.
$(O
) rbtree.
$(O
) \
62 float.
$(O
) insnsa.
$(O
) insnsb.
$(O
) \
64 assemble.
$(O
) labels.
$(O
) hashtbl.
$(O
) parser.
$(O
) \
65 output
/outform.
$(O
) output
/outlib.
$(O
) output
/nulldbg.
$(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
/outmacho.
$(O
) \
72 output
/codeview.
$(O
) \
73 preproc.
$(O
) quote.
$(O
) pptok.
$(O
) \
74 macros.
$(O
) listing.
$(O
) eval.
$(O
) exprlib.
$(O
) stdscan.
$(O
) \
75 strfunc.
$(O
) tokhash.
$(O
) regvals.
$(O
) regflags.
$(O
) \
80 NDISASM
= ndisasm.
$(O
) disasm.
$(O
) sync.
$(O
) \
81 insnsd.
$(O
) insnsb.
$(O
) insnsn.
$(O
) regs.
$(O
) regdis.
$(O
) \
84 LIBOBJ
= stdlib
/snprintf.
$(O
) stdlib
/vsnprintf.
$(O
) stdlib
/strlcpy.
$(O
) \
85 nasmlib
/nasmlib.
$(O
) nasmlib
/ver.
$(O
) \
86 nasmlib
/file.
$(O
) nasmlib
/realpath.
$(O
) \
87 nasmlib
/ilog2.
$(O
) nasmlib
/md5c.
$(O
) nasmlib
/crc64.
$(O
)
88 #-- End File Lists --#
91 @echo
'Please build "dos", "win32" or "os2"'
94 $(MAKE
) -f
$(MAKEFILE_LIST
) all TARGET_FLAGS
='-bt=DOS -l=DOS4G'
97 $(MAKE
) -f
$(MAKEFILE_LIST
) all TARGET_FLAGS
='-bt=NT -l=NT'
100 $(MAKE
) -f
$(MAKEFILE_LIST
) all TARGET_FLAGS
='-bt=OS2 -l=OS2V2'
102 all: nasm
$(X
) ndisasm
$(X
)
105 $(LD
) $(LDFLAGS
) -fe
=nasm
$(X
) $(NASM
) $(LIBS
)
107 ndisasm
$(X
): $(NDISASM
)
108 $(LD
) $(LDFLAGS
) -fe
=ndisasm
$(X
) $(NDISASM
) $(LIBS
)
110 # These source files are automagically generated from a single
111 # instruction-table file by a Perl script. They're distributed,
112 # though, so it isn't necessary to have Perl just to recompile NASM
113 # from the distribution.
115 insns.pl
: insns-iflags.pl
117 iflag.c iflag.h
: insns.dat insns.pl
118 $(PERL
) $(srcdir)/insns.pl
-t
$(srcdir)/insns.dat
119 insnsb.c
: insns.dat insns.pl
120 $(PERL
) $(srcdir)/insns.pl
-b
$(srcdir)/insns.dat
121 insnsa.c
: insns.dat insns.pl
122 $(PERL
) $(srcdir)/insns.pl
-a
$(srcdir)/insns.dat
123 insnsd.c
: insns.dat insns.pl
124 $(PERL
) $(srcdir)/insns.pl
-d
$(srcdir)/insns.dat
125 insnsi.h
: insns.dat insns.pl
126 $(PERL
) $(srcdir)/insns.pl
-i
$(srcdir)/insns.dat
127 insnsn.c
: insns.dat insns.pl
128 $(PERL
) $(srcdir)/insns.pl
-n
$(srcdir)/insns.dat
130 # These files contains all the standard macros that are derived from
131 # the version number.
132 version.h
: version version.pl
133 $(PERL
) $(srcdir)/version.pl h
< $(srcdir)/version
> version.h
135 version.mac
: version version.pl
136 $(PERL
) $(srcdir)/version.pl mac
< $(srcdir)/version
> version.mac
138 # This source file is generated from the standard macros file
139 # `standard.mac' by another Perl script. Again, it's part of the
140 # standard distribution.
142 macros.c
: macros.pl standard.mac version.mac
143 $(PERL
) $(srcdir)/macros.pl
$(srcdir)/standard.mac version.mac
145 # These source files are generated from regs.dat by yet another
147 regs.c
: regs.dat regs.pl
148 $(PERL
) $(srcdir)/regs.pl c
$(srcdir)/regs.dat
> regs.c
149 regflags.c
: regs.dat regs.pl
150 $(PERL
) $(srcdir)/regs.pl
fc $(srcdir)/regs.dat
> regflags.c
151 regdis.c
: regs.dat regs.pl
152 $(PERL
) $(srcdir)/regs.pl dc
$(srcdir)/regs.dat
> regdis.c
153 regdis.h
: regs.dat regs.pl
154 $(PERL
) $(srcdir)/regs.pl dh
$(srcdir)/regs.dat
> regdis.h
155 regvals.c
: regs.dat regs.pl
156 $(PERL
) $(srcdir)/regs.pl vc
$(srcdir)/regs.dat
> regvals.c
157 regs.h
: regs.dat regs.pl
158 $(PERL
) $(srcdir)/regs.pl h
$(srcdir)/regs.dat
> regs.h
160 # Assembler token hash
161 tokhash.c
: insns.dat regs.dat tokens.dat tokhash.pl perllib
/phash.ph
162 $(PERL
) $(srcdir)/tokhash.pl c
$(srcdir)/insns.dat
$(srcdir)/regs.dat \
163 $(srcdir)/tokens.dat
> tokhash.c
165 # Assembler token metadata
166 tokens.h
: insns.dat regs.dat tokens.dat tokhash.pl perllib
/phash.ph
167 $(PERL
) $(srcdir)/tokhash.pl h
$(srcdir)/insns.dat
$(srcdir)/regs.dat \
168 $(srcdir)/tokens.dat
> tokens.h
170 # Preprocessor token hash
171 pptok.h
: pptok.dat pptok.pl perllib
/phash.ph
172 $(PERL
) $(srcdir)/pptok.pl h
$(srcdir)/pptok.dat pptok.h
173 pptok.c
: pptok.dat pptok.pl perllib
/phash.ph
174 $(PERL
) $(srcdir)/pptok.pl c
$(srcdir)/pptok.dat pptok.c
176 # This target generates all files that require perl.
177 # This allows easier generation of distribution (see dist target).
178 PERLREQ
= macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
179 regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
180 tokhash.c tokens.h pptok.h pptok.c \
181 version.h version.mac iflag.c iflag.h
196 # cd rdoff && $(MAKE) clean
198 distclean: clean .SYMBOLIC
213 -rm -f
/s autom4te
*.cache
214 # cd rdoff && $(MAKE) distclean
216 cleaner
: clean .SYMBOLIC
220 # cd doc && $(MAKE) clean
222 spotless
: distclean cleaner .SYMBOLIC
231 # cd rdoff && $(MAKE)
234 # cd doc && $(MAKE) all
236 everything
: all doc rdf
238 #-- Magic hints to mkdep.pl --#
239 # @object-ending: ".$(O)"
240 # @path-separator: "/"
241 # @exclude: "config.h"
243 #-- Everything below is generated by mkdep.pl - do not edit --#
244 assemble.
$(O
): assemble.c assemble.h compiler.h directiv.h disp8.h iflag.h \
245 iflaggen.h insns.h insnsi.h listing.h nasm.h nasmint.h nasmlib.h opflags.h \
246 pptok.h preproc.h regs.h tables.h tokens.h
247 directiv.
$(O
): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
248 nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
249 disasm.
$(O
): disasm.c compiler.h directiv.h disasm.h disp8.h iflag.h \
250 iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h \
251 preproc.h regdis.h regs.h sync.h tables.h tokens.h
252 disp8.
$(O
): disp8.c compiler.h directiv.h disp8.h insnsi.h nasm.h nasmint.h \
253 nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
254 eval.
$(O
): eval.c compiler.h directiv.h eval.h float.h insnsi.h labels.h \
255 nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
256 exprlib.
$(O
): exprlib.c compiler.h directiv.h insnsi.h nasm.h nasmint.h \
257 nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
258 float.
$(O
): float.c compiler.h directiv.h float.h insnsi.h nasm.h nasmint.h \
259 nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
260 hashtbl.
$(O
): hashtbl.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
261 nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
262 iflag.
$(O
): iflag.c compiler.h iflag.h iflaggen.h nasmint.h
263 insnsa.
$(O
): insnsa.c compiler.h directiv.h iflag.h iflaggen.h insns.h \
264 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h \
266 insnsb.
$(O
): insnsb.c compiler.h directiv.h iflag.h iflaggen.h insns.h \
267 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h \
269 insnsd.
$(O
): insnsd.c compiler.h directiv.h iflag.h iflaggen.h insns.h \
270 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h \
272 insnsn.
$(O
): insnsn.c compiler.h insnsi.h nasmint.h tables.h
273 labels.
$(O
): labels.c compiler.h directiv.h hashtbl.h insnsi.h labels.h \
274 nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
275 listing.
$(O
): listing.c compiler.h directiv.h insnsi.h listing.h nasm.h \
276 nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
277 macros.
$(O
): macros.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
278 nasmint.h nasmlib.h opflags.h output
/outform.h pptok.h preproc.h regs.h \
280 nasm.
$(O
): nasm.c assemble.h compiler.h directiv.h eval.h float.h iflag.h \
281 iflaggen.h insns.h insnsi.h labels.h listing.h nasm.h nasmint.h nasmlib.h \
282 opflags.h output
/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h \
283 stdscan.h tables.h tokens.h ver.h
284 nasmlib
/crc64.
$(O
): nasmlib
/crc64.c compiler.h hashtbl.h nasmint.h nasmlib.h
285 nasmlib
/file.
$(O
): nasmlib
/file.c compiler.h nasmint.h nasmlib.h
286 nasmlib
/ilog2.
$(O
): nasmlib
/ilog2.c compiler.h nasmint.h nasmlib.h
287 nasmlib
/md5c.
$(O
): nasmlib
/md5c.c compiler.h md5.h nasmint.h
288 nasmlib
/nasmlib.
$(O
): nasmlib
/nasmlib.c compiler.h directiv.h iflag.h \
289 iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h \
290 preproc.h regs.h tables.h tokens.h
291 nasmlib
/realpath.
$(O
): nasmlib
/realpath.c compiler.h nasmint.h nasmlib.h
292 nasmlib
/ver.
$(O
): nasmlib
/ver.c ver.h version.h
293 ndisasm.
$(O
): ndisasm.c compiler.h directiv.h disasm.h iflag.h iflaggen.h \
294 insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h \
295 regs.h sync.h tables.h tokens.h ver.h
296 output
/codeview.
$(O
): output
/codeview.c compiler.h directiv.h insnsi.h md5.h \
297 nasm.h nasmint.h nasmlib.h opflags.h output
/outlib.h output
/pecoff.h \
298 pptok.h preproc.h regs.h saa.h tables.h version.h
299 output
/nulldbg.
$(O
): output
/nulldbg.c compiler.h directiv.h insnsi.h nasm.h \
300 nasmint.h nasmlib.h opflags.h output
/outlib.h pptok.h preproc.h regs.h \
302 output
/nullout.
$(O
): output
/nullout.c compiler.h directiv.h insnsi.h nasm.h \
303 nasmint.h nasmlib.h opflags.h output
/outlib.h pptok.h preproc.h regs.h \
305 output
/outaout.
$(O
): output
/outaout.c compiler.h directiv.h eval.h insnsi.h \
306 nasm.h nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h \
307 pptok.h preproc.h raa.h regs.h saa.h stdscan.h tables.h
308 output
/outas86.
$(O
): output
/outas86.c compiler.h directiv.h insnsi.h nasm.h \
309 nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h pptok.h \
310 preproc.h raa.h regs.h saa.h tables.h
311 output
/outbin.
$(O
): output
/outbin.c compiler.h directiv.h eval.h insnsi.h \
312 labels.h nasm.h nasmint.h nasmlib.h opflags.h output
/outform.h \
313 output
/outlib.h pptok.h preproc.h regs.h saa.h stdscan.h tables.h
314 output
/outcoff.
$(O
): output
/outcoff.c compiler.h directiv.h eval.h insnsi.h \
315 nasm.h nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h \
316 output
/pecoff.h pptok.h preproc.h raa.h regs.h saa.h tables.h
317 output
/outdbg.
$(O
): output
/outdbg.c compiler.h directiv.h insnsi.h nasm.h \
318 nasmint.h nasmlib.h opflags.h output
/outform.h pptok.h preproc.h regs.h \
320 output
/outelf.
$(O
): output
/outelf.c compiler.h directiv.h insnsi.h nasm.h \
321 nasmint.h nasmlib.h opflags.h output
/dwarf.h output
/elf.h output
/outelf.h \
322 output
/outform.h pptok.h preproc.h rbtree.h regs.h saa.h tables.h
323 output
/outelf32.
$(O
): output
/outelf32.c compiler.h directiv.h eval.h \
324 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output
/dwarf.h output
/elf.h \
325 output
/outelf.h output
/outform.h output
/outlib.h output
/stabs.h pptok.h \
326 preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
327 output
/outelf64.
$(O
): output
/outelf64.c compiler.h directiv.h eval.h \
328 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output
/dwarf.h output
/elf.h \
329 output
/outelf.h output
/outform.h output
/outlib.h output
/stabs.h pptok.h \
330 preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
331 output
/outelfx32.
$(O
): output
/outelfx32.c compiler.h directiv.h eval.h \
332 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output
/dwarf.h output
/elf.h \
333 output
/outelf.h output
/outform.h output
/outlib.h output
/stabs.h pptok.h \
334 preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h
335 output
/outform.
$(O
): output
/outform.c compiler.h directiv.h insnsi.h nasm.h \
336 nasmint.h nasmlib.h opflags.h output
/outform.h pptok.h preproc.h regs.h \
338 output
/outieee.
$(O
): output
/outieee.c compiler.h directiv.h insnsi.h nasm.h \
339 nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h pptok.h \
340 preproc.h regs.h tables.h ver.h
341 output
/outlib.
$(O
): output
/outlib.c compiler.h directiv.h insnsi.h nasm.h \
342 nasmint.h nasmlib.h opflags.h output
/outlib.h pptok.h preproc.h regs.h \
344 output
/outmacho.
$(O
): output
/outmacho.c compiler.h directiv.h insnsi.h \
345 nasm.h nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h \
346 pptok.h preproc.h raa.h rbtree.h regs.h saa.h tables.h
347 output
/outobj.
$(O
): output
/outobj.c compiler.h directiv.h eval.h insnsi.h \
348 nasm.h nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h \
349 pptok.h preproc.h regs.h stdscan.h tables.h ver.h
350 output
/outrdf2.
$(O
): output
/outrdf2.c compiler.h directiv.h insnsi.h nasm.h \
351 nasmint.h nasmlib.h opflags.h output
/outform.h output
/outlib.h pptok.h \
352 preproc.h rdoff
/rdoff.h regs.h saa.h tables.h
353 parser.
$(O
): parser.c compiler.h directiv.h eval.h float.h iflag.h \
354 iflaggen.h insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h parser.h \
355 pptok.h preproc.h regs.h stdscan.h tables.h tokens.h
356 pptok.
$(O
): pptok.c compiler.h hashtbl.h nasmint.h nasmlib.h pptok.h \
358 preproc-nop.
$(O
): preproc-nop.c compiler.h directiv.h insnsi.h listing.h \
359 nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
360 preproc.
$(O
): preproc.c compiler.h directiv.h eval.h hashtbl.h insnsi.h \
361 listing.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h quote.h \
362 regs.h stdscan.h tables.h tokens.h
363 quote.
$(O
): quote.c compiler.h nasmint.h nasmlib.h quote.h
364 raa.
$(O
): raa.c compiler.h nasmint.h nasmlib.h raa.h
365 rbtree.
$(O
): rbtree.c compiler.h nasmint.h rbtree.h
366 regdis.
$(O
): regdis.c regdis.h regs.h
367 regflags.
$(O
): regflags.c compiler.h directiv.h insnsi.h nasm.h nasmint.h \
368 nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
369 regs.
$(O
): regs.c compiler.h insnsi.h nasmint.h tables.h
370 regvals.
$(O
): regvals.c compiler.h insnsi.h nasmint.h tables.h
371 saa.
$(O
): saa.c compiler.h nasmint.h nasmlib.h saa.h
372 stdlib
/snprintf.
$(O
): stdlib
/snprintf.c compiler.h nasmint.h nasmlib.h
373 stdlib
/strlcpy.
$(O
): stdlib
/strlcpy.c compiler.h nasmint.h
374 stdlib
/vsnprintf.
$(O
): stdlib
/vsnprintf.c compiler.h nasmint.h nasmlib.h
375 stdscan.
$(O
): stdscan.c compiler.h directiv.h iflag.h iflaggen.h insns.h \
376 insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h quote.h \
377 regs.h stdscan.h tables.h tokens.h
378 strfunc.
$(O
): strfunc.c compiler.h directiv.h insnsi.h nasm.h nasmint.h \
379 nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
380 sync.
$(O
): sync.c compiler.h nasmint.h nasmlib.h sync.h
381 tokhash.
$(O
): tokhash.c compiler.h directiv.h hashtbl.h iflag.h iflaggen.h \
382 insns.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h pptok.h preproc.h \
383 regs.h stdscan.h tables.h tokens.h