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

INCLUDES = \
	-FImsvc_recommended_pragmas.h \
	-I. -I$(PRJ_TOP) \
	$(GLIB_CFLAGS) $(GTK2_CFLAGS) $(LIBXML2_CFLAGS) \
	-I$(PRJ_TOP)\lib \

# -DWIN32 for newer libxml versions
DEFINES = \
	-DHAVE_CONFIG_H \
	-DWIN32 \
	-DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \

PKG_LINK = $(GTK2_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) $(PANGOWIN32_LIBS) $(PANGOCAIRO_LIBS) \
	$(LIBXML2_LIBS) \
	$(PRJ_TOP)\lib\libdia.lib $(CAIRO_LIBS) \
	$(GDK_PIXBUF_LIBS) $(INTL_LIBS) \

OBJECTS = \
	autosave.obj \
	app_procs.obj \
	color_area.obj \
	commands.obj \
	confirm.obj \
	connectionpoint_ops.obj \
	create_object.obj \
	cursor.obj \
	cut_n_paste.obj \
	defaults.obj \
	diagram.obj \
	diapagelayout.obj \
	dia-props.obj \
	disp_callbacks.obj \
	display.obj \
	dynamic_refresh.obj \
	exit_dialog.obj \
	filedlg.obj \
	find-and-replace.obj \
	grid.obj \
	gtkhwrapbox.obj \
	gtkvwrapbox.obj \
	gtkwrapbox.obj \
	handle_ops.obj \
	highlight.obj \
	interface.obj \
	layer_dialog.obj \
	linewidth_area.obj \
	load_save.obj \
	magnify.obj \
	menus.obj \
	modify_tool.obj \
	navigation.obj \
	object_ops.obj \
	pagesetup.obj \
	plugin-manager.obj \
	preferences.obj \
	properties-dialog.obj \
	recent_files.obj \
	render_gdk.obj \
	ruler.obj \
	scroll_tool.obj \
	select.obj \
	sheets.obj \
	sheets_dialog.obj \
	sheets_dialog_callbacks.obj \
	splash.obj \
	textedit.obj \
	textedit_tool.obj \
	tool.obj \
	toolbox.obj \
	undo.obj \
	\
	diagram_tree_model.obj \
	diagram_tree_view.obj \
	\
	dia-application.obj

ICON_PNG_PAIRS = \
	dia_connectable_icon pixmaps\connectable.png \
	dia_connectable_empty_icon pixmaps\connectable-empty.png \
	dia_selectable_icon pixmaps\selectable.png \
	dia_selectable_empty_icon pixmaps\selectable-empty.png \
	dia_on_grid_icon pixmaps\on-grid.png \
	dia_off_grid_icon pixmaps\off-grid.png \
	dia_visible_icon pixmaps\visible.png \
	dia_visible_empty_icon pixmaps\visible-empty.png \
	dia_modify_tool_icon pixmaps\arrow-22.png \
	dia_textedit_tool_icon pixmaps\textedit-22.png \
	dia_scroll_tool_icon pixmaps\scroll-22.png \
	dia_zoom_tool_icon pixmaps\zoom-22.png \
	dia_group_icon pixmaps\group.png \
	dia_ungroup_icon pixmaps\ungroup.png \
	dia_mainpoints_on_icon pixmaps\mainpoints-on.png \
	dia_mainpoints_off_icon pixmaps\mainpoints-off.png \
	\
	dia_diagram_icon pixmaps\dia-diagram.png \
	dia_app_icon pixmaps\dia-app.png \
	\
	dia_objects_layer_above pixmaps\objects-layer-above.png \
	dia_objects_layer_below pixmaps\objects-layer-below.png \
	dia_layers pixmaps\layers.png \
	dia_layer_add pixmaps\layer-add.png \
	dia_layer_rename pixmaps\layer-rename.png \
	\
	dia_cursor_create pixmaps\cursor-create.png \
	dia_cursor_hand_open pixmaps\cursor-hand-open.png \
	dia_cursor_hand_closed pixmaps\cursor-hand-closed.png \
	dia_cursor_magnify_minus pixmaps\cursor-magnify-minus.png \
	dia_cursor_magnify_plus pixmaps\cursor-magnify-plus.png \

dia-app-icons.h : makefile.msc pixmaps\*.png
	gdk-pixbuf-csource --build-list \
	$(ICON_PNG_PAIRS) > dia-app-icons.h || del dia-app-icons.h

# No general LDFLAGS needed
# /subsystem:console and /subsystem:windows have their own exe
INSTALL = copy

## targets
all : \
	$(PRJ_TOP)\config.h \
	dia-app-icons.h \
	$(PACKAGE)-app.dll \
	$(PACKAGE).exe \
	$(PACKAGE)w.exe \
	$(PACKAGE)-win-remote.exe

$(PACKAGE).res : $(PACKAGE).rc $(PACKAGE).ico
	rc -r -fo $(PACKAGE).res $(PACKAGE).rc

RESOURCE = $(PACKAGE).res

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

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

$(PACKAGE).exe : $(OBJECTS) $(PACKAGE).def $(PACKAGE).res main.obj $(PACKAGE)-app.dll
	$(CC) $(CFLAGS) -Fe$(PACKAGE).exe $(PACKAGE).res main.obj \
	$(LDFLAGS) dia-app.lib $(PKG_LINK) user32.lib advapi32.lib /subsystem:console

$(PACKAGE)w.exe : $(OBJECTS) $(PACKAGE).def $(PACKAGE).res winmain.obj $(PACKAGE)-app.dll
	$(CC) $(CFLAGS) -Fe$(PACKAGE)w.exe $(PACKAGE).res winmain.obj \
	$(LDFLAGS) dia-app.lib $(PKG_LINK) gdi32.lib comdlg32.lib user32.lib advapi32.lib $(LDFLAGS) /subsystem:windows

$(PACKAGE)-win-remote.exe : dia-win-remote.c dia-win-remote.obj
	$(CC) $(CFLAGS) -Fedia-win-remote.exe $(PACKAGE).res dia-win-remote.obj \
	$(LDFLAGS) $(GLIB_LIBS) gdi32.lib comdlg32.lib user32.lib advapi32.lib shell32.lib \
	shlwapi.lib /subsystem:windows

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