File: rules

package info (click to toggle)
vim 1%3A7.0-122%2B1etch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 9,992 kB
  • ctags: 55
  • sloc: makefile: 444; sh: 224; perl: 97; python: 25
file content (563 lines) | stat: -rwxr-xr-x 17,207 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
#!/usr/bin/make -f

export SHELL=/bin/bash
export DH_OPTIONS

DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)

BUILDER := $(shell echo $${DEBEMAIL:-$${EMAIL:-$$(echo $$LOGNAME@$$(cat /etc/mailname 2> /dev/null))}})

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS+=-O0
else
  CFLAGS+=-O2
endif

ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
  MAKETEST = yes
else
  MAKETEST = no
endif

INSTALL+=install
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
  INSTALL+=-s
endif

CFLAGS+=$(if $(findstring nodebug,$(DEB_BUILD_OPTIONS)),,-g -Wall)
CFGFLAGS+=--prefix=/usr
CFGFLAGS+=--mandir='$${prefix}'/share/man
CFGFLAGS+=--with-compiledby="$(BUILDER)"

# "vim-tiny" features: in addition to those coming from the --with-features=xxx,
# "vim-tiny" is built with those listed in debian/tiny/features.txt
TINYFLAGS+=--with-features=small
TINYFLAGS+=--disable-syntax
TINYFLAGS+=--disable-gui
TINYFLAGS+=--disable-xsmp
TINYFLAGS+=--disable-xsmp-interact
TINYFLAGS+=--disable-netbeans
TINYFLAGS+=--disable-acl
TINYFLAGS+=--disable-gpm
TINYFLAGS+=--enable-nls
TINYFLAGS+=--enable-multibyte
TINYFLAGS+=--enable-multilang

# add -DFEAT_* from debian/tiny/features.txt
TINYCFLAGS:=$(patsubst %,-D%,$(shell grep ^FEAT_ debian/tiny/features.txt | cut -f 1))

OPTFLAGS+=--enable-gpm
OPTFLAGS+=--enable-cscope
OPTFLAGS+=--with-features=big
OPTFLAGS+=--enable-multibyte

GUIFLAGS+=--with-x
GUIFLAGS+=--enable-xim
GUIFLAGS+=--enable-fontset
GTK2FLAGS+=--enable-gui=gtk2
GTK2FLAGS+=--with-features=big

GNOMEFLAGS+=--enable-gui=gnome2

LESSTIFFLAGS+=--enable-gui=motif

PERLFLAGS+=--enable-perlinterp
PERLFLAGS+=--disable-mzschemeinterp
PERLFLAGS+=--disable-pythoninterp
PERLFLAGS+=--disable-rubyinterp
PERLFLAGS+=--disable-tclinterp

PYTHONFLAGS+=--enable-pythoninterp
PYTHONFLAGS+=--disable-mzschemeinterp
PYTHONFLAGS+=--disable-perlinterp
PYTHONFLAGS+=--disable-rubyinterp
PYTHONFLAGS+=--disable-tclinterp

RUBYFLAGS+=--enable-rubyinterp
RUBYFLAGS+=--disable-mzschemeinterp
RUBYFLAGS+=--disable-perlinterp
RUBYFLAGS+=--disable-pythoninterp
RUBYFLAGS+=--disable-tclinterp

TCLFLAGS+=--enable-tclinterp
TCLFLAGS+=--disable-mzschemeinterp
TCLFLAGS+=--disable-perlinterp
TCLFLAGS+=--disable-pythoninterp
TCLFLAGS+=--disable-rubyinterp

BASICFLAGS+=--disable-mzschemeinterp
BASICFLAGS+=--disable-tclinterp
BASICFLAGS+=--disable-perlinterp
BASICFLAGS+=--disable-pythoninterp
BASICFLAGS+=--disable-rubyinterp

ALLINTERPFLAGS+=--disable-mzschemeinterp
ALLINTERPFLAGS+=--enable-perlinterp
ALLINTERPFLAGS+=--enable-pythoninterp
ALLINTERPFLAGS+=--enable-rubyinterp
ALLINTERPFLAGS+=--enable-tclinterp

