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

INCLUDES = \
	-FImsvc_recommended_pragmas.h \
	-I. -I.. \
	$(GTK2_CFLAGS) \
	$(LIBXML2_CFLAGS) \
	$(ZLIB_CFLAGS) \
!IFDEF USEFT2
	-DHAVE_FREETYPE $(FREETYPE2_CFLAGS) \
!ENDIF

DEFINES = \
	-DHAVE_CONFIG_H \
	-DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
	-DLIBDIA_COMPILATION

# in GTK_CFLAGS: $(GLIB_CFLAGS) 

PKG_LINK = $(GTK2_LIBS)  $(PANGOWIN32_LIBS) $(GLIB_LIBS) \
	$(PANGOCAIRO_LIBS) \
!IFDEF USEFT2
	$(PANGOFT2_LIBS) \
!ENDIF
	$(LIBXML2_LIBS) $(ZLIB_LIBS) \
	$(GDK_PIXBUF_LIBS) $(CAIRO_LIBS) \
	$(INTL_LIBS)

ICON_PNG_PAIRS = \
	dia_broken_icon pixmaps\broken.png \
	dia_broken_chain_icon pixmaps\broken-chain.png \
	dia_unbroken_chain_icon pixmaps\unbroken-chain.png \
	stdpath_icon pixmaps\standard-path.png

# Note that this doesn't seem to get run automatically.  It should, but
# I'm not gonna chase goblins right now.
dia-lib-icons.h:
	gdk-pixbuf-csource --build-list \
	$(ICON_PNG_PAIRS) > dia-lib-icons.h || del dia-lib-icons.h

OBJECTS = \
	autoroute.obj \
	arrows.obj \
	attributes.obj \
	bezier-common.obj \
	bezier_conn.obj \
	beziershape.obj \
	boundingbox.obj \
	color.obj \
	connection.obj \
	connectionpoint.obj \
	connpoint_line.obj \
	create.obj \
	debug.obj \
	diaarrowchooser.obj \
	diaarrowselector.obj \
	diacellrendererenum.obj \
	diacolorselector.obj \
	diacontext.obj \
	dialinechooser.obj \
	dialinestyleselector.obj \
	dialogs.obj \
	diatransform.obj \
	dia_dirs.obj \
	dia_image.obj \
	dia_svg.obj \
	dia_xml.obj \
	diaerror.obj \
	diagramdata.obj \
	diagdkrenderer.obj \
	diaimportrenderer.obj \
	diainteractiverenderer.obj \
	diarenderer.obj \
	diapathrenderer.obj \
	diapatternselector.obj \
	diatransformrenderer.obj \
	diasvgrenderer.obj \
	dynamic_obj.obj \
	element.obj \
	filter.obj \
	focus.obj \
	font.obj \
	geometry.obj \
	group.obj \
	intl.obj \
	dialib.obj \
	layer.obj \
	message.obj \
	objchange.obj \
	object.obj \
	object-alias.obj \
	object_defaults.obj \
	orth_conn.obj \
	paper.obj \
	parent.obj \
	path-math.obj \
	pattern.obj \
	persistence.obj \
	plug-ins.obj \
	poly_conn.obj \
	polyshape.obj \
	prefs.obj \
	prop_attr.obj \
	prop_basic.obj \
	prop_dict.obj \
	prop_geomtypes.obj \
	prop_inttypes.obj \
	prop_matrix.obj \
	prop_pattern.obj \
	prop_pixbuf.obj \
	prop_sdarray.obj \
	prop_sdarray_widget.obj \
	prop_text.obj \
	prop_widgets.obj \
	propdesc.obj \
	propdialogs.obj  \
	properties.obj \
	proplist.obj \
	propobject.obj \
	propoffsets.obj \
	propregistry.obj \
	render_pixmap.obj \
	sheet.obj \
	standard-path.obj \
	text.obj \
	textline.obj \
	units.obj \
	utils.obj \
	widgets.obj \
	diaoptionmenu.obj \
	diadynamicmenu.obj \
	diafontselector.obj \
	\
	diacellrendererproperty.obj \
	\
	diamarshal.obj \

#
# rules to generate built sources
#
# setup autogeneration dependancies
gen_sources = xgen-gwmh xgen-gwmc
CLEANFILES = $(gen_sources)

!IFNDEF GLIB_GEN_MARSHAL
GLIB_GEN_MARSHAL=$(TOP)\glib\gobject\glib-genmarshal
!ENDIF

diamarshal.h: diamarshal.list
	$(GLIB_GEN_MARSHAL) --prefix=dia_marshal diamarshal.list --header >> xgen-gwmh \
	&& copy /y xgen-gwmh diamarshal.h \
	&& del xgen-gwmh xgen-gwmh~

diamarshal.c: diamarshal.h
	echo #include "diamarshal.h" >> xgen-gwmc \
	&& $(GLIB_GEN_MARSHAL) --prefix=dia_marshal diamarshal.list --body >> xgen-gwmc \
	&& copy xgen-gwmc diamarshal.c \
	&& del xgen-gwmc xgen-gwmc~


# No general LDFLAGS needed
INSTALL = copy

## targets
all : \
	$(PRJ_TOP)\config.h \
	dia-lib-icons.h \
	diamarshal.c \
	$(PACKAGE).dll

$(PACKAGE).lib : $(OBJECTS)
	lib /out:$(PACKAGE).lib $(OBJECTS)

$(PACKAGE).dll : $(OBJECTS) $(PACKAGE).def
	$(CC) $(CFLAGS) -LD -Fe$(PACKAGE).dll $(OBJECTS) \
	$(LDFLAGS) $(PKG_LINK) user32.lib advapi32.lib wsock32.lib /def:$(PACKAGE).def

$(PRJ_TOP)\config.h: $(PRJ_TOP)\config.h.win32
	copy $(PRJ_TOP)\config.h.win32 $(PRJ_TOP)\config.h

font-height.exe : font-height.obj
	$(CC) $(CFLAGS) -Fe$@ font-height.obj \
	$(PKG_LINK) $(LDFLAGS) gdi32.lib user32.lib $(LDFLAGS) /subsystem:console

splint :
	sp -weak -fcnuse $(CFLAGS) proplist.c >sp.log

!IFDEF SCA
#sca : $(OBJECTS)
#	clang -analyze $(INCLUDES) $(DEFINES)
# Not using $(CFLAGS) for msvc either
.c.obj :
	clang --analyze $(INCLUDES) $(DEFINES) $(PKG_CFLAGS) $<
!ENDIF
