summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: ecf11d211f503bbb898a77ebb0882c78a1b04456 (plain)
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
#!/usr/bin/make -f

export DH_OPTIONS

# Upstream handles the _FORTIFY_SOURCE flag on their own
DEB_BUILD_MAINT_OPTIONS=hardening=+all,-fortify

include /usr/share/dpkg/default.mk
DEB_VENDOR := Debian

BUILDER := team+vim@tracker.debian.org

MAKETEST := no
ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
    MAKETEST := yes
  endif
endif

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    MAKEFLAGS += -j$(NUMJOBS)
endif

CFGFLAGS := --prefix=/usr --mandir='$${prefix}'/share/man --without-local-dir
CFGFLAGS += --with-modified-by="$(BUILDER)"
CFGFLAGS += --with-compiledby="$(BUILDER)"
CFGFLAGS += --enable-fail-if-missing

TINYFLAGS:=--with-features=small
TINYFLAGS+=--disable-gui
TINYFLAGS+=--disable-xsmp
TINYFLAGS+=--disable-xsmp-interact
TINYFLAGS+=--disable-netbeans
TINYFLAGS+=--disable-gpm
TINYFLAGS+=--enable-nls
TINYFLAGS+=--enable-multibyte
TINYFLAGS+=--enable-acl
TINYFLAGS+=--disable-terminal

OPTFLAGS:=--enable-cscope
ifeq ($(DEB_HOST_ARCH_OS),linux)
    OPTFLAGS+=--enable-gpm
    OPTFLAGS+=--enable-selinux --disable-smack
    TINYFLAGS+=--enable-selinux --disable-smack
else
    OPTFLAGS+=--disable-gpm
endif
OPTFLAGS+=--with-features=huge
OPTFLAGS+=--enable-multibyte
OPTFLAGS+=--enable-acl
OPTFLAGS+=--enable-terminal

NOXFLAGS:=--without-x
NOXFLAGS+=--enable-gui=no

GUIFLAGS:=--with-x
GUIFLAGS+=--enable-xim

GTK2FLAGS:=--enable-gui=gtk2
GTK2FLAGS+=--enable-gtk2-check
GTK2FLAGS+=--disable-gnome-check
GTK2FLAGS+=--disable-motif-check
GTK2FLAGS+=--disable-athena-check
GTK2FLAGS+=--disable-fontset

GTK3FLAGS:=--enable-gui=gtk3
GTK3FLAGS+=--enable-gtk3-check
GTK3FLAGS+=--disable-gnome-check
GTK3FLAGS+=--disable-motif-check
GTK3FLAGS+=--disable-athena-check
GTK3FLAGS+=--disable-fontset

ATHENAFLAGS:=--enable-gui=athena
ATHENAFLAGS+=--disable-gtk2-check
ATHENAFLAGS+=--disable-gtk3-check
ATHENAFLAGS+=--disable-gnome-check
ATHENAFLAGS+=--disable-motif-check
ATHENAFLAGS+=--enable-athena-check
ATHENAFLAGS+=--enable-fontset

NOINTERPFLAGS:=--disable-luainterp
NOINTERPFLAGS+=--disable-mzschemeinterp
NOINTERPFLAGS+=--disable-perlinterp
ifeq ($(DEB_VENDOR),Ubuntu)
	NOINTERPFLAGS+=--enable-python3interp --with-python3-config-dir=$(shell python3-config --configdir)
	NOINTERPFLAGS+=--disable-pythoninterp
	GTK3FLAGS+=--disable-rubyinterp
	RUBY_SUBSTVARS=
else
	NOINTERPFLAGS+=--disable-pythoninterp
	NOINTERPFLAGS+=--disable-python3interp
	RUBY_SUBSTVARS=-Vvim:Ruby-Provides=vim-ruby -Vvim:Ruby-Desc=" Ruby,"
endif
NOINTERPFLAGS+=--disable-rubyinterp
NOINTERPFLAGS+=--disable-tclinterp

ALLINTERPFLAGS:=--enable-luainterp
ALLINTERPFLAGS+=--disable-mzschemeinterp
ALLINTERPFLAGS+=--enable-perlinterp
ALLINTERPFLAGS+=--enable-python3interp --with-python3-config-dir=$(shell python3-config --configdir)
ALLINTERPFLAGS+=--disable-pythoninterp
ALLINTERPFLAGS+=--enable-rubyinterp
ALLINTERPFLAGS+=--enable-tclinterp
ALLINTERPFLAGS+=--with-tclsh=/usr/bin/tclsh

# 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 build 4 packages: "vim", "vim-runtime",
# "vim-common", "vim-gui-common". "vim-tiny" is the only variant package not
# depending on vim-runtime.

VARIANTS+=vim-tiny
VARIANTS+=vim-gtk
VARIANTS+=vim-gtk3
VARIANTS+=vim-athena
VARIANTS+=vim-nox
VARIANTS+=vim-basic

