Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add Makefile

  • Loading branch information...
commit f50a6a327ecbb57ded2a7b67c3de356e8707aad9 1 parent 747cd10
othree authored February 24, 2011

Showing 1 changed file with 376 additions and 0 deletions. Show diff stats Hide diff stats

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

0 notes on commit f50a6a3

Please sign in to comment.
Something went wrong with that request. Please try again.