Makefile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. LFS_EN = /home/xry111/svn-repos/LFS-BOOK
  2. MLANG=zh_CN
  3. ALL_XML_FILES = $(shell find $(LFS_EN) -type f -name '*.xml')
  4. EXCLUDE_FILES = $(LFS_EN)/chapter01/livecd.xml \
  5. $(LFS_EN)/chapter04/creatingtoolsdir.xml \
  6. $(LFS_EN)/chapter04/aboutlfs.xml
  7. XML_FILES = $(filter-out $(EXCLUDE_FILES), $(ALL_XML_FILES))
  8. PO_FILES = $(patsubst $(LFS_EN)/%.xml, $(MLANG)/%.po, $(XML_FILES))
  9. run: $(PO_FILES)
  10. $(MLANG)/chapter01/changelog.po: $(LFS_EN)/chapter01/changelog.xml changelogtranslator.py templatetranslator.py
  11. mkdir -pv "$(@D)"
  12. po4a-updatepo -f docbook -m $< -p $@
  13. ./changelogtranslator.py $(MLANG)
  14. $(MLANG)/%.po: $(LFS_EN)/%.xml
  15. mkdir -pv "$(@D)"
  16. po4a-updatepo -f docbook -m $< -p $@
  17. touch $@
  18. MXML_FILES = $(patsubst $(LFS_EN)/%.xml, %.xml, $(XML_FILES))
  19. BOOK_FILES = $(patsubst $(LFS_EN)/%, %, $(shell find $(LFS_EN) -type f -not -path "$(LFS_EN)/.svn/*"))
  20. KEEP_FILES = $(filter-out $(MXML_FILES), KEEP_FILES)
  21. MBOOK_FILES = $(patsubst %, $(MLANG)/book/%, $(BOOK_FILES))
  22. .PHONY: booksrc
  23. booksrc: booksrc_unfixed
  24. [ ! -e $(MLANG)/fix.sh ] || (pushd $(MLANG)/book; sh ../fix.sh; popd)
  25. booksrc_unfixed: $(MBOOK_FILES) $(PATCHES)
  26. $(MLANG)/book/%.xml: $(LFS_EN)/%.xml $(MLANG)/%.po
  27. mkdir -pv "$(@D)"
  28. po4a-translate -f docbook -m $< -p $(filter-out $<, $^) -l $@
  29. [ -e $@ ] || cp -v $< $@
  30. relpath=$$(echo $@ | sed 's@$(MLANG)/book/@@'); \
  31. patch_path=$(MLANG)/patches/$${relpath}.patch; \
  32. if [ -e $${patch_path} ]; then \
  33. pushd $(MLANG)/book; patch -Np1 -i ../patches/$${relpath}.patch; popd; \
  34. fi
  35. $(MLANG)/book/%: $(LFS_EN)/%
  36. mkdir -pv "$(@D)"
  37. cp -v $< $@
  38. relpath=$$(echo $@ | sed 's@$(MLANG)/book/@@'); \
  39. patch_path=$(MLANG)/patches/$${relpath}.patch; \
  40. if [ -e $${patch_path} ]; then \
  41. pushd $(MLANG)/book; patch -Np1 -i ../patches/$${relpath}.patch; popd; \
  42. fi
  43. test:
  44. echo $(XML_FILES)