#
# Copyright (C) 2008-Present      Sigma Designs
#
# Sigma Designs
# 1778 McCarthy BLVD
# Milpitas CA 95035, USA
#
#############################################################
#############################################################
#
# CONFIGURE ICU
#
#############################################################
TARGETS+=libicu
ifeq ($(strip $(BR2_PACKAGE_ICU)),y)
SUBDIR:=package/icu
BUILD_DIR:=$(BASE_DIR)/$(SUBDIR)
VERSION:=$(strip $(subst ",, $(BR2_ICU_VERSION)))
SRC_VERSION:=$(strip $(subst .,_, $(VERSION)))
#"))
SOURCE = icu4c-$(SRC_VERSION)-src.tgz
UNZIP:=$(TAR)
UNZIP_OPTIONS:=$(GZ_EXT)
ifeq ($(strip $(DOWNLOAD_SITE_PUBLIC)),y)
SITE =  http://download.icu-project.org/files/icu4c/$(VERSION)/
else
SITE := $(DOWNLOAD_SITE)
endif
SOURCE_DIR:=$(BUILD_DIR)/icu/source
SOURCE_LIBS:= $(SOURCE_DIR)/lib/$(TARGETS)*.so*
STAGING_LIBS:= $(STAGING_DIR)/lib/$(TARGETS)*.so*
TARGET_LIBS:= $(TARGET_DIR)/lib/$(TARGETS)*.so*
CONFIG_ARGS:=Y
LD_FLAGS:=Y
EXTRA_INSTALL:=Y
EXTRA_RM:=Y
TARGET_CFLAGS:=-fPIC $(TARGET_CFLAGS)
-include $(BASE_DIR)/makefile.newrules
ICU_CONF_OPT = --with-cross-build=$(BUILD_DIR)/icu/host_build --disable-samples --disable-tests
HOST_ICU_CONF_OPT = --disable-samples --disable-tests

# In order to cross-compile ICU one needs to compile it first natively for the PC,
# and then configure the build also for the target.
# (see http://src.chromium.org/svn/trunk/deps/third_party/icu42/readme.html#HowToCrossCompileICU)
# The code below is not very nice but it does the job.
CONFIGURE:=(mkdir -p $(BUILD_DIR)/icu/host_build; rm -rf config.cache; \
		cd $(BUILD_DIR)/icu/host_build;  \
		$(SOURCE_DIR)/configure $(HOST_ICU_CONF_OPT); \
		make -j$(BR2_JLEVEL) || exit 1; \
		cd $(SOURCE_DIR); rm -rf config.cache; \
		$(TARGET_CONFIGURE_ARGS) \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="$(TARGET_CFLAGS)" \
		LDFLAGS="$(TARGET_LDFLAGS)" \
		./configure \
		--target=$(GNU_TARGET_NAME) \
		--host=$(GNU_TARGET_NAME) \
		--build=$(GNU_HOST_NAME) \
		--prefix= \
		$(ICU_CONF_OPT) \
	)
else
$(error Please use "make menuconfig" to enable $(TARGETS))
endif
