## Makefile for building the GIMP DLLs and LIBs with gcc on Win32.
## You should use GNU make running on cygwin.
## Use: make -f makefile.mingw

TOP = ../..

include ../build/win32/make.mingw

# Possibly override GIMP version from build/win32/module.defs
GIMP_VER = @GIMP_MAJOR_VERSION@.@GIMP_MINOR_VERSION@

################################################################

# The name of the directory in your %HOME% where the GIMP's personal settings
# and stuff is saved.
GIMPDIR = _gimp$(GIMP_VER)

INCLUDES =  -I .. 
DEPCFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) $(INTL_CFLAGS)
DEFINES = -DGIMPDIR=\"$(GIMPDIR)\" -DG_LOG_DOMAIN=\"LibGimpBase\"

all :						\
	../config.h				\
	libgimpi.a				\
	gimp-$(GIMP_VER).dll			\
	gimpui-$(GIMP_VER).dll

../config.h : ../config.h.win32
	cp $< $@

PDB_WRAPPERS_O =				\
	gimpbrushes_pdb.o			\
	gimpbrushselect_pdb.o			\
	gimpchannel_pdb.o			\
	gimpchannelops_pdb.o			\
	gimpcolor_pdb.o				\
	gimpconvert_pdb.o			\
	gimpdisplay_pdb.o			\
	gimpdrawable_pdb.o			\
	gimpedit_pdb.o				\
	gimpfileops_pdb.o			\
	gimpfloatingsel_pdb.o			\
	gimpgimprc_pdb.o			\
	gimpgradients_pdb.o			\
	gimpgradientselect_pdb.o		\
	gimpguides_pdb.o			\
	gimphelp_pdb.o				\
	gimpimage_pdb.o				\
	gimplayer_pdb.o				\
	gimpmessage_pdb.o			\
	gimpmisc_pdb.o				\
	gimppalette_pdb.o			\
	gimpparasite_pdb.o			\
	gimppaths_pdb.o				\
	gimppatterns_pdb.o			\
	gimppatternselect_pdb.o			\
	gimpplugin_pdb.o			\
	gimpproceduraldb_pdb.o			\
	gimpselection_pdb.o			\
	gimptexttool_pdb.o			\
	gimptools_pdb.o				\
	gimpundo_pdb.o				\
	gimpunit_pdb.o

gimpi_OBJECTS =					\
	gimpenv.o				\
	gimpchainbutton.o			\
	gimpcolorbutton.o			\
	gimpcolorspace.o			\
	gimpdialog.o				\
	gimpfileselection.o			\
	gimphelpui.o				\
	gimpmatrix.o				\
	gimpparasite.o				\
	gimpparasiteio.o			\
	gimppatheditor.o			\
	gimppixmap.o				\
	gimpprotocol.o				\
	gimpquerybox.o				\
	gimpsizeentry.o				\
	gimpunitmenu.o				\
	gimputils.o				\
	gimpvector.o				\
	gimpwidgets.o				\
	gimpwire.o

libgimpi.a : $(gimpi_OBJECTS)
	ar cr libgimpi.a $(gimpi_OBJECTS)

gimp_OBJECTS =					\
	gimp.o					\
	$(PDB_WRAPPERS_O)			\
	gimpchannel.o				\
	gimpcolorspace.o			\
	gimpdrawable.o				\
	gimpenv.o				\
	gimpgradientselect.o			\
	gimphelp.o				\
	gimpimage.o				\
	gimplayer.o				\
	gimpmatrix.o				\
	gimpparasite.o				\
	gimpparasiteio.o			\
	gimppixelrgn.o				\
	gimpproceduraldb.o			\
	gimpprotocol.o				\
	gimpselection.o				\
	gimptile.o				\
	gimpunit.o				\
	gimpvector.o				\
	gimpwire.o

gimp-$(GIMP_VER).dll : $(gimp_OBJECTS) gimp.def
	$(GLIB)/build-dll gimp $(GIMP_VER) gimp.def -s $(gimp_OBJECTS) $(INTL_LIBS) $(GLIB_LIBS) -luser32

# Pass -DLIBGIMP_COMPILATION when compiling gimp.c which
# defines the exported variables.

gimp.o : gimp.c
	$(CC) $(CFLAGS) -c -DLIBGIMP_COMPILATION gimp.c

gimpui_OBJECTS =				\
	gimpmenu.o				\
	gimpbrushmenu.o				\
	gimpchainbutton.o			\
	gimpcolorbutton.o			\
	gimpdialog.o				\
	gimpexport.o				\
	gimpfileselection.o			\
	gimphelpui.o				\
	gimpgradientmenu.o			\
	gimppatheditor.o			\
	gimppatternmenu.o			\
	gimppixmap.o				\
	gimpquerybox.o				\
	gimpsizeentry.o				\
	gimpui.o				\
	gimpunitmenu.o				\
	gimpwidgets.o

gimpui-$(GIMP_VER).dll : $(gimpui_OBJECTS) gimpui.def
	$(GLIB)/build-dll gimpui $(GIMP_VER) gimpui.def -s $(gimpui_OBJECTS) -L . -lgimp-$(GIMP_VER) $(GTK_LIBS) $(INTL_LIBS) $(GLIB_LIBS)

# Hack to get an updated makefile.mingw automatically after updating
# makefile.mingw.in. Only for developer use.
makefile.mingw: makefile.mingw.in
	sed -e 's,@GIMP[_]MAJOR_VERSION@,@GIMP_MAJOR_VERSION@,' \
	    -e 's,@GIMP[_]MINOR_VERSION@,@GIMP_MINOR_VERSION@,' <$< >$@
