Advertisement
Emulatorman

GNUmakefile.team

Jan 19th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.04 KB | None | 0 0
  1. # This is -*-makefile-gmake-*-, because we adore GNU make.
  2. # Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
  3.  
  4. # This file is part of GNUnited Nations.
  5.  
  6. # GNUnited Nations is free software: you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10.  
  11. # GNUnited Nations is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15.  
  16. # You should have received a copy of the GNU General Public License
  17. # along with GNUnited Nations. If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. ########################################################################
  20. ### TRANSLATORS: Rename this file as GNUmakefile and install it in the #
  21. ### root of your project's *Sources* repository. For details, see the #
  22. ### section "PO Files and Team" in the manual. #
  23. ########################################################################
  24.  
  25. ### DEPENDENCIES ###
  26. # GNU make >= 3.81 (prereleases are OK too)
  27. # GNU gettext >= 0.16
  28. # CVS
  29. # Subversion (if the www-LANG repository is SVN)
  30. # GNU Bzr (if the www-LANG repository is Bzr)
  31. # Git (if the www-LANG repository is Git)
  32. # Mercurial (if the www-LANG repository is Hg)
  33. # GNU Arch (if the www-LANG repository is Arch)
  34.  
  35. SHELL = /bin/bash
  36.  
  37. # Set this variable to your language code.
  38. TEAM := pt-br
  39.  
  40. # The relative or absolute path to the working copy of the master
  41. # "www" repository; must end with a trailing slash.
  42. wwwdir := /home/andre/FSF_projects/www/
  43.  
  44. # Adjust these variables if you don't have the programs in your PATH.
  45. MSGMERGE := msgmerge
  46. MSGFMT := msgfmt
  47. MSGCAT := msgcat
  48. CVS := cvs
  49. SVN := svn
  50. BZR := bzr
  51. GIT := git
  52. HG := hg
  53. # Baz can be used alternatively; its commands are compatible.
  54. TLA := tla
  55.  
  56. translations := $(shell find -name '*.$(TEAM).po' | sort)
  57. log := "Automatic merge from the master repository."
  58. # Warning message for the `publish' rule.
  59. pubwmsg := "Warning (%s): %s\n does not exist; (either obsolete or \`cvs\
  60. update\' in $(wwwdir) needed).\n"
  61.  
  62. # Determine the VCS.
  63. REPO := $(shell (test -d CVS && echo CVS) || (test -d .svn && echo SVN) \
  64. || (test -d .bzr && echo Bzr) || (test -d .git && echo Git) \
  65. || (test -d .hg && echo Hg) || (test -d \{arch\} && echo Arch))
  66. ifndef REPO
  67. $(error Unsupported Version Control System)
  68. endif
  69.  
  70. # For those who love details.
  71. ifdef VERBOSE
  72. $(info Repository: $(REPO))
  73. $(info translations = $(translations))
  74. MSGMERGEVERBOSE := --verbose
  75. ECHO := echo $$file: ;
  76. CVSQUIET :=
  77. # Applicable for Bzr, Git and Hg.
  78. QUIET := --verbose
  79. else
  80. CVSQUIET := -q
  81. QUIET := --quiet
  82. endif
  83.  
  84. # The command to update the CVS repositories.
  85. define cvs-update
  86. $(CVS) $(CVSQUIET) update -d -P
  87. endef
  88.  
  89. # The command to update the Subversion repository.
  90. define svn-update
  91. $(SVN) $(CVSQUIET) update
  92. endef
  93.  
  94. .PHONY: all
  95. all: update sync
  96.  
  97. # Update the master and the team repositories.
  98. .PHONY: update
  99. update:
  100. ifeq ($(VCS),yes)
  101. @echo Updating the repositories...
  102. cd $(wwwdir) && $(cvs-update)
  103. ifeq ($(REPO),CVS)
  104. $(cvs-update)
  105. else ifeq ($(REPO),SVN)
  106. $(svn-update)
  107. else ifeq ($(REPO),Bzr)
  108. $(BZR) pull $(QUIET)
  109. else ifeq ($(REPO),Git)
  110. $(GIT) pull $(QUIET)
  111. else ifeq ($(REPO),Hg)
  112. # The "fetch" extension is not guaranteed to be available, and/or
  113. # enabled in user's ~/.hgrc.
  114. $(HG) pull --update $(QUIET)
  115. else ifeq ($(REPO),Arch)
  116. $(TLA) update
  117. endif
  118. else
  119. $(info Repositories were not updated, you might want "make VCS=yes".)
  120. endif
  121.  
  122. # Synchronize (update) the PO files from the master POTs.
  123. .PHONY: sync
  124. sync: update
  125. @for file in $(translations); do \
  126. if [ ! -f $(wwwdir)`dirname $$file`/po/`basename \
  127. $${file/.$(TEAM).po/.pot}` ]; then \
  128. echo "Warning: $(notdir $$file) has no equivalent .pot in www."; \
  129. else \
  130. $(ECHO) $(MSGMERGE) $(MSGMERGEVERBOSE) --quiet --update \
  131. --previous $$file \
  132. $(wwwdir)`dirname $$file`/po/`basename $${file/.$(TEAM).po/.pot}`; \
  133. fi; \
  134. done
  135. ifeq ($(VCS),yes)
  136. ifeq ($(REPO),CVS)
  137. $(CVS) commit -m $(log)
  138. else ifeq ($(REPO),SVN)
  139. $(SVN) commit -m $(log)
  140. else ifeq ($(REPO),Bzr)
  141. # The behavior of `bzr commit' is not very script-friendly: it will
  142. # exit with an error if there are no changes to commit.
  143. if $(BZR) status --versioned --short | grep --quiet '^ M'; then \
  144. $(BZR) commit $(QUIET) -m $(log) && $(BZR) push $(QUIET); \
  145. else \
  146. true; \
  147. fi
  148. else ifeq ($(REPO),Git)
  149. # Git (`git commit', to be precise) will exit with an error if there
  150. # are only untracked files present (a common situation). Sadly, there
  151. # doesn't seem to be a decent workaround, so exit status is ignored.
  152. -$(GIT) commit --all $(QUIET) -m $(log)
  153. $(GIT) push $(QUIET)
  154. else ifeq ($(REPO),Hg)
  155. $(HG) commit $(QUIET) -m $(log) && $(HG) push $(QUIET)
  156. else ifeq ($(REPO),Arch)
  157. # Arch is so dumb that it will do a bogus commit (adding another
  158. # absolutely useless revision) even if there are no changes.
  159. # Fortunately, the exit status of `tla changes' is sane.
  160. $(TLA) changes >/dev/null || $(TLA) commit -s $(log)
  161. endif
  162. endif
  163.  
  164. # Helper target to check which articles have to be updated.
  165. .PHONY: report
  166. report:
  167. @for file in $(translations) ; do \
  168. LC_ALL=C $(MSGFMT) --statistics -o /dev/null $$file 2>&1 \
  169. | egrep '(fuzzy|untranslated)' \
  170. && echo "$${file#./} needs updating." || true ; \
  171. done
  172.  
  173. # Helper target to rewrap all PO files; avoids spurious diffs when
  174. # they get remerged by the official build.
  175. .PHONY: format
  176. format:
  177. @echo Formatting .po files with msgcat:
  178. @for file in $(translations); do \
  179. if [ `LC_ALL=C <$$file wc --max-line-length` -gt 80 ]; then \
  180. $(MSGCAT) -o $$file $$file && echo " $${file#./}"; \
  181. fi; \
  182. done
  183.  
  184. # Helper target to copy all (supposedly) modified files to the `www'
  185. # master repository. A warning is printed if the corresponding
  186. # directory in `www' cannot be found, or if the template is missing
  187. # (which in almost all cases means that the original article has been
  188. # renamed or deleted).
  189. .PHONY: publish
  190. publish: format
  191. @echo Copying edited .po files back to $(wwwdir):
  192. @for file in $(translations); do \
  193. wwwfdir=$(wwwdir)`dirname $$file`/po; \
  194. wwwfpot=$${wwwfdir}/`basename $${file/.$(TEAM).po/.pot}`; \
  195. wwwfile=$${wwwfdir}/`basename $$file`; \
  196. if [ ! -d $$wwwfdir ]; then \
  197. printf $(pubwmsg) "$${file#./}" "directory $$wwwfdir"; \
  198. continue; \
  199. fi; \
  200. if [ ! -f $$wwwfpot ]; then \
  201. printf $(pubwmsg) "$${file#./}" "template $$wwwfpot"; \
  202. continue; \
  203. fi; \
  204. if [ $$file -nt $$wwwfile ]; then \
  205. cp $$file $$wwwfile && echo " $${file#./}"; \
  206. fi; \
  207. done
  208.  
  209. # Helper target to delete common auto-generated files.
  210. .PHONY: clean
  211. clean:
  212. @echo -n Deleting unnecessary auto-generated files...
  213. @for file in $(translations); do \
  214. $(RM) $$file~; \
  215. $(RM) $${file/.po/.mo}; \
  216. $(RM) $$file.bak; \
  217. done
  218. @echo " done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement