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

TOP = ../..
PRJ_TOP = ..
PACKAGE = libdia
include $(TOP)/glib/build/win32/make.mingw

# OPTIMIZE = -g

PKG_CFLAGS = -I .. \
	$(GLIB_CFLAGS) \
	$(GTK2_CFLAGS) \
	-DWIN32 $(LIBXML2_CFLAGS) \
	$(ZLIB_CFLAGS) \
	-I $(LIBART)/.. \
	$(INTL_CFLAGS) \
	-DLIBDIA_COMPILATION

# in GTK_CFLAGS: $(GLIB_CFLAGS) 

PKG_LINK = -lm $(GTK2_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) \
	$(LIBXML2_LIBS) $(ZLIB_LIBS) $(INTL_LIBS)

# Debug
# OPTIMIZE = -g

OBJECTS = \
	arrows.o \
	attributes.o \
	bezier_conn.o \
	beziershape.o \
	boundingbox.o \
	color.o \
	connection.o \
	connpoint_line.o \
	dia_dirs.o \
	dia_image.o \
	dia_svg.o \
	dia_xml.o \
	diagramdata.o \
	diagdkrenderer.o \
	diagtkfontsel.o \
	diainteractiverenderer.o \
	dialibartrenderer.o \
	diarenderer.o \
	diatransform.o \
	dynamic_obj.o \
	element.o \
	filter.o \
	focus.o \
	font.o \
	geometry.o \
	group.o \
	intl.o \
	message.o \
	neworth_conn.o \
	objchange.o \
	object.o \
	object_defaults.o \
	orth_conn.o \
	paper.o \
	plug-ins.o \
	poly_conn.o \
	polyshape.o \
	prefs.o \
	prop_attr.o \
	prop_basic.o \
	prop_geomtypes.o \
	prop_inttypes.o \
	prop_sdarray.o \
	prop_text.o \
	prop_widgets.o \
	propdesc.o \
	propdialogs.o  \
	properties.o \
	proplist.o \
	propobject.o \
	propoffsets.o \
	propregistry.o \
	ps-utf8.o \
	sheet.o \
	text.o \
	utils.o \
	widgets.o \

DEPCFLAGS = -I . -DHAVE_CONFIG_H $(PKG_CFLAGS)

## targets
all : \
	$(PRJ_TOP)/config.h \
	$(PACKAGE).dll

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

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

# -Wl,-Map,libdia.map 
$(PACKAGE).dll : $(OBJECTS) $(PACKAGE).def
	dllwrap --mno-cygwin --dllname $(PACKAGE).dll --output-exp $(PACKAGE).exp --def $(PACKAGE).def $(OBJECTS) $(PKG_LINK) -luser32 -lwsock32 -ladvapi32

# how to get the functions exported ??
#$(PACKAGE).dll : $(OBJECTS) $(PACKAGE).def
#	$(CC) --shared -o $(PACKAGE).dll --def $(PACKAGE).def $(OBJECTS) $(PKG_LINK) -luser32 -lwsock32 -ladvapi32 -Wl,--out-implib,$(PACKAGE).a 

#$(PACKAGE).dll : $(OBJECTS) $(PACKAGE).def
#	sh $(PRJ_TOP)/build/win32/build-dll libdia - $(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 

clean::
	del config.h
	del *.exe
	del *.o
	del *.dll
	del *.lib
	del *.err
	del *.map
	del *.sym
	del *.exp
	del *.lk1
	del *.mk1
	del *.pdb
	del *.ilk
