####
#### Out of order! Use autoconfiscation.
####

## Makefile for building the GTK DLL with gcc on Win32
## Use: make -f makefile.mingw

## There is no install target, you have to decide where and 
## how to install for yourself.

OPTIMIZE = -g

TOP = ../..

include ../build/win32/make.mingw

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

# Possibly override versions from build/win32/module.defs
GTK_VER = @GTK_MAJOR_VERSION@.@GTK_MINOR_VERSION@
GDK_PIXBUF_VER = @GDK_PIXBUF_MAJOR@.@GDK_PIXBUF_MINOR@

GDK_LIBS = -L ../gdk -lgdk-win32-$(GTK_VER)
GTK_LIBS = -L . -lgtk-win32-$(GTK_VER)
GDK_PIXBUF_LIBS = -L ../gdk-pixbuf -lgdk_pixbuf-$(GDK_PIXBUF_VER)

# Perl and awk are needed to generate some source files.
# These generated source files are distributed with the Win32 GTk+ source
# distributions, so don't worry if you don't have perl and awk.
PERL = perl
AWK = awk

INCLUDES = -I . -I .. -I ../gdk -I ../gdk-pixbuf
DEPCFLAGS = $(PANGO_CFLAGS) $(GLIB_CFLAGS) $(LIBICONV_CFLAGS) $(INTL_CFLAGS)
DEFINES = -DGTK_COMPILATION -DG_LOG_DOMAIN=\"Gtk\" -DGTK_VERSION=\"@GTK_VERSION@\"

GLIB_GENMARSHAL = $(GLIB)/gobject/glib-genmarshal.exe

all :				\
	../config.h		\
	generated		\
	gtk-win32-$(GTK_VER).dll\
	testcalendar.exe	\
	testdnd.exe		\
	testgtk.exe		\
	testinput.exe		\
	testrgb.exe		\
	testselection.exe	\
	testtext.exe		\
	testtextbuffer.exe	\
	simple.exe

gtk_OBJECTS =			\
	fnmatch.o		\
	gtkaccelgroup.o		\
	gtkaccellabel.o		\
	gtkadjustment.o		\
	gtkalignment.o		\
	gtkarg.o		\
	gtkarrow.o		\
	gtkaspectframe.o	\
	gtkbin.o		\
	gtkbindings.o		\
	gtkbbox.o		\
	gtkbox.o		\
	gtkbutton.o		\
	gtkcalendar.o		\
	gtkcellrenderer.o	\
	gtkcellrenderertext.o	\
	gtkcellrenderertextpixbuf.o	\
	gtkcellrenderertoggle.o	\
	gtkcellrendererpixbuf.o	\
	gtkcheckbutton.o	\
	gtkcheckmenuitem.o	\
	gtkclipboard.o		\
	gtkclist.o		\
	gtkcolorsel.o		\
	gtkcolorseldialog.o	\
	gtkcombo.o		\
	gtkcontainer.o		\
	gtkctree.o		\
	gtkcurve.o		\
	gtkdialog.o		\
	gtkdnd.o		\
	gtkdrawingarea.o	\
	gtkeditable.o		\
	gtkentry.o		\
	gtkeventbox.o		\
	gtkfilesel.o		\
	gtkfixed.o		\
	gtkfontsel.o		\
	gtkframe.o		\
	gtkgamma.o		\
	gtkgc.o			\
	gtkhandlebox.o		\
	gtkhbbox.o		\
	gtkhbox.o		\
	gtkhpaned.o		\
	gtkhruler.o		\
	gtkhscale.o		\
	gtkhscrollbar.o		\
	gtkhseparator.o		\
	gtkhsv.o		\
	gtkiconfactory.o	\
	gtkimage.o		\
	gtkimagemenuitem.o	\
	gtkimcontext.o		\
	gtkimcontextsimple.o	\
	gtkimmodule.o		\
	gtkimmulticontext.o	\
	gtkinputdialog.o	\
	gtkinvisible.o		\
	gtkitem.o		\
	gtkitemfactory.o	\
	gtklabel.o		\
	gtklayout.o		\
	gtklist.o		\
	gtklistitem.o		\
	gtkmain.o		\
	gtkmenu.o		\
	gtkmenubar.o		\
	gtkmenufactory.o	\
	gtkmenuitem.o		\
	gtkmenushell.o		\
	gtkmessagedialog.o	\
	gtkmisc.o		\
	gtknotebook.o		\
	gtkobject.o		\
	gtkoldeditable.o	\
	gtkoptionmenu.o		\
	gtkpacker.o		\
	gtkpaned.o		\
	gtkpixmap.o		\
	gtkplug.o		\
	gtkpreview.o		\
	gtkprogress.o		\
	gtkprogressbar.o	\
	gtkradiobutton.o	\
	gtkradiomenuitem.o	\
	gtkrange.o		\
	gtkrbtree.o		\
	gtkrc.o			\
	gtkruler.o		\
	gtkscale.o		\
	gtkscrollbar.o		\
	gtkscrolledwindow.o	\
	gtkselection.o		\
	gtkseparator.o		\
	gtkseparatormenuitem.o	\
	gtksettings.o		\
	gtksignal.o		\
	gtksocket.o		\
	gtkspinbutton.o		\
	gtkstyle.o		\
	gtkstatusbar.o		\
	gtkstock.o		\
	gtktable.o		\
	gtktearoffmenuitem.o	\
	gtktext.o		\
	gtktextbtree.o		\
	gtktextbuffer.o		\
	gtktextchild.o		\
	gtktextdisplay.o	\
	gtktextiter.o		\
	gtktextlayout.o		\
	gtktextmark.o		\
	gtktextsegment.o	\
	gtktexttag.o		\
	gtktexttagtable.o	\
	gtktexttypes.o		\
	gtktextview.o		\
	gtkthemes.o		\
	gtktipsquery.o		\
	gtktogglebutton.o	\
	gtktoolbar.o		\
	gtktooltips.o		\
	gtktree.o		\
	gtktreeitem.o		\
	gtktreedatalist.o	\
	gtktreednd.o		\
	gtktreemodel.o		\
	gtktreemodelsort.o	\
	gtktreeselection.o	\
	gtktreestore.o		\
	gtktreeview.o		\
	gtktreeviewcolumn.o	\
	gtktypeutils.o		\
	gtkvbbox.o		\
	gtkvbox.o		\
	gtkviewport.o		\
	gtkvpaned.o		\
	gtkvruler.o		\
	gtkvscale.o		\
	gtkvscrollbar.o		\
	gtkvseparator.o		\
	gtkwidget.o		\
	gtkwindow.o		\
	gtkwindow-decorate.o

