# ******************************************************************** #
# This makefile builds one lang's components for Adobe InDesign CS4    #
# ******************************************************************** #

# Needed to get the correct hyphenation pattern file:
LANG       := $(shell pwd | rev | cut -d '/' -f1 | rev)

# Language-specific paths:
SHAREDLIB   = $(TOOLLIBS)/shared/$(LANG)
RESOURCES   = $(TOOLLIBS)/mac/AdobeInDesign/CS3/$(LANG)

##################################################
#***** start of language-specific variables: *****
WINSPELL     = mssp3samiSout.lex
PATTERNSRC   = SamiSout-hy-pat.lex

SPELDICT   = SamiSout-sp-dic.lex
HYPHDICT   = SamiSout-hy-dic.lex
HYPHPATT   = SamiSout-hy-pat.lex

SPELLERLIB  = PldSplSamiSouthern
HYPHENLIB   = PldHypSamiSouthern
SPELLERRSRC = PldSplSamiSouthern.rsrc
HYPHENRSRC  = PldHypSamiSouthern.rsrc

SPELROOT = PldSplSamiSouthern.InDesignPlugin
HYPHROOT = PldHypSamiSouthern.InDesignPlugin
#****** end of language-specific variables: ******
##################################################

PLDICTSDIR  = Dictionaries/Polderland
IDRSRCDIR   = Versions/A/Resources
FULLSPELDIR = $(SPELROOT)/$(IDRSRCDIR)
FULLHYPHDIR = $(HYPHROOT)/$(IDRSRCDIR)

all: dirs lex lib res

dirs:
	@echo "*** Setting up dirs ***"
	$(MKDIR) $(COMPONENTDIR)/$(PLDICTSDIR)
	$(MKDIR) $(COMPONENTDIR)/$(FULLSPELDIR)
	$(MKDIR) $(COMPONENTDIR)/$(FULLHYPHDIR)

lex:
	@echo "*** Copying lexicon files ***"
	$(CP) $(DOWNLOADDIR)/$(WINSPELL)         $(COMPONENTDIR)/$(PLDICTSDIR)/$(SPELDICT)
	$(CP) $(DOWNLOADDIR)/$(WINSPELL)         $(COMPONENTDIR)/$(PLDICTSDIR)/$(HYPHDICT)
	$(CP) $(SHAREDLIB)/hyph/$(PATTERNSRC) $(COMPONENTDIR)/$(PLDICTSDIR)/$(HYPHPATT)

lib:
	@echo "*** Copying library files ***"
	$(CP) $(RESOURCES)/spell/$(SPELLERLIB) $(COMPONENTDIR)/$(SPELROOT)/Versions/A/
	$(CP) $(RESOURCES)/hyph/$(HYPHENLIB)   $(COMPONENTDIR)/$(HYPHROOT)/Versions/A/

res:
	@echo "*** Copying resource files, creating links ***"
	$(CP) $(RESOURCES)/spell/Info.plist     $(COMPONENTDIR)/$(FULLSPELDIR)/
	$(CP) $(RESOURCES)/spell/$(SPELLERRSRC) $(COMPONENTDIR)/$(FULLSPELDIR)/
	cd    $(COMPONENTDIR)/$(SPELROOT)/Versions && $(LN) A Current
	cd    $(COMPONENTDIR)/$(SPELROOT) && $(LN) $(IDRSRCDIR) Resources
	cd    $(COMPONENTDIR)/$(SPELROOT) && $(LN) Versions/A/$(SPELLERLIB) $(SPELLERLIB)
	$(CP) $(RESOURCES)/hyph/Info.plist    $(COMPONENTDIR)/$(FULLHYPHDIR)/
	$(CP) $(RESOURCES)/hyph/$(HYPHENRSRC) $(COMPONENTDIR)/$(FULLHYPHDIR)/
	cd    $(COMPONENTDIR)/$(HYPHROOT)/Versions && $(LN) A Current
	cd    $(COMPONENTDIR)/$(HYPHROOT) && $(LN) $(IDRSRCDIR) Resources
	cd    $(COMPONENTDIR)/$(HYPHROOT) && $(LN) Versions/A/$(HYPHENLIB) $(HYPHENLIB)