COM_OBJECTS = XCircuit.obj XCObject.obj XCArc.obj XCPolygon.obj XCText.obj XCPoint.obj xccom.obj utils.obj XCDotNet.obj xccom-def.obj \
	      xccom-iface.obj XCMenu.obj
COM_LIBRARY = XCCom.lib
DOTNET_ASSEMBLY = ../XCircuit.COM.dll ../XCircuit.dll
EXAMPLES = zoomtest.dll baseformtest.dll comtest.dll colorchooser.dll colorchooser2.dll

MSSCRIPT_FILES = msscript.h msscript_i.c msscript.tlb msscript.tlh msscript.tli

DEFS = -DHAVE_PUTENV -DXC_WIN32 -DDOUBLEBUFFER -DHAVE_XPM -DUSE_WIN32_COM -DUSE_DOTNET

all: $(COM_LIBRARY) $(DOTNET_ASSEMBLY)

examples: all $(EXAMPLES)

$(COM_LIBRARY): $(COM_OBJECTS)
	link -lib /OUT:$(COM_LIBRARY) $(COM_OBJECTS)

.c.obj:
	cl /EHsc /Zi /W3 /I.. /DWIN32 /D_WIN32_WINNT=0x0400 /DCOBJMACROS /D_OLE32_ $(DEFS) /c /Fo$@ $<

clean:
	-for %i in ($(COM_OBJECTS) $(COM_LIBRARY) XCCom_i.c XCCom.h XCCom.tlb XCCom_p.c dlldata.c $(MSSCRIPT_FILES)) do del /q %i
	-for %i in ($(DOTNET_ASSEMBLY:/=\) $(EXAMPLES)) do del /q %i
	-del /q *.pdb
	-del /q *~

XCCom_i.c XCCom.h XCCom.tlb: XCCom.idl
	midl /h XCCom.h XCCom.idl

msscript_i.c msscript.h: msscript.idl
	midl /h msscript.h msscript.idl

../XCircuit.COM.dll: XCCom.tlb
	tlbimp /out:$@ /namespace:XCircuit.COM XCCom.tlb

../XCircuit.dll: xcdotnet.cs ../XCircuit.COM.dll
	csc /t:library /out:$@ /r:../XCircuit.COM.dll xcdotnet.cs

xccom.c: XCCom.h XCircuit.h XCArc.h XCObject.h XCPoint.h XCPolygon.h XCText.h msscript_i.c
XCircuit.c: XCircuit.h XCArc.h XCPolygon.h XCDotNet.h
XCircuit.h: utils.h XCCom.h xccom-def.h msscript.h
XCArc.c: XCArc.h
XCArc.h: XCCom.h utils.h XCObject.h
XCObject.c: XCObject.h
XCObject.h: XCCom.h utils.h
XCPoint.c: XCPoint.h
XCPoint.h: XCCom.h utils.h
XCPolygon.c: XCPolygon.h
XCPolygon.h: XCCom.h utils.h XCObject.h
XCText.c: XCText.h
XCText.h: XCCom.h utils.h XCObject.h
XCDotNet.h: XCCom.h utils.h
XCDotNet.c: XCDotNet.h
XCMenu.c: XCircuit.h
utils.c: utils.h
xccom-iface.c: xccom-iface.h

$(EXAMPLES): ../XCircuit.dll

.cs.dll:
	csc /t:library /out:$@ /r:../XCircuit.dll $<

comtest.dll: comtest.cs
	csc /t:library /out:$@ /r:../XCircuit.COM.dll comtest.cs

.SUFFIXES: .cs .dll .c .obj
