# This builds a PDOS-generic ELF executable for x64

# although l64supa is linked in, it isn't used for any of
# the linux functions. It is only used if some generated
# code requires it

CC=gcc
COPTS=-S -O0 -fno-common -fno-builtin -DXHAVE_DIR -D__UNOPT__ \
    -D__PDOS386__ -D__PDOSGEN__ -mno-red-zone -D__NOBIVA__ \
    -D__64BIT__ -fno-stack-protector \
    -I . -I../pdpclib -I../src

all: clean pcomm.exe

pcomm.exe: ../pdpclib/pgastart.o pcomm.o ../pdpclib/l64supa.o
  rm -f pcomm.exe
  ld -s -e __crt0 -o pcomm.exe ../pdpclib/pgastart.o pcomm.o ../pdpclib/l64supa.o

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

.asm.o:
  as --defsym LINUX=0 --defsym ELF=1 --defsym STACKPARM=0 -o $@ $<

clean:
  rm -f pcomm.exe
