Skip to content
Newer
Older
100644 331 lines (272 sloc) 9.04 KB
001759e @c9s use Makefile
authored
1 # vim:filetype=make:foldmethod=marker:fdl=0:
2372484 @c9s add version
authored
2 #
001759e @c9s use Makefile
authored
3 # Makefile: install/uninstall/link vim plugin files.
4 # Author: Cornelius <cornelius.howl@gmail.com>
5 # Date: 一 3/15 22:49:26 2010
2372484 @c9s add version
authored
6 # Version: 1.0
7 #
001759e @c9s use Makefile
authored
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`
833c64e @c9s Update Makefile
authored
47 README_FILES=`ls -1 | grep -i readme`
2372484 @c9s add version
authored
48 WGET_OPT=-c -nv
49 CURL_OPT=
50 RECORD_SCRIPT=.mkrecord
177e734 @c9s update makefile
authored
51 TAR=tar czvf
52
53 GIT_SOURCES=
001759e @c9s use Makefile
authored
54
2372484 @c9s add version
authored
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
177e734 @c9s update makefile
authored
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
2372484 @c9s add version
authored
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)
001759e @c9s use Makefile
authored
105
106 # fetch script from an url
2372484 @c9s add version
authored
107 fetch_url = \
001759e @c9s use Makefile
authored
108 @if [[ -e $(2) ]] ; then \
109 exit \
110 ; fi \
111 ; echo " => $(2)" \
2372484 @c9s add version
authored
112 ; if [[ ! -z `which curl` ]] ; then \
113 curl $(CURL_OPT) $(1) -o $(2) ; \
114 ; elif [[ ! -z `which wget` ]] ; then \
001759e @c9s use Makefile
authored
115 wget $(WGET_OPT) $(1) -O $(2) \
116 ; fi \
117 ; echo $(2) >> .bundlefiles
118
177e734 @c9s update makefile
authored
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
001759e @c9s use Makefile
authored
126 # fetch script from github
127 fetch_github = \
128 @if [[ -e $(5) ]] ; then \
129 exit \
130 ; fi \
131 ; echo " => $(5)" \
2372484 @c9s add version
authored
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 \
001759e @c9s use Makefile
authored
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
177e734 @c9s update makefile
authored
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
001759e @c9s use Makefile
authored
150 # }}}
151 # }}}
152 # ======= DEFAULT CONFIG ======= {{{
153
154 # Default plugin name
155 NAME=`basename \`pwd\``
2372484 @c9s add version
authored
156 VERSION=0.1
001759e @c9s use Makefile
authored
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:
98ab8de @c9s Fix makefile
authored
165 FILES=`ls -1 | grep '.vim$$'`
166 MKFILES=Makefile `ls -1 | grep '.mk$$'`
001759e @c9s use Makefile
authored
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 #
2372484 @c9s add version
authored
182 # FILES=
001759e @c9s use Makefile
authored
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
177e734 @c9s update makefile
authored
191 SHELL=bash
001759e @c9s use Makefile
authored
192
2372484 @c9s add version
authored
193 CONFIG_FILE=config.mk
194 -include ~/.vimauthor.mk
195 -include $(CONFIG_FILE)
196
197 # }}}
001759e @c9s use Makefile
authored
198 # }}}
199 # ======= SECTIONS ======= {{{
2372484 @c9s add version
authored
200 -include ext.mk
201
177e734 @c9s update makefile
authored
202 all: install-deps install
001759e @c9s use Makefile
authored
203
177e734 @c9s update makefile
authored
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)
001759e @c9s use Makefile
authored
211
2372484 @c9s add version
authored
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
001759e @c9s use Makefile
authored
234
235 dist: bundle mkfilelist
98ab8de @c9s Fix makefile
authored
236 @$(TAR) $(NAME)-$(VERSION).tar.gz --exclude '*.svn' --exclude '.git' $(DIRS) $(README_FILES) $(FILES) $(MKFILES)
3ebbe4e @c9s Update Makefile
authored
237 @echo "$(NAME)-$(VERSION).tar.gz is ready."
001759e @c9s use Makefile
authored
238
239 init-runtime:
2372484 @c9s add version
authored
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
001759e @c9s use Makefile
authored
244
245 release:
246 if [[ -n `which vimup` ]] ; then \
247 fi
248
249 pure-install:
177e734 @c9s update makefile
authored
250 @echo "Using Shell:" $(SHELL)
001759e @c9s use Makefile
authored
251 @echo "Installing"
2372484 @c9s add version
authored
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
001759e @c9s use Makefile
authored
257
25d28ba @c9s Remove record part from Makefile.
authored
258 install: init-runtime bundle pure-install
001759e @c9s use Makefile
authored
259
2372484 @c9s add version
authored
260
261 uninstall-files:
001759e @c9s use Makefile
authored
262 @echo "Uninstalling"
2372484 @c9s add version
authored
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
25d28ba @c9s Remove record part from Makefile.
authored
269 uninstall: uninstall-files
001759e @c9s use Makefile
authored
270
271 link: init-runtime
272 @echo "Linking"
2372484 @c9s add version
authored
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
001759e @c9s use Makefile
authored
278
279 mkfilelist:
280 @echo $(NAME) > $(RECORD_FILE)
2372484 @c9s add version
authored
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
177e734 @c9s update makefile
authored
291 vim .tmp_list -c ":%MkVimball $(NAME)-$(VERSION) ." -c "q"
2372484 @c9s add version
authored
292 @rm -vf .tmp_list
293 @echo "$(NAME)-$(VERSION).vba is ready."
294
295 vimball:
296 find $(DIRS) -type f > .tmp_list
177e734 @c9s update makefile
authored
297 vim .tmp_list -c ":%MkVimball $(NAME)-$(VERSION) ." -c "q"
2372484 @c9s add version
authored
298 @rm -vf .tmp_list
299 @echo "$(NAME)-$(VERSION).vba is ready."
001759e @c9s use Makefile
authored
300
25d28ba @c9s Remove record part from Makefile.
authored
301
001759e @c9s use Makefile
authored
302
303 clean: clean-bundle-deps
2372484 @c9s add version
authored
304 @rm -vf $(RECORD_FILE)
305 @rm -vf $(RECORD_SCRIPT)
306 @rm -vf install.log
307 @rm -vf *.tar.gz
001759e @c9s use Makefile
authored
308
309 clean-bundle-deps:
2372484 @c9s add version
authored
310 @echo "Removing Bundled scripts..."
001759e @c9s use Makefile
authored
311 @if [[ -e .bundlefiles ]] ; then \
312 rm -fv `echo \`cat .bundlefiles\``; \
313 fi
314 @rm -fv .bundlefiles
315
2372484 @c9s add version
authored
316 update:
317 @echo "Updating Makefile..."
318 @URL=http://github.com/c9s/vim-makefile/raw/master/Makefile ; \
319 if [[ -n `which curl` ]]; then \
320 curl $$URL -o Makefile ; \
321 if [[ -n `which wget` ]]; then \
322 wget -c $$URL ; \
323 elif [[ -n `which fetch` ]]; then \
324 fetch $$URL ; \
325 fi
326
001759e @c9s use Makefile
authored
327 version:
328 @echo version - $(MAKEFILE_VERSION)
329
330 # }}}
Something went wrong with that request. Please try again.