#
# 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): 
#

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

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 \
		  ucnative \
		  $(NULL)

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

CPPSRCS		= \
		nsUConvModule.cpp \
		nsCharsetAliasImp.cpp \
		nsConverterInputStream.cpp \
		nsTextToSubURI.cpp \
		nsURLProperties.cpp \
		nsCharsetConverterManager.cpp \
		nsUTF8ConverterService.cpp \
		$(NULL)

ifndef MOZ_USE_NATIVE_UCONV
CPPSRCS         += \
		nsScriptableUConv.cpp \
		nsUnicodeDecodeHelper.cpp \
		nsUnicodeEncodeHelper.cpp \
		nsMappingCache.cpp \
		nsISO88591ToUnicode.cpp \
		nsCP1252ToUnicode.cpp \
		nsMacRomanToUnicode.cpp \
		nsUTF8ToUnicode.cpp \
		nsUnicodeToISO88591.cpp \
		nsUnicodeToCP1252.cpp \
		nsUnicodeToMacRoman.cpp \
		nsUnicodeToUTF8.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 

