# Makefile for the Netwide Assembler under 16-bit DOS
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the licence given in the file "Licence"
# distributed in the NASM archive.
#
# This Makefile is designed to build NASM using a 16-bit DOS C
# compiler such as Microsoft C, provided you have a compatible MAKE.
# It's been tested with Microsoft C 5.x plus Borland Make. (Yes, I
# know it's silly, but...)

CC = cc386 /c
LINK = valx -use32 -PE -nci -map
LINKFLAGS =
LIBRARIES =
OBJ = obj

.c.obj:
	&$(CC) $&

NDISASMOBJS = ndisasm.$(OBJ) disasm.$(OBJ) sync.$(OBJ) nasmlib.$(OBJ) \
              insnsd.$(OBJ)

NASMOBJS = nasm.$(OBJ) nasmlib.$(OBJ) eval.$(OBJ) float.$(OBJ) insnsa.$(OBJ) \
           assemble.$(OBJ) labels.$(OBJ) parser.$(OBJ) outform.$(OBJ) \
	   outbin.$(OBJ) outaout.$(OBJ) outcoff.$(OBJ) outelf.$(OBJ) \
	   outobj.$(OBJ) outas86.$(OBJ) outrdf.$(OBJ) outrdf2.$(OBJ) outdbg.$(OBJ) \
     outieee.$(OBJ) \
           preproc.$(OBJ) listing.$(OBJ)

all : nasm.exe

# We have to have a horrible kludge here to get round the 128 character
# limit, as usual...
LINKOBJS = a*.obj e*.obj f*.obj insnsa.obj l*.obj na*.obj o*.obj p*.obj m*
nasm.exe: upbuild $(NASMOBJS) nasm.res
        $(LINK) @&&|
c0xwin.obj $(LINKOBJS:.obj=)
nasm
nasm
clwin climp
nasm.res

|

nasm.res: nasm.rc ..\version.h
        xrc -r nasm.rc

upbuild:
        ..\upbuild $(FULLBUILD) NASM

ndisasm.exe: $(NDISASMOBJS)
  $(LINK) c0xwin.obj $(NDISASMOBJS:.obj=),ndisasm,ndisasm,clwin climp,,
!ifdef	FULLBUILD
	upx -9 $.
!endif

assemble.$(OBJ): assemble.c nasm.h assemble.h insns.h
disasm.$(OBJ): disasm.c nasm.h disasm.h sync.h insns.h names.c
float.$(OBJ): float.c nasm.h
labels.$(OBJ): labels.c nasm.h nasmlib.h
listing.$(OBJ): listing.c nasm.h nasmlib.h listing.h
nasm.$(OBJ): nasm.c nasm.h nasmlib.h parser.h assemble.h labels.h \
	listing.h outform.h
nasmlib.$(OBJ): nasmlib.c nasm.h nasmlib.h
ndisasm.$(OBJ): ndisasm.c nasm.h sync.h disasm.h
outas86.$(OBJ): outas86.c nasm.h nasmlib.h
outaout.$(OBJ): outaout.c nasm.h nasmlib.h
outbin.$(OBJ): outbin.c nasm.h nasmlib.h
outcoff.$(OBJ): outcoff.c nasm.h nasmlib.h
outdbg.$(OBJ): outdbg.c nasm.h nasmlib.h
outelf.$(OBJ): outelf.c nasm.h nasmlib.h
outobj.$(OBJ): outobj.c nasm.h nasmlib.h
outrdf.$(OBJ): outrdf.c nasm.h nasmlib.h
outrdf2.$(OBJ): outrdf2.c nasm.h nasmlib.h
outform.$(OBJ): outform.c outform.h nasm.h
profile.obj : profile.c
	cc386 /C+N profile.c
	nasm -fobj profile.asm
proftime.obj : proftime.c
	cc386 /C+N proftime.c
	nasm -fobj proftime.asm
parser.$(OBJ): parser.c nasm.h nasmlib.h parser.h float.h names.c
preproc.$(OBJ): preproc.c macros.c preproc.h nasm.h nasmlib.h
eval.$(OBJ): eval.c nasm.h nasmlib.h eval.h
sync.$(OBJ): sync.c sync.h
insnsa.$(OBJ): insnsa.c nasm.h insns.h