# Source headers which are non-autogenerated headers
gtk_public_h_sources =		\
	gtk.h			\
	gtkaccelgroup.h		\
	gtkaccellabel.h		\
	gtkadjustment.h		\
	gtkalignment.h		\
	gtkarg.h		\
	gtkarrow.h		\
	gtkaspectframe.h	\
	gtkbin.h		\
	gtkbindings.h		\
	gtkbbox.h		\
	gtkbox.h		\
	gtkbutton.h		\
	gtkcalendar.h		\
	gtkcheckbutton.h	\
	gtkcheckmenuitem.h	\
	gtkseparatormenuitem.h	\
	gtkclist.h		\
	gtkclipboard.h		\
	gtkcolorsel.h		\
	gtkcolorseldialog.h	\
	gtkcombo.h		\
	gtkcontainer.h		\
	gtkctree.h		\
	gtkcurve.h		\
	gtkcellrenderer.h	\
	gtkcellrenderertext.h	\
	gtkcellrenderertextpixbuf.h	\
	gtkcellrenderertoggle.h	\
	gtkcellrendererpixbuf.h	\
	gtkdebug.h		\
	gtkdialog.h		\
	gtkdnd.h		\
	gtkdrawingarea.h	\
	gtkeditable.h		\
	gtkentry.h		\
	gtkenums.h		\
	gtkeventbox.h		\
	gtkfilesel.h		\
	gtkfixed.h		\
	gtkfontsel.h		\
	gtkframe.h		\
	gtkgamma.h		\
	gtkgc.h			\
	gtkhandlebox.h		\
	gtkhbbox.h		\
	gtkhbox.h		\
	gtkhpaned.h		\
	gtkhruler.h		\
	gtkhscale.h		\
	gtkhscrollbar.h		\
	gtkhseparator.h		\
	gtkhsv.h		\
	gtkiconfactory.h	\
	gtkimage.h		\
	gtkimagemenuitem.h	\
	gtkimcontext.h		\
	gtkimmodule.h		\
	gtkimmulticontext.h	\
	gtkinputdialog.h	\
	gtkinvisible.h		\
	gtkitem.h		\
	gtkitemfactory.h	\
	gtklabel.h		\
	gtklayout.h		\
	gtklist.h		\
	gtklistitem.h		\
	gtkliststore.h		\
	gtkmain.h		\
	gtkmenu.h		\
	gtkmenubar.h		\
	gtkmenufactory.h	\
	gtkmenuitem.h		\
	gtkmenushell.h		\
	gtkmessagedialog.h	\
	gtkmisc.h		\
	gtknotebook.h		\
	gtkoldeditable.h	\
	gtkobject.h		\
	gtkoptionmenu.h		\
	gtkpacker.h		\
	gtkpaned.h		\
	gtkpixmap.h		\
	gtkplug.h		\
	gtkpreview.h		\
	gtkprivate.h		\
	gtkprogress.h		\
	gtkprogressbar.h	\
	gtkradiobutton.h	\
	gtkradiomenuitem.h	\
	gtkrange.h		\
	gtkrc.h			\
	gtkruler.h		\
	gtkscale.h		\
	gtkscrollbar.h		\
	gtkscrolledwindow.h	\
	gtkselection.h		\
	gtkseparator.h		\
	gtksettings.h		\
	gtksignal.h		\
	gtksocket.h		\
	gtkspinbutton.h		\
	gtkstyle.h		\
	gtkstatusbar.h		\
	gtkstock.h		\
	gtktable.h		\
	gtktearoffmenuitem.h	\
	gtktextbuffer.h		\
	gtktextchild.h		\
	gtktextdisplay.h	\
	gtktextiter.h		\
	gtktextlayout.h		\
	gtktextmark.h		\
	gtktexttag.h		\
	gtktexttagtable.h	\
	gtktextview.h		\
	gtktext.h		\
	gtktipsquery.h		\
	gtktogglebutton.h	\
	gtktoolbar.h		\
	gtktooltips.h		\
	gtktree.h		\
	gtktreednd.h		\
	gtktreeitem.h		\
	gtktreemodel.h		\
	gtktreemodelsort.h	\
	gtktreeselection.h	\
	gtktreesortable.h	\
	gtktreestore.h		\
	gtktreeview.h		\
	gtktreeviewcolumn.h	\
	gtktypeutils.h		\
	gtkvbbox.h		\
	gtkvbox.h		\
	gtkviewport.h		\
	gtkvpaned.h		\
	gtkvruler.h		\
	gtkvscale.h		\
	gtkvscrollbar.h		\
	gtkvseparator.h		\
	gtkwidget.h		\
	gtkwindow.h

