# Note that this file is hardly maintained, hardly usable without
# manual editing, and not really part of a recommended way to build
# GLib and related software with Microsoft's compilers. Only a few
# persons use a build setup that involves this file.

# Common makefile definitions for building GLib, GTk+, and various
# software that use these libraries with msvc on Win32

# Debug builds shoud link with msvcrtd release build with msvcrt.
!IFNDEF DEBUG
# Full optimization:
OPTIMIZE = -Ox
# release with debug
OPTIMIZE = -Zi -DG_ENABLE_DEBUG=1
CRUNTIME = -MD
LINKDEBUG = /OPT:REF
!ELSE
# Debugging:
OPTIMIZE = 
CRUNTIME = -MDd
DEBUGINFO = -Zi -DG_ENABLE_DEBUG=1
LINKDEBUG = /debug /nodefaultlib:msvcrt.lib
!ENDIF

LDFLAGS = /link /machine:ix86 $(LINKDEBUG)

!IFNDEF TOP
TOP = ..
!ENDIF

!IFNDEF PERL
PERL = perl
!ENDIF

XSLTPROC = d:\gnome-0\xsltproc

# paths and version numbers
!INCLUDE $(TOP)\glib\build\win32\module.defs

################
# CFLAGS and LIBS for the packages in module.defs.
# In alphabetical order.

# Note that these CFLAGS and LIBS refer to stuff in "source"
# directories. This is for historical reasons, and only useable if you
# have the GLib, Pango, etc sources. If you use the prebuilt developer
# packages, you should fix these to instead refer to the place where
# you unzipped the developer packages. Easiest of all, run pkg-config
# --cflags gtk+-2.0 (for instance), and paste its output as the
# definition of GTK2_CFLAGS. Etc.

ATK_CFLAGS = -I $(ATK)
ATK_LIBS = $(ATK)\atk\atk-$(ATK_VER).lib
BABL_CFLAGS = -I $(BABL)
BABL_LIBS = $(BABL)\babl\babl-1.0.lib

# force inclusion of the _right_ cairoversion.h even when using without installation 
CAIRO_CFLAGS = -FI $(CAIRO)\cairo-version.h -I $(CAIRO)\src -I $(CAIRO)
CAIRO_LIBS = $(CAIRO)\src\libcairo.lib

DIRENT_CFLAGS = -I $(GLIB)\build\win32\dirent
DIRENT_LIBS = $(GLIB)\build\win32\dirent\dirent.lib

!IFNDEF EXIF
EXIF_CFLAGS = -I $(DEVTOP)\include 
EXIF_LIBS = $(DEVTOP)\lib\exif.lib
EXIF = 1
!ENDIF

# Don't know if Freetype2, FriBiDi and some others actually can be
# built with MSVC, but one can produce an import library even if the
# DLL was built with gcc.
!IFDEF FREETYPE2
FREETYPE2_CFLAGS = -I $(FREETYPE2)\include
FREETYPE2_LIBS = $(FREETYPE2)\obj\freetype-$(FREETYPE2_VER).lib
!ELSE
FREETYPE2_CFLAGS = -I $(DEVTOP)\include -I $(DEVTOP)\include\freetype2
FREETYPE2_LIBS = $(DEVTOP)\lib\freetype6.lib
!ENDIF

!IFNDEF FONTCONFIG
FONTCONFIG_CFLAGS = -I $(DEVTOP)\include
FONTCONFIG_LIBS = $(DEVTOP)\lib\fontconfig.lib
!ENDIF

GDK_PIXBUF_CFLAGS = -I $(GDK_PIXBUF)
GDK_PIXBUF_LIBS = $(GTK2)\gdk-pixbuf\gdk_pixbuf-$(GDK_PIXBUF_VER).lib

GIMP_CFLAGS = -I $(GIMP)
GIMP_PLUGIN_LIBS = $(GIMP)\libgimp\gimp-$(GIMP_VER).lib $(GIMP)\libgimp\gimpui-$(GIMP_VER).lib

# overide definition to use it as callable path
GLIB = $(TOP)\glib

