# This builds a PDOS-generic executable for x64 EBCDIC

# We don't normally need the assembler support file, but we build
# it here for others to use

CC=gcc
COPTS=-S -O0 -fno-builtin -D__64BIT__ -I . -m64 \
    -mno-red-zone \
    -fno-common -U__gnu_linux__ -fno-stack-protector \
    -D__USEBIVA__ -D__NOSPECBIVA__ \
    -nostdlib -nostdinc \
    -U__MINGW32__ --no-pie -fno-leading-underscore \
    -I../src -D__EBCDIC__ \
    -D__PDOSGEN__ \
    -I . -I../generic -I../src

# Use EBCDIC
COPTS:=$(COPTS) -funsigned-char \
    -fexec-charset=IBM1047

AS=pdas --64 --oformat coff
#AS=as --64

LD=pdlde --64 --oformat coff -nostdlib --emit-relocs


all: clean pdptest.exe

pdptest.exe: pgastart.obj pdptest.obj x64supa.obj
  rm -f pdptest.exe
  $(LD) -e __crt0 -o pdptest.exe pgastart.obj pdptest.obj x64supa.obj

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

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

x64supa.obj: x64supa.asm
  pdas --oformat coff --defsym PDAS=1 --no-pseudo-dot --64 -o $@ $<

clean:
  rm -f pdptest.exe
