/[pdpsoft]/nl.nikhef.pdp.lrms-py-generic/trunk/Makefile
ViewVC logotype

Diff of /nl.nikhef.pdp.lrms-py-generic/trunk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1964 by templon, Tue Sep 28 12:03:08 2010 UTC revision 1965 by templon, Tue Sep 28 12:22:22 2010 UTC
# Line 37  ifeq ($(INSTALLPREFIX),) Line 37  ifeq ($(INSTALLPREFIX),)
37          INSTALLPREFIX := $(TARGPREFIX)          INSTALLPREFIX := $(TARGPREFIX)
38  endif  endif
39    
 # some SVN commands (ckeckout, update, commit) are by default quiet unless  
 # SVN_VERB is defined  
 _svn := svn --quiet  
 ifneq ($(SVN_VERB),)  
         _svn := svn  
 endif  
   
40  _os        := $(shell uname -s)  _os        := $(shell uname -s)
41  _date      := $(shell date '+%d/%m/%y %H:%M')  _date      := $(shell date '+%d/%m/%y %H:%M')
42    
# Line 65  _warn  = echo "[WARN] $(1)">&2 Line 58  _warn  = echo "[WARN] $(1)">&2
58  _SVN_BRNCH_SDIR := branches  _SVN_BRNCH_SDIR := branches
59  _SVN_TAG_SDIR   := tags  _SVN_TAG_SDIR   := tags
60  _SVN_TRNK_SDIR  := trunk  _SVN_TRNK_SDIR  := trunk
61  _SVN_ROOT_PATH  := $(shell svn info | grep "Repository Root" | awk '{print $NF}')  _SVN_ROOT_PATH  := $(shell svn info | grep 'Repository Root' | awk '{print $$NF}')
62    
63  ###################################################################  ###################################################################
64  # Create linux specific build directories  # Create linux specific build directories
# Line 103  $(_rpmdir): Line 96  $(_rpmdir):
96  # - refuse to run if SVN passwords/credentials caching is off  # - refuse to run if SVN passwords/credentials caching is off
97  # - forbid committing in tags/ directory  # - forbid committing in tags/ directory
98    
99  release: config.tmp  release:
100          @echo '${_SVN_ROOT_PATH}'          @echo 'Please figure out what release number you want to use'
101            @echo 'Suppose it is x.y.z'
102  minorversion: _checkop config.tmp          @echo 'Issue the following command:'
103          @echo '[INFO] increasing minorversion number x.<X>.x and timestamp..'          @echo 'svn copy -m "Creating Release Branch x.y.z" ${_SVN_ROOT_PATH}/trunk ${_SVN_ROOT_PATH}/branches/RB-x.y.z'
104          @perl <config.tmp >$(CFG_MK) -e 'while (<>) ' \          @echo 'then to work on this branch, do the following command:'
105            -e '{ s/^(VERSION=\d+\.)(\d+)(\..*)$$/$$1.($$2+1).".0"/e;' \          @echo 'svn switch ${_SVN_ROOT_PATH}/branches/RB-x.y.z'
           -e ' s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }'  
         @$(MAKE) tagversion  
   
 majorversion: _checkop config.tmp  
         @echo '[INFO] increasing majorversion number <X>.x.x and timestamp..'  
         @perl <config.tmp >$(CFG_MK) -e 'while (<>)' \  
           -e '{ s/^(VERSION=)(\d+)(\..*)$$/$$1.($$2+1).".0.0"/e;' \  
           -e ' s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }'  
         @$(MAKE) tagversion  
106    
107  config.tmp: $(CFG_MK)  config.tmp: $(CFG_MK)
         @$(_svn) update .  