GLIB_CFLAGS = -I $(GLIB) -I $(GLIB)\glib -I $(GLIB)\gmodule $(INTL_CFLAGS)
GLIB_LIBS = $(GLIB)\glib\glib-$(GLIB_VER).lib $(GLIB)\gmodule\gmodule-$(GLIB_VER).lib $(GLIB)\gobject\gobject-$(GLIB_VER).lib $(GLIB)\gio\gio-$(GLIB_VER).lib
GTHREAD_LIBS = $(GLIB)\gthread\gthread-$(GLIB_VER).lib

!IFNDEF GDK_PIXBUF
GDK_PIXBUF_CFLAGS = $(GTK2_CFLAGS)
GDK_PIXBUF_LIBS = $(GTK2_LIBS)
!ENDIF

GNOMECANVAS_CFLAGS = -I $(GNOMECANVAS)
GNOMECANVAS_LIBS = $(GNOMECANVAS)\libgnomecanvas\libgnomecanvas-$(GNOMECANVAS_VER).lib

GNOMEPRINT_CFLAGS = -I $(GNOMEPRINT)
GNOMEPRINT_LIBS = $(GNOMEPRINT)\libgnomeprint\gnome-print-$(GNOMEPRINT_VER).lib

GNOMEPRINTUI_CFLAGS = -I $(GNOMEPRINTUI)
GNOMEPRINTUI_LIBS = $(GNOMEPRINTUI)\libgnomeprintui\gnome-printui-$(GNOMEPRINTUI_VER).lib

GTK_CFLAGS = -I$(GTK)\gdk -I$(GTK)\gdk -I$(GTK) 
GTK_LIBS = $(GTK)\gtk\gtk.lib $(GTK)\gdk\gdk.lib 

GTK2_CFLAGS = $(GLIB_CFLAGS) $(ATK_CFLAGS) -I$(GTK2)\gdk -I$(GTK2)\gdk -I$(GTK2) -I$(PANGO) -I$(ATK) $(CAIRO_CFLAGS)
GTK2_LIBS = $(GTK2)\gtk\gtk-win32-$(GTK2_VER).lib $(GTK2)\gdk\gdk-win32-$(GTK2_VER).lib $(GTK2)\gdk-pixbuf\gdk_pixbuf-$(GTK2_VER).lib $(PANGO_LIBS)

GTKGLAREA_CFLAGS = -I $(GTKGLAREA)
GTKGLAREA_LIBS = $(GTKGLAREA)\gtkgl\gtkgl-$(GTKGLAREA_VER).lib

GTKSOURCEVIEW_CFLAGS = -I $(GTKSOURCEVIEW)
GTKSOURCEVIEW_LIBS = $(GTKSOURCEVIEW)\gtksourceview\gtksourceview.lib

LIBART_CFLAGS = -I$(LIBART)\.. -FIlibart_lgpl/art_config.h
LIBART_LIBS = $(LIBART)\art_lgpl_2.lib

!IFNDEF INTL
INTL_CFLAGS = -I $(DEVTOP)\include
INTL_LIBS = $(DEVTOP)\lib\intl.lib 
!ELSE
INTL_CFLAGS = -I $(INTL)
INTL_LIBS = $(INTL)\intl.lib 
!ENDIF

!IFDEF LCMS
LCMS_CFLAGS = -DLCMS_DLL -I $(LCMS)\include
LCMS_LIBS = $(LCMS)\Projects\VC6\Release\lcms.lib 
!ENDIF

LIBICONV_CFLAGS = -I $(LIBICONV)\include
LIBICONV_LIBS = $(LIBICONV)\lib\iconv.lib

LIBXML_CFLAGS = -I $(LIBXML)
LIBXML_LIBS = $(LIBXML)\xml-$(LIBXML_VER).lib

LIBXML2_CFLAGS = $(LIBICONV_CFLAGS) -I $(LIBXML2)\include
LIBXML2_LIBS = $(LIBXML2)\libxml2.lib

LIBXSLT_CFLAGS = -I $(LIBXSLT)
LIBXSLT_LIBS = $(LIBXSLT)\libxslt\libxslt.lib

LCMS_CFLAGS = -I $(LCMS)\include -DLCMS_DLL
LCMS_LIBS = $(LCMS)\Projects\VC6\Release\lcms.lib

