#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

DEPTH		= ../../..
topsrcdir	= ../../..
srcdir		= .
VPATH		= .

include $(DEPTH)/config/autoconf.mk

MODULE		= gfx
LIBRARY_NAME	= gfx_gtk
EXPORT_LIBRARY = 1
IS_COMPONENT	= 1
MODULE_NAME	= nsGfxGTKModule
GRE_MODULE	= 1
LIBXUL_LIBRARY = 1

REQUIRES	= xpcom \
		  string \
		  widget \
		  view \
		  util \
		  pref \
		  uconv \
		  unicharutil \
		  locale \
		  necko \
		  content \
		  layout \
		  $(NULL)

# Sun's Complex Text Layout support
ifdef SUNCTL
REQUIRES	+= ctl
endif

ifdef MOZ_ENABLE_XPRINT
REQUIRES	+= xprintutil
endif

NATIVE_THEME_SUPPORT = 1

CSRCS		= nsPrintdGTK.c

# Code shared between GTK+, Xlib and Xprint gfx modules
X11SHARED_LCPPSRCS = \
		nsAntiAliasedGlyph.cpp \
		nsX11AlphaBlend.cpp \
		nsXFontAAScaledBitmap.cpp \
		nsXFontNormal.cpp \
		$(NULL)

ifdef MOZ_ENABLE_FREETYPE2
X11SHARED_LCPPSRCS += \
		nsFontFreeType.cpp \
		nsFT2FontNode.cpp \
		nsFT2FontCatalog.cpp \
		nsNameValuePairDB.cpp \
		$(NULL)
endif
                
CPPSRCS		= \
		nsDeviceContextGTK.cpp \
		nsDeviceContextSpecFactoryG.cpp \
		nsDeviceContextSpecG.cpp \
		nsDrawingSurfaceGTK.cpp \
		nsGfxFactoryGTK.cpp \
		nsGraphicsStateGTK.cpp \
		nsImageGTK.cpp \
		nsGCCache.cpp \
		nsRenderingContextGTK.cpp \
		nsScreenGtk.cpp \
		nsScreenManagerGtk.cpp \
		nsPrintOptionsGTK.cpp \
		nsFontMetricsUtils.cpp \
		$(NULL)

ifdef MOZ_ENABLE_COREXFONTS
CPPSRCS		+= \
		$(X11SHARED_LCPPSRCS) \
		nsFontMetricsGTK.cpp \
		nsGdkUtils.cpp
endif

ifdef MOZ_ENABLE_XFT
CPPSRCS		+= \
		nsFontMetricsXft.cpp
endif

ifdef MOZ_ENABLE_PANGO
CPPSRCS		+= \
		nsFontMetricsPango.cpp \
		mozilla-decoder.cpp
endif

ifdef MOZ_ENABLE_GTK
CPPSRCS 	+= \
		nsRegionGTK.cpp \
		$(NULL)

ifdef NATIVE_THEME_SUPPORT
CSRCS		+= gtkdrawing.c
CPPSRCS		+= nsNativeThemeGTK.cpp
DEFINES		+= -DNATIVE_THEME_SUPPORT
endif

endif

ifdef MOZ_ENABLE_GTK2
CPPSRCS		+= \
		nsRegionGTK2.cpp \
		$(NULL)

ifdef NATIVE_THEME_SUPPORT
CSRCS		+= gtk2drawing.c
CPPSRCS		+= nsNativeThemeGTK.cpp
DEFINES		+= -DNATIVE_THEME_SUPPORT
endif

endif

GARBAGE         += $(X11SHARED_LCPPSRCS) $(XPU_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))

ifdef MOZ_ENABLE_FREETYPE2
# the SHARED_LIBRARY_LIBS line must be before the rules.mk include
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)gfxft2_s.$(LIB_SUFFIX)
endif

EXTRA_DSO_LDOPTS = $(DIST)/lib/$(LIB_PREFIX)gfxshared_s.$(LIB_SUFFIX)

include $(topsrcdir)/config/rules.mk

ifdef MOZ_ENABLE_XINERAMA
GFX_XINERAMA_LIBS += $(MOZ_XINERAMA_LIBS)
endif

ifdef MOZ_ENABLE_GTK
EXTRA_DSO_LDOPTS += \
		$(LIBS_DIR) \
		-lgkgfx \
		$(GFX_XINERAMA_LIBS) \
		-lgtksuperwin \
		$(MOZ_COMPONENT_LIBS) \
		$(MOZ_JS_LIBS) \
		$(MOZ_UNICHARUTIL_LIBS) \
		$(NULL)
endif

ifdef MOZ_ENABLE_XFT
EXTRA_DSO_LDOPTS += $(FT2_LIBS)

libs:: fontEncoding.properties pangoFontEncoding.properties
	$(INSTALL) $^ $(DIST)/bin/res/fonts
 
install:: fontEncoding.properties pangoFontEncoding.properties
	$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/res/fonts
endif

ifdef MOZ_ENABLE_GTK2
EXTRA_DSO_LDOPTS += \
		$(LIBS_DIR) \
		-lgkgfx \
		$(GFX_XINERAMA_LIBS) \
		$(MOZ_JS_LIBS) \
		$(MOZ_UNICHARUTIL_LIBS) \
		$(MOZ_COMPONENT_LIBS) \
		-lfontconfig \
		$(NULL)
endif

ifdef MOZ_ENABLE_PANGO
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS)
endif

EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(MOZ_GTK_LDFLAGS) $(MOZ_XFT_LIBS) $(MOZ_GTK2_LIBS)
CXXFLAGS	+= $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
CFLAGS		+= $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)

ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES		+= -D_TIME_H=1
endif
endif

ifeq ($(OS_ARCH), OpenVMS)
DEFINES		+= -DGENERIC_MOTIF_REDEFINES
OS_CXXFLAGS	+= -Wc,warn=disa=NOSIMPINT 
endif

ifdef MOZ_ENABLE_POSTSCRIPT
DEFINES         += -DUSE_POSTSCRIPT
EXTRA_DSO_LDOPTS += -lgfxpsshar
endif

ifdef MOZ_ENABLE_XPRINT
DEFINES         += -DUSE_XPRINT -DUSE_MOZILLA_TYPES
EXTRA_DSO_LDOPTS += \
		-lxprintutil \
		$(MOZ_XPRINT_LDFLAGS)
endif

LOCAL_INCLUDES	= \
		-I../.. \
		-I$(srcdir)/. \
		-I$(srcdir)/.. \
		-I$(srcdir)/../shared \
		-I$(srcdir)/../x11shared \
		$(MOZ_XFT_CFLAGS) \
		$(NULL)

ifdef MOZ_ENABLE_FREETYPE2
INCLUDES        += $(FT2_CFLAGS)
LOCAL_INCLUDES        += -I$(srcdir)/../freetype
endif

ifdef MOZ_ENABLE_XPRINT
export:: $(addprefix $(srcdir)/../xprint/,$(XPU_LCSRCS)) $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
	$(INSTALL) $^ .
else
export:: $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
	$(INSTALL) $^ .
endif

