# Produces x64 EFI executable that is a shim to an
# x86 PE32 module running in CM32.

# We link with the library produced by makefile.vb6
# And we (don't) use makefile.w64 and makecomm.w64
# which are PE

# Define CM16 for a 16-bit version instead

# Rename bios.exe to bios.efi and then run it under qemu
# or whatever and then type "pdos" and then "exit" and enter

# It needs a helper program built with makefile.h32 and
# that contains more documentation on how to build pdos.exe


CC=cl
AS=pdas --64 --oformat coff
LD=link
COPTS=-c -nologo -O2 -Oi- -GS- -Za -Zl -u -X -D__MSC__ -D__64BIT__ \
   -D__EFI__ -D__EFIBIOS__ -U__WIN32__ -I../pdpclib \
   -I../bios -I../src \
   -DTARGET_64BIT -DNEED_MZ -DNEED_ELF -DNO_DLLENTRY \
   -DGENSHELL -DSHIMCM32 -w -DXCM16 -DSTYLE3

TARGET=bios.exe
OBJS=../bios/exeload.o shimcm32.o

$(TARGET): clean bios.o $(OBJS)
  $(LD) -nologo -map -fixed:no -base:0x400000 -nodefaultlib -entry:efimain -out:$(TARGET) -subsystem:EFI_APPLICATION bios.o $(OBJS) ../pdpclib/pdpefi.a
#  pdld --no-insert-timestamp -s -subsystem 10 -e efimain -nostdlib --image-base 0x400000 -o bios.exe bios.obj $(OBJS) ../pdpclib/pdpefi.lib

.c.o:
  $(CC) $(COPTS) -Fo$*.o $<

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

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