# Released to the public domain.
#
# Anyone and anything may copy, edit, publish,
# use, compile, sell and distribute this work
# and all its parts in any form for any purpose,
# commercial and non-commercial, without any restrictions,
# without complying with any conditions
# and by any means.

# This makefile builds 32-bit a.out pdos-generic uemacs.exe for ARM
# makefile.aga in PDPCLIB must be used before using this makefile

CC=gccarm
CFLAGS=-O0 -D__UNOPT__
COPTS=$(CFLAGS) -S -D__PDOS386__ -D__PDOSGEN__ -D__ARMGEN__ -D__NOBIVA__ \
    -I. -I../pdos/pdpclib -I../pdos/generic -DC90 \
    -ansi -fno-common -fno-builtin -mapcs-32
LD=ldarm -N -e ___crt0 
LDFLAGS=
AS=asarm
AR=ararm

TARGET=uemacs.exe
TEMP_ARCHIVE=temp.lib
OBJS=		ansi.obj basic.obj bind.obj buffer.obj display.obj file.obj \
		fileio.obj line.obj lock.obj main.obj random.obj region.obj \
		search.obj spawn.obj termio.obj window.obj word.obj

all: clean $(TARGET)

$(TARGET): $(OBJS)
  $(AR) s $(TEMP_ARCHIVE)
  $(LD) -s -o $(TARGET) ../pdos/pdpclib/pgastart.o main.obj $(TEMP_ARCHIVE) ../pdos/pdpclib/armsupa.o
  rm -f $(TEMP_ARCHIVE)

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

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