# 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 uemacs.exe on Windows.
# makefile.std in PDPCLIB must be used before using this makefile.
# Because this does a dynamic link, you will need an
# msvcrt.dll that does ANSI X3.64 escapes by default

CC=gccwin
CFLAGS=-O2 -ansi
COPTS=$(CFLAGS) -S -fno-common -D__WIN32__ -I. -I../pdos/pdpclib -DC90
AS=pdas
AR=xar
LD=pdld

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) --no-insert-timestamp -s -o $(TARGET) ../pdos/pdpclib/w32start.obj main.obj $(TEMP_ARCHIVE) ../pdos/pdpclib/msvcrt.lib
  rm -f $(TEMP_ARCHIVE)

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

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