build_po.mk 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # PO build script
  2. _FUNC_PO2MO = $(patsubst %.po,$(2)/res/locale/%/LC_MESSAGES/$(3).mo,$(notdir $(1)))
  3. # parameter :
  4. # $(1) - C/C++ soruce file
  5. # $(2) - output path
  6. # $(3) - app name
  7. CONVERT_ESC_PO_TO_MO = $(call CONVERT_4MAKE_TO_OUT,$(call _FUNC_PO2MO,$(1),$(2),$(3)))
  8. # parameter :
  9. # $(1) - encoded one C/C++ soruce file
  10. # $(2) - output path
  11. # $(3) - app name
  12. # output :
  13. # $(4) - output files list
  14. define MO_BUILD_PROC_RAW
  15. $(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) : $(call DECODE_4MAKE,$(1))
  16. @echo ' Building file: $$<'
  17. @echo ' Invoking: msgfmt String Formatter'
  18. $$(call MAKEDIRS,$$(@D))
  19. $$(MSGFMT) -o "$$@" "$$<"
  20. @echo ' Finished building: $$<'
  21. $(4) += $(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3))
  22. endef
  23. # parameter :
  24. # $(1) - output dir
  25. # $(2) - src paths
  26. # $(3) - app name
  27. # output :
  28. # $(4) - OBJS
  29. define MO_PROC_RAW
  30. _PROJ_ROOT := $(1)
  31. _SRCS := $(2)
  32. _APPNAME := $(3)
  33. ifneq ($$(strip $$(_SRCS)),)
  34. _ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS))
  35. _NORMAL_SRCS := $$(filter-out %*.po,$$(_ENC_SRCS))
  36. _WIDLCARD_SRCS := $$(filter %*.po,$$(_ENC_SRCS))
  37. _ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \
  38. $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var))))
  39. ifneq ($$(strip $$(_ALL_SRCS)),)
  40. _ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS))
  41. $$(foreach var,$$(_ENC_SRCS),$$(eval $$(call MO_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_APPNAME),$(4))))
  42. endif # (_(strip _(_ALL_SRCS)),)
  43. endif # (_(strip _(_SRCS)),)
  44. endef