# This creates a PDOS-generic app (hence the "p" in "yap"),
# suitable for running under PdAndro etc.
# It uses the gcc built with aarch64-mingw64
# The output is a PE/COFF, but the subsystem is 0, ie neither
# UEFI nor Win64 - since it is neither.
# But the function calling convention is the same.

# long is 32-bit with this compiler, so it properly matches
# the pseudobios built with Visual C.

# You should build makecomm.pa6 first to get the PDOS-generic
# dependencies in PDPCLIB built.

# This executable uses ANSI screen I/O


CC=gcc
COPTS=-S -I../src -D__ARM__ -I. -U__WIN32__ -D__PDPCLIB_DLL \
    -D__ARMGEN__ -D__PDOSGEN__ \
    -O2 -U__gnu_linux__ \
    -D__64BIT__ -nostdlib -nostdinc \
    -D__NODECLSPEC__ \
    -fno-stack-protector --no-pie -fno-builtin -fno-common \
    -I. -I../../pdos/pdpclib -I../../pdos/generic \
    -DNO_QUICK -DARM -I../../pdos/src \
    -ansi

AR=ar
LD=pdld --oformat coff --no-insert-timestamp --subsystem 0
#LD=ld
AS=as

EXTRA1=../../pdos/pdpclib/pgastart.o
EXTRA2=../../pdos/pdpclib/a64supa.obj

TARGET=msged.exe
TEMP_ARCHIVE=temp.lib

all: clean msged.exe

msged.exe: \
     ansi.o     \
     areas.o    \
     bmg.o      \
     config.o   \
     control.o  \
     date.o     \
     dialogs.o  \
     dirute.o   \
     dlgbox.o   \
     fido.o     \
     getopts.o  \
     help.o     \
     helpcmp.o  \
     helpinfo.o \
     init.o     \
     keycode.o  \
     list.o     \
     maintmsg.o \
     makemsgn.o \
     memextra.o \
     menu.o     \
     misc.o     \
     mnu.o      \
     msged.o    \
     mxbt.o     \
     normalc.o  \
     nshow.o    \
     quote.o    \
     readmail.o \
     screen.o   \
     strextra.o \
     system.o   \
     template.o \
     textfile.o \
     userlist.o \
     vsev.o     \
     vsevops.o  \
     win.o      \
     wrap.o     \
     unixio.o
  $(AR) s $(TEMP_ARCHIVE)
  $(LD) -s -o msged.exe $(EXTRA1) msged.o $(TEMP_ARCHIVE) $(EXTRA2)

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

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

clean:
  rm -f *.o
  rm -f $(TARGET)
  rm -f $(TEMP_ARCHIVE)