108          @sed <$(CFG_MK) >config.tmp '/^DATE=/d'          @sed <$(CFG_MK) >config.tmp '/^DATE=/d'
109          @echo 'DATE=$(_date)' >>config.tmp          @echo 'DATE=$(_date)' >>config.tmp
110          @cp $(CFG_MK) $(CFG_MK)~          @cp $(CFG_MK) $(CFG_MK)~
111    
 tagversion: _checkop  
         @echo "[INFO] svn committing new release: $(VERSION)"  
         @rm -f config.tmp  
         @perl -e '$$date=`date +%Y-%m-%d`;' \  
                 -e 'chomp($$date);' \  
                 -e '$$login=getlogin();' \  
                 -e '$$logstr="<unknown>";' \  
                 -e '$$logstr=(getpwnam($$login))[6] if defined $$login;' \  
                 -e 'print $$date."  $$logstr\n\n"; '\  
                 -e 'print "\t* Release: $(NAME)-$(VERSION)\n";' >ChangeLog.tmp  
         @if [ "$(EDITOR)" -a -x "$(EDITOR)" ]; then \  
                 perl -e 'print "\t- [your comment here]"' >>ChangeLog.tmp; \  
                 $(EDITOR) ChangeLog.tmp; \  
                 perl -e '$$/=undef; $$text=<>; $$text =~ s/\s*\n*$$//s;' \  
                 -e 'print "$$text\n\n"' < ChangeLog.tmp > ChangeLog.tmp2; \  
                 mv ChangeLog.tmp2 ChangeLog.tmp; \  
         else \  
                 echo "[INFO] Enter ChangeLog comment (hit CTRL+D to stop):"; \  
                 perl -e '$$text=""; while(<>) { $$text .= "\t$$_" };' \  
                 -e '$$text =~ s/^\s*(.+?)\s*\n*$$/$$1/s;' \  
                 -e 'chomp($$text); print "\t- $$text\n\n"' >>ChangeLog.tmp; \  
         fi  
         @if [ ! -r ChangeLog ] ; then touch ChangeLog ; $(_svn) add ChangeLog ; fi  
         @cp ChangeLog.tmp /tmp/ChangeLog.tmp.$$$  
         @cat ChangeLog >>ChangeLog.tmp  
         @mv ChangeLog.tmp ChangeLog  
         @$(_svn) commit -F /tmp/ChangeLog.tmp.$$$  
         @rm -f /tmp/ChangeLog.tmp.$$$  
         @$(MAKE) _tag_dir=$(_vtag) svntag  
         @$(MAKE) _tag_dir=latest _trg_tag=$(_vtag) svnextag  
         @$(MAKE) tagstable  
   
 # auxiliary target to build an SVN tag. Input parameter is _tag_dir, which  
 # is the leaf subdirectory (intermediate subdirectories are built transparently);  
 #       _co_root is the checkout root,  
 #       _co_locl is the local path to the module in the checkout  
 #       _co_subd is the sub-path to the module in the checkout  
 # that is:  
 #       $pwd == $_co_root/$_co_locl == $_co_root/$_co_subd/$_module  
 #  
 _svn_root = $(shell svn info | sed -nr 's/^.+Root:\s+(\S+)$$/\1/ p')  
 _svn_url = $(shell svn info | sed -nr 's/^URL:\s+(\S+)$$/\1/ p')  
 _co_locl = $(shell echo $(_svn_url) | sed -nr 's%^\S+?/$(_SVN_TRNK_SDIR)/%% p')  
 _co_subd = $(shell echo $(_co_locl) | sed -nr 's%/$(_module)$$%% p')  
 # don't ask me why this doesn't work...  
 # _co_root = $(shell echo -n $(PWD) |\  
 #        sed -r 's%^(.+?)/(\S*$(_SVN_TRNK_SDIR)/)?$(_co_locl)$$%\1%' | sed -r 's%/*$$%%')  
 _co_root = $(shell pwd | \  
         perl -e '$$a=<>; $$a=~s%^(\S+?)/([^/]*$(_SVN_TRNK_SDIR)/)?$(_co_locl)$$%$$1%; print $$a' |\  
         sed -r 's%/*$$%%')  
 ifneq ($(QTTR_CO_ROOT),)  
         _co_root = $(QTTR_CO_ROOT)  
 endif  
 svntag: _checkop  
         @if [ "$(DEBUG)" ]; then\  
                 echo "[DEBUG] _svn_root=$(_svn_root)" >&2;\  
                 echo "[DEBUG] _svn_url=$(_svn_url)" >&2;\  
                 echo "[DEBUG] _co_locl=$(_co_locl)" >&2;\  
                 echo "[DEBUG] _co_subd=$(_co_subd)" >&2;\  
                 echo "[DEBUG] _co_root=$(_co_root)" >&2;\  
         fi  
         @[ "$(_tag_dir)" ] || $(call _fatal,no tag directory specified,1)  
         @[ "$(_co_root)" -a "$(_svn_root)" ]\  
                 || $(call _fatal,checkout and/or SVN root not defined,2)  
         @echo "[INFO] svn tagging new release: $(_tag_dir)"  
         @src_path=$$PWD;\  
         dst_url=$(_svn_root)/$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module);\  
         dst_path=$(_co_root)/$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module);\  
         [ "$(DEBUG)" ] && echo "[DEBUG] dst_url=$$dst_url" >&2;\  
         [ "$(DEBUG)" ] && echo "[DEBUG] dst_path=$$dst_path" >&2;\  
         aux=$(_co_subd);\  
         [ "$(DEBUG)" ] && echo "[DEBUG] aux=$$aux" >&2;\  
         saux='';\  
         made_sdir=0;\  
         tag_mod_root='';\  
         while [ "$$aux" ]; do\  
                 sdir=`echo -n $$aux | sed -nr 's%^([^/]+).*?$$%\1% p'`;\  
                 [ $$made_sdir -eq 0 ] && tag_mod_root=$$sdir;\  
                 [ "$(DEBUG)" ] && echo "[DEBUG] sdir=$$sdir" >&2;\  
                 saux=$$saux/$$sdir;\  
                 dst_surl=$(_svn_root)/$(_SVN_TAG_SDIR)/$$saux;\  
                 [ "$(DEBUG)" ] && echo "[DEBUG] dst_surl=$$dst_surl" >&2;\  
                 if (svn info $$dst_surl 2>&1 | egrep "\(Not a valid URL\)") >/dev/null; then\  
                         $(_svn) mkdir $$dst_surl -m "Made directory $(_SVN_TAG_SDIR)$$saux" \  
                                 || $(call _fatal,$$dst_surl: cant make svn dir,3);\  
                 fi;\  
                 aux=`echo -n $$aux | sed -nr "s%^$$sdir/%% p"`;\  
                 [ "$(DEBUG)" ] && echo "[DEBUG] aux=$$aux" >&2;\  
                 made_sdir=1;\  
         done;\  
         if (svn info $$dst_url 2>&1 | egrep "\(Not a valid URL\)") >/dev/null; then\  
                 [ "$(DEBUG)" ] && echo "[DEBUG] svn mkdir $$dst_url" >&2;\  
                 $(_svn) mkdir $$dst_url -m "Made directory $(_SVN_TAG_SDIR)/$(_co_subd)/$(_module)"\  
                         || $(call _fatal,$$dst_url: cant make svn dir,4);\  
         fi;\  
         [ "$(DEBUG)" ] && echo "[DEBUG] svn copy $$src_path $$dst_url/$(_tag_dir)" >&2;\  
         $(_svn) copy $$src_path $$dst_url/$(_tag_dir) -m "Added tag $(_module)/$(_tag_dir)" \  
                 || $(call _fatal,$$src_path: cant svn copy to $$dst_url/$(_tag_dir),5);\  
         [ "$(DEBUG)" ] && echo "[DEBUG] svn co $$dst_url/$(_tag_dir) $$dst_path/$(_tag_dir)" >&2;\  
         $(_svn) checkout $$dst_url/$(_tag_dir) $$dst_path/$(_tag_dir) \  
                 || $(call _fatal,$$dst_url/$(_tag_dir): cant svn check out,6)  
   
   
 svnextag: _checkop  
         @[ "$(_tag_dir)" ] || $(call _fatal,no tag directory specified,1)  
         @[ "$(_trg_tag)" ] || $(call _fatal,no target tag specified,2)  
         @echo "[INFO] svn tagging external reference: $(_tag_dir) -> $(_trg_tag)"  
         @[ "$(_co_root)" -a "$(_svn_root)" ]\  
                 || $(call _fatal,checkout and/or SVN root not defined,3)  
         @src_sdir=$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module)/$(_trg_tag);\  
         src_url=$(_svn_root)/$$src_sdir;\  
         src_path=$(_co_root)/$$src_sdir;\  
         dst_sdir=$(_SVN_TAG_SDIR)/$(_co_subd)/$(_module)/$(_tag_dir);\  
         dst_url=$(_svn_root)/$$dst_sdir;\  
         dst_path=$(_co_root)/$$dst_sdir;\  
         if (svn info $$dst_url 2>&1 | egrep "\(Not a valid URL\)") >/dev/null; then\  
                 $(_svn) mkdir $$dst_url -m "Made directory $$dst_surl"\  
                         || $(call _fatal,$$dst_surl: cant make svn dir,4);\  
                 cd $(_co_root)/$(_SVN_TAG_SDIR);\  
                 $(_svn) checkout $$dst_url $$dst_path \  
                         || $(call _fatal,$$dst_url: cant svn check out,5);\  
         else\  
                 $(_svn) checkout $$dst_url $$dst_path \  
                         || $(call _fatal,$$dst_url: cant svn check out,6);\  
                 $(_svn) propdel svn:externals $$dst_path \  
                         || $(call _fatal,$$dst_path: cant delete svn:externals,7);\  
                 rm -rf $$dst_path/*;\  
         fi;\  
         ext_rev=`svn info $$src_url | sed -nr 's%^Revision:\s+(\S+)$$%\1% p'`;\  
         [ "$$ext_rev" ] || $(call _fatal,cant determine external revision,8);\  
         $(_svn) propset svn:externals "$(_trg_tag) -r$$ext_rev $$src_url" $$dst_path \  
                 || $(call _fatal,$$dst_path: cant set svn:externals,9);\  
         $(_svn) commit $$dst_path -m "Added tag $(_module)/$(_tag_dir) -> $(_trg_tag)" \  
                 || $(call _fatal,$$dst_path: cant svn commit,10);\  
         $(_svn) update $$dst_path || $(call _fatal,$$dst_path: cant svn update,11)  
   
   
 tagstable: _checkop  
         @echo "[INFO] tagging 'stable' release"  
         @prompt='Do you want to tag this release as 'stable'? [no]: ';\  
         while read -p "$$prompt" ans || exit 1; do\  
                 [ -z $$ans ] && ans='no';\  
                 case $$ans in\  
                         [Yy]|[Yy]es)\  
                                 _tag_dir=stable _trg_tag=$(_vtag) $(MAKE) svnextag;\  
                                 break;\  
                                 ;;\  
                         [Nn]|[Nn]o)\  
                                 break;\  
                                 ;;\  
                         *)\  
                                 prompt='Answer either "yes" or not at all: ';\  
                 esac;\  
         done  
   
   
 # mark as OBSOLETE (no SVN tag is added). A message to be added to config.mk  
 # can be passed through the variable OBSOLETE_MSG  
 markobsolete: _checkop  
         @[ -w config.mk ]\  
                 || $(call _fatal,config.mk: file missing or not writable,1)  
         @if [ "`sed -nr '/^\s*OBSOLETE/ p' config.mk`" ]; then\  
                 $(call _fatal,already marked as OBSOLETE,2);\  
         fi  
         @echo "[INFO] marking as OBSOLETE"  
         @obs_msg='1';\  
         if [ ! -z "$$OBSOLETE_MSG" ]; then\  
                 obs_msg="$$OBSOLETE_MSG";\  
         fi;\  
         echo OBSOLETE="$$obs_msg" >> config.mk  
         @$(_svn) commit -m 'Module marked as OBSOLETE'\  
                 || $(call _fatal,cant svn commit,3)  
   
   
   
112  ####################################################################  ####################################################################
113  # Build distributions in tar & RPM/PKG format  # Build distributions in tar & RPM/PKG format
114  ####################################################################  ####################################################################

Legend:
Removed from v.1964  
changed lines
  Added in v.1965

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28