# Each vim-xxx package is said to be a vim variant and contains only a vim
# binary built with some compile-time options. Makefile VARIANTS below are
# one-to-one with those packages with the exception of "vim-basic". In this
# Makefile vim-basic is used to built 4 packages: "vim", "vim-runtime",
# "vim-common", "vim-gui-common". "vim-tiny" is the only variant package not
# depending on vim-runtime.

# vim-basic must be the last one
ifneq ($(DEB_HOST_GNU_SYSTEM),gnu)
	VARIANTS+=vim-tiny
	VARIANTS+=vim-ruby
	VARIANTS+=vim-tcl
	VARIANTS+=vim-gtk
	VARIANTS+=vim-lesstif
	VARIANTS+=vim-perl
	VARIANTS+=vim-python
	VARIANTS+=vim-gnome
	VARIANTS+=vim-full
	VARIANTS+=vim-basic
else
	VARIANTS+=vim-tiny
	VARIANTS+=vim-ruby
	VARIANTS+=vim-gtk
	VARIANTS+=vim-python
	VARIANTS+=vim-lesstif
	VARIANTS_SKIP+=vim-perl
	VARIANTS_SKIP+=vim-gnome
	VARIANTS_SKIP+=vim-tcl
	VARIANTS_SKIP+=vim-full
	VARIANTS+=vim-basic
endif
ifeq ($(origin VARIANT), command line)
	VARIANTS = $(VARIANT) vim-basic
endif

CFLAGS_vim-basic=$(CFLAGS)
CFGFLAGS_vim-basic=$(CFGFLAGS) $(OPTFLAGS) --without-x --enable-gui=no

CFLAGS_vim-tiny=$(CFLAGS) $(TINYCFLAGS)
CFGFLAGS_vim-tiny=$(CFGFLAGS) $(TINYFLAGS)

CFLAGS_vim-perl=$(CFLAGS)
CFGFLAGS_vim-perl=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(PERLFLAGS) $(GTK2FLAGS)

CFLAGS_vim-python=$(CFLAGS)
CFGFLAGS_vim-python=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(PYTHONFLAGS) $(GTK2FLAGS)

CFLAGS_vim-ruby=$(CFLAGS)
CFGFLAGS_vim-ruby=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(RUBYFLAGS) $(GTK2FLAGS)

CFLAGS_vim-tcl=$(CFLAGS)
CFGFLAGS_vim-tcl=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(TCLFLAGS) $(GTK2FLAGS)

CFLAGS_vim-gtk=$(CFLAGS)
CFGFLAGS_vim-gtk=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(BASICFLAGS) $(GTK2FLAGS)

CFLAGS_vim-gnome=$(CFLAGS)
CFGFLAGS_vim-gnome=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(BASICFLAGS) $(GNOMEFLAGS)

CFLAGS_vim-lesstif=$(CFLAGS)
CFGFLAGS_vim-lesstif=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(BASICFLAGS) $(LESSTIFFLAGS)

CFLAGS_vim-full=$(CFLAGS)
CFGFLAGS_vim-full=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(GNOMEFLAGS) $(ALLINTERPFLAGS)

NAME=vim
VERSION=7.0
DEBVERSION=$(VERSION)
VIMCUR=$(NAME)$(subst .,,$(VERSION))
SRCDIR=$(VIMCUR)
CHANGELOG=$(SRCDIR)/runtime/doc/version7.txt # latest version upstream changelog
MAIN_TARBALL=$(NAME)-$(VERSION).tar.bz2
LANG_TARBALL=$(NAME)-$(VERSION)-lang.tar.gz
EXTRA_TARBALL=$(NAME)-$(VERSION)-extra.tar.gz
SOURCES = $(MAIN_TARBALL) $(LANG_TARBALL) $(EXTRA_TARBALL)
BASE_URL=ftp://ftp.vim.org/pub/vim
PER_VARIANT_FILES = install postinst prerm links preinst
LANGS += fr fr.ISO8859-1 fr.UTF-8
LANGS += it it.ISO8859-1 it.UTF-8
LANGS += pl pl.ISO8859-2 pl.UTF-8
LANGS += ru

