PRJ_TOP=..
TOP = ..\..
!INCLUDE $(PRJ_TOP)\dia-make.msc

!IFNDEF PYTHON_VERSION
PYTHON_VERSION=27
!ENDIF
!IFNDEF PYTHON
PYTHON = ..\..\..\python$(PYTHON_VERSION)
!ENDIF

EXTRALIBS = $(PYTHON)\libs\python$(PYTHON_VERSION).lib user32.lib

INCLUDES = \
	-I.. \
	-I..\lib

SWIG_FLAGS = $(INCLUDES)

# we don't depend on Gtk at runtime, but some dia headers need it at compile time
CFLAGS = -FImsvc_recommended_pragmas.h \
!IFDEF DEBUG
	-D_DEBUG=1 \
!ENDIF
	-DHAVE_CONFIG_H $(INCLUDES) \
	-I$(PYTHON)\include $(GLIB_CFLAGS) $(GTK2_CFLAGS) $(INTL_CFLAGS) \
	$(LIBXML2_CFLAGS)

CPPFLAGS = $(CFLAGS) -GX -GR -Zi

EXTRALIBS = $(EXTRALIBS) $(LIBXML2_LIBS) $(INTL_LIBS) $(PANGO_LIBS) \
	..\lib\libdia.lib

GENERATED = \
	dia-python.cpp \
#	csharp\dia-csharp.cpp \
#	csharp\*.cs \

INTERFACES = \
	dia.swig \
	dia-properties.h \
	dia-object.h \
	dia-renderer.h \
	dia-diagramdata.h \
	dia-connections.h \

OBJECTS = \
        dia-connections.obj \
	dia-properties.obj \
	dia-object.obj \
	dia-renderer.obj \
	dia-diagramdata.obj \
	\
	dia-extra.obj \
	\
	dia-python-extra.obj

all : \
	_dia.pyd \
	
other : \
	dia-csharp.cpp \
	dia-xml.cpp \
	dia-perl.cpp \

dia-python.cpp : $(INTERFACES)
	swig $(SWIG_FLAGS) -python -modern -extranative -c++ -o $*.cpp dia.swig

dia-csharp.cpp : $(INTERFACES)
	swig $(SWIG_FLAGS) -csharp -c++ -o csharp\$*.cpp dia.swig

dia-xml.cpp : $(INTERFACES)
	swig $(SWIG_FLAGS) -xml -c++ -o xml\$*.cpp dia.swig

dia-perl.cpp : $(INTERFACES)
	swig $(SWIG_FLAGS) -perl -c++ -o perl\$*.cpp dia.swig

_dia.pyd : $(OBJECTS) dia-python.obj
	$(CC) -nologo $(CFLAGS) -LD -Fe$@ $(OBJECTS) dia-python.obj $(LDFLAGS) $(EXTRALIBS) $(GLIB_LIBS)

clean::
	del _dia.pyd dia.py dia.pyc $(GENERATED)
