# This builds EFI executables for x86_64 using mcc

CC=mcc
CPP=pdcc -E
AR=xar
LD=pdld --no-insert-timestamp
AS=sasm -f win64 -DCC64
#AS=pdas --oformat coff --64 --defsym PDAS=1 --defsym CC64=1 --no-pseudo-dot
#AS=ml64 -DCC64

GAS=pdas --oformat coff --64
COPTS=-D__64BIT__ -D__EFI__ -D__EFIBIOS__ -U__WIN32__ -I. \
    -D__GENSHELL__ -D__XNO_LONG_LONG__ -DWINNEWMOD

TARGET=pdptest.efi
OBJS=efistart.obj stdio.obj string.obj stdlib.obj start.obj time.obj errno.obj \
    assert.obj signal.obj locale.obj ctype.obj setjmp.obj math.obj x64supa.obj

$(TARGET): clean pdptest.obj $(OBJS)
  rm -f pdpefi.lib
  $(AR) r pdpefi.lib $(OBJS)
  $(AR) s pdpefi.lib
  $(LD) -s -subsystem 10 -e efimain -nostdlib -o $(TARGET) pdptest.obj $(OBJS)

.c.obj:
  $(CPP) $(COPTS) -o $*.i $<
  $(CC) -s -o:$*.s $*.i
  rm -f $*.i
  $(GAS) -o $@ $*.s 
  rm -f $*.s

.asm.obj:
  $(AS) -o $@ $<
#  $(AS) -nologo -c -Fo$@ $<

clean:
  rm -f *.obj
  rm -f $(TARGET)
