CPPFLAGS = $(DEFS) -I. -I..\h -I..\..\lib_misc\h -I..\..\watcom\h
# -wd4214 "bit field types other than int"
# -wd4244 "conversion ....., possible loss of data"
CFLAGS = -nologo -Zi -W4 -WX -MT -Fm -wd4214 -wd4244 -wd4063
DEFS = -D_BLDVER=$(OWBLDVERTOOL) -D_CYEAR=xxxx -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D__NT__ -DBOOTSTRAP -DPREBOOT -DINCL_MSGTEXT $(EXTRADEF)
LFLAGS = -link -INCREMENTAL:NO -DEBUG -NODEFAULTLIB:libucrt.lib -DEFAULTLIB:ucrt.lib

{..\c}.c.obj :
        $(CC) -c $(CFLAGS) $(CPPFLAGS) -Fo$@ $<

{..\..\builder\c}.c.obj :
        $(CC) -c $(CFLAGS) $(CPPFLAGS) -Fo$@ $<

{..\..\watcom\c}.c.obj :
        $(CC) -c $(CFLAGS) $(CPPFLAGS) -Fo$@ $<

all: ..\..\..\build\$(OWOBJDIR)\wmake.exe

OBJS= macros.obj main.obj mautodep.obj mautoomf.obj \
  memory.obj mexec.obj mglob.obj mhash.obj mlex.obj mlexmac.obj \
  mlexprs.obj mparse.obj mpreproc.obj mrcmsg.obj msg.obj mstream.obj \
  msuffix.obj msysdep.obj mtarget.obj mupdate.obj mvecstr.obj \
  mcache.obj misc.obj depinfo.obj clibext.obj

wsplice.exe: wsplice.obj clibext.obj
        $(CC) $(CFLAGS) -Fe$@ $** $(LFLAGS)

# Use inline files for wsplice as a way to sidestep the metacharacter hell.
usage.gh : ..\h\usage.sp wsplice.exe
        wsplice -u0 -kENGLISH @<<usage.tmp
-f "pick((MSG_USAGE_BASE+%#%+), \"%s\", \"\")" ..\h\usage.sp $@
<<

cretype.exe : ..\c\cretype.c
        $(CC) -nologo -I..\..\watcom\h -D__NT__ -Fe$@ $** $(LFLAGS)

isarray.gh : cretype.exe
        cretype.exe $@

..\..\..\build\$(OWOBJDIR)\wmake.exe: wmake.exe
        copy wmake.exe $@

wmake.exe: usage.gh isarray.gh $(OBJS)
        $(CC) $(CFLAGS) -Fe$@ $(OBJS) $(LFLAGS)

clean:
        -if exist *.obj erase *.obj
        -if exist *.gh  erase *.gh
        -if exist *.exe erase *.exe
