INCLUDES = -I.. $(PYTHON_INCLUDES) $(PYGTK_CFLAGS)

if PLATFORM_WIN32
no_undefined = -no-undefined
CYGWIN_LIBADD =-L/usr/lib/python2.2/config -lpython2.2
endif

PYGTK_DEFSDIR = @PYGTK_DEFSDIR@

defsdir = @PYGTK_DEFSDIR@
defs_DATA = \
	diacanvas.defs \
	diaview.defs \
	diageometry.defs \
	diashape.defs \
	../diacanvas/dia-boxed.defs

pydiacanvasdir = $(pythondir)/diacanvas
pydiacanvas_PYTHON = __init__.py placementtool.py
pydiacanvasexecdir = $(pyexecdir)/diacanvas

# pydiacanvas_LDFLAGS should be followed by the init-function
pydiacanvas_LDFLAGS = $(no_undefined) -module -avoid-version -export-symbols-regex
pydiacanvas_LIBADD = $(DIACANVAS2_LIBS) -L../diacanvas -ldiacanvas2 $(CYGWIN_LIBADD)


pydiacanvasexec_LTLIBRARIES = \
	_canvasmodule.la \
	viewmodule.la \
	geometrymodule.la \
	shapemodule.la

# Canvas module: Canvas, CanvasItem, Solver, etc.
_canvasmodule_la_CFLAGS = -I.. $(DIACANVAS2_CFLAGS)
_canvasmodule_la_LDFLAGS = $(pydiacanvas_LDFLAGS) init_canvas
_canvasmodule_la_LIBADD = $(pydiacanvas_LIBADD)
_canvasmodule_la_SOURCES = diacanvasmodule.c pydiacanvasitem.c
nodist__canvasmodule_la_SOURCES = diacanvas.c

# CanvasView module: CanvasView, CanvasViewItem, Tool, etc.
viewmodule_la_CFLAGS = -I.. $(DIACANVAS2_CFLAGS)
viewmodule_la_LDFLAGS = $(pydiacanvas_LDFLAGS) initview
viewmodule_la_LIBADD = $(pydiacanvas_LIBADD)
viewmodule_la_SOURCES = diaviewmodule.c
nodist_viewmodule_la_SOURCES = diaview.c

# Geometry module: Point, Rectangle, Affine
geometrymodule_la_CFLAGS = -I.. $(DIACANVAS2_CFLAGS)
geometrymodule_la_LDFLAGS = $(pydiacanvas_LDFLAGS) initgeometry
geometrymodule_la_LIBADD = $(pydiacanvas_LIBADD)
geometrymodule_la_SOURCES = diageometrymodule.c
nodist_geometrymodule_la_SOURCES = diageometry.c

# Shape module: Path, Ellipse, Image, Text, etc.
shapemodule_la_CFLAGS = -I.. $(DIACANVAS2_CFLAGS)
shapemodule_la_LDFLAGS = $(pydiacanvas_LDFLAGS) initshape
shapemodule_la_LIBADD = $(pydiacanvas_LIBADD)
shapemodule_la_SOURCES = diashapemodule.c
nodist_shapemodule_la_SOURCES = diashape.c

CLEANFILES = diacanvas.c diaview.c diageometry.c diashape.c

EXTRA_DIST = \
	diacanvas.override \
	diaview.override \
	diageometry.override \
	diashape.override \
	test-canvas.py \
	demo.py \
	demoitem.py \
	demo.sh \
	__init__.py \
	setup.py \
	$(defs_DATA)

all-local: .libs/__init__.py
	test -L ./diacanvas || $(LN_S) .libs diacanvas

.libs/__init__.py: __init__.py
	cp __init__.py .libs/__init__.py

diacanvas.c: diacanvas.defs ../diacanvas/dia-boxed.defs diacanvas.override
	(cd $(srcdir) \
	 && $(PYGTK_CODEGEN) \
	    --register $(PYGTK_DEFSDIR)/pango-types.defs \
	    --register ../diacanvas/dia-boxed.defs \
	    --register diashape.defs \
	    --override diacanvas.override \
	    --prefix pydiacanvas diacanvas.defs) > gen-diacanvas.c \
	 && cp gen-diacanvas.c diacanvas.c \
	 && rm -f gen-diacanvas.c

diaview.c: diacanvas.defs diaview.defs diaview.override
	(cd $(srcdir) \
	 && $(PYGTK_CODEGEN) \
	    --register $(PYGTK_DEFSDIR)/pango-types.defs \
	    --register $(PYGTK_DEFSDIR)/gdk-types.defs \
	    --register $(PYGTK_DEFSDIR)/gtk-types.defs \
	    --register $(PYGTK_DEFSDIR)/canvas.defs \
	    --register diacanvas.defs \
	    --override diaview.override \
	    --prefix pydiaview diaview.defs) > gen-diaview.c \
	 && cp gen-diaview.c diaview.c \
	 && rm -f gen-diaview.c

diageometry.c: diacanvas.defs diageometry.defs diageometry.override
	(cd $(srcdir) \
	 && $(PYGTK_CODEGEN) \
	    --register diacanvas.defs \
	    --override diageometry.override \
	    --prefix pydiageometry diageometry.defs) > gen-diageometry.c \
	 && cp gen-diageometry.c diageometry.c \
	 && rm -f gen-diageometry.c

diashape.c: diacanvas.defs diashape.defs diashape.override
	(cd $(srcdir) \
	 && $(PYGTK_CODEGEN) \
	    --register $(PYGTK_DEFSDIR)/pango-types.defs \
	    --register $(PYGTK_DEFSDIR)/gdk-types.defs \
	    --register diacanvas.defs \
	    --override diashape.override \
	    --prefix pydiashape diashape.defs) > gen-diashape.c \
	 && cp gen-diashape.c diashape.c \
	 && rm -f gen-diashape.c
