# 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
LD=pdld --oformat coff --no-insert-timestamp --subsystem 0
LDFLAGS=
AS=asprm
AR=arprm
COPTS=$(CFLAGS) -S -D__PDOS386__ -D__PDOSGEN__ -D__ARMGEN__ \
    -D__USEBIVA__ -fno-common -ansi \
    -I. -I../../pdos/pdpclib -I../../pdos/src -I../../pdos/generic \
    -DUNIXSEP -DARM -DUSE_MBASE -DBINKLEYSTYLE \
    -ansi -fno-common -fno-builtin -mapcs-32 -msoft-float

all: clean tobruk.exe

tobruk.exe: tobruk.o seenby.o dtsplit.o getopts.o \
     faddr.o mailproc.o error.o prseaddr.o strinl.o \
     stritr.o estdio.o estdlib.o dtfido.o trav.o \
     exists.o reform.o patmat.o pkt.o repo.o repofile.o \
     findkblk.o slidwin.o dtsplitm.o route.o mbase.o \
     dostime.o
  rm -f temp.a
  $(AR) r temp.a seenby.o dtsplit.o getopts.o
  $(AR) r temp.a faddr.o mailproc.o error.o prseaddr.o strinl.o
  $(AR) r temp.a stritr.o estdio.o estdlib.o dtfido.o trav.o
  $(AR) r temp.a exists.o reform.o patmat.o pkt.o repo.o repofile.o
  $(AR) r temp.a findkblk.o slidwin.o dtsplitm.o route.o mbase.o
  $(AR) r temp.a dostime.o
  $(LD) $(LDFLAGS) -s -o tobruk.exe ../../pdos/pdpclib/pgastart.o tobruk.o temp.a ../../pdos/pdpclib/string.o ../../pdos/pdpclib/armsupa.o ../../pdos/pdpclib/fpfuncsa.o

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

clean:
  rm -f *.o tobruk.exe
