# 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=gccw64_l64
AS=pdas --oformat coff --64
LD=pdld --oformat elf --no-insert-timestamp --emit-relocs
AR=xar

COPTS=-S -O2 -U__WIN32__ -D__PDOS386__ \
    -D__64BIT__ -D__LONG64__ -I . -D__USEBIVA__ -fno-common \
    -DXHAVE_DIR -D__PDOSGEN__ \
    -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