DOT_IN_DEPS = debian/vim-runtime.install
DOT_IN_DEPS += debian/vim-runtime.install
DOT_IN_DEPS += debian/vim-common.install
DOT_IN_DEPS += debian/vim-gui-common.install
DOT_IN_DEPS += debian/vim-common.links
DOT_IN_DEPS += debian/vim-gui-common.links
DOT_IN_DEPS += debian/vim-runtime.links
DOT_IN_DEPS += debian/runtime/debian.vim

# nothing to do per default
all:

sources:
	cd upstream/tarballs	\
	&& rm -f $(MAIN_TARBALL) $(EXTRA_TARBALL) $(LANG_TARBALL)	\
	&& wget $(BASE_URL)/unix/$(MAIN_TARBALL)	\
	&& wget $(BASE_URL)/extra/$(EXTRA_TARBALL)	\
	&& wget $(BASE_URL)/extra/$(LANG_TARBALL)

export: clean
	test -d ../build-area # this dir is in the svn repo
	rm -rf ../build-area/vim-$(DEBVERSION)
	mkdir ../build-area/vim-$(DEBVERSION)
	svn export debian ../build-area/vim-$(DEBVERSION)/debian
	svn export patches ../build-area/vim-$(DEBVERSION)/patches
	svn export upstream ../build-area/vim-$(DEBVERSION)/upstream
	for tb in $(MAIN_TARBALL) $(LANG_TARBALL) $(EXTRA_TARBALL) ; do \
	   cp upstream/tarballs/$$tb \
	      ../build-area/vim-$(VERSION)/upstream/tarballs/ ; \
	done
	cd ../build-area && \
	  [ -f vim_$(DEBVERSION).orig.tar.gz ] || \
	  tar cvzf vim_$(DEBVERSION).orig.tar.gz \
	           vim-$(DEBVERSION)/upstream/tarballs/
	cd ../build-area && \
	  dpkg-source -b vim-$(DEBVERSION)

extract: extract-stamp
extract-stamp: $(foreach s,$(SOURCES),extract-stamp-$(s))
	if [ ! -L vim -o "`readlink vim`" != "$(VIMCUR)" ]; then \
	  ln -fs $(SRCDIR) vim; \
	fi
# Add 7.1/7.2[abc] patches for upstream's fix for CVE-2007-2953 & CVE-2008-2712
	@for f in $$(find upstream/patches -type f -name "7.[01]*" | sort -n) ; do\
	  echo "applying upstream patch: $$(basename $$f)" ;\
	  cat $$f | patch -s -d$(SRCDIR) -p0 ;\
	done
# Need separate loops to ensure 7.2[abc] get applied first
	@for f in $$(find upstream/patches -type f -name "7.2[abc]*" | sort -n) ; do\
	  echo "applying upstream patch: $$(basename $$f)" ;\
	  cat $$f | patch -s -d$(SRCDIR) -p0 ;\
	done
# Add 7.2 patches for upstream's fix for CVE-2008-4104
	@for f in $$(find upstream/patches -type f -name "7.2.*" | sort -n) ; do\
	  echo "applying upstream patch: $$(basename $$f)" ;\
	  cat $$f | patch -s -d$(SRCDIR) -p0 ;\
	done
	quilt push -a
	touch $@

# {{{1 hackish way of updating to latest unstable snapshot
updatesnapshot:
	zipurl=`uscan --report | tail -2 | head -1` \
	&& test ! -z "$$zipurl" \
	&& zipbasename=`basename $$zipurl` \
	&& wget -O upstream/tarballs/$$zipbasename $$zipurl \
	&& noext=`echo $$zipbasename | sed 's/.zip//'` \
	&& rulesversion=`echo $$noext | cut -c5-8` \
	&& rulessnapshot=`echo $$noext | cut -c9-10` \
	&& sedcmd="s/^VERSION=.*/VERSION=$$rulesversion/;s/^SNAPSHOT=.*/SNAPSHOT=$$rulessnapshot/" \
	&& sed -i.bak "$$sedcmd" debian/rules \
	&& sed -i.bak "1{s/+.*-/+$$rulesversion$$rulessnapshot-/};4{s/(......)/($$rulesversion$$rulessnapshot)/}" debian/changelog
# }}}

extract-stamp-%.bz2:
	bunzip2 -c upstream/tarballs/$(*).bz2 | tar -x
	touch $@

