SubDir HAIKU_TOP src libs icu source data brkitr ;

# this file has been converted to Jamfile format from brkfiles.mk

ICU_BRK_RES_CLDR_VERSION = 1.7 ;

ICU_BRK_RES_SYNTHETIC_ALIAS = ;

ICU_BRK_RES_ALIAS_SOURCE = $(BRK_RES_SYNTHETIC_ALIAS) ;

ICU_BRK_CTD_SOURCE = thaidict.txt ;

ICU_BRK_SOURCE = word_POSIX.txt word_ja.txt sent_el.txt char_th.txt char.txt
	word.txt line.txt sent.txt title.txt
	;

ICU_BRK_RES_SOURCE = el.txt en.txt en_US.txt en_US_POSIX.txt ja.txt th.txt ;

NotFile ICU_BreakIterators ;

# -----------------------------------------------------------------------------
# break iterators (*.brk)
# -----------------------------------------------------------------------------

rule GenerateBreakIterator target : source
{
	MakeLocateICUData $(target) : brkitr ;
	Depends $(target) : <build>genbrk $(ICU_DAT_FILES) $(source) ;
	LocalClean clean : $(target) ;
	GenerateBreakIterator1 $(target) : <build>genbrk $(source) ;
}

actions GenerateBreakIterator1
{
	$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
	$(2[1]) -c -i $(ICU_DATA_DIR) -r $(2[2]) -o $(1) >/dev/null
}

local brkitrSources = [ FGristFiles $(ICU_BRK_SOURCE) ] ;
local brkitrTargets ;
for source in $(brkitrSources) {
	local target = $(source:D=:S=.brk) ;
	brkitrTargets += $(target) ;
	Depends ICU_BreakIterators : $(target) ;
	GenerateBreakIterator $(target) : $(source) ;
}

# -----------------------------------------------------------------------------
# special (ctd) break iterators (*.ctd)
# -----------------------------------------------------------------------------

rule GenerateCtdBreakIterator target : source
{
	MakeLocateICUData $(target) : brkitr ;
	Depends $(target) : <build>genctd $(ICU_DAT_FILES) $(source) ;
	LocalClean clean : $(target) ;
	GenerateCtdBreakIterator1 $(target) : <build>genctd $(source) ;
}

actions GenerateCtdBreakIterator1
{
	$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
	$(2[1]) -c -i $(ICU_DATA_DIR) -o $(1) $(2[2]) >/dev/null
}

local ctdSources = [ FGristFiles $(ICU_BRK_CTD_SOURCE) ] ;
for source in $(ctdSources) {
	local target = $(source:D=:S=.ctd) ;
	Depends ICU_BreakIterators : $(target) ;
	GenerateCtdBreakIterator $(target) : $(source) ;
}

# -----------------------------------------------------------------------------
# general resource bundles (*.res)
# -----------------------------------------------------------------------------

local installableBrkitrSources = [ FGristFiles $(ICU_BRK_RES_SOURCE) ] ;
local otherBrkitrSources
	= [ FGristFiles root.txt $(ICU_BRK_RES_ALIAS_SOURCE) ] ;

SEARCH on $(brkitrSources) = $(SUBDIR) ;
SEARCH on $(ctdSources) = $(SUBDIR) ;
SEARCH on $(installableBrkitrSources) = $(SUBDIR) ;
SEARCH on $(otherBrkitrSources) = $(SUBDIR) ;

GenerateIndexedResourceBundles res_index.txt
	: $(installableBrkitrSources) : $(otherBrkitrSources)
	: brkitr : brkitr : $(brkitrTargets) ;
