#
#   Copyright (C) 2008 Clozure Associates
#   This file is part of OpenMCL.  
#
#   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
#   License , known as the LLGPL and distributed with OpenMCL as the
#   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
#   which is distributed with OpenMCL as the file "LGPL".  Where these
#   conflict, the preamble takes precedence.  
#
#   OpenMCL is referenced in the preamble as the "LIBRARY."
#
#   The LLGPL is also available online at
#   http://opensource.franz.com/preamble.html


# With nmake, VPATH is broken.  Invoke from the directory above:
#
# Z:\ccl-source\lisp-kernel> nmake /f win64/Makefile.nmake

RM = del
CC = cl
M4 = m4
MV = move
LD = link
ASFLAGS = -f win64 -g cv8 -p gas
AS = yasm
M4FLAGS = -DWIN64 -DWINDOWS -DX86 -DX8664 -DHAVE_TLS -DEMUTLS
CDEFINES = /I.. /DWIN64 /DWINDOWS /D_REENTRANT /DX86 /DX8664 /D_GNU_SOURCE /DHAVE_TLS /DEMUTLS /DVC #-DDISABLE_EGC
CDEBUG = /Zi
COPT =
LDFLAGS =

.SUFFIXES : .exe .obj .c .asm .s

.s.asm:
	$(M4) $(M4FLAGS) -I. $< > $@.temp && mv $@.temp $@
.asm.obj:
	$(AS) $(ASFLAGS) -o $@ $<
.c.obj:
	$(CC) /c $< $(CDEFINES) $(CDEBUG) $(COPT)

SPOBJ = pad.obj x86-spjump64.obj x86-spentry64.obj x86-subprims64.obj
ASMOBJ = x86-asmutils64.obj imports.obj

COBJ  = pmcl-kernel.obj gc-common.obj x86-gc.obj bits.obj  x86-exceptions.obj \
	image.obj thread_manager.obj lisp-debug.obj memory.obj

DEBUGOBJ = lispdcmd.obj plprint.obj plsym.obj xlbt.obj x86_print.obj
KERNELOBJ= $(COBJ) x86-asmutils64.obj  imports.obj

SPINC =	lisp.s m4macros.m4 x86-constants.s x86-macros.s errors.s x86-uuo.s \
	x86-constants64.s

CHEADERS = area.h bits.h x86-constants.h lisp-errors.h gc.h lisp.h \
	lisp-exceptions.h lisp_globals.h macros.h memprotect.h image.h \
	threads.h x86-constants64.h x86-exceptions.h lisptypes.h


KSPOBJ = $(SPOBJ)
all:	..\wx86cl64

OSLIBS = bufferoverflowu.lib

..\wx86cl64:	$(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) Makefile 
	$(LD) $(LDFLAGS) /out:$@ $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) $(OSLIBS)

cobjs: $(COBJ)

$(SPOBJ): $(SPINC)
$(ASMOBJ): $(SPINC)
$(COBJ): $(CHEADERS)
$(DEBUGOBJ): $(CHEADERS) lispdcmd.h


cclean:
	$(RM) $(KERNELOBJ) $(DEBUGOBJ) ../../wx86cl64

clean:	cclean
	$(RM) $(SPOBJ)

strip:	../../wx86cl64
	strip -g ../../wx86cl64