# More headers to use when autogenerating.
gdk_headers =			\
	../gdk/gdkcolor.h	\
	../gdk/gdkcursor.h	\
	../gdk/gdkdnd.h		\
	../gdk/gdkdrawable.h	\
	../gdk/gdkevents.h	\
	../gdk/gdkfont.h	\
	../gdk/gdkgc.h		\
	../gdk/gdkimage.h	\
	../gdk/gdkinput.h	\
	../gdk/gdkpixmap.h	\
	../gdk/gdkproperty.h	\
	../gdk/gdkregion.h	\
	../gdk/gdkrgb.h		\
	../gdk/gdkselection.h	\
	../gdk/gdktypes.h	\
	../gdk/gdkvisual.h	\
	../gdk/gdkwindow.h

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

GENERATED = gtk.defs gtktypebuiltins.h gtktypebuiltins_vars.c gtktypebuiltins_ids.c gtktypebuiltins_evals.c gtkmarshal.h gtkmarshal.c

#
# Generated source files:
#
generated : $(GENERATED)

gtk.defs : makeenums.pl gtk-boxed.defs $(gtk_public_h_sources) $(gdk_headers)
	$(PERL) makeenums.pl defs $(gtk_public_h_sources) $(gdk_headers) >gd.tmp
	cat gd.tmp gtk-boxed.defs >gtk.defs
	rm gd.tmp

# generate type identifier header (GTK_TYPE_WIDGET_FLAGS)
gtktypebuiltins.h: gtk.defs maketypes.awk
	$(AWK) -f maketypes.awk gtk.defs macros >gtktypebuiltins.h

