Makefile
changeset 1316 870abedea142
parent 1314 3bd48b5e12c6
child 1322 59b94ff17754
equal deleted inserted replaced
1315:6532512bbac4 1316:870abedea142
   114 RST2HTML_RENDER_FLAGS := --strip-comments --embed-stylesheet --no-xml-declaration --math-output=HTML --initial-header-level=2
   114 RST2HTML_RENDER_FLAGS := --strip-comments --embed-stylesheet --no-xml-declaration --math-output=HTML --initial-header-level=2
   115 RST2HTML_FLAGS := $(RST_FLAGS) $(RST2HTML_RENDER_FLAGS)
   115 RST2HTML_FLAGS := $(RST_FLAGS) $(RST2HTML_RENDER_FLAGS)
   116 
   116 
   117 LATEX2PDF := pdflatex
   117 LATEX2PDF := pdflatex
   118 
   118 
       
   119 PYTHON ?= python3
       
   120 
   119 ifeq '$(ANKI_PY_DIR)' ''
   121 ifeq '$(ANKI_PY_DIR)' ''
   120   ANKI_PY_DIR := /usr/share/anki
   122   ANKI_PY_DIR := /usr/share/anki
   121 endif
   123 endif
   122 
   124 
   123 ADB := adb
   125 ADB := adb
   554 
   556 
   555 FREQ_FILTER += -12000f:wordlist/oanc.freq
   557 FREQ_FILTER += -12000f:wordlist/oanc.freq
   556 
   558 
   557 .PHONY: freq
   559 .PHONY: freq
   558 freq: dist/wordlist/gadict.list py/gadict_freq.py $(FREQ_DEP) $(BUILD_SCRIPTS)
   560 freq: dist/wordlist/gadict.list py/gadict_freq.py $(FREQ_DEP) $(BUILD_SCRIPTS)
   559 	python3 -B py/gadict_freq.py +b:dist/wordlist/gadict.list $(FREQ_FILTER)
   561 	$(PYTHON) -B py/gadict_freq.py +b:dist/wordlist/gadict.list $(FREQ_FILTER)
   560 
   562 
   561 .PHONY: missing
   563 .PHONY: missing
   562 missing: missing-words missing-stat
   564 missing: missing-words missing-stat
   563 
   565 
   564 .PHONY: missing-words
   566 .PHONY: missing-words
   565 missing-words: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
   567 missing-words: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
   566 	@echo ===== VOA =====
   568 	@echo ===== VOA =====
   567 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:dist/wordlist/voa.list
   569 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:dist/wordlist/voa.list
   568 	@echo ===== GSL =====
   570 	@echo ===== GSL =====
   569 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/gsl.freq
   571 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/gsl.freq
   570 	@echo ===== AWL =====
   572 	@echo ===== AWL =====
   571 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/awl.freq
   573 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/awl.freq
   572 	@echo ===== NGSL =====
   574 	@echo ===== NGSL =====
   573 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/ngsl.freq
   575 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/ngsl.freq
   574 	@echo ===== NAWL =====
   576 	@echo ===== NAWL =====
   575 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/nawl.freq
   577 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/nawl.freq
   576 	@echo ===== BSL =====
   578 	@echo ===== BSL =====
   577 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/bsl.var
   579 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/bsl.var
   578 	@echo ===== TSL =====
   580 	@echo ===== TSL =====
   579 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/tsl.var
   581 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/tsl.var
   580 	@echo ===== KET =====
   582 	@echo ===== KET =====
   581 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/ket.var
   583 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/ket.var
   582 	@echo ===== PET =====
   584 	@echo ===== PET =====
   583 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/pet.var
   585 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/pet.var
   584 
   586 
   585 .PHONY: missing-speakout
   587 .PHONY: missing-speakout
   586 missing-speakout: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
   588 missing-speakout: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
   587 	@echo ===== so1 =====
   589 	@echo ===== so1 =====
   588 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so1.list | tee so1.miss
   590 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so1.list | tee so1.miss
   589 	@echo ===== so2 =====
   591 	@echo ===== so2 =====
   590 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so2.list | tee so2.miss
   592 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so2.list | tee so2.miss
   591 	@echo ===== so3 =====
   593 	@echo ===== so3 =====
   592 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so3.list | tee so3.miss
   594 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so3.list | tee so3.miss
   593 	@echo ===== so4 =====
   595 	@echo ===== so4 =====
   594 	python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so4.list | tee so4.miss
   596 	$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so4.list | tee so4.miss
   595 
   597 
   596 define stat-cmd
   598 define stat-cmd
   597 { \
   599 { \
   598 stat() { \
   600 stat() { \
   599   lack=`python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list $$2:$$3 | wc -l`; \
   601   lack=`$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list $$2:$$3 | wc -l`; \
   600   total=`grep -v '^[ 	]' $$3 | wc -l`; \
   602   total=`grep -v '^[ 	]' $$3 | wc -l`; \
   601   cover=$$((total - lack)); \
   603   cover=$$((total - lack)); \
   602   printf "   %4s %5s %5s %4s\n" $$1 $$cover $$total $$lack; \
   604   printf "   %4s %5s %5s %4s\n" $$1 $$cover $$total $$lack; \
   603 }; \
   605 }; \
   604 echo "   ==== ===== ===== ===="; \
   606 echo "   ==== ===== ===== ===="; \
   620 .PHONY: missing-stat
   622 .PHONY: missing-stat
   621 missing-stat: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
   623 missing-stat: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS)
   622 	@${stat-cmd}
   624 	@${stat-cmd}
   623 
   625 
   624 dist/wordlist/%.list: %.gadict py/gadict_headwords.py $(BUILD_SCRIPTS) | dist/wordlist/
   626 dist/wordlist/%.list: %.gadict py/gadict_headwords.py $(BUILD_SCRIPTS) | dist/wordlist/
   625 	python3 -B py/gadict_headwords.py  $< $@
   627 	$(PYTHON) -B py/gadict_headwords.py  $< $@
   626 
   628 
   627 dist/wordlist/gsl.var: $(GSL_BASEWORD) | dist/wordlist/
   629 dist/wordlist/gsl.var: $(GSL_BASEWORD) | dist/wordlist/
   628 	cat $(GSL_BASEWORD) >$@
   630 	cat $(GSL_BASEWORD) >$@
   629 
   631 
   630 dist/wordlist/ngsl.var: $(NGSL_BASEWORD) | dist/wordlist/
   632 dist/wordlist/ngsl.var: $(NGSL_BASEWORD) | dist/wordlist/
   631 	cat $(NGSL_BASEWORD) >$@
   633 	cat $(NGSL_BASEWORD) >$@
   632 
   634 
   633 dist/wordlist/voa.list: gadict_voa.gadict py/gadict_headwords.py $(MAKEFILE_LIST) | dist/wordlist/
   635 dist/wordlist/voa.list: gadict_voa.gadict py/gadict_headwords.py $(MAKEFILE_LIST) | dist/wordlist/
   634 	python3 -B py/gadict_headwords.py gadict_voa.gadict >$@
   636 	$(PYTHON) -B py/gadict_headwords.py gadict_voa.gadict >$@
   635 
   637 
   636 dist/wordlist/:
   638 dist/wordlist/:
   637 	mkdir -p $@
   639 	mkdir -p $@
   638 
   640 
   639 ################################################################
   641 ################################################################
   667 	:
   669 	:
   668 
   670 
   669 # -B  suppress __pycache__ dir
   671 # -B  suppress __pycache__ dir
   670 
   672 
   671 dist/dictd/gadict.c5: gadict.gadict $(FREQLIST_DEP) py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   673 dist/dictd/gadict.c5: gadict.gadict $(FREQLIST_DEP) py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   672 	LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py $(FREQLIST_OPT)  $< $@
   674 	LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py $(FREQLIST_OPT)  $< $@
   673 	echo "gadict En-Ru+Uk"> dist/dictd/gadict.c5.name
   675 	echo "gadict En-Ru+Uk"> dist/dictd/gadict.c5.name
   674 
   676 
   675 dist/dictd/gadict_en-ru.c5: gadict.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   677 dist/dictd/gadict_en-ru.c5: gadict.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   676 	LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py  $< $@ -lang:ru
   678 	LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py  $< $@ -lang:ru
   677 	echo "gadict En-Ru"> dist/dictd/gadict_en-ru.c5.name
   679 	echo "gadict En-Ru"> dist/dictd/gadict_en-ru.c5.name
   678 
   680 
   679 dist/dictd/gadict_en-uk.c5: gadict.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   681 dist/dictd/gadict_en-uk.c5: gadict.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   680 	LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py  $< $@ -lang:uk
   682 	LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py  $< $@ -lang:uk
   681 	echo "gadict En-Uk"> dist/dictd/gadict_en-uk.c5.name
   683 	echo "gadict En-Uk"> dist/dictd/gadict_en-uk.c5.name
   682 
   684 
   683 dist/dictd/gadict_voa.c5: gadict_voa.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   685 dist/dictd/gadict_voa.c5: gadict_voa.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   684 	LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py  $< $@ -lang:en
   686 	LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py  $< $@ -lang:en
   685 
   687 
   686 dist/dictd/%.c5: %.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   688 dist/dictd/%.c5: %.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/
   687 	LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py  $< $@
   689 	LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py  $< $@
   688 
   690 
   689 dist/dictd/:
   691 dist/dictd/:
   690 	mkdir -p $@
   692 	mkdir -p $@
   691 
   693 
   692 .PHONY: srs
   694 .PHONY: srs
   701   GADICT_DEL_OPT := -delfile=$(GADICT_DEL_FILE)
   703   GADICT_DEL_OPT := -delfile=$(GADICT_DEL_FILE)
   702 endif
   704 endif
   703 
   705 
   704 # Specific rules (due to renames or other customization).
   706 # Specific rules (due to renames or other customization).
   705 dist/anki/gadict.apkg: gadict.gadict $(GADICT_DEL_FILE) py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   707 dist/anki/gadict.apkg: gadict.gadict $(GADICT_DEL_FILE) py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   706 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_en-ru+uk" -rich $(GADICT_DEL_OPT) $(FREQLIST_OPT) $< $@
   708 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name="gadict_en-ru+uk" -rich $(GADICT_DEL_OPT) $(FREQLIST_OPT) $< $@
   707 
   709 
   708 dist/anki/gadict_voa.apkg: gadict_voa.gadict py/gadict.py py/gadict_srs_anki.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   710 dist/anki/gadict_voa.apkg: gadict_voa.gadict py/gadict.py py/gadict_srs_anki.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   709 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@
   711 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@
   710 
   712 
   711 dist/anki/%.apkg: %.gadialog py/gadialog_srs_anki.py $(MAKEFILE_LIST) | dist/anki/
   713 dist/anki/%.apkg: %.gadialog py/gadialog_srs_anki.py $(MAKEFILE_LIST) | dist/anki/
   712 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadialog_srs_anki.py -name="$*" $< $@
   714 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadialog_srs_anki.py -name="$*" $< $@
   713 
   715 
   714 dist/anki/%.apkg: %.gaphrase py/gaphrase_srs_anki.py $(MAKEFILE_LIST) | dist/anki/
   716 dist/anki/%.apkg: %.gaphrase py/gaphrase_srs_anki.py $(MAKEFILE_LIST) | dist/anki/
   715 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gaphrase_srs_anki.py -name="$*" $< $@
   717 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gaphrase_srs_anki.py -name="$*" $< $@
   716 
   718 
   717 # General rules.
   719 # General rules.
   718 dist/anki/%.apkg: %.gadict %.del py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   720 dist/anki/%.apkg: %.gadict %.del py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   719 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name=$* -rich -delfile=$*.del $(FREQLIST_OPT) $< $@
   721 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name=$* -rich -delfile=$*.del $(FREQLIST_OPT) $< $@
   720 
   722 
   721 dist/anki/%.apkg: %.gadict py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   723 dist/anki/%.apkg: %.gadict py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/
   722 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name=$* -rich $(FREQLIST_OPT) $< $@
   724 	PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name=$* -rich $(FREQLIST_OPT) $< $@
   723 
   725 
   724 .PHONY: tab
   726 .PHONY: tab
   725 tab: $(SRS_TAB_FILES)
   727 tab: $(SRS_TAB_FILES)
   726 
   728 
   727 dist/srs/gadict.tab.txt: gadict.gadict py/gadict.py py/gadict_srs_tab.py $(MAKEFILE_LIST) | dist/srs/
   729 dist/srs/gadict.tab.txt: gadict.gadict py/gadict.py py/gadict_srs_tab.py $(MAKEFILE_LIST) | dist/srs/
   728 	python3 -B py/gadict_srs_tab.py  $< $@ -lang:ru,uk
   730 	$(PYTHON) -B py/gadict_srs_tab.py  $< $@ -lang:ru,uk
   729 
   731 
   730 dist/srs/%.tab.txt: %.gadict py/gadict.py py/gadict_srs_tab.py $(MAKEFILE_LIST) | dist/srs/
   732 dist/srs/%.tab.txt: %.gadict py/gadict.py py/gadict_srs_tab.py $(MAKEFILE_LIST) | dist/srs/
   731 	python3 -B py/gadict_srs_tab.py  $< $@
   733 	$(PYTHON) -B py/gadict_srs_tab.py  $< $@
   732 
   734 
   733 dist/anki/ dist/srs/:
   735 dist/anki/ dist/srs/:
   734 	mkdir -p $@
   736 	mkdir -p $@
   735 
   737 
   736 .PHONY: html
   738 .PHONY: html
   737 html: $(DICT_HTML_FILES)
   739 html: $(DICT_HTML_FILES)
   738 
   740 
   739 dist/html/gadict_voa.html: gadict_voa.gadict py/gadict.py py/gadict_html.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/html/
   741 dist/html/gadict_voa.html: gadict_voa.gadict py/gadict.py py/gadict_html.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/html/
   740 	python3 -B py/gadict_html.py $(VOA_FREQLIST_OPT) $< $@
   742 	$(PYTHON) -B py/gadict_html.py $(VOA_FREQLIST_OPT) $< $@
   741 
   743 
   742 dist/html/%.html: %.gadict py/gadict.py py/gadict_html.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/html/
   744 dist/html/%.html: %.gadict py/gadict.py py/gadict_html.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/html/
   743 	python3 -B py/gadict_html.py $(FREQLIST_OPT) $< $@
   745 	$(PYTHON) -B py/gadict_html.py $(FREQLIST_OPT) $< $@
   744 
   746 
   745 dist/html/gadialog.html: gadialog.gadialog py/gadialog.py py/gadialog_html.py | dist/html/
   747 dist/html/gadialog.html: gadialog.gadialog py/gadialog.py py/gadialog_html.py | dist/html/
   746 	python3 -B py/gadialog_html.py $< $@
   748 	$(PYTHON) -B py/gadialog_html.py $< $@
   747 
   749 
   748 dist/html/:
   750 dist/html/:
   749 	mkdir -p $@
   751 	mkdir -p $@
   750 
   752 
   751 ################################################################
   753 ################################################################
   875 
   877 
   876 # Install:
   878 # Install:
   877 #   $ sudo apt-get install python3-enchant hunspell-en-us hunspell-en-gb hunspell-en-au hunspell-en-ca
   879 #   $ sudo apt-get install python3-enchant hunspell-en-us hunspell-en-gb hunspell-en-au hunspell-en-ca
   878 .PHONY: check
   880 .PHONY: check
   879 check:
   881 check:
   880 	python3 -B py/gadict_spellcheck.py gadict.gadict
   882 	$(PYTHON) -B py/gadict_spellcheck.py gadict.gadict
   881 
   883 
   882 ################################################################
   884 ################################################################
   883 # Clean targets.
   885 # Clean targets.
   884 
   886 
   885 .PHONY: distclean
   887 .PHONY: distclean