!ifdef __DOS__
bld_os          = dos
link_sys_dos    = causeway
wsplice_opts_dos = -u0
!else ifdef __MSDOS__
bld_os          = dos
link_sys_dos    = causeway
wsplice_opts_dos = -u0
!else ifdef __NT__
bld_os          = nt
link_sys_nt     = nt
wsplice_opts_nt = -u0
!else ifdef __OS2__
bld_os          = os2
link_sys_os2    = os2v2
wsplice_opts_os2 = -u0
!else ifdef __LINUX__
bld_os              = linux
link_sys_linux      = linux
wsplice_opts_linux  = -u -kUNIX
!endif

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

.c : ../c;../../builder/c;../../watcom/c

!ifdef __UNIX__
../../../build/$(%OWOBJDIR)/wmake : wmk.exe
    cp wmk.exe $@
!else
..\..\..\build\$(%OWOBJDIR)\wmake.exe : wmk.exe
    copy wmk.exe $@
!endif

.c.obj : .AUTODEPEND
    *wcc386 -zq -D_BLDVER=$(%OWBLDVERTOOL) -D_CYEAR=xxxx -DBOOTSTRAP -DPREBOOT -DINCL_MSGTEXT $(EXTRADEF) -w8-we-s-oaxt-j-fpc-zc -d2 -bt=$(bld_os) -I. -I"../h" -I"../../lib_misc/h" -I"../../watcom/h" -fo="$@" "$<"

./wsplice.exe : wsplice.obj
    *wlink name $@ op q, map sys $(link_sys_$(bld_os)) file {$<}

./cretype.exe : cretype.obj
    *wlink name $@ op q, map sys $(link_sys_$(bld_os)) file {$<}

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

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

wmk.exe: usage.gh isarray.gh $(objs)
    *wlink debug all name $@ op q, map sys $(link_sys_$(bld_os)) file {$(objs)}

clean:  .symbolic
    rm -f *.obj *.gh *.exe *.err