ifneq ($(origin VARIANT), undefined)
	VARIANTS = $(VARIANT) vim-basic
endif

CFLAGS_vim-basic:=$(CFLAGS)
CFGFLAGS_vim-basic:=$(CFGFLAGS) $(OPTFLAGS) $(NOXFLAGS) $(NOINTERPFLAGS)

CFLAGS_vim-tiny:=$(CFLAGS) -DTINY_VIMRC
CFGFLAGS_vim-tiny:=$(CFGFLAGS) $(TINYFLAGS)

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

CFLAGS_vim-gtk3:=$(CFLAGS)
CFGFLAGS_vim-gtk3:=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(ALLINTERPFLAGS) $(GTK3FLAGS)

CFLAGS_vim-athena:=$(CFLAGS)
CFGFLAGS_vim-athena:=$(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(ATHENAFLAGS) $(ALLINTERPFLAGS)

CFLAGS_vim-nox:=$(CFLAGS)
CFGFLAGS_vim-nox:=$(CFGFLAGS) $(OPTFLAGS) $(NOXFLAGS) $(ALLINTERPFLAGS)

NAME:=vim
# Convert x.y.z to x.y
VERSION:=$(basename $(DEB_VERSION_UPSTREAM))
VIMCUR:=$(NAME)$(subst .,,$(VERSION))
PER_VARIANT_FILES := install postinst prerm lintian-overrides maintscript
LANGS := da de fr it ja pl ru

DOT_IN_DEPS := debian/vim-common.install
DOT_IN_DEPS += debian/vim-runtime.links
DOT_IN_DEPS += debian/vim-runtime.postrm
DOT_IN_DEPS += debian/vim-runtime.preinst
DOT_IN_DEPS += debian/runtime/debian.vim
DOT_IN_DEPS_TINY := debian/tiny/vimrc.tiny

# nothing to do per default
all:

update-changelog:
	dh_testdir
	wget -O debian/changelog.upstream http://ftp.vim.org/pub/vim/patches/$(VERSION)/README

clean: $(foreach v,$(VARIANTS),clean-$(v))
	dh_testdir
	dh_testroot
	rm -f extract-stamp* build-stamp* install-stamp* configure-stamp* autoconf-stamp
	rm -f debian/helpztags.1
	rm -rf debian/policy/vim-policy.html
	rm -f debian/policy/vim-policy.txt
	rm -f debian/tmplogo.*
	[ ! -f src/auto/config.cache ] || make distclean
	rm -f src/auto/config.mk src/pixmaps src/runtime
	[ ! -f debian/configure.dist ] || mv debian/configure.dist src/auto/configure
	rm -f src/auto/config.h
	rm -f runtime/doc/doctags runtime/doc/tags.ref
	rm -f runtime/doc/*.html runtime/doc/*.log
	find src/testdir -name '*.pyc' -delete
	dh_clean

clean-vim-basic:
	dh_testdir
	dh_testroot
	for x in $(PER_VARIANT_FILES) ; do \
	  rm -f debian/vim.$$x ; \
	done
	[ ! -L src/vim-basic/po ] || $(MAKE) -C src/vim-basic/po clean
	rm -f $(DOT_IN_DEPS)
	rm -rf src/vim-basic

clean-%: SHADOWDIR=$*
clean-%:
	dh_testdir
	dh_testroot
	for x in $(PER_VARIANT_FILES) ; do \
	  rm -f debian/$*.$$x ; \
	done
	if [ "$*" = "vim-tiny" ]; then \
	  rm -f $(DOT_IN_DEPS_TINY); \
	fi
	rm -rf src/$(SHADOWDIR)

build: build-stamp-arch

build-indep: build-stamp-indep
build-stamp-indep: export DH_OPTIONS=-pvim-doc
build-stamp-indep: autoconf-stamp
	dh_testdir
	dh_prep
	$(MAKE) -C runtime/doc html
	$(MAKE) -C debian/policy text html
	$(MAKE) -C src/po vim.pot
	touch $@

build-arch: build-stamp-arch
build-stamp-arch: build-stamp-xxd $(foreach v,$(VARIANTS),build-stamp-$(v))
	dh_testdir
	touch $@

build-stamp-xxd: export DH_OPTIONS=-pxxd
build-stamp-xxd: build-stamp-vim-basic
	dh_testdir
	dh_prep
	$(MAKE) -C src/vim-basic xxd/xxd
	touch $@

autoconf-stamp:
	dh_testdir
	[ -f debian/configure.dist ] || cp src/auto/configure debian/configure.dist
# src/Makefile includes src/auto/config.mk, so we need to ensure it exists.
# distclean will then wipe it out and re-copy it.
	[ -f src/auto/config.mk ] || cp src/config.mk.dist src/auto/config.mk
# The autoconf target generates a new configure, and touches some other
# configure-related things.  Need to run distclean afterward or timestamps
# will be off and the next make that runs will think it needs to run
# configure.  This breaks parallel builds since two configures are being run
# in the same directory at the same time instead of in their own shadow
# directories.
	$(MAKE) -C src autoconf
	$(MAKE) -C src scratch
	touch $@

configure-stamp-%: SHADOWDIR=$*
# When configure.in is being patched by Debian, autoconf-stamp needs to be a
# prerequisite for this target and autoconf needs to be added to Build-Depends
configure-stamp-%: autoconf-stamp
	dh_testdir
	@echo "*** DEBIAN *** CONFIGURING VARIANT $*"
	$(MAKE) -C src shadow SHADOWDIR=$(SHADOWDIR)
	cd src/$(SHADOWDIR) && LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS_$(*))" ./configure $(CFGFLAGS_$(*))
	touch $@

build-stamp-%: PKG=$(subst -basic,,$*)
build-stamp-%: CURCFLAGS=$(CFLAGS_$*)
build-stamp-%: SHADOWDIR=$*
build-stamp-%: configure-stamp-%
	dh_testdir
	dh_prep -p $(PKG)
	@echo "*** DEBIAN *** BUILDING VARIANT $*"
	$(MAKE) -C src/$(SHADOWDIR)
	# Ensure $TERM is set to a sane value for testing
	[ $(MAKETEST) != "yes" ] || env LANG=C.UTF-8 TERM=xterm $(MAKE) -j1 -C src/$(SHADOWDIR) test
	touch $@

install: install-stamp-xxd $(foreach v,$(VARIANTS),install-stamp-$(v))

# Use UTF-8 manpages for all languages
# If a .UTF-8 directory doesn't exist, then the $L directory is already UTF-8.
define munge-man-directories
for L in $(LANGS); do \
  if [ -d "$(DESTDIR)/usr/share/man/$$L.UTF-8" ]; then \
    rm -rf "$(DESTDIR)/usr/share/man/$$L"; \
    mv "$(DESTDIR)/usr/share/man/$$L.UTF-8" "$(DESTDIR)/usr/share/man/$$L"; \
  fi; \
  rm -rf "$(DESTDIR)/usr/share/man/$$L."*; \
done
endef

install-stamp-indep: export DH_OPTIONS=-i
install-stamp-indep: DESTDIR=$(CURDIR)/debian/tmp
install-stamp-indep: build-stamp-vim-basic build-stamp-indep $(DOT_IN_DEPS)
	dh_testdir
	dh_testroot
	dh_installdirs

	mkdir -p "$(DESTDIR)/usr/bin"
	# installruntime requires a "vim" in /usr/bin
	cp src/vim-basic/vim "$(DESTDIR)/usr/bin"
	$(MAKE) -C src/vim-basic "DESTDIR=$(DESTDIR)" \
	    installtutorbin \
	    installgtutorbin \
	    installruntime \
	    install-languages \
	    install-icons
	rm -f "$(DESTDIR)/usr/bin/vim"

	$(munge-man-directories)

	# rm stuff handled by alternatives or our own symlinks
	find "$(DESTDIR)/usr/share/man" \( -name view.1 -o -name ex.1 -o -name rvim.1 -o -name rview.1 \) -delete

	# helpztags manpage
	pod2man -c "User Commands" -s 1 -q none -r "vim $(VERSION)" \
		-d "August 2010" debian/helpztags debian/helpztags.1

	# Icons
	for sz in 16 32 48; do \
	  cp runtime/vim$${sz}x$${sz}.xpm debian/vim-common/usr/share/pixmaps/vim-$${sz}.xpm; \
	done
	gs -sDefaultCMYKProfile=ps_cmyk.icc -sOutputICCProfile=ps_rgb.icc \
	    -dSAFER -dEPSCrop -dBATCH -dNOPAUSE \
	    -sDEVICE=ps2write -sOutputFile=debian/tmplogo.ps runtime/vimlogo.eps
	ps2pdf debian/tmplogo.ps debian/tmplogo.pdf
	pdf2svg debian/tmplogo.pdf debian/vim-common/usr/share/pixmaps/gvim.svg
	cp debian/vim-common/usr/share/pixmaps/gvim.svg \
	   debian/vim-common/usr/share/icons/hicolor/scalable/apps/gvim.svg

	dh_install
	# 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
	cp debian/vim-runtime/usr/share/man/man1/vimtutor.1 \
	   debian/vim-gui-common/usr/share/man/man1/gvimtutor.1
	for L in $(LANGS); do \
	  DIR=usr/share/man/$$L; \
	  [ ! -e "debian/vim-common/$$DIR/man1/vim.1" ] || \
	    cp debian/vim-common/$$DIR/man1/vim.1 \
	       debian/vim-gui-common/$$DIR/man1/gvim.1; \
	  [ ! -e "debian/vim-common/$$DIR/man1/vimdiff.1" ] || \
	    cp debian/vim-common/$$DIR/man1/vimdiff.1 \
	       debian/vim-gui-common/$$DIR/man1/gvimdiff.1; \
	  [ ! -e "debian/vim-runtime/$$DIR/man1/vimtutor.1" ] || \
	    cp debian/vim-runtime/$$DIR/man1/vimtutor.1 \
	       debian/vim-gui-common/$$DIR/man1/gvimtutor.1; \
	done
	dh_link
	dh_installman
	dh_installchangelogs debian/changelog.upstream
	dh_installdocs
	dh_installmime
	touch $@

install-stamp-xxd: export DH_OPTIONS=-pxxd
install-stamp-xxd: DESTDIR=$(CURDIR)/debian/xxd
install-stamp-xxd: build-stamp-xxd
	dh_testdir
	dh_testroot
	$(MAKE) -C src/vim-basic STRIP=: DESTDIR=$(DESTDIR) installtools install-tool-languages
	rm -r $(DESTDIR)/usr/share/vim
	$(munge-man-directories)
	# No xxd.1 translations for Danish or German yet
	rmdir $(DESTDIR)/usr/share/man/da/man1 $(DESTDIR)/usr/share/man/da \
	      $(DESTDIR)/usr/share/man/de/man1 $(DESTDIR)/usr/share/man/de
	dh_installchangelogs
	dh_installdocs
	touch $@

install-stamp-%: PKG=$(subst -basic,,$*)
install-stamp-%: export DH_OPTIONS=-p$(PKG)
install-stamp-%: DESTDIR=$(CURDIR)/debian/$(PKG)
install-stamp-%: VARIANT=$(patsubst vim-%,%,$*)
install-stamp-%: build-stamp-%
	dh_testdir
	dh_testroot
	@echo "*** DEBIAN *** INSTALLING VARIANT $*"
	dh_installdirs

	cp src/$*/vim src/$*/$(subst -,.,$*)
	# variant-related installations
	for x in $(PER_VARIANT_FILES) ; do \
	  case "$(PKG)" in \
	    vim-nox|vim|vim-tiny) \
	      sed -e "s:@PKG@:$(PKG):g" -e "s:@VARIANT@:$(VARIANT):g" \
	          -e "s:@COMMON@:vim-common:g" \
	          debian/vim-variant.$$x > debian/$(PKG).$$x ;\
	      ;; \
	    *) \
	      sed -e "s:@PKG@:$(PKG):g" -e "s:@VARIANT@:$(VARIANT):g" \
	          -e "s:@COMMON@:vim-gui-common:g" \
	          debian/vim-variant.$$x > debian/$(PKG).$$x ;\
	      ;; \
	  esac \
	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/$(PKG).postinst; \
	done
	sed -i "/@LANG_ALTS@/d" debian/$(PKG).postinst
	# fake help installation for vim-tiny
	if [ "$(PKG)" = "vim-tiny" ]; then \
	  $(MAKE) -f debian/rules $(DOT_IN_DEPS_TINY); \
	  echo "debian/tiny/doc/	usr/share/vim/$(VIMCUR)" >> debian/vim-tiny.install; \
	  echo "debian/tiny/vimrc.tiny	etc/vim" >> debian/vim-tiny.install; \
	fi
	dh_install
	dh_installchangelogs debian/changelog.upstream
	dh_installdocs
	dh_link
	dh_bugfiles -A

	touch $@

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

binary-indep: export DH_OPTIONS=-i
binary-indep: install-stamp-indep
	dh_testdir
	dh_testroot
	dh_compress
	dh_fixperms
	dh_lintian
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb -- -Zxz

binary-arch: binary-arch-xxd $(foreach v,$(VARIANTS),binary-arch-$(v))

binary-arch-%: PKG=$(subst -basic,,$*)
binary-arch-%: export DH_OPTIONS=-p$(PKG) $(foreach v,$(VARIANTS_SKIP),-N$(v))
binary-arch-%: install-stamp-%
	dh_testdir
	dh_testroot
	dh_strip --dbgsym-migration='vim-dbg (<< 2:7.4.1689-1~)'
	dh_compress
	dh_fixperms
	dh_lintian
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol -- $(RUBY_SUBSTVARS)
	dh_md5sums
	dh_builddeb -- -Zxz

binary-arch-xxd: export DH_OPTIONS=-pxxd
binary-arch-xxd: install-stamp-xxd
	dh_testdir
	dh_testroot
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: beginlog binary-indep binary-arch endlog
.PHONY: patch unpatch extract clean build install 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"

.NOTPARALLEL:
# vim: set foldmethod=marker: