# vim:set noet ts=8:
# ***** 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):
#
# 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		= uconv
LIBRARY_NAME	= uconv
EXPORT_LIBRARY  = 1
IS_COMPONENT	= 1
MODULE_NAME	= nsUConvModule
GRE_MODULE	= 1
LIBXUL_LIBRARY = 1
ifneq ($(OS_ARCH),WINNT)
# To avoid conflict with OS/2 system uconv.dll
SHORT_LIBNAME  = mozuconv
endif

PACKAGE_FILE = uconv.pkg

REQUIRES	= xpcom \
		  string \
		  intl \
		  locale \
		  unicharutil \
		  chardet \
		  necko \
		  $(NULL)

CSRCS		= \
		ugen.c \
		uscan.c \
		umap.c \
		$(NULL)

CPPSRCS		= \
		nsUConvModule.cpp \
		nsCharsetAliasImp.cpp \
		nsConverterInputStream.cpp \
		nsConverterOutputStream.cpp \
		nsTextToSubURI.cpp \
		nsGREResProperties.cpp \
		nsCharsetConverterManager.cpp \
		nsUTF8ConverterService.cpp \
		nsUTF8ToUnicode.cpp \
		nsUnicodeToUTF8.cpp \
		$(NULL)

ifdef MOZ_USE_NATIVE_UCONV
REQUIRES	+= ucnative
else
CPPSRCS         += \
		nsScriptableUConv.cpp \
		nsUnicodeDecodeHelper.cpp \
		nsUnicodeEncodeHelper.cpp \
		nsMappingCache.cpp \
		nsISO88591ToUnicode.cpp \
		nsCP1252ToUnicode.cpp \
		nsMacRomanToUnicode.cpp \
		nsUnicodeToISO88591.cpp \
		nsUnicodeToCP1252.cpp \
		nsUnicodeToMacRoman.cpp \
		$(NULL)

endif

EXPORT_RESOURCE	= \
		charsetalias.properties \
		charsetData.properties \
		$(NULL)

ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS			+= nsOS2Charset.cpp
EXPORT_RESOURCE		+= os2charset.properties
else
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS			+= nsWinCharset.cpp
EXPORT_RESOURCE		+= wincharset.properties
else
ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
CPPSRCS			+= nsMacCharset.cpp
EXPORT_RESOURCE		+= maccharset.properties
else
ifeq ($(OS_ARCH),BeOS)
CPPSRCS			+= nsBeOSCharset.cpp
else
CPPSRCS			+= nsUNIXCharset.cpp
EXPORT_RESOURCE		+= unixcharset.properties
# add platform charset remapping properties files here if necessary
# (see unixcharset.sample.properties for an example file)
# eg: if we needed a charset remap for OSARCH=Linux then add the following line:
#EXPORT_RESOURCE		+= unixcharset.Linux.properties
endif
endif
endif
endif

EXTRA_DSO_LDOPTS = \
		$(DIST)/lib/$(LIB_PREFIX)ucvutil_s.$(LIB_SUFFIX) \
		$(MOZ_UNICHARUTIL_LIBS) \
		$(MOZ_NECKO_UTIL_LIBS) \
		$(MOZ_COMPONENT_LIBS) \
		$(NULL)

LOCAL_INCLUDES	= -I$(srcdir)/../util

ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
EXTRA_DSO_LDOPTS += $(TK_LIBS)
endif

LOCAL_INCLUDES	= -I$(srcdir)/../util \
		  -I$(srcdir)/../ucvlatin \
		  -I$(srcdir)/../ucvibm \
		  -I$(srcdir)/../ucvja \
		  -I$(srcdir)/../ucvtw2 \
		  -I$(srcdir)/../ucvtw \
		  -I$(srcdir)/../ucvko \
		  -I$(srcdir)/../ucvcn \
		  -I$(srcdir)/../native \
		  $(NULL)

ifndef MOZ_USE_NATIVE_UCONV
SHARED_LIBRARY_LIBS += \
	$(DIST)/lib/$(LIB_PREFIX)ucvlatin_s.$(LIB_SUFFIX) \
	$(DIST)/lib/$(LIB_PREFIX)ucvibm_s.$(LIB_SUFFIX) \
	$(DIST)/lib/$(LIB_PREFIX)ucvja_s.$(LIB_SUFFIX) \
	$(DIST)/lib/$(LIB_PREFIX)ucvtw2_s.$(LIB_SUFFIX) \
	$(DIST)/lib/$(LIB_PREFIX)ucvtw_s.$(LIB_SUFFIX) \
	$(DIST)/lib/$(LIB_PREFIX)ucvko_s.$(LIB_SUFFIX) \
	$(DIST)/lib/$(LIB_PREFIX)ucvcn_s.$(LIB_SUFFIX) \
	$(NULL)
else
SHARED_LIBRARY_LIBS += \
	$(DIST)/lib/$(LIB_PREFIX)ucnative_s.$(LIB_SUFFIX) \
	$(NULL)
endif

include $(topsrcdir)/config/rules.mk

# CODESET is not automatically defined on some older versions of Redhat.
# Define _XOPEN_SOURCE so CODESET will get defined and thus allow 
# nl_langinfo(CODESET) to compile on these systems.
ifeq ($(OS_ARCH), Linux)
DEFINES         += -D_XOPEN_SOURCE=500
endif

libs:: $(EXPORT_RESOURCE)
	$(INSTALL) $^ $(DIST)/bin/res

install:: $(EXPORT_RESOURCE)
	$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/res 

