# 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 uemacs.exe for Linux.
# You need to first build makefile.lnp in pdpclib

CC=gcc386
AR=are86
LD=lde86
AS=ase86
COPTS=-S -O2 -D__gnu_linux__ -D__NOBIVA__ -DC90 -I. -I../pdos/pdpclib

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

all: clean $(TARGET)

$(TARGET): $(OBJS)
  $(LD) -s -nostdlib --emit-relocs -e __start -o $(TARGET) ../pdos/pdpclib/linstart.o main.o $(TEMP_ARCHIVE) ../pdos/pdpclib/pdplinux.a
  rm -f $(TEMP_ARCHIVE)

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

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