# This builds a 64-bit PDOS-generic PE executable for ARM

ifeq "$(tools)" "mingw64"
CC=gcc -U__WIN32__
ASPARM=
else
CC=gcc -D__LONG64__
ASPARM=--defsym ELF=1
endif

COPTS=-S -O2 -fno-common -fno-builtin -DHAVE_DIR \
    -D__PDOS386__ -D__PDOSGEN__ -D__USEBIVA__ \
    -D__64BIT__ -fno-stack-protector --no-pie \
    -I . -I../pdpclib -I../src

all: clean pcomm.exe

EXTRA1=../pdpclib/pgastart.o
EXTRA2=../pdpclib/string.o ../pdpclib/a64supa.o

pcomm.exe: $(EXTRA1) pcomm.o $(EXTRA2)
  rm -f pcomm.exe
  pdld -s -e __crt0 -o pcomm.exe $(EXTRA1) pcomm.o $(EXTRA2)

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

.asm.o:
  as --defsym LINUX=0 $(ASPARM) --defsym STACKPARM=0 -o $@ $<

clean:
  rm -f pcomm.exe
