ifeq "$(crt)" "ucrt"
CRTCOPTS=-D_UCRT
CRTEXTRA=../../pdos/pdpclib/ucrtwrap.lib ../pdpclib/ucrtbase.lib
else
CRTEXTRA=../../pdos/pdpclib/msvcrt.lib
endif

CPP=pdcc

ifeq "$(tools)" "mcc"
CC=mcc
CFLAGS=
else
CC=cc64
CFLAGS=-D__CC64__
endif

LD=pdld
LDFLAGS=-s -nostdlib --no-insert-timestamp --image-base 0x400000
AS=pdas --oformat coff --64
COPTS=-I. -I../../pdos/pdpclib -I../../pdos/generic -D__WIN32__ -D__NOBIVA__ \
    -D__64BIT__ $(CRTCOPTS)

OBJS=tobruk.obj seenby.obj dtsplit.obj getopts.obj \
     faddr.obj mailproc.obj error.obj prseaddr.obj strinl.obj \
     stritr.obj estdio.obj estdlib.obj dtfido.obj trav.obj \
     exists.obj reform.obj patmat.obj pkt.obj repo.obj repofile.obj \
     findkblk.obj slidwin.obj dtsplitm.obj route.obj dostime.obj

  
tobrukd.exe: $(OBJS)
  $(LD) $(LDFLAGS) -o $(TARGET) ../../pdos/pdpclib/w32start.obj $(OBJS) $(CRTEXTRA)

.c.obj:
  $(CPP) -E $(COPTS) -o $*.i $<
ifeq "$(tools)" "mcc"
  $(CC) -o:$*.s $*.i
else
  $(CC) -c -out:$@ $*.i
endif
  rm -f $*.i
ifeq "$(tools)" "mcc"
  $(AS) -o $@ $*.s
  rm -f $*.s
endif

clean:
  rm -f $(OBJS) $(TARGET)
