## Makefile for building the GIMP DLLs and LIBs with Microsoft C.
## Use: nmake -f makefile.msc

# Change this to wherever you want to install the DLLs. This directory
# should be in your PATH. As these DLLs are for the GIMP and its plug-ins
# only, it probably is best to keep them in the GIMP's bin directory.
BIN = C:\gimp\bin

GIMP_VER = 1.1

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

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

# Nothing much configurable below

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

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

LDFLAGS = /link $(LINKDEBUG)
INSTALL = copy

GTK_VER = 1.3
GLIB_VER = 1.3

GTK = ..\..\gtk+
GLIB = ..\..\glib
INTL = ..\..\intl

CFLAGS = -I.. -I$(GLIB) -I$(GTK)\gdk -I$(GTK)\gdk -I$(GTK) -I$(INTL) -DGIMPDIR=\"$(GIMPDIR)\"

all : \
	..\config.h	\
	gimpi.lib	\
	gimp-$(GIMP_VER).dll	\
	gimpui-$(GIMP_VER).dll

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

install : all
	$(INSTALL) gimp-$(GIMP_VER).dll $(BIN)
	$(INSTALL) gimpui-$(GIMP_VER).dll $(BIN)

gimpi_OBJECTS = \
	gimpenv.obj	\
	gimpchainbutton.obj\
	gimpcolorbutton.obj\
	gimpcolorspace.obj \
	gimpdialog.obj	\
	gimpfileselection.obj\
	gimphelpui.obj	\
	gimpmatrix.obj	\
	gimppatheditor.obj\
	gimpprotocol.obj\
	gimpquerybox.obj\
	gimpsizeentry.obj\
	gimpunitmenu.obj\
	gimpvector.obj	\
	gimpwidgets.obj	\
	gimpwire.obj	\
	gserialize.obj	\
	parasite.obj	\
	parasiteio.obj

gimpi.lib : $(gimpi_OBJECTS)
	lib /out:gimpi.lib $(gimpi_OBJECTS)

gimp_OBJECTS = \
	gimp.obj	\
	gimpchannel.obj	\
	gimpcolorspace.obj \
	gimpdisplay.obj	\
	gimpdrawable.obj\
	gimpenv.obj	\
	gimpgradient.obj\
	gimphelp.obj	\
	gimpimage.obj	\
	gimplayer.obj	\
	gimpmatrix.obj	\
	gimppalette.obj	\
	gimpparasite.obj\
	gimppixelrgn.obj\
	gimpprotocol.obj\
	gimpselection.obj\
	gimptile.obj	\
	gimpunit.obj	\
	gimpvector.obj	\
	gimpwire.obj	\
	gserialize.obj	\
	parasite.obj	\
	parasiteio.obj

gimp-$(GIMP_VER).dll : $(gimp_OBJECTS) gimp.def
	$(CC) $(CFLAGS) -LD -Fegimp-$(GIMP_VER).dll $(gimp_OBJECTS) $(INTL)\gnu-intl.lib $(GLIB)\glib-$(GLIB_VER).lib $(LDFLAGS) user32.lib /def:gimp.def

# Pass -DLIBGIMP_COMPILATION when compiling gimp_OBJECTS

gimp.obj : gimp.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimp.c
gimpchannel.obj : gimpchannel.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpchannel.c
gimpdisplay.obj : gimpdisplay.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpdisplay.c
gimpdrawable.obj : gimpdrawable.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpdrawable.c
gimpenv.obj : gimpenv.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpenv.c
gimpgradient.obj : gimpgradient.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpgradient.c
gimpimage.obj : gimpimage.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpimage.c
gimplayer.obj : gimplayer.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimplayer.c
gimpmatrix.obj : gimpmatrix.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpmatrix.c
gimppalette.obj : gimppalette.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimppalette.c
gimpparasite.obj : gimpparasite.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpparasite.c
gimppixelrgn.obj : gimppixelrgn.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimppixelrgn.c
gimpprotocol.obj : gimpprotocol.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpprotocol.c
gimptile.obj : gimptile.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimptile.c
gimpunit.obj : gimpunit.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpunit.c
gimpvector.obj : gimpvector.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpvector.c
gimpwire.obj : gimpwire.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gimpwire.c
gserialize.obj : gserialize.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION gserialize.c
parasite.obj : parasite.c
	$(CC) $(CFLAGS) -GD -c -DLIBGIMP_COMPILATION parasite.c

gimpui_OBJECTS = \
	gimpmenu.obj	\
	gimpbrushmenu.obj\
	gimpchainbutton.obj\
	gimpcolorbutton.obj\
	gimpdialog.obj	\
	gimpexport.obj	\
	gimpfileselection.obj\
	gimpgradientmenu.obj\
	gimphelpui.obj	\
	gimppatternmenu.obj\
	gimpquerybox.obj\
	gimpsizeentry.obj\
	gimpunitmenu.obj\
	gimpwidgets.obj

gimpui-$(GIMP_VER).dll : $(gimpui_OBJECTS) gimpui.def
	$(CC) $(CFLAGS) -LD -Fegimpui-$(GIMP_VER).dll $(gimpui_OBJECTS) gimp-$(GIMP_VER).lib $(GTK)\gtk\gtk-$(GTK_VER).lib $(GTK)\gdk\gdk-$(GTK_VER).lib $(INTL)\gnu-intl.lib $(GLIB)\glib-$(GLIB_VER).lib $(LDFLAGS) /def:gimpui.def

gimpmenu.obj : gimpmenu.c
	$(CC) $(CFLAGS) -GD -c gimpmenu.c

gimpbrushmenu.obj : gimpbrushmenu.c
	$(CC) $(CFLAGS) -GD -c gimpbrushmenu.c

gimpgradientmenu.obj : gimpgradientmenu.c
	$(CC) $(CFLAGS) -GD -c gimpgradientmenu.c

gimppatternmenu.obj : gimppatternmenu.c
	$(CC) $(CFLAGS) -GD -c gimppatternmenu.c

# General rule for compiling, used by the objects that don't go into
# gimp-$(GIMP_VER).dll. 
.c.obj:
	$(CC) $(CFLAGS) -c $<
clean:
	del *.exe
	del *.obj
	del *.exp
	del *.err
	del *.map
