Makefile
changeset 131 1bcce07aabf5
parent 128 ca6ceff4941c
child 132 236e638526a5
equal deleted inserted replaced
130:7c6fc5f06884 131:1bcce07aabf5
    52 
    52 
    53 # Here are vmajor and vminor. Look README section "Versioning rules."
    53 # Here are vmajor and vminor. Look README section "Versioning rules."
    54 -include VERSION
    54 -include VERSION
    55 
    55 
    56 VERSION:
    56 VERSION:
    57 	ver=$$(hg log -r . --template '{latesttag}'); \
    57 	\
    58 ver=$${ver#t}; \
    58 vtagdist=$$(hg log -r . --template '{latesttagdistance}'); \
    59 major=$${ver%.*}; \
    59 vatrelease=$$([ $$vtagdist = 0 ] && echo yes || echo no); \
    60 minor=$${ver#*.}; \
    60 vtag=$$(hg log -r . --template '{latesttag}'); \
    61 printf "vmajor=%s\nvminor=%s\n" $$major $$minor >VERSION
    61 vmajor=$${vtag#t}; \
    62 	# is_release=`hg log --template '{latesttagdistance}'`
    62 vmajor=$${vmajor%.*}; \
       
    63 vminor=$${vtag#*.}; \
       
    64 vrev=$$(hg id -i); \
       
    65 visclean=$$(case $$vrev in *+) echo no;; *) echo yes;; esac); \
       
    66 vrev=$${vrev%+}; \
       
    67 { \
       
    68 echo "vrev=$$vrev"; \
       
    69 echo "vtag=$$vtag"; \
       
    70 echo "vtagdist=$$vtagdist"; \
       
    71 echo "visclean=$$visclean"; \
       
    72 echo "vatrelease=$$vatrelease"; \
       
    73 echo "vmajor=$$vmajor"; \
       
    74 echo "vminor=$$vminor"; \
       
    75 } >VERSION
    63 
    76 
    64 ################################################################
    77 ################################################################
    65 # Determine platform/environment.
    78 # Determine platform/environment.
    66 
    79 
    67 host_os = unix
    80 host_os = unix
   149 .PHONY: deploy2sf
   162 .PHONY: deploy2sf
   150 deploy2sf: deploy2sf-doc deploy2sf-release deploy2sf-src
   163 deploy2sf: deploy2sf-doc deploy2sf-release deploy2sf-src
   151 
   164 
   152 # Will be accessed via http://$(pkgname).sourceforge.net
   165 # Will be accessed via http://$(pkgname).sourceforge.net
   153 .PHONY: deploy2sf-doc
   166 .PHONY: deploy2sf-doc
   154 deploy2sf-doc: $(HTML_FILES)
   167 deploy2sf-doc: deploy-check $(HTML_FILES)
   155 	( echo 'cd htdocs'; \
   168 	( echo 'cd htdocs'; \
   156 for f in $(HTML_FILES); do \
   169 for f in $(HTML_FILES); do \
   157   echo "put $$f"; \
   170   echo "put $$f"; \
   158   echo "chmod 644 $$f"; \
   171   echo "chmod 644 $$f"; \
   159 done; \
   172 done; \
   160 echo 'quit'; \
   173 echo 'quit'; \
   161 ) | sftp -b - $(SF_USER),$(pkgname)@web.sourceforge.net
   174 ) | sftp -b - $(SF_USER),$(pkgname)@web.sourceforge.net
   162 
   175 
   163 .PHONY: deploy2sf-release
   176 .PHONY: deploy2sf-release
   164 deploy2sf-release: $(DIST_TARBALLS) $(DISTSRC_TARBALLS)
   177 deploy2sf-release: deploy-check $(DIST_TARBALLS) $(DISTSRC_TARBALLS)
   165 	( echo 'cd /home/frs/project/g/ga/gadict'; \
   178 	( echo 'cd /home/frs/project/g/ga/gadict'; \
   166 echo "put CHANGES.rst"; \
   179 echo "put CHANGES.rst"; \
   167 echo "chmod 644 CHANGES.rst"; \
   180 echo "chmod 644 CHANGES.rst"; \
   168 echo "put  README.rst"; \
   181 echo "put  README.rst"; \
   169 echo "chmod 644 README.rst"; \
   182 echo "chmod 644 README.rst"; \
   178 
   191 
   179 .PHONY: deploy2sf-src
   192 .PHONY: deploy2sf-src
   180 deploy2sf-src:
   193 deploy2sf-src:
   181 	hg push ssh://gavenkoa@hg.code.sf.net/p/$(pkgname)/code
   194 	hg push ssh://gavenkoa@hg.code.sf.net/p/$(pkgname)/code
   182 
   195 
       
   196 .PHONY: deploy-check
       
   197 deploy-check:
       
   198 	case ${visclean} in \
       
   199 		no) echo "Local changes found. Build stop."; \
       
   200 			exit 1;; \
       
   201 	esac
       
   202 	case $(vatrelease) in \
       
   203 		no) echo "We are not at release. Build stop."; \
       
   204 			exit 1;; \
       
   205 	esac
       
   206 
   183 ################################################################
   207 ################################################################
   184 # Dist targets.
   208 # Dist targets.
   185 
   209 
   186 .PHONY: dist
   210 .PHONY: dist
   187 dist: dist-dictd dist-src
   211 dist: dist-dictd dist-src
   254 $(HTML_FILES): %.html: %.rst rst.css VERSION.rst $(BUILD_SCRIPT)
   278 $(HTML_FILES): %.html: %.rst rst.css VERSION.rst $(BUILD_SCRIPT)
   255 	$(RST2HTML) $(RST2HTML_FLAGS) --stylesheet=rst.css $*.rst $@
   279 	$(RST2HTML) $(RST2HTML_FLAGS) --stylesheet=rst.css $*.rst $@
   256 
   280 
   257 VERSION.rst: VERSION $(BUILD_SCRIPT)
   281 VERSION.rst: VERSION $(BUILD_SCRIPT)
   258 	{ \
   282 	{ \
   259 	echo 'Version: '$(vmajor).$(vminor); \
   283 	echo 'For ``$(pkgname)`` version: ``$(vmajor).$(vminor)``.'; \
   260 	echo; \
   284 	echo; \
   261 	echo 'Date: '`date +%F`; \
   285 	case ${visclean} in \
       
   286 		yes) echo 'Source files are at revision: ``$(vrev)``.';; \
       
   287 		no) echo 'Some source files was modified from revision: ``$(vrev)``.';; \
       
   288 	esac; \
       
   289 	echo; \
       
   290 	case ${vatrelease} in \
       
   291 		yes) echo 'Package is at release state.';; \
       
   292 		no) echo 'Package is far from release state by $(vtagdist) changes.';; \
       
   293 	esac; \
       
   294 	echo; \
       
   295 	echo 'Build date: ``'$$(date +%F)'``.'; \
   262 	} >$@
   296 	} >$@
   263 
   297 
   264 ################################################################
   298 ################################################################
   265 # Helpers targets.
   299 # Helpers targets.
   266 
   300 
   267 .PHONY: help
   301 .PHONY: help
   268 help:
   302 help:
   269 	@echo
   303 	@\
   270 	@echo vmajor=$(vmajor)
   304 echo; \
   271 	@echo vminor=$(vminor)
   305 echo Current configuration:; \
   272 	@echo
   306 echo; \
   273 	@echo Supported targets:
   307 sed 's=^=  =' <VERSION
   274 	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(BUILD_SCRIPT)
   308 	@if [ -f Makefile.config ]; then \
       
   309 		echo; \
       
   310 		echo User configuration:; \
       
   311 		echo; \
       
   312 		sed 's=^=  =' <Makefile.config; \
       
   313 	fi
       
   314 	@\
       
   315 echo; \
       
   316 echo Supported targets:; \
       
   317 echo; \
       
   318 sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(BUILD_SCRIPT)
   275 
   319 
   276 .PHONY: stat
   320 .PHONY: stat
   277 stat:
   321 stat: STAT.rst
   278 	total=0; \
   322 
   279 	for dic in *.dict-c5; do \
   323 STAT.rst: $(C5_FILES) $(BUILD_SCRIPT)
   280 		cnt=`grep '^_____' $$dic | wc -l`; \
   324 	{ \
   281 		echo $$dic 'has  ' $$cnt words.; \
   325 echo '============================'; \
   282 		total=$$(($$total + $$cnt)); \
   326 echo ' gadict project statistics.'; \
   283 	done; \
   327 echo '============================'; \
   284 	echo Total words count is $$total.
   328 echo '.. contents::'; \
       
   329 echo; \
       
   330 echo 'gadict article count.'; \
       
   331 echo '====================='; \
       
   332 echo; \
       
   333 echo '======================================== ====='; \
       
   334 echo '             Dictionary                  Count'; \
       
   335 echo '======================================== ====='; \
       
   336 total=0; \
       
   337 for dic in $(C5_FILES); do \
       
   338   cnt=`grep '^_____' $$dic | wc -l`; \
       
   339   printf '%40s %5s\n' $$dic $$cnt; \
       
   340   total=$$(($$total + $$cnt)); \
       
   341 done; \
       
   342 printf '%40s %5s\n' '**Total**' $$total; \
       
   343 echo '======================================== ====='; \
       
   344 } >$@
   285 
   345 
   286 ################################################################
   346 ################################################################
   287 # Clean targets.
   347 # Clean targets.
   288 
   348 
   289 .PHONY: distclean
   349 .PHONY: distclean
   290 distclean: clean
   350 distclean: clean
   291 	rm -f VERSION
   351 	rm -f VERSION
   292 
   352 
   293 .PHONY: clean
   353 .PHONY: clean
   294 clean:
   354 clean:
   295 	rm -f $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES)
   355 	rm -f $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES) STAT.rst
   296 	rm -rf $(DIST_DIR) $(DIST_TARBALLS)
   356 	rm -rf $(DIST_DIR) $(DIST_TARBALLS)
   297 	rm -rf $(DISTSRC_DIR) $(DISTSRC_TARBALLS)
   357 	rm -rf $(DISTSRC_DIR) $(DISTSRC_TARBALLS)
   298 
   358