My dotfiles. Period.

Makefile 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. # vim:filetype=make:foldmethod=marker:fdl=0:
  2. #
  3. # Makefile: install/uninstall/link vim plugin files.
  4. # Author: Cornelius <cornelius.howl@gmail.com>
  5. # Date: 一 3/15 22:49:26 2010
  6. # Version: 1.0
  7. #
  8. # PLEASE DO NOT EDIT THIS FILE. THIS FILE IS AUTO-GENERATED FROM Makefile.tpl
  9. # LICENSE {{{
  10. # Copyright (c) 2010 <Cornelius (c9s)>
  11. #
  12. # Permission is hereby granted, free of charge, to any person
  13. # obtaining a copy of this software and associated documentation
  14. # files (the "Software"), to deal in the Software without
  15. # restriction, including without limitation the rights to use,
  16. # copy, modify, merge, publish, distribute, sublicense, and/or sell
  17. # copies of the Software, and to permit persons to whom the
  18. # Software is furnished to do so, subject to the following
  19. # conditions:
  20. #
  21. # The above copyright notice and this permission notice shall be
  22. # included in all copies or substantial portions of the Software.
  23. #
  24. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  26. # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  28. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  29. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  30. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  31. # OTHER DEALINGS IN THE SOFTWARE.
  32. # }}}
  33. # VIM RECORD FORMAT: {{{
  34. # {
  35. # version => 0.2, # record spec version
  36. # generated_by => 'Vimana-' . $Vimana::VERSION,
  37. # install_type => 'auto', # auto , make , rake ... etc
  38. # package => $self->package_name,
  39. # files => \@e,
  40. # }
  41. # }}}
  42. # INTERNAL VARIABLES {{{
  43. RECORD_FILE=.record
  44. PWD=`pwd`
  45. README_FILES=`ls -1 | grep -i readme`
  46. WGET_OPT=-c -nv
  47. CURL_OPT=
  48. RECORD_SCRIPT=.mkrecord
  49. TAR=tar czvf
  50. GIT_SOURCES=
  51. # INTERNAL FUNCTIONS {{{
  52. record_file = \
  53. PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  54. echo $(VIMRUNTIME)/$$PTYPE/$(1) >> $(2)
  55. # }}}
  56. # PUBLIC FUNCTIONS {{{
  57. GIT_SOURCES=
  58. DEPEND_DIR=/tmp/vim-deps
  59. # Usage:
  60. #
  61. # $(call install_git_sources)
  62. #
  63. install_git_source = \
  64. PWD=$(PWD) ; \
  65. mkdir -p $(DEPEND_DIR) ; \
  66. cd $(DEPEND_DIR) ; \
  67. for git_uri in $(GIT_SOURCES) ; do \
  68. OUTDIR=$$(echo $$git_uri | perl -pe 's{^.*/}{}') ;\
  69. echo $$OUTDIR ; \
  70. if [[ -e $$OUTDIR ]] ; then \
  71. cd $$OUTDIR ; \
  72. git pull origin master && \
  73. make install && cd .. ; \
  74. else \
  75. git clone $$git_uri $$OUTDIR && \
  76. cd $$OUTDIR && \
  77. make install && cd .. ; \
  78. fi; \
  79. done ;
  80. # install file by inspecting content
  81. install_file = \
  82. PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  83. cp -v $(1) $(VIMRUNTIME)/$$PTYPE/$(1)
  84. link_file = \
  85. PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  86. cp -v $(1) $(VIMRUNTIME)/$$PTYPE/$(1)
  87. unlink_file = \
  88. PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  89. rm -fv $(VIMRUNTIME)/$$PTYPE/$(1)
  90. # fetch script from an url
  91. fetch_url = \
  92. @if [[ -e $(2) ]] ; then \
  93. exit \
  94. ; fi \
  95. ; echo " => $(2)" \
  96. ; if [[ ! -z `which curl` ]] ; then \
  97. curl $(CURL_OPT) $(1) -o $(2) ; \
  98. ; elif [[ ! -z `which wget` ]] ; then \
  99. wget $(WGET_OPT) $(1) -O $(2) \
  100. ; fi \
  101. ; echo $(2) >> .bundlefiles
  102. install_source = \
  103. for git_uri in $(GIT_SOURCES) ; do \
  104. OUTDIR=$$(echo $$git_uri | perl -pe 's{^.*/}{}') ;\
  105. echo $$OUTDIR ; \
  106. done
  107. # fetch script from github
  108. fetch_github = \
  109. @if [[ -e $(5) ]] ; then \
  110. exit \
  111. ; fi \
  112. ; echo " => $(5)" \
  113. ; if [[ ! -z `which curl` ]] ; then \
  114. curl $(CURL_OPT) http://github.com/$(1)/$(2)/raw/$(3)/$(4) -o $(5) \
  115. ; elif [[ ! -z `which wget` ]] ; then \
  116. wget $(WGET_OPT) http://github.com/$(1)/$(2)/raw/$(3)/$(4) -O $(5) \
  117. ; fi \
  118. ; echo $(5) >> .bundlefiles
  119. # fetch script from local file
  120. fetch_local = @cp -v $(1) $(2) \
  121. ; @echo $(2) >> .bundlefiles
  122. # 1: NAME , 2: URI
  123. dep_from_git = \
  124. D=/tmp/$(1)-$$RANDOM ; git clone $(2) $$D ; cd $$D ; make install ;
  125. dep_from_svn = \
  126. D=/tmp/$(1)-$$RANDOM ; svn checkout $(2) $$D ; cd $$D ; make install ;
  127. # }}}
  128. # }}}
  129. # ======= DEFAULT CONFIG ======= {{{
  130. # Default plugin name
  131. NAME=`basename \`pwd\``
  132. VERSION=0.1
  133. # Files to add to tarball:
  134. DIRS=`ls -1F | grep / | sed -e 's/\///'`
  135. # Runtime path to install:
  136. VIMRUNTIME=~/.vim
  137. # Other Files to be added:
  138. FILES=`ls -1 | grep '.vim$$'`
  139. MKFILES=Makefile `ls -1 | grep '.mk$$'`
  140. # ======== USER CONFIG ======= {{{
  141. # please write config in config.mk
  142. # this will override default config
  143. #
  144. # Custom Name:
  145. #
  146. # NAME=[plugin name]
  147. #
  148. # Custom dir list:
  149. #
  150. # DIRS=autoload after doc syntax plugin
  151. #
  152. # Files to add to tarball:
  153. #
  154. # FILES=
  155. #
  156. # Bundle dependent scripts:
  157. #
  158. # bundle-deps:
  159. # $(call fetch_github,[account id],[project],[branch],[source path],[target path])
  160. # $(call fetch_url,[file url],[target path])
  161. # $(call fetch_local,[from],[to])
  162. SHELL=bash
  163. CONFIG_FILE=config.mk
  164. -include ~/.vimauthor.mk
  165. -include $(CONFIG_FILE)
  166. # }}}
  167. # }}}
  168. # ======= SECTIONS ======= {{{
  169. -include ext.mk
  170. all: install-deps install
  171. install-deps:
  172. # check required binaries
  173. [[ -n $$(which git) ]]
  174. [[ -n $$(which bash) ]]
  175. [[ -n $$(which vim) ]]
  176. [[ -n $$(which wget) || -n $$(which curl) ]]
  177. $(call install_git_sources)
  178. check-require:
  179. @if [[ -n `which wget` || -n `which curl` || -n `which fetch` ]]; then echo "wget|curl|fetch: OK" ; else echo "wget|curl|fetch: NOT OK" ; fi
  180. @if [[ -n `which vim` ]] ; then echo "vim: OK" ; else echo "vim: NOT OK" ; fi
  181. config:
  182. @rm -f $(CONFIG_FILE)
  183. @echo "NAME=" >> $(CONFIG_FILE)
  184. @echo "VERSION=" >> $(CONFIG_FILE)
  185. @echo "#DIRS="
  186. @echo "#FILES="
  187. @echo "" >> $(CONFIG_FILE)
  188. @echo "bundle-deps:" >> $(CONFIG_FILE)
  189. @echo "\t\t\$$(call fetch_github,ID,REPOSITORY,BRANCH,PATH,TARGET_PATH)" >> $(CONFIG_FILE)
  190. @echo "\t\t\$$(call fetch_url,FILE_URL,TARGET_PATH)" >> $(CONFIG_FILE)
  191. init-author:
  192. @echo "AUTHOR=" > ~/.vimauthor.mk
  193. bundle-deps:
  194. bundle: bundle-deps
  195. dist: bundle mkfilelist
  196. @$(TAR) $(NAME)-$(VERSION).tar.gz --exclude '*.svn' --exclude '.git' $(DIRS) $(README_FILES) $(FILES) $(MKFILES)
  197. @echo "$(NAME)-$(VERSION).tar.gz is ready."
  198. init-runtime:
  199. @mkdir -vp $(VIMRUNTIME)
  200. @mkdir -vp $(VIMRUNTIME)/record
  201. @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type d | while read dir ; do \
  202. mkdir -vp $(VIMRUNTIME)/$$dir ; done ; fi
  203. release:
  204. if [[ -n `which vimup` ]] ; then \
  205. fi
  206. pure-install:
  207. @echo "Using Shell:" $(SHELL)
  208. @echo "Installing"
  209. @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type f | while read file ; do \
  210. cp -v $$file $(VIMRUNTIME)/$$file ; done ; fi
  211. @echo "$(FILES)" | while read vimfile ; do \
  212. if [[ -n $$vimfile ]] ; then \
  213. $(call install_file,$$vimfile) ; fi ; done
  214. install: init-runtime bundle pure-install record
  215. uninstall-files:
  216. @echo "Uninstalling"
  217. @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type f | while read file ; do \
  218. rm -fv $(VIMRUNTIME)/$$file ; done ; fi
  219. @echo "$(FILES)" | while read vimfile ; do \
  220. if [[ -n $$vimfile ]] ; then \
  221. $(call unlink_file,$$vimfile) ; fi ; done
  222. uninstall: uninstall-files rmrecord
  223. link: init-runtime
  224. @echo "Linking"
  225. @if [[ -n "$(DIRS)" ]]; then find $(DIRS) -type f | while read file ; do \
  226. ln -sfv $(PWD)/$$file $(VIMRUNTIME)/$$file ; done ; fi
  227. @echo "$(FILES)" | while read vimfile ; do \
  228. if [[ -n $$vimfile ]] ; then \
  229. $(call link_file,$$vimfile) ; fi ; done
  230. mkfilelist:
  231. @echo $(NAME) > $(RECORD_FILE)
  232. @echo $(VERSION) >> $(RECORD_FILE)
  233. @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type f | while read file ; do \
  234. echo $(VIMRUNTIME)/$$file >> $(RECORD_FILE) ; done ; fi
  235. @echo "$(FILES)" | while read vimfile ; do \
  236. if [[ -n $$vimfile ]] ; then \
  237. $(call record_file,$$vimfile,$(RECORD_FILE)) ; fi ; done
  238. vimball-edit:
  239. find $(DIRS) -type f > .tmp_list
  240. vim .tmp_list
  241. vim .tmp_list -c ":%MkVimball $(NAME)-$(VERSION) ." -c "q"
  242. @rm -vf .tmp_list
  243. @echo "$(NAME)-$(VERSION).vba is ready."
  244. vimball:
  245. find $(DIRS) -type f > .tmp_list
  246. vim .tmp_list -c ":%MkVimball $(NAME)-$(VERSION) ." -c "q"
  247. @rm -vf .tmp_list
  248. @echo "$(NAME)-$(VERSION).vba is ready."
  249. mkrecordscript:
  250. @echo "" > $(RECORD_SCRIPT)
  251. @echo "fun! s:mkmd5(file)" >> $(RECORD_SCRIPT)
  252. @echo " if executable('md5')" >> $(RECORD_SCRIPT)
  253. @echo " return system('cat ' . a:file . ' | md5')" >> $(RECORD_SCRIPT)
  254. @echo " else" >> $(RECORD_SCRIPT)
  255. @echo " return \"\"" >> $(RECORD_SCRIPT)
  256. @echo " endif" >> $(RECORD_SCRIPT)
  257. @echo "endf" >> $(RECORD_SCRIPT)
  258. @echo "let files = readfile('.record')" >> $(RECORD_SCRIPT)
  259. @echo "let package_name = remove(files,0)" >> $(RECORD_SCRIPT)
  260. @echo "let script_version = remove(files,0)" >> $(RECORD_SCRIPT)
  261. @echo "let record = { 'version' : 0.3 , 'generated_by': 'Vim-Makefile' , 'script_version': script_version , 'install_type' : 'makefile' , 'package' : package_name , 'files': [ ] }" >> $(RECORD_SCRIPT)
  262. @echo "for file in files " >> $(RECORD_SCRIPT)
  263. @echo " let md5 = s:mkmd5(file)" >> $(RECORD_SCRIPT)
  264. @echo " cal add( record.files , { 'checksum': md5 , 'file': file } )" >> $(RECORD_SCRIPT)
  265. @echo "endfor" >> $(RECORD_SCRIPT)
  266. @echo "redir => output" >> $(RECORD_SCRIPT)
  267. @echo "silent echon record" >> $(RECORD_SCRIPT)
  268. @echo "redir END" >> $(RECORD_SCRIPT)
  269. @echo "let content = join(split(output,\"\\\\n\"),'')" >> $(RECORD_SCRIPT)
  270. @echo "let record_file = expand('~/.vim/record/' . package_name )" >> $(RECORD_SCRIPT)
  271. @echo "cal writefile( [content] , record_file )" >> $(RECORD_SCRIPT)
  272. @echo "cal delete('.record')" >> $(RECORD_SCRIPT)
  273. @echo "echo \"Done\"" >> $(RECORD_SCRIPT)
  274. record: mkfilelist mkrecordscript
  275. vim --noplugin -V10install.log -c "so $(RECORD_SCRIPT)" -c "q"
  276. @echo "Vim script record making log: install.log"
  277. # @rm -vf $(RECORD_FILE)
  278. rmrecord:
  279. @echo "Removing Record"
  280. @rm -vf $(VIMRUNTIME)/record/$(NAME)
  281. clean: clean-bundle-deps
  282. @rm -vf $(RECORD_FILE)
  283. @rm -vf $(RECORD_SCRIPT)
  284. @rm -vf install.log
  285. @rm -vf *.tar.gz
  286. clean-bundle-deps:
  287. @echo "Removing Bundled scripts..."
  288. @if [[ -e .bundlefiles ]] ; then \
  289. rm -fv `echo \`cat .bundlefiles\``; \
  290. fi
  291. @rm -fv .bundlefiles
  292. update:
  293. @echo "Updating Makefile..."
  294. @URL=http://github.com/c9s/vim-makefile/raw/master/Makefile ; \
  295. if [[ -n `which curl` ]]; then \
  296. curl $$URL -o Makefile ; \
  297. if [[ -n `which wget` ]]; then \
  298. wget -c $$URL ; \
  299. elif [[ -n `which fetch` ]]; then \
  300. fetch $$URL ; \
  301. fi
  302. version:
  303. @echo version - $(MAKEFILE_VERSION)
  304. # }}}