# Last edited on 2004-01-29 21:37:11 by stolfi

DIRS := \
  engl/cul \
  engl/poi \
  engl/wow
  
LATER := \
  chin/red \
  chin/ptt \
  tibe/vim \
  tibe/ccv \
  viet/ptt \
  arab/qur \
  geez/gok \
  latn/ptt \
  latn/ben \
  span/qvi \
  rugg/hnd \
  rugg/sfw
  
NOT_READY_YET := \
  geez/eno \

WDSFILES := ${shell echo "${DIRS} " | sed -e 's: :/main.wds :g'}
WCTFILES := ${shell echo "${DIRS} " | sed -e 's: :/main.wct :g'}
  
.PHONY: all clean-all clean-single single

all: 
	for d in ${DIRS}; do \
	  ( cd $$d && ${MAKE} -f ../../Makefile single ) ; \
	done
	@echo " "
	@echo "============================================================"
	@echo "Token sequence files:"
	${TOOLS}/dicio-wc ${WDSFILES}
	@echo " "
	@echo "============================================================"
	@echo "Lexicons:"
	${TOOLS}/dicio-wc ${WCTFILES}
        
clean-all: 
	for d in ${DIRS}; do \
          ( cd $$d && ${MAKE} -f ../../Makefile clean-single ) ; \
        done
        
######################################################################
# Single-file make - executed in a sub-directory

TOOLS = /home/staff/stolfi/bin
PREP = preprocess-org

single: main.evt main.txt main.wds main.wct .diff

clean-single: 
	/bin/rm -f .raw.wds .kuk.wds .diff -diff2

# Text with EVT locators:

main.evt: main.org ${TOOLS}/org-to-evt ${PREP}
	@echo '====== building main.evt ======'
	cat main.org \
          | ${PREP} \
	  | ${TOOLS}/org-to-evt \
              -v omitControls=1 \
              -v omitBlanks=1 \
          > main.evt
          
# Cleaned text with original line breaks:

main.txt: main.evt ${TOOLS}/evt-to-txt
	@echo '====== extracting main.txt ======'
	cat main.evt \
          | ${TOOLS}/evt-to-txt \
          > main.txt

# Word sequence:

main.wds: main.evt ${TOOLS}/evt-to-wds
	@echo '====== extracting main.wds ======'
	cat main.evt \
          | ${TOOLS}/evt-to-wds \
              -v smashSymbols=0 \
              -v showPuncts=1 -v showBreaks=0 -v showParags=0 \
          > main.wds
	wc main.wds
	
# Word counts:

main.wct: main.wds
	@echo '====== computing main.wct ======'
	cat main.wds \
          | sort | uniq -c | expand \
          | sort -b +0 -1nr +1 -2 \
          > main.wct
	wc -l main.wct

# Checking whether something was lost in the formatting:

.raw.wds: main.raw raw-to-wds 
	cat main.raw \
          | raw-to-wds \
          > .raw.wds

.kuk.wds: main.evt   ${TOOLS}/evt-to-wds cook-wds-for-diff
	cat main.evt \
          | ${TOOLS}/evt-to-wds \
              -v smashSymbols=0 \
              -v showPuncts=1 -v showBreaks=1 -v showParags=1 \
          | cook-wds-for-diff \
          > .kuk.wds

.diff: .raw.wds .kuk.wds
	diff -C3 .raw.wds .kuk.wds > .diff

# End of "single" part.
######################################################################