SubDir HAIKU_TOP src libs icu source data unidata ;

NotFile ICU_Confusables ;

# -----------------------------------------------------------------------------
# property names (pnames.icu)
# -----------------------------------------------------------------------------

rule GeneratePNames target : sources
{
	MakeLocateICUData $(target) ;
	Depends $(target) : <build>genpname $(sources) ;
	LocalClean clean : $(target) ;
	GeneratePNames1 $(target) : <build>genpname ;
}

actions GeneratePNames1
{
	$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
	$(2) -d $(1:D)
}

local propertyFiles
	= [ FGristFiles Blocks.txt PropertyAliases.txt PropertyValueAliases.txt ] ;
SEARCH on $(propertyFiles) = $(SUBDIR) ;

local propertyHeaders = [ FGristFiles uscript.h uchar.h ] ;
SEARCH on $(propertyHeaders)
	= [ FDirName $(HAIKU_TOP) headers libs icu unicode ] ;

GeneratePNames pnames.icu : $(propertyFiles) $(propertyHeaders) ;

# -----------------------------------------------------------------------------
# unicode character names (unames.icu)
# -----------------------------------------------------------------------------

rule GenerateUNames target : sources
{
	MakeLocateICUData $(target) ;
	Depends $(target) : <build>gennames $(sources) ;
	LocalClean clean : $(target) ;
	GenerateUNames1 $(target) : <build>gennames $(sources) ;
}

actions GenerateUNames1
{
	$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
	$(2[1]) -1 -d $(1:D) $(2[2-]) -u $(ICU_UNICODE_VERSION) >/dev/null
}

local unicodeData = [ FGristFiles UnicodeData.txt ] ;
SEARCH on $(unicodeData) = $(SUBDIR) ;
GenerateUNames unames.icu : $(unicodeData) ;

# -----------------------------------------------------------------------------
# unicode collation algorithm data (ucadata.icu invuca.icu)
# -----------------------------------------------------------------------------

rule GenerateUcaData targets : source
{
	MakeLocateICUData $(targets) : "coll" ;
	Depends $(targets) : <build>genuca $(source) ;
	LocalClean clean : $(targets) ;
	GenerateUcaData1 $(targets) : <build>genuca $(source) ;
}

actions GenerateUcaData1
{
	$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
	$(2[1]) -s $(2[2]:D) -d $(1[1]:D) -i $(2[2]:D)
}

local fractionalUCA = [ FGristFiles FractionalUCA.txt ] ;
SEARCH on $(fractionalUCA) = $(SUBDIR) ;
GenerateUcaData ucadata.icu invuca.icu : $(fractionalUCA) ;

# -----------------------------------------------------------------------------
# unicode confusables (confusables.cfu)
# -----------------------------------------------------------------------------

rule GenerateConfusables target : sources
{
	MakeLocateICUData $(target) ;
	Depends $(target) : <build>gencfu $(ICU_DAT_FILES) $(sources) ;
	LocalClean clean : $(target) ;
	GenerateConfusables1 $(target) : <build>gencfu $(sources) ;
}

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

local confusableSources
	= [ FGristFiles confusables.txt confusablesWholeScript.txt ] ;
SEARCH on $(confusableSources) = $(SUBDIR) ;
local target = $(confusableSources[1]:D=:S=.cfu) ;
Depends ICU_Confusables : $(target) ;
GenerateConfusables $(target) : $(confusableSources) ;
