VPATH=./hashtab
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
#AS=x86_64-w64-mingw32-as
COPTS=-I. -I./hashtab -I../pdpclib -D__WIN32__ -D__NOBIVA__ \
  -D__64BIT__ $(CFLAGS)

OBJS=main.obj read.obj rule.obj variable.obj xmalloc.obj hashtab.obj
OBJS2=../pdpclib/x64supb.obj
#bcclib.obj

TARGET=pdmake.exe

all: clean $(TARGET)

$(TARGET): $(OBJS) $(OBJS2)
  $(LD) $(LDFLAGS) -o $(TARGET) ../pdpclib/w32start.obj $(OBJS) $(OBJS2) ../pdpclib/msvcrt.lib

.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

.asm.obj:
#  aa bcclib.asm -obj
  $(AS) -o $@ $<

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