# Makefile for mingw (with gnu make, but without bash), use :
# make -f makefile.mingw

# OPTIMIZE = -g

ifndef PACKAGE

PLUGINS = cgm dummy dxf hpgl pstricks shape svg wmf wpg xfig

# The main target
all : sub-all

sub-all : 
	for %%d in ($(PLUGINS)) do make --no-print-directory -f makefile.mingw sub-one THIS=%%d

sub-one :
	make -C $(THIS) -f ../makefile.mingw $(THIS).dll PACKAGE=$(THIS) OBJ_$(THIS)=1

else

TOP = ../../..
PRJ_TOP = ../..
PKG_DEF = ../objects.def

include $(TOP)/glib/build/win32/make.mingw

PKG_CFLAGS = $(GLIB_CFLAGS) $(GTK2_CFLAGS) $(PANGO_LIBS) \
	-I. $(LIBXML2_CFLAGS) -I$(PRJ_TOP)/lib \

PKG_LINK = $(GTK2_LIBS) $(GLIB_LIBS) $(LIBXML2_LIBS) \
	-L $(PRJ_TOP)/lib -llibdia

#
# Special object definitions for the various plugins, if needed
#

ifdef OBJ_dxf
OBJECTS = \
  dxf.o \
  dxf-export.o \
  dxf-import.o
endif

ifdef OBJ_pstricks
OBJECTS = \
  pstricks.o \
  render_pstricks.o
endif

ifdef OBJ_shape
OBJECTS = \
  shape.o \
  shape-export.o
endif

ifdef OBJ_svg
OBJECTS = \
  svg.o \
  render_svg.o
endif

ifdef OBJ_wmf
OBJECTS = \
  wmf.o \
  wmf_gdi.o
endif

ifdef OBJ_xfig
OBJECTS = \
  xfig.o \
  xfig-common.o \
  xfig-export.o \
  xfig-import.o
# this plug-in imports group_create () from dia.exe 
#PKG_LINK = $(PKG_LINK) -L ../../app -ldia
endif

# just one file ...
ifndef OBJECTS
OBJECTS = $(PACKAGE).o
endif

## common stuff

DEPCFLAGS = -I. -I$(PRJ_TOP) -DHAVE_CONFIG_H $(PKG_CFLAGS)

$(PACKAGE).dll : $(OBJECTS)
	dllwrap --mno-cygwin --dllname $(PACKAGE).dll --implib $(PACKAGE).lib --output-exp $(PACKAGE).exp --def ../objects.def $(OBJECTS) $(PKG_LINK) -luser32 -lwsock32 -ladvapi32

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

endif
