# Makefile.in for kaffevm - a Java(tm) compatible virtual machine.
# for MSVC
# Copyright (c) 1996 Systems Architecture Research Centre,
#		   City University, London, UK.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.

srcdir=		@srcdir@
prefix=		@prefix@
exec_prefix=	@exec_prefix@
libdir=		@libdir@
INSTALL=	@INSTALL@
INSTALL_DATA=	@INSTALL_DATA@
CC=		@CC@
PIC=		@PIC@
LDFLAGS=	@LIBSHARE@
LDTAIL=		@LDTAIL@
KVER=		@KVER@
OBJEXT=@OBJEXT@
LIBEXT=@LIBEXT@

jit_CFLAGS=	-DTRANSLATOR 
intrp_CFLAGS=	-DINTERPRETER 

CFLAGS=		@CFLAGS@ @KAFFEVMFLAGS@ -I. -I$(srcdir) -I$(srcdir)/../config -I../config \
		 -I$(srcdir)/@TYPE@ $(@TYPE@_CFLAGS)

LIBNAME=	libkaffe_vm
LIBX=		$(LIBNAME)$(LIBEXT).$(KVER)
LLIB=		$(LIBNAME)$(LIBEXT)

COMMON=\
		code$(OBJEXT) \
		lookup$(OBJEXT) \
		external$(OBJEXT) \
		constants$(OBJEXT) \
		classMethod$(OBJEXT) \
		readClass$(OBJEXT) \
		findClass$(OBJEXT) \
		baseClasses$(OBJEXT) \
		object$(OBJEXT) \
		itypes$(OBJEXT) \
		gc$(OBJEXT) \
		thread$(OBJEXT) \
		locks$(OBJEXT) \
		threadCalls$(OBJEXT) \
		support$(OBJEXT) \
		zextract$(OBJEXT) \
		soft$(OBJEXT) \
		flags$(OBJEXT) \
		md$(OBJEXT)

intrp_OBJECTS=\
		exception$(OBJEXT) \
		machine$(OBJEXT)

jit_OBJECTS=\
		basecode$(OBJEXT) \
		funcs$(OBJEXT) \
		icode$(OBJEXT) \
		labels$(OBJEXT) \
		registers$(OBJEXT) \
		slots$(OBJEXT) \
		machine$(OBJEXT) \
		seq$(OBJEXT) \
		exception$(OBJEXT)

OBJECT=		$(COMMON) $(@TYPE@_OBJECTS)

all:		links $(LLIB)

{$(srcdir)}.c$(OBJEXT):
		$(CC) $(CFLAGS) -c $(PIC) $<

{$(srcdir)/@TYPE@}.c$(OBJEXT):
		$(CC) $(CFLAGS) -c $(PIC) $<

{.}.c$(OBJEXT):
		$(CC) $(CFLAGS) -c $(PIC) $<

LINK32_FLAGS=wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
 comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
 odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:yes\
 /pdb:$(LIBNAME).pdb /debug /machine:I386 /def:$(LIBNAME).def\
 /out:$(LLIB) /implib:$(LIBNAME).lib 
DEF_FILE= \
	$(LIBNAME).def

$(LLIB) : $(DEF_FILE) $(OBJECT)
    link @<<
  $(LINK32_FLAGS) $(OBJECT)
<<


links:		md.h md.c $(LIBNAME).def icode.h jit.def ..\config\config.h

md.h:		..\..\config\i386\win32\msvc\md.h
		copy ..\..\config\i386\win32\msvc\md.h md.h

md.c:		..\..\config\i386\win32\msvc\md.c
		copy ..\..\config\i386\win32\msvc\md.c md.c

$(LIBNAME).def: ..\..\config\i386\win32\msvc\$(LIBNAME).def
		copy ..\..\config\i386\win32\msvc\$(LIBNAME).def $(LIBNAME).def

icode.h:	..\..\config\i386\jit-icode.h
		copy ..\..\config\i386\jit-icode.h icode.h

jit.def:	..\..\config\i386\jit-i386.def
		copy ..\..\config\i386\jit-i386.def jit.def

..\config\config.h:	..\..\config\i386\win32\msvc\config.h
		copy ..\..\config\i386\win32\msvc\config.h ..\config\config.h


clean:
		del *.obj
		del *.lib
		del *.dll
	-@erase $(LIBNAME).dll
	-@erase $(LIBNAME).exp
	-@erase $(LIBNAME).ilk
	-@erase $(LIBNAME).lib
	-@erase $(LIBNAME).pdb
	-@erase vc40.idb
	-@erase vc40.pdb
	-@erase vc41.pch

distclean:	clean
		del md.h
		del md.c
		del jit.def
		del icode.h
		del $(LIBNAME).def
		del ..\config\config.h
		del Makefile
		del config.log
		del config.status

install:
        if not exist "$(libdir)/$(NULL)" mkdir "$(libdir)"
		$(INSTALL_DATA) $(LLIB) $(libdir)/$(LLIB)
		del $(libdir)/$(LLIB)
