# Makefile to compile with gccprm using ANSI screen I/O

# This builds a PDOS-generic executable for ARM
# Using the standard ARM32 (including UEFI) calling convention
# We don't have an appropriate subsystem for this executable
# as it is neither Windows nor UEFI - it is PDOS-generic - so
# we use 0 (unknown)

# You should build pdos/generic/makecomm.prm first
# to get the appropriate files in pdpclib built

CC=gccprm
CFLAGS=-O0
COPTS=$(CFLAGS) -S -D__PDOS386__ -D__PDOSGEN__ -D__ARMGEN__ -D__USEBIVA__ \
    -I. -I../../pdos/pdpclib -I../../pdos/generic \
    -DNO_QUICK -DARM -I../../pdos/src \
    -ansi -fno-common -fno-builtin -mapcs-32 -msoft-float
LD=pdld --oformat coff --no-insert-timestamp --subsystem 0
LDFLAGS=
AS=asprm
AR=arprm

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 ../../pdos/pdpclib/pgastart.o msged.o $(TEMP_ARCHIVE) ../../pdos/pdpclib/string.o ../../pdos/pdpclib/armsupa.o

.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)