extract-stamp-%.gz:
	gunzip -c upstream/tarballs/$(*).gz | tar -x
	touch $@

extract-stamp-%.zip:
	unzip -d $(SRCDIR) upstream/tarballs/$(*).zip
	touch $@

clean: $(foreach v,$(VARIANTS),clean-$(v))
	dh_testdir
	dh_testroot
	rm -f extract-stamp* build-stamp* install-stamp*
	rm -f debian/helpztags.1
	- quilt pop -a
	rm -rf $(SRCDIR)
	rm -f vim
	dh_clean

clean-vim-basic:
	for x in $(PER_VARIANT_FILES) ; do \
	  rm -f debian/vim.$$x ; \
	done
	for x in vim-gui-common.{install,links} vim-common.{install,links} \
	         vim-runtime.install; do \
	  rm -f debian/$$x; \
	done
	rm -f $(DOT_IN_DEPS)

clean-%:
	for x in $(PER_VARIANT_FILES) ; do \
	  rm -f debian/$*.$$x ; \
	done
	rm -f debian/vim.links
	rm -f debian/lintian/$*

build: extract
build: build-stamp
build-stamp: $(foreach v,$(VARIANTS),build-stamp-$(v))
	$(MAKE) -C $(SRCDIR)/runtime/doc html # gen html docs (destroys tags)
# (re)generate the tags file
#	$(SRCDIR)/src/vim-common -u /dev/null \
#	  -c "helptags $(SRCDIR)/runtime/doc" -c quit
	touch $@

configure-stamp-%:
	dh_testdir
	@echo "*** DEBIAN *** CONFIGURING VARIANT $*"
	$(MAKE) -C $(SRCDIR) clean
	cd $(SRCDIR) \
	  && make distclean \
	  && CFLAGS="$(CFLAGS_$(*))" ./configure $(CFGFLAGS_$(*))
	touch $@

build-stamp-%: CURCFLAGS=$(CFLAGS_$*)
build-stamp-%: configure-stamp-%
	dh_testdir
	@echo "*** DEBIAN *** BUILDING VARIANT $*"
	if [ "$*" = "vim-tiny" ]; then \
	  patch -Np0 < debian/tiny/vimrc.tiny.diff; \
	fi
	$(MAKE) -C $(SRCDIR) CFLAGS="$(CURCFLAGS)"
	if [ "$*" = "vim-tiny" ]; then \
	  patch -Rp0 < debian/tiny/vimrc.tiny.diff; \
	fi
	mv $(SRCDIR)/src/vim $(SRCDIR)/src/$(subst -,.,$*)
	touch $@

install: build
install: install-stamp
install-stamp: $(foreach v,$(VARIANTS),install-stamp-$(v))
	dh_testdir
	dh_testroot
	touch $@

