## Makefile for building gimp modules with Microsoft C
## Use: nmake -f makefile.msc

# Change this to wherever you install the gimp.
GIMP = C:\gimp
BIN = $(GIMP)\modules

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

# Nothing much configurable below

!IFNDEF DEBUG
# Full optimization:
OPTIMIZE = -Ox -MD
LINKDEBUG = /subsystem:windows
!ELSE
# Debugging:
OPTIMIZE = -Zi -MDd
LINKDEBUG = /subsystem:console /debug
!ENDIF

# cl -? describes the options
CC = cl -G5 -GF $(OPTIMIZE) -W3 -nologo

LDFLAGS = /link $(LINKDEBUG)
INSTALL = copy

GIMP_VER = 1.1
GTK_VER = 1.3
GLIB_VER = 1.3

GLIB = ..\..\glib
GMODULE = $(GLIB)\gmodule
GTK = ..\..\gtk+
INTL = ..\..\intl

CFLAGS = -DHAVE_CONFIG_H -DMODULE_COMPILATION -I. -I.. -I$(GLIB) -I$(GMODULE) -I$(GTK)\gdk -I$(GTK) -I$(INTL)

MODULES = \
	colorsel_gtk-$(GIMP_VER).dll \
	colorsel_triangle-$(GIMP_VER).dll \
	colorsel_water-$(GIMP_VER).dll


all : \
	$(MODULES)

install : all
	for %m in ($(MODULES)) do copy %m $(BIN)

..\config.h : ..\config.h.win32
	copy ..\config.h.win32 ..\config.h

colorsel_gtk-$(GIMP_VER).dll : colorsel_gtk.obj module.def
	$(CC) $(CFLAGS) -LD -Fe$@ colorsel_gtk.obj $(LDFLAGS) ..\app\gimp.lib $(GTK)\gtk\gtk-$(GTK_VER).lib $(GLIB)\gmodule-$(GLIB_VER).lib $(GLIB)\glib-$(GLIB_VER).lib /def:module.def

colorsel_triangle-$(GIMP_VER).dll : colorsel_triangle.obj module.def
	$(CC) $(CFLAGS) -LD -Fe$@ colorsel_triangle.obj $(LDFLAGS) ..\app\gimp.lib $(GTK)\gtk\gtk-$(GTK_VER).lib $(GTK)\gdk\gdk-$(GTK_VER).lib $(INTL)\gnu-intl.lib $(GLIB)\gmodule-$(GLIB_VER).lib $(GLIB)\glib-$(GLIB_VER).lib /def:module.def

colorsel_water-$(GIMP_VER).dll : colorsel_water.obj module.def
	$(CC) $(CFLAGS) -LD -Fe$@ colorsel_water.obj $(LDFLAGS) ..\app\gimp.lib $(GTK)\gtk\gtk-$(GTK_VER).lib $(GTK)\gdk\gdk-$(GTK_VER).lib $(INTL)\gnu-intl.lib $(GLIB)\gmodule-$(GLIB_VER).lib $(GLIB)\glib-$(GLIB_VER).lib /def:module.def

# General rule for building 
.c.obj:
	$(CC) $(CFLAGS) -GD -c $<

clean:
	del *.dll
	del *.lib
	del *.obj
	del *.exp
	del *.err
	del *.map
	del *.sym
	del *.pdb
	del *.ilk
