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

# OPTIMIZE = -g

ifndef PACKAGE

PLUGINS = chronogram custom er flowchart fs grafcet \
		network sadt standard uml 

# 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 = ../../..
include $(TOP)/glib/build/win32/make.mingw
PRJ_TOP = ../..
PKG_DEF = ../objects.def

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

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

#
# Object definitions for the various plugins
#

ifdef OBJ_chronogram
OBJECTS = \
	chronogram.o \
	chronoline.o \
	chronoline_event.o \
	chronoref.o

endif

ifdef OBJ_custom
OBJECTS = \
	custom.o \
	custom_object.o \
	custom_util.o \
	shape_info.o
endif

ifdef OBJ_eml
OBJECTS = \
        dbox.o \
        eml.o \
        instantiation.o \
        interaction.o \
        interaction-ortho.o \
        listfun.o \
        nlist.o \
        process.o \
        process_dialog.o
endif

ifdef OBJ_er
OBJECTS = \
	attribute.o \
	entity.o \
	er.o \
	participation.o \
	relationship.o
endif

ifdef OBJ_flowchart
OBJECTS = \
	box.o \
	diamond.o \
	ellipse.o \
	flowchart.o \
	parallelogram.o
endif

ifdef OBJ_fs
OBJECTS = \
	flow.o \
	flow-ortho.o \
	fs.o \
	function.o
endif

ifdef OBJ_grafcet
OBJECTS = \
	action.o \
	action_text_draw.o \
	boolequation.o \
	condition.o \
	grafcet.o \
	step.o \
	transition.o \
	vector.o \
	vergent.o
endif

ifdef OBJ_labels
OBJECTS = \
	labels.o \
	labelline.o \
	labeltextobj.o
endif

ifdef OBJ_network
OBJECTS = \
	bus.o \
	network.o \
	wanlink.o
endif

ifdef OBJ_sadt
OBJECTS = \
	annotation.o \
	arrow.o \
	box.o \
	sadt.o
endif

ifdef OBJ_standard
OBJECTS = \
	arc.o \
	bezier.o \
	beziergon.o \
	box.o \
	ellipse.o \
	image.o \
	line.o \
	polygon.o
	polyline.o \
	standard.o \
	textobj.o \
	zigzagline.o
endif

ifdef OBJ_sybase
OBJECTS = \
	sybase.o
endif

ifdef OBJ_uml
OBJECTS = \
	activity.o \
	actor.o \
	association.o \
	branch.o \
	class.o \
	class_dialog.o \
	classicon.o \
	component.o \
	constraint.o \
	dependency.o \
	fork.o \
	generalization.o \
	implements.o \
	large_package.o \
	lifeline.o \
	message.o \
	node.o \
	note.o \
	object.o \
	realizes.o \
	small_package.o \
	state.o \
	state_term.o \
	stereotype.o \
	uml.o \
	usecase.o
endif

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

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

all : $(PACKAGE).dll

$(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