install-stamp-vim-basic: export DH_OPTIONS=-pvim-runtime -pvim-common -pvim-gui-common -pvim -pvim-doc
install-stamp-vim-basic: DESTDIR=$(CURDIR)/debian/tmp
install-stamp-vim-basic: build-stamp-vim-basic $(DOT_IN_DEPS)
	dh_testdir
	dh_testroot
	@echo "*** DEBIAN *** INSTALLING VARIANT vim-basic"
	dh_clean -k
	dh_installdirs
	
	# UPSTREAM INSTALLATION
	
	cp $(SRCDIR)/src/{vim.basic,vim}
	$(MAKE) -C $(SRCDIR)/src DESTDIR=$(DESTDIR) installvimbin \
	                                            installtutorbin \
	                                            installruntime \
	                                            installtools \
	                                            install-icons \
	                                            install-languages
	if [ $(MAKETEST) = "yes" ]; then \
	  $(MAKE) -C $(SRCDIR)/src DESTDIR=$(DESTDIR) test; \
	fi
	
	# DEBIAN INSTALLATION
	
	# According to #368754 and #323820, Russian manpages should be in
	# /usr/share/man/ru (KOI8-R encoded) and man will handle the
	# transcoding
	mv $(DESTDIR)/usr/share/man/ru{.KOI8-R,}
	# Remove this so the dh_install later doesn't fail
	rm -rf $(DESTDIR)/usr/share/man/ru.UTF-8
	
	 # disabled, waiting for an update
	 #cp debian/vim-install $(DESTDIR)/usr/bin
	mv $(DESTDIR)/usr/bin/{vim,vim.basic} # use variant name
	# rm stuff handled by alternatives
	rm -f $(DESTDIR)/usr/bin/{ex,view}
	@for f in `find $(DESTDIR)/usr/share/man -name view.1 -o -name ex.1`; do \
	  rm -f $$f; \
	done
	 # rm C part of maze (no longer working)
	rm -f $(DESTDIR)/usr/share/vim/$(VIMCUR)/macros/maze/{*.c,Makefile}
	 # fix for CAN-2005-0069
	rm -f $(DESTDIR)/usr/share/vim/$(VIMCUR)/tools/vimspell.*
	 # helpztags manpage
	pod2man -c "User Commands" -s 1 -q none -r "vim 7.0aa"	\
		-d "September 2003" debian/helpztags debian/helpztags.1
	
	 # variant-related installations for package "vim"
	 # to be kept in sync with those in "install-stamp-%" target
	for x in $(PER_VARIANT_FILES) ; do \
	  sed -e "s:@PKG@:vim:;s:@VARIANT@:basic:" \
	      -e "s:@DESTDIR@:debian/tmp/usr/bin:" \
	      -e "s:@COMMON@:vim-common:" \
	  	debian/vim-variant.$$x > debian/vim.$$x ;\
	done
	for L in $(LANGS); do \
	  sed -e "s:\(.*\)@LANG_ALTS@:\1--slave \$$mandir/$$L/man1/\$$i.1.gz \$$i.$$L.1.gz \$$mandir/$$L/man1/vim.1.gz \\\\\n&:" \
	      -i debian/vim.postinst; \
	done
	sed -i "/@LANG_ALTS@/d" debian/vim.postinst
	sed -e "s:@PKG@:vim:;s:@VARIANT@:basic:" \
		debian/lintian/vim-variant > debian/lintian/vim
	
	# Generate language-specific sections of
	# vim-{runtime,common,gui-common}.install files
	@for L in $(LANGS); do \
	  echo debian/tmp/usr/share/man/$$L/man1/vimtutor.1  \
	    usr/share/man/$$L/man1/ >>debian/vim-runtime.install; \
	done
	
	@for L in $(LANGS); do \
	  echo debian/tmp/usr/share/man/$$L/man1/\*  \
	    usr/share/man/$$L/man1/ >>debian/vim-common.install; \
	done
	
	@for L in $(LANGS); do \
	  echo debian/tmp/usr/share/man/$$L/man1/evim.1  \
	    usr/share/man/$$L/man1/ >>debian/vim-gui-common.install; \
	done
	
	dh_installman
	dh_install -X.svn --fail-missing
	# adjust things for vim-gui-common
	cp debian/vim-common/usr/share/man/man1/vim.1 \
	   debian/vim-gui-common/usr/share/man/man1/gvim.1
	cp debian/vim-common/usr/share/man/man1/vimdiff.1 \
	   debian/vim-gui-common/usr/share/man/man1/gvimdiff.1
	rm -f debian/vim-common/usr/share/man/man1/evim.1
	@for L in $(LANGS); do \
	  cp debian/vim-common/usr/share/man/$$L/man1/vim.1 \
	     debian/vim-gui-common/usr/share/man/$$L/man1/gvim.1; \
	  cp debian/vim-common/usr/share/man/$$L/man1/vimdiff.1 \
	     debian/vim-gui-common/usr/share/man/$$L/man1/gvimdiff.1; \
	  rm -f debian/vim-common/usr/share/man/$$L/man1/evim.1; \
	done
	# remove things that are in vim-runtime
	rm -f debian/vim-common/usr/share/man/man1/vimtutor.1
	@for L in $(LANGS); do \
	  rm -f debian/vim-common/usr/share/man/$$L/man1/vimtutor.1; \
	done
	rmdir debian/vim-gui-common/usr/bin
	# Generate language-specific sections of
	# vim-{common,gui-common}.links files
	@for L in $(LANGS); do \
	  for p in rvim rview; do \
	    echo usr/share/man/$$L/man1/vim.1  \
	      usr/share/man/$$L/man1/$$p.1 >>debian/vim-common.links; \
	  done; \
	done
	
	@for L in $(LANGS); do \
	  for p in gview rgvim rgview; do \
	    echo usr/share/man/$$L/man1/gvim.1  \
	      usr/share/man/$$L/man1/$$p.1 >>debian/vim-gui-common.links; \
	  done; \
	  echo usr/share/man/$$L/man1/evim.1 \
	    usr/share/man/$$L/man1/eview.1 >>debian/vim-gui-common.links; \
	done
	dh_link
	
	 # all excepts vim
	dh_installchangelogs -Nvim
	dh_installdocs
	dh_installmenu
	dh_installmime
	
	touch $@

# the other variants only include the binary
install-stamp-%: export DH_OPTIONS=-p$*
install-stamp-%: DESTDIR=$(CURDIR)/debian/$*
install-stamp-%: build-stamp-%
	dh_testdir
	dh_testroot
	@echo "*** DEBIAN *** INSTALLING VARIANT $*"
	dh_clean -k
	dh_installdirs
	
	 # variant-related installations
	 # to be kept in sync with those in "install-stamp-vim-basic" target
	for x in $(PER_VARIANT_FILES) ; do \
	  if [ "$*" = "vim-tiny" ]; then \
	    sed -e "s:@PKG@:$*:" -e "s:@VARIANT@:$(patsubst vim-%,%,$*):" \
	        -e "s:@DESTDIR@:$(SRCDIR)/src:" -e "s:@COMMON@:vim-common:" \
	        debian/vim-variant.$$x > debian/$*.$$x ;\
	  else \
	    sed -e "s:@PKG@:$*:" -e "s:@VARIANT@:$(patsubst vim-%,%,$*):" \
	        -e "s:@DESTDIR@:$(SRCDIR)/src:" -e "s:@COMMON@:vim-gui-common:" \
	        debian/vim-variant.$$x > debian/$*.$$x ;\
	  fi \
	done
	sed -e "s:@PKG@:$*:;s:@VARIANT@:$(patsubst vim-%,%,$*):" \
	    debian/lintian/vim-variant > debian/lintian/$*
	for L in $(LANGS); do \
	  sed -e "s:\(.*\)@LANG_ALTS@:\1--slave \$$mandir/$$L/man1/\$$i.1.gz \$$i.$$L.1.gz \$$mandir/$$L/man1/vim.1.gz \\\\\n&:" \
	      -i debian/$*.postinst; \
	done
	sed -i "/@LANG_ALTS@/d" debian/$*.postinst
	# fake help installation for vim-tiny
	if [ "$*" = "vim-tiny" ]; then \
		echo "debian/tiny/doc/	usr/share/vim/" >> debian/$*.install; \
	fi
	dh_install -X.svn
	dh_link
	
	touch $@

uninstall:
	dh_testdir
	dh_testroot
	rm -f install-stamp*
	dh_clean

%: %.in
	cat $< | sed 's/@VIMCUR@/$(VIMCUR)/' > $@

binary-indep: export DH_OPTIONS=-i
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build install
binary-arch: $(foreach v,$(VARIANTS),binary-arch-$(v))

binary-arch-vim-basic: export DH_OPTIONS=-pvim-common -pvim
binary-arch-vim-basic:
	dh_testdir
	dh_testroot
	dh_desktop
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch-%: export DH_OPTIONS=-p$* $(foreach v,$(VARIANTS_SKIP),-N$(v))
binary-arch-%: build install
	dh_testdir
	dh_testroot
	dh_desktop
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
binary: beginlog binary-indep binary-arch endlog
.PHONY: extract clean build install uninstall binary-indep binary-arch binary

.PHONY: beginlog endlog
beginlog:
	@echo "*** DEBIAN *** BUILD STARTED"
	@echo "*** DEBIAN *** BUILDING VARIANTS: $(VARIANTS)"
	@echo "*** DEBIAN *** SKIPPING VARIANTS: $(VARIANTS_SKIP)"
endlog:
	@echo "*** DEBIAN *** BUILD COMPLETED"

# vim: set foldmethod=marker: