#  Makefile for a GTK+-Binding for Haskell: Examples
#
#  Author : Manuel M. T. Chakravarty
#  Created: 16 January 1999
#
#  Version $Revision: 1.15 $ from $Date: 2002/01/17 10:41:53 $
#
#  Copyright (c) [1999..2001] Manuel M. T. Chakravarty
#
#  This file is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This file is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  = DOCU =====================================================================
#

#  ***************************************
#  !!! This makefile requires GNU make !!!
#  ***************************************

# slurp in the autoconf definitions
#
include ../mk/config.mk ../mk/common.mk

EXTRAHCFLAGS = -i../glib -i../gdk -i../gtk -I../glib -I../gdk -I../gtk\
	       '-\#include<gtk/gtk.h>' '-\#include"gtkHaskell.h"'
EXTRALDFLAGS = -L../glib -L../gdk -L../gtk\
               -lgtkHS -lgdkHS -lglibHS 
GTKHSLIBS = ../gtk/libgtkHS.a ../gdk/libgdkHS.a ../glib/libglibHS.a 

ALLTARGETS=hello hello2 hello3 hello4 hello5 butest drawtest etytest fseltest\
	   lbltest idletest rngtest tabtest threadtest tipstest menutest\
	   modtest gdkcoltest coltest booled

default:
	@echo "Targets: $(ALLTARGETS)"
	@echo "The target \`all' makes them all."

all: $(ALLTARGETS)

.phony: libglibHS.a libgdkHS.a libgtkHS.a
libglibHS.a:
	$(MAKE) -C ../glib $@
libgdkHS.a:
	$(MAKE) -C ../gdk $@
libgtkHS.a:
	$(MAKE) -C ../gtk $@

# the `Hello World!' series
#

hello: GtkHelloWorld.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

hello2: GtkHelloWorld2.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

hello3: GtkHelloWorld3.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

hello4: GtkHelloWorld4.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

hello5: GtkHelloWorld5.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

# some simple tests
#

butest: ButtonTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

drawtest: DrawTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

etytest: EntryTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

fseltest: FileSel.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

idletest: IdleTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

lbltest: LabelTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

modtest: ModuleTest.hs module_test.c $(GTKHSLIBS)
	$(CC) -c -fPIC -o modtest.o module_test.c
	$(CC) -shared -o libmodtest.so modtest.o
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

rngtest: RangeTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

tabtest: TableTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

threadtest: ThreadTest.hs $(GTKHSLIBS)
	$(HC) -syslib concurrent -o $@ $(HCFLAGS) $(HLDFLAGS) $<

tipstest: TooltipsTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

menutest: MenuTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

gdkcoltest: GdkColorTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

coltest: ColorTest.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<

booled: BoolEd.hs $(GTKHSLIBS)
	$(HC) -o $@ $(HCFLAGS) $(HLDFLAGS) $<


# auxilliary targets
#
.PHONY: clean spotless cleanall
clean:
	-$(RM) *.o *.so *.hi $(ALLTARGETS)

spotless cleanall: clean
