# Produces EFI executable.
# We link with the library produced by makefile.eb6
# And we use makefile.p64 and makecomm.p64
# which are PE

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

CC=x86_64-w64-mingw32-gcc
#AR=x86_64-w64-mingw32-ar
AR=ar
LD=x86_64-w64-mingw32-ld
#LD=pdld --no-insert-timestamp
AS=x86_64-w64-mingw32-as
#AS=pdas --64 --oformat coff
COPTS=-S -O2 -mno-red-zone -D__64BIT__ -D__EFI__ -D__EFIBIOS__ -U__WIN32__ \
    -I../pdpclib -I../bios -I../src \
    -fno-common -ansi \
    -DTARGET_64BIT -DNEED_MZ -DNO_DLLENTRY -D__W64SHELL__ \
    -DGENSHELL -DW64EMUL

all: clean bios.exe

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

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

.c.o:
    $(CC) $(COPTS) -o $*.s $<
    $(AS) -o $@ $*.s
    rm -f $*.s

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

clean:
    rm -f *.o bios.exe
