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 78308cf9a752f1b5ff602c6f648271719bbd7341 1 parent 484337b
othree authored

Showing 2 changed files with 370 additions and 0 deletions. Show diff stats Hide diff stats

  1. +364 0 Makefile
  2. +6 0 config.mk
364 Makefile
... ... @@ -0,0 +1,364 @@
  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 +
  43 +# INTERNAL VARIABLES {{{
  44 +
  45 +RECORD_FILE=.record
  46 +PWD=`pwd`
  47 +README_FILES=`ls -1 | grep -i readme`
  48 +WGET_OPT=-c -nv
  49 +CURL_OPT=
  50 +RECORD_SCRIPT=.mkrecord
  51 +TAR=tar czvf
  52 +
  53 +GIT_SOURCES=
  54 +
  55 +# INTERNAL FUNCTIONS {{{
  56 +record_file = \
  57 + PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  58 + echo $(VIMRUNTIME)/$$PTYPE/$(1) >> $(2)
  59 +
  60 +# }}}
  61 +
  62 +# PUBLIC FUNCTIONS {{{
  63 +
  64 +GIT_SOURCES=
  65 +DEPEND_DIR=/tmp/vim-deps
  66 +
  67 +# Usage:
  68 +#
  69 +# $(call install_git_sources)
  70 +#
  71 +
  72 +install_git_source = \
  73 + PWD=$(PWD) ; \
  74 + mkdir -p $(DEPEND_DIR) ; \
  75 + cd $(DEPEND_DIR) ; \
  76 + for git_uri in $(GIT_SOURCES) ; do \
  77 + OUTDIR=$$(echo $$git_uri | perl -pe 's{^.*/}{}') ;\
  78 + echo $$OUTDIR ; \
  79 + if [[ -e $$OUTDIR ]] ; then \
  80 + cd $$OUTDIR ; \
  81 + git pull origin master && \
  82 + make install && cd .. ; \
  83 + else \
  84 + git clone $$git_uri $$OUTDIR && \
  85 + cd $$OUTDIR && \
  86 + make install && cd .. ; \
  87 + fi; \
  88 + done ;
  89 +
  90 +
  91 +
  92 +
  93 +# install file by inspecting content
  94 +install_file = \
  95 + PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  96 + cp -v $(1) $(VIMRUNTIME)/$$PTYPE/$(1)
  97 +
  98 +link_file = \
  99 + PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  100 + cp -v $(1) $(VIMRUNTIME)/$$PTYPE/$(1)
  101 +
  102 +unlink_file = \
  103 + PTYPE=`cat $(1) | perl -nle 'print $$1 if /^"\s*script\s*type:\s*(\S*)$$/i'` ;\
  104 + rm -fv $(VIMRUNTIME)/$$PTYPE/$(1)
  105 +
  106 +# fetch script from an url
  107 +fetch_url = \
  108 + @if [[ -e $(2) ]] ; then \
  109 + exit \
  110 + ; fi \
  111 + ; echo " => $(2)" \
  112 + ; if [[ ! -z `which curl` ]] ; then \
  113 + curl $(CURL_OPT) $(1) -o $(2) ; \
  114 + ; elif [[ ! -z `which wget` ]] ; then \
  115 + wget $(WGET_OPT) $(1) -O $(2) \
  116 + ; fi \
  117 + ; echo $(2) >> .bundlefiles
  118 +
  119 +
  120 +install_source = \
  121 + for git_uri in $(GIT_SOURCES) ; do \
  122 + OUTDIR=$$(echo $$git_uri | perl -pe 's{^.*/}{}') ;\
  123 + echo $$OUTDIR ; \
  124 + done
  125 +
  126 +# fetch script from github
  127 +fetch_github = \
  128 + @if [[ -e $(5) ]] ; then \
  129 + exit \
  130 + ; fi \
  131 + ; echo " => $(5)" \
  132 + ; if [[ ! -z `which curl` ]] ; then \
  133 + curl $(CURL_OPT) http://github.com/$(1)/$(2)/raw/$(3)/$(4) -o $(5) \
  134 + ; elif [[ ! -z `which wget` ]] ; then \
  135 + wget $(WGET_OPT) http://github.com/$(1)/$(2)/raw/$(3)/$(4) -O $(5) \
  136 + ; fi \
  137 + ; echo $(5) >> .bundlefiles
  138 +
  139 +# fetch script from local file
  140 +fetch_local = @cp -v $(1) $(2) \
  141 + ; @echo $(2) >> .bundlefiles
  142 +
  143 +# 1: NAME , 2: URI
  144 +dep_from_git = \
  145 + D=/tmp/$(1)-$$RANDOM ; git clone $(2) $$D ; cd $$D ; make install ;
  146 +
  147 +dep_from_svn = \
  148 + D=/tmp/$(1)-$$RANDOM ; svn checkout $(2) $$D ; cd $$D ; make install ;
  149 +
  150 +# }}}
  151 +# }}}
  152 +# ======= DEFAULT CONFIG ======= {{{
  153 +
  154 +# Default plugin name
  155 +NAME=`basename \`pwd\``
  156 +VERSION=0.1
  157 +
  158 +# Files to add to tarball:
  159 +DIRS=`ls -1F | grep / | sed -e 's/\///'`
  160 +
  161 +# Runtime path to install:
  162 +VIMRUNTIME=~/.vim
  163 +
  164 +# Other Files to be added:
  165 +FILES=`ls -1 | grep '.vim$$'`
  166 +MKFILES=Makefile `ls -1 | grep '.mk$$'`
  167 +
  168 +# ======== USER CONFIG ======= {{{
  169 +# please write config in config.mk
  170 +# this will override default config
  171 +#
  172 +# Custom Name:
  173 +#
  174 +# NAME=[plugin name]
  175 +#
  176 +# Custom dir list:
  177 +#
  178 +# DIRS=autoload after doc syntax plugin
  179 +#
  180 +# Files to add to tarball:
  181 +#
  182 +# FILES=
  183 +#
  184 +# Bundle dependent scripts:
  185 +#
  186 +# bundle-deps:
  187 +# $(call fetch_github,[account id],[project],[branch],[source path],[target path])
  188 +# $(call fetch_url,[file url],[target path])
  189 +# $(call fetch_local,[from],[to])
  190 +
  191 +SHELL=bash
  192 +
  193 +CONFIG_FILE=config.mk
  194 +-include ~/.vimauthor.mk
  195 +-include $(CONFIG_FILE)
  196 +
  197 +# }}}
  198 +# }}}
  199 +# ======= SECTIONS ======= {{{
  200 +-include ext.mk
  201 +
  202 +all: install-deps install
  203 +
  204 +install-deps:
  205 + # check required binaries
  206 + [[ -n $$(which git) ]]
  207 + [[ -n $$(which bash) ]]
  208 + [[ -n $$(which vim) ]]
  209 + [[ -n $$(which wget) || -n $$(which curl) ]]
  210 + $(call install_git_sources)
  211 +
  212 +check-require:
  213 + @if [[ -n `which wget` || -n `which curl` || -n `which fetch` ]]; then echo "wget|curl|fetch: OK" ; else echo "wget|curl|fetch: NOT OK" ; fi
  214 + @if [[ -n `which vim` ]] ; then echo "vim: OK" ; else echo "vim: NOT OK" ; fi
  215 +
  216 +config:
  217 + @rm -f $(CONFIG_FILE)
  218 + @echo "NAME=" >> $(CONFIG_FILE)
  219 + @echo "VERSION=" >> $(CONFIG_FILE)
  220 + @echo "#DIRS="
  221 + @echo "#FILES="
  222 + @echo "" >> $(CONFIG_FILE)
  223 + @echo "bundle-deps:" >> $(CONFIG_FILE)
  224 + @echo "\t\t\$$(call fetch_github,ID,REPOSITORY,BRANCH,PATH,TARGET_PATH)" >> $(CONFIG_FILE)
  225 + @echo "\t\t\$$(call fetch_url,FILE_URL,TARGET_PATH)" >> $(CONFIG_FILE)
  226 +
  227 +
  228 +init-author:
  229 + @echo "AUTHOR=" > ~/.vimauthor.mk
  230 +
  231 +bundle-deps:
  232 +
  233 +bundle: bundle-deps
  234 +
  235 +dist: bundle mkfilelist
  236 + @$(TAR) $(NAME)-$(VERSION).tar.gz --exclude '*.svn' --exclude '.git' $(DIRS) $(README_FILES) $(FILES) $(MKFILES)
  237 + @echo "$(NAME)-$(VERSION).tar.gz is ready."
  238 +
  239 +init-runtime:
  240 + @mkdir -vp $(VIMRUNTIME)
  241 + @mkdir -vp $(VIMRUNTIME)/record
  242 + @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type d | while read dir ; do \
  243 + mkdir -vp $(VIMRUNTIME)/$$dir ; done ; fi
  244 +
  245 +release:
  246 + if [[ -n `which vimup` ]] ; then \
  247 + fi
  248 +
  249 +pure-install:
  250 + @echo "Using Shell:" $(SHELL)
  251 + @echo "Installing"
  252 + @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type f | while read file ; do \
  253 + cp -v $$file $(VIMRUNTIME)/$$file ; done ; fi
  254 + @echo "$(FILES)" | while read vimfile ; do \
  255 + if [[ -n $$vimfile ]] ; then \
  256 + $(call install_file,$$vimfile) ; fi ; done
  257 +
  258 +install: init-runtime bundle pure-install record
  259 +
  260 +
  261 +uninstall-files:
  262 + @echo "Uninstalling"
  263 + @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type f | while read file ; do \
  264 + rm -fv $(VIMRUNTIME)/$$file ; done ; fi
  265 + @echo "$(FILES)" | while read vimfile ; do \
  266 + if [[ -n $$vimfile ]] ; then \
  267 + $(call unlink_file,$$vimfile) ; fi ; done
  268 +
  269 +uninstall: uninstall-files rmrecord
  270 +
  271 +link: init-runtime
  272 + @echo "Linking"
  273 + @if [[ -n "$(DIRS)" ]]; then find $(DIRS) -type f | while read file ; do \
  274 + ln -sfv $(PWD)/$$file $(VIMRUNTIME)/$$file ; done ; fi
  275 + @echo "$(FILES)" | while read vimfile ; do \
  276 + if [[ -n $$vimfile ]] ; then \
  277 + $(call link_file,$$vimfile) ; fi ; done
  278 +
  279 +mkfilelist:
  280 + @echo $(NAME) > $(RECORD_FILE)
  281 + @echo $(VERSION) >> $(RECORD_FILE)
  282 + @if [[ -n "$(DIRS)" ]] ; then find $(DIRS) -type f | while read file ; do \
  283 + echo $(VIMRUNTIME)/$$file >> $(RECORD_FILE) ; done ; fi
  284 + @echo "$(FILES)" | while read vimfile ; do \
  285 + if [[ -n $$vimfile ]] ; then \
  286 + $(call record_file,$$vimfile,$(RECORD_FILE)) ; fi ; done
  287 +
  288 +vimball-edit:
  289 + find $(DIRS) -type f > .tmp_list
  290 + vim .tmp_list
  291 + vim .tmp_list -c ":%MkVimball $(NAME)-$(VERSION) ." -c "q"
  292 + @rm -vf .tmp_list
  293 + @echo "$(NAME)-$(VERSION).vba is ready."
  294 +
  295 +vimball:
  296 + find $(DIRS) -type f > .tmp_list
  297 + vim .tmp_list -c ":%MkVimball $(NAME)-$(VERSION) ." -c "q"
  298 + @rm -vf .tmp_list
  299 + @echo "$(NAME)-$(VERSION).vba is ready."
  300 +
  301 +mkrecordscript:
  302 + @echo "" > $(RECORD_SCRIPT)
  303 + @echo "fun! s:mkmd5(file)" >> $(RECORD_SCRIPT)
  304 + @echo " if executable('md5')" >> $(RECORD_SCRIPT)
  305 + @echo " return system('cat ' . a:file . ' | md5')" >> $(RECORD_SCRIPT)
  306 + @echo " else" >> $(RECORD_SCRIPT)
  307 + @echo " return \"\"" >> $(RECORD_SCRIPT)
  308 + @echo " endif" >> $(RECORD_SCRIPT)
  309 + @echo "endf" >> $(RECORD_SCRIPT)
  310 + @echo "let files = readfile('.record')" >> $(RECORD_SCRIPT)
  311 + @echo "let package_name = remove(files,0)" >> $(RECORD_SCRIPT)
  312 + @echo "let script_version = remove(files,0)" >> $(RECORD_SCRIPT)
  313 + @echo "let record = { 'version' : 0.3 , 'generated_by': 'Vim-Makefile' , 'script_version': script_version , 'install_type' : 'makefile' , 'package' : package_name , 'files': [ ] }" >> $(RECORD_SCRIPT)
  314 + @echo "for file in files " >> $(RECORD_SCRIPT)
  315 + @echo " let md5 = s:mkmd5(file)" >> $(RECORD_SCRIPT)
  316 + @echo " cal add( record.files , { 'checksum': md5 , 'file': file } )" >> $(RECORD_SCRIPT)
  317 + @echo "endfor" >> $(RECORD_SCRIPT)
  318 + @echo "redir => output" >> $(RECORD_SCRIPT)
  319 + @echo "silent echon record" >> $(RECORD_SCRIPT)
  320 + @echo "redir END" >> $(RECORD_SCRIPT)
  321 + @echo "let content = join(split(output,\"\\\\n\"),'')" >> $(RECORD_SCRIPT)
  322 + @echo "let record_file = expand('~/.vim/record/' . package_name )" >> $(RECORD_SCRIPT)
  323 + @echo "cal writefile( [content] , record_file )" >> $(RECORD_SCRIPT)
  324 + @echo "cal delete('.record')" >> $(RECORD_SCRIPT)
  325 + @echo "echo \"Done\"" >> $(RECORD_SCRIPT)
  326 +
  327 +
  328 +record: mkfilelist mkrecordscript
  329 + vim --noplugin -V10install.log -c "so $(RECORD_SCRIPT)" -c "q"
  330 + @echo "Vim script record making log: install.log"
  331 +# @rm -vf $(RECORD_FILE)
  332 +
  333 +rmrecord:
  334 + @echo "Removing Record"
  335 + @rm -vf $(VIMRUNTIME)/record/$(NAME)
  336 +
  337 +clean: clean-bundle-deps
  338 + @rm -vf $(RECORD_FILE)
  339 + @rm -vf $(RECORD_SCRIPT)
  340 + @rm -vf install.log
  341 + @rm -vf *.tar.gz
  342 +
  343 +clean-bundle-deps:
  344 + @echo "Removing Bundled scripts..."
  345 + @if [[ -e .bundlefiles ]] ; then \
  346 + rm -fv `echo \`cat .bundlefiles\``; \
  347 + fi
  348 + @rm -fv .bundlefiles
  349 +
  350 +update:
  351 + @echo "Updating Makefile..."
  352 + @URL=http://github.com/c9s/vim-makefile/raw/master/Makefile ; \
  353 + if [[ -n `which curl` ]]; then \
  354 + curl $$URL -o Makefile ; \
  355 + if [[ -n `which wget` ]]; then \
  356 + wget -c $$URL ; \
  357 + elif [[ -n `which fetch` ]]; then \
  358 + fetch $$URL ; \
  359 + fi
  360 +
  361 +version:
  362 + @echo version - $(MAKEFILE_VERSION)
  363 +
  364 +# }}}
6 config.mk
... ... @@ -0,0 +1,6 @@
  1 +NAME=javascript-libries-syntax.vim
  2 +VERSION=0.1
  3 +
  4 +bundle-deps:
  5 + $(call fetch_github,ID,REPOSITORY,BRANCH,PATH,TARGET_PATH)
  6 + $(call fetch_url,FILE_URL,TARGET_PATH)

0 comments on commit 78308cf

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