# ***** 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
# Google Inc.
# Portions created by the Initial Developer are Copyright (C) 2005
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#  Brian Ryner <bryner@brianryner.com>
#  Stuart Parmenter <pavlov@pavlov.net>
#  Vladimir Vukicevic <vladimir@pobox.com>
#
# 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	= @top_srcdir@
srcdir		= @srcdir@
VPATH		= @srcdir@

include $(DEPTH)/config/autoconf.mk

MODULE		= libpixman
LIBRARY_NAME	= mozlibpixman
LIBXUL_LIBRARY = 1

ifdef GNU_CC
MODULE_OPTIMIZE_FLAGS = -O2
else
ifeq ($(OS_ARCH),SunOS)
MODULE_OPTIMIZE_FLAGS = -xO5
endif
ifeq ($(OS_ARCH),WINNT)
# FIXME: bug 413019
OS_COMPILE_CFLAGS += -GL-
MODULE_OPTIMIZE_FLAGS = -O2
endif
endif

# Build MMX code either with VC or with gcc-on-x86
ifdef _MSC_VER
ifeq (86,$(findstring 86,$(OS_TEST)))
ifeq (64,$(findstring 64,$(OS_TEST)))
else
USE_MMX=1
USE_SSE2=1
MMX_CFLAGS=
endif
endif
ifeq (arm,$(findstring arm,$(OS_TEST)))
USE_ARM_SIMD_MSVC=1
endif
endif

ifdef GNU_CC

ifeq (86,$(findstring 86,$(OS_TEST)))
USE_MMX=1
MMX_CFLAGS=-mmmx -Winline
# See bug 410509 why we can't use SSE2 yet on linux
#USE_SSE2=1
#MMX_CFLAGS+=-msse -msse2
ifneq ($(MOZ_WIDGET_TOOLKIT),os2)
MMX_CFLAGS+=--param inline-unit-growth=10000 --param large-function-growth=10000
endif
endif
ifeq (arm,$(findstring arm,$(OS_TEST)))
ifdef HAVE_ARM_SIMD
USE_ARM_SIMD=1
endif
endif

endif


CSRCS	= \
	pixman-access.c \
	pixman-access-accessors.c \
	pixman-combine32.c \
	pixman-combine64.c \
	pixman-compose.c \
	pixman-compose-accessors.c \
	pixman-compute-region.c \
	pixman-edge.c \
	pixman-edge-accessors.c \
	pixman-image.c \
	pixman-matrix.c \
	pixman-pict.c \
	pixman-region16.c \
	pixman-region32.c \
	pixman-source.c \
	pixman-transformed.c \
	pixman-transformed-accessors.c \
	pixman-trap.c \
	pixman-utils.c \
	$(NULL)

ifdef USE_MMX
CSRCS += pixman-mmx.c
DEFINES += -DUSE_MMX
endif

ifdef USE_SSE2
CSRCS += pixman-sse2.c
DEFINES += -DUSE_SSE -DUSE_SSE2
endif

ifdef USE_VMX
CSRCS += pixman-vmx.c
DEFINES += -DUSE_VMX
endif

ifdef USE_ARM_SIMD
CSRCS += pixman-arm-simd.c
DEFINES += -DUSE_ARM_SIMD
endif

ifdef USE_ARM_SIMD_MSVC
ASFILES += pixman-arm-detect-win32.asm pixman-wce-arm-simd.asm
DEFINES += -DUSE_ARM_SIMD
AS_DASH_C_FLAG = 
endif

EXPORTS		= pixman.h pixman-version.h

LOCAL_INCLUDES	+= -I$(srcdir) -I$(srcdir)/../../cairo/src

FORCE_STATIC_LIB = 1
# This library is used by other shared libs in a static build
FORCE_USE_PIC = 1

include $(topsrcdir)/config/rules.mk

CFLAGS += -DPACKAGE="mozpixman" -D_USE_MATH_DEFINES

# special rule for pixman-mmx to get the right cflags
pixman-mmx.$(OBJ_SUFFIX): pixman-mmx.c Makefile Makefile.in
	$(REPORT_BUILD)
	@$(MAKE_DEPS_AUTO_CC)
	$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(MMX_CFLAGS) $(_VPATH_SRCS)

pixman-sse2.$(OBJ_SUFFIX): pixman-sse2.c Makefile Makefile.in
	$(REPORT_BUILD)
	@$(MAKE_DEPS_AUTO_CC)
	$(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(MMX_CFLAGS) $(_VPATH_SRCS)
