# 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 64-bit uemacs.exe on Windows.
# Because msvcrt.dll is used, rather than linking with the
# library makefile.c64, you won't actually be able to use the
# executable on genuine Windows, you will need UCX64, which
# handles msvcrt.dll differently.

CPP=pdcc

ifeq "$(tools)" "mcc"
CC=mcc
CFLAGS=
else
CC=cc64
CFLAGS=-D__CC64__
endif

LD=pdld
LDFLAGS=-s -nostdlib --no-insert-timestamp --image-base 0x400000
AS=pdas --oformat coff --64
COPTS=-I. -I../pdos/pdpclib -D__WIN32__ -D__NOBIVA__ \
    -D__64BIT__ $(CFLAGS) -DC90

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

TARGET=uemacs.exe

all: clean $(TARGET)

$(TARGET): $(OBJS)
  $(LD) $(LDFLAGS) -o $(TARGET) ../pdos/pdpclib/w32start.obj $(OBJS) ../pdos/pdpclib/msvcrt.lib

.c.obj:
  $(CPP) -E $(COPTS) -o $*.i $<
ifeq "$(tools)" "mcc"
  $(CC) -o:$*.s $*.i
else
  $(CC) -c -out:$@ $*.i
endif
  rm -f $*.i
ifeq "$(tools)" "mcc"
  $(AS) -o $@ $*.s
  rm -f $*.s
endif

clean:
  rm -f $(OBJS) $(TARGET)
