# Produces EFI executable.
# We link with the library produced by makefile.mce

# And we DON'T use makefile.p64 and makecomm.p64
# which are PE. Or makecomm.c64

# We need this executable to load below the 4 GiB mark.
# So we use the image-base keyword on the link step

CC=mcc
CPP=pdcc -E
AR=xar
LD=pdld --no-insert-timestamp
AS=sasm -f win64 -DCC64
GAS=pdas --oformat coff --64
COPTS=-D__64BIT__ -D__EFI__ -D__EFIBIOS__ -U__WIN32__ \
    -I../pdpclib -I../bios -I. -I../src -DNEED_ELF -D__XNO_LONG_LONG__ \
    -DTARGET_64BIT -DNEED_MZ -DNO_DLLENTRY -DWINNEWMOD -D__GENSHELL__ \
    -DGENSHELL

all: clean bios.exe

OBJS=../bios/exeload.obj
# w32hack.obj

bios.exe: bios.obj $(OBJS)
    $(LD) -s -subsystem 10 -e efimain -nostdlib --image-base 0x400000 -o bios.exe bios.obj $(OBJS) ../pdpclib/pdpefi.lib

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

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

clean:
    rm -f *.obj bios.exe