# generate type identifier variables (GTK_TYPE_WIDGET_FLAGS)
gtktypebuiltins_vars.c: gtk.defs maketypes.awk
	$(AWK) -f maketypes.awk gtk.defs variables >gtktypebuiltins_vars.c

# generate type entries for type-id registration
gtktypebuiltins_ids.c: gtk.defs maketypes.awk
	$(AWK) -f maketypes.awk gtk.defs entries >gtktypebuiltins_ids.c

# generate enum value arrays
gtktypebuiltins_evals.c: makeenums.pl gtk.defs
	$(PERL) makeenums.pl arrays $(gtk_public_h_sources) $(gdk_headers) >gtktypebuiltins_evals.c

gtkmarshal.h : gtkmarshal.list
	$(GLIB_GENMARSHAL) --prefix=gtk_marshal gtkmarshal.list --header >gtkmarshal.h

gtkmarshal.c : gtkmarshal.list
	$(GLIB_GENMARSHAL) --prefix=gtk_marshal gtkmarshal.list --body >gtkmarshal.c

#
# Linking:
#
gtk-win32-$(GTK_VER).dll : generated $(gtk_OBJECTS) gtk.def 
	$(GLIB)/build-dll gtk-win32 $(GTK_VER) gtk.def $(gtk_OBJECTS) $(GDK_LIBS) $(GDK_PIXBUF_LIBS) $(PANGO_LIBS) $(GLIB_LIBS) $(LIBICONV_LIBS) $(INTL_LIBS) -luser32

#
# Test programs:
#
testcalendar.exe : testcalendar.o
	$(CC) $(CFLAGS) -o $@ testcalendar.o $(GTK_LIBS) $(GDK_LIBS) $(PANGO_LIBS) $(GLIB_LIBS) $(LDFLAGS)

# Must have separate rules for these objects that don't go in the DLL
testcalendar.o : testcalendar.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testcalendar\" testcalendar.c

testdnd.exe : testdnd.o
	$(CC) $(CFLAGS) -o $@ testdnd.o $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testdnd.o : testdnd.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testdnd\" testdnd.c

testgtk.exe : testgtk.o
	$(CC) $(CFLAGS) -o $@  testgtk.o $(GTK_LIBS) $(GDK_LIBS) $(PANGO_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testgtk.o : testgtk.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testgtk\" testgtk.c

testinput.exe : testinput.o
	$(CC) $(CFLAGS) -o $@  testinput.o $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testinput.o : testinput.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testinput\" testinput.c

testrgb.exe : testrgb.o
	$(CC) $(CFLAGS) -o $@  testrgb.o $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testrgb.o : testrgb.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testrgb\" testrgb.c

testselection.exe : testselection.o
	$(CC) $(CFLAGS) -o $@  testselection.o $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testselection.o : testselection.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testselection\" testselection.c

testtext.exe : testtext.o
	$(CC) $(CFLAGS) -o $@  testtext.o $(PANGO_LIBS) $(GDK_PIXBUF_LIBS) $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testtext.o : testtext.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testtext\" testtext.c

testtextbuffer.exe : testtextbuffer.o
	$(CC) $(CFLAGS) -o $@  testtextbuffer.o $(GDK_PIXBUF_LIBS) $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

testtextbuffer.o : testtextbuffer.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"testtextbuffer\" testtextbuffer.c

simple.exe : simple.o
	$(CC) $(CFLAGS) -o $@  simple.o $(GTK_LIBS) $(GDK_LIBS) $(GLIB_LIBS) $(LDFLAGS)

simple.o : simple.c
	$(CC) $(CFLAGS) -UGTK_COMPILATION -c -DG_LOG_DOMAIN=\"simple\" simple.c

# The rmgen target removes just the generated source files
rmgen:
	-rm $(GENERATED)

# 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,@GTK_MAJOR[_]VERSION@,@GTK_MAJOR_VERSION@,' \
	    -e 's,@GTK_MINOR[_]VERSION@,@GTK_MINOR_VERSION@,' \
	    -e 's,@GTK[_]VERSION@,@GTK_VERSION@,' \
	    -e 's,@GDK_PIXBUF[_]MAJOR@,@GDK_PIXBUF_MAJOR@,'   \
	    -e 's,@GDK_PIXBUF[_]MINOR@,@GDK_PIXBUF_MINOR@,'     <$< >$@
