!IFNDEF PACKAGE

# dummy sissi
PLUGINS = cairo cgm dxf hpgl libart metapost pgf pixbuf \
	postscript pstricks shape svg vdx wmf wpg xfig xslt \
	drs stress layout pdf

# The main target
all : sub-all

sub-all: 
	for %d in ($(PLUGINS)) do @nmake -nologo -f makefile.msc sub-one THIS=%d

sub-one:
	@cd $(THIS)
	@nmake -nologo -f ..\makefile.msc $(THIS).dll PACKAGE=$(THIS) OBJ_$(THIS)=1
	@cd ..

clean:
	for %d in ($(PLUGINS)) do @nmake -nologo -f makefile.msc sub-clean THIS=%d

sub-clean:
	@cd $(THIS)
	@nmake -nologo -f ..\makefile.msc PACKAGE=$(THIS) clean
	@cd ..

!ELSE

TOP = ..\..\..
PRJ_TOP = ..\..
PKG_DEF = ..\objects.def

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

DEFINES = \
	-DHAVE_CONFIG_H \
	-DGTK_DISABLE_DEPRECATED

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

PKG_LINK = $(GTK2_LIBS) $(GLIB_LIBS) \
	$(LIBXML2_LIBS) $(GDK_PIXBUF_LIBS) \
	$(INTL_LIBS) \
	$(PRJ_TOP)\lib\libdia.lib

#
# Special object definitions for the various plugins, if needed
#
!IFDEF OBJ_autolayout
DEPCFLAGS = -I $(PRJ_TOP)\app
PKG_LINK = $(PKG_LINK) $(PRJ_TOP)\app\dia-app.lib
OBJECTS = \
	autolayout.obj \
	autolayout-force.obj \
	autolayout-register.obj
!ENDIF

!IFDEF OBJ_cairo
DEPCFLAGS = $(CAIRO_CFLAGS) -DHAVE_PANGOCAIRO_H
PKG_LINK = $(PKG_LINK) $(CAIRO_LIBS) $(PANGOCAIRO_LIBS) gdi32.lib
OBJECTS = \
	diacairo.obj \
	diacairo-interactive.obj \
	diacairo-renderer.obj \
	diacairo-print.obj
!ENDIF

!IFDEF OBJ_drs
OBJECTS = \
  dia-render-script.obj \
  dia-render-script-object.obj \
  dia-render-script-renderer.obj \
  dia-render-script-import.obj
!ENDIF

!IFDEF OBJ_dxf
OBJECTS = \
  autocad_pal.obj \
  dxf.obj \
  dxf-export.obj \
  dxf-import.obj
!ENDIF

!IFDEF OBJ_layout
DEPCFLAGS = -GX -I $(PRJ_TOP)\app $(OGDF_CFLAGS)
PKG_LINK = $(PKG_LINK) $(PRJ_TOP)\app\dia-app.lib $(OGDF_LIBS)
OBJECTS = \
	dia-graph.obj \
	layout.obj
!ENDIF

!IFDEF OBJ_libart
DEPCFLAGS = -DHAVE_LIBART -DHAVE_LIBPNG $(LIBART_CFLAGS) $(PNG_CFLAGS)
PKG_LINK = $(PKG_LINK) $(LIBART_LIBS) $(PNG_LIBS) ..\..\app\dia-app.lib
OBJECTS = \
  dialibart.obj \
  export_png.obj \
  render_libart.obj \
  dialibartrenderer.obj
!ENDIF

!IFDEF OBJ_metapost
OBJECTS = \
  metapost.obj \
  render_metapost.obj
!ENDIF

!IFDEF OBJ_pdf
DEPCFLAGS = -DWIN32 -DHAVE_POPPLER=1 $(POPPLER_CFLAGS) -GX -GR -EHs
EXTRALIBS = $(POPPLER_LIBS) $(JPEG_LIBS)
OBJECTS = \
  pdf.obj \
  pdf-import.obj
!ENDIF

!IFDEF OBJ_pstricks
OBJECTS = \
  pstricks.obj \
  render_pstricks.obj
!ENDIF

!IFDEF OBJ_postscript
OBJECTS = \
  render_eps.obj \
  paginate_psprint.obj \
!IFDEF USEFT2
  diapsft2renderer.obj \
!ENDIF
  diapsrenderer.obj \
  win32print.obj \
  postscript.obj \
  ps-utf8.obj

PKG_LINK = $(PKG_LINK) winspool.lib \
!IFDEF USEFT2
	$(PANGOFT2_LIBS) $(FREETYPE2_LIBS) \
!ENDIF
!ENDIF

!IFDEF OBJ_pgf
OBJECTS = \
  pgf.obj \
  render_pgf.obj
!ENDIF

!IFDEF OBJ_shape
OBJECTS = \
  shape.obj \
  shape-export.obj
!ENDIF

!IFDEF OBJ_stress
OBJECTS = \
  stress.obj \
  stress-memory.obj
!ENDIF

!IFDEF OBJ_svg
OBJECTS = \
  svg.obj \
  svg-import.obj \
  render_svg.obj
!ENDIF

!IFDEF OBJ_vdx 
OBJECTS = \
  vdx.obj \
  vdx-common.obj \
  vdx-export.obj \
  vdx-import.obj \
  vdx-xml.obj
!ENDIF

!IFDEF OBJ_wmf
PKG_LINK = $(PKG_LINK) $(PANGOWIN32_LIBS) comdlg32.lib winspool.lib 
OBJECTS = \
  paginate_gdiprint.obj \
  wmf.obj \
  wmf_gdi.obj
!ENDIF

!IFDEF OBJ_wpg
OBJECTS = \
  wpg.obj \
  wpg-import.obj
!ENDIF

!IFDEF OBJ_xfig
OBJECTS = \
  xfig.obj \
  xfig-common.obj \
  xfig-export.obj \
  xfig-import.obj
!ENDIF

!IFDEF OBJ_xslt
DEPCFLAGS = -DWIN32 $(LIBXSLT_CFLAGS)
EXTRALIBS = $(LIBXSLT_LIBS)
OBJECTS = xslt.obj \
	xsltdialog.obj
!ENDIF

# just one file ...
!IFNDEF OBJECTS
OBJECTS = $(PACKAGE).obj
!ENDIF

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

$(PACKAGE).dll : $(OBJECTS) $(PKG_DEF) $(EXTRALIBS)
	$(CC) $(CFLAGS) -LD -Fe$(PACKAGE).dll $(OBJECTS) \
	$(LDFLAGS) $(PKG_LINK) $(EXTRALIBS) user32.lib advapi32.lib wsock32.lib /def:$(PKG_DEF)
$(PRJ_TOP)\config.h: $(PRJ_TOP)\config.h.win32
	copy $(PRJ_TOP)\config.h.win32 $(PRJ_TOP)\config.h
.cpp.obj :
	$(CC) $(CFLAGS) -c $(PKG_CFLAGS) $<

!ENDIF

