# This builds a PDOS-generic executable for ARM
# Using the standard ARM32 (including UEFI) calling convention
# We don't have an appropriate subsystem for this executable
# as it is neither Windows nor UEFI - it is PDOS-generic
# So we set it to 0 (unknown)

# At time of writing we didn't actually need the memcpy
# from string.o, but it is required by other applications
# like msged, and this is the place where it is currently built

CC=gccprm
CFLAGS=-O0
#LD=ldprm -subsystem efi
LD=pdld --oformat coff --no-insert-timestamp --subsystem 0
LDFLAGS=
AS=asprm
AR=arprm
COPTS=-S $(CFLAGS) -ansi -I. -I../pdpclib -I../src \
  -D__ARM__ -fno-common -mapcs-32 -fno-builtin \
  -msoft-float -DHAVE_DIR \
  -D__PDOS386__ -D__PDOSGEN__ -D__ARMGEN__ -D__NOBIVA__ 

all: clean pcomm.exe

pcomm.exe: ../pdpclib/pgastart.o pcomm.o ../pdpclib/armsupa.o ../pdpclib/string.o ../pdpclib/fpfuncsa.o
  rm -f pcomm.exe
  $(LD) $(LDFLAGS) -s -e ___crt0 -o pcomm.exe ../pdpclib/pgastart.o pcomm.o ../pdpclib/string.o ../pdpclib/armsupa.o ../pdpclib/fpfuncsa.o

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

.asm.o:
  $(AS) --defsym LINUX=0 --defsym ELF=0 --defsym STACKPARM=0 -o $@ $<

clean:
  rm -f *.o pcomm.exe