!IFNDEF JPEG
JPEG_CFLAGS = -I $(DEVTOP)\include
JPEG_LIBS = $(DEVTOP)\lib\jpeg.lib
!ELSE
JPEG_CFLAGS = -I $(JPEG)
JPEG_LIBS = $(JPEG)\libjpeg.lib
!ENDIF

OPENGL_CFLAGS = # None needed, headers bundled with the compiler
OPENGL_LIBS = opengl32.lib lglu32.lib

PANGO_CFLAGS = -I $(PANGO)
PANGO_LIBS = $(PANGO)\pango\pango-$(PANGO_VER).lib
PANGOCAIRO_LIBS = $(PANGO_LIBS) $(PANGO)\pango\pangocairo-$(PANGO_VER).lib
PANGOWIN32_LIBS = $(PANGO_LIBS) $(PANGO)\pango\pangowin32-$(PANGO_VER).lib
PANGOFT2_LIBS = $(PANGO_LIBS) $(PANGO)\pango\pangoft2-$(PANGO_VER).lib

!IFDEF PNG
PNG_CFLAGS = -I $(PNG) $(ZLIB_CFLAGS)
PNG_LIBS = $(PNG)\projects\visualc6\Win32_LIB_Release\libpng.lib  $(ZLIB_LIBS)
!ELSE
PNG_CFLAGS = -I $(DEVTOP)\include $(ZLIB_CFLAGS)
PNG_LIBS = $(DEVTOP)\lib\libpng.lib  $(ZLIB_LIBS)
!ENDIF

RSVG_CFLAGS = -I $(RSVG)\..
RSVG_LIBS = $(RSVG)\librsvg-2.lib

SVG_CFLAGS = -I $(SVG)\src
SVG_LIBS = $(SVG)\src\libsvg-$(SVG_VER).lib

!IFDEF TIFF
TIFF_CFLAGS = -I $(TIFF)\libtiff
# Use single import library for both libtiff DLL versions (with or
# without LZW code). The user selects which DLL to use.
TIFF_LIBS = $(TIFF)\libtiff\libtiff.lib $(JPEG_LIBS) $(ZLIB_LIBS) user32.lib
!ELSE
TIFF_CFLAGS = -I $(DEVTOP)\include
TIFF_LIBS = $(DEVTOP)\lib\libtiff.lib
!ENDIF

VIPS_CFLAGS = -I $(VIPS)/include
VIPS_LIBS = $(VIPS)/libsrc/vips.lib

!IFDEF ZLIB
ZLIB_CFLAGS = -I $(ZLIB)
ZLIB_LIBS = $(ZLIB)\projects\visualc6\Win32_LIB_Release\zlib.lib
!ELSE
ZLIB_CFLAGS = -I $(DEVTOP)\include
ZLIB_LIBS = $(DEVTOP)\lib\zdll.lib
!ENDIF

################
# Compiler to use.

CCOMPILER = cl
CC = $(CCOMPILER) $(OPTIMIZE) $(CRUNTIME) -W3 -nologo

################
# The including makefile should define INCLUDES, DEFINES and
# DEPCFLAGS.  INCLUDES are the includes related to the module being
# built.  DEFINES similarly. DEPCFLAGS should be set to a set of
# GLIB_CFLAGS, GTK_CFLAGS etc corresponding to what other modules we
# depend on.

CFLAGS = $(OPTIMIZE) $(DEBUGINFO) $(INCLUDES) $(DEFINES) $(DEPCFLAGS)
# make cl/wcl386 compatible (c99 and cdecl)
#OPTIMIZE = -Ox
#CFLAGS = /passwopts:-za99 /passwopts:-ecc $(DEBUGINFO) $(INCLUDES) $(DEFINES) $(DEPCFLAGS)
.c.i :
	$(CC) $(CFLAGS) -E $< >$@

# The default target should be "all"

default: all

clean::
	-del *.obj *.res *.i *.exe *.dll *.lib *.err *.map *.exp *.lk1 *.mk1 *.ilk *.manifest
	-del *.pdb

# Needed by hacker rule to make makefile.msc from makefile.msc.in:
SED = e:\cygwin\bin\sed
