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

# Produces Linux executable.
# Links against library produced by makefile.lnp

CC=gccwin
COPTS=-U__WIN32__ -O2 -fno-common -ansi \
    -DC90 \
    -D__gnu_linux__ -D__NOBIVA__ -S -I. -I../pdos/pdpclib
AR=xar
LD=pdld
LDFLAGS=-s --no-insert-timestamp -nostdlib --oformat elf --emit-relocs

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) $(LDFLAGS) -o uemacs.exe ../pdos/pdpclib/linstart.o main.obj $(TEMP_ARCHIVE) ../pdos/pdpclib/pdplinux.a
  rm -f $(TEMP_ARCHIVE)

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

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