#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): 
#   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
#

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

REQUIRES	= xpcom \
		  string \
		  widget \
		  view \
		  util \
		  pref \
		  uconv \
		  unicharutil \
		  locale \
		  necko \
		  content \
		  dom \
		  layout \
		  imglib2 \
		  $(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 \
		nsFontFreeType.cpp \
		nsFT2FontNode.cpp \
		nsFT2FontCatalog.cpp \
		nsX11AlphaBlend.cpp \
		nsXFontAAScaledBitmap.cpp \
		nsXFontNormal.cpp \
		$(NULL)
                
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_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

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 \
		-lgfxshared_s \
		$(GFX_XINERAMA_LIBS) \
		-lgtksuperwin \
		$(MOZ_COMPONENT_LIBS) \
		$(MOZ_JS_LIBS) \
		$(MOZ_UNICHARUTIL_LIBS) \
		$(NULL)
endif

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

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

EXTRA_DSO_LDOPTS += $(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
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)/../freetype \
		-I$(srcdir)/../x11shared \
		$(MOZ_XFT_CFLAGS) \
		$(NULL)

ifdef MOZ_ENABLE_FREETYPE2
INCLUDES        += $(FT2_CFLAGS)
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

