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

export DH_OPTIONS

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

include /usr/share/dpkg/default.mk

BUILDER = maintainers@lists.progress-linux.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

ifneq (,$(filter pkg.vim.noruby,$(DEB_BUILD_PROFILES)))
  RUBY_SUBSTVARS = -Vvim:Ruby-Provides= -Vvim:Ruby-Desc=
  RUBY_CFGFLAGS = --disable-ruby
else ifneq (,$(filter alpha ia64,$(DEB_HOST_ARCH)))
  # Disable ruby on these architectures at the request of porters (c.f., #983308)
  RUBY_SUBSTVARS = -Vvim:Ruby-Provides= -Vvim:Ruby-Desc=
  RUBY_CFGFLAGS = --disable-rubyinterp
else
  RUBY_SUBSTVARS = -Vvim:Ruby-Provides='vim-ruby (= $${binary:Version})' -Vvim:Ruby-Desc=' Ruby,'
  RUBY_CFGFLAGS = --enable-rubyinterp
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
CFGFLAGS += --with-global-runtime='/var/lib/vim/addons,/etc/vim,$$VIM/vimfiles'

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-acl
TINYFLAGS += --disable-terminal
TINYFLAGS += --disable-canberra
TINYFLAGS += --disable-libsodium

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-acl
OPTFLAGS += --enable-terminal
OPTFLAGS += --enable-libsodium

NOXFLAGS = --without-x
NOXFLAGS += --enable-gui=no
NOXFLAGS += --disable-canberra

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

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

MOTIFFLAGS = --enable-gui=motif
MOTIFFLAGS += --disable-gtk2-check
MOTIFFLAGS += --disable-gtk3-check
MOTIFFLAGS += --disable-gnome-check
MOTIFFLAGS += --disable-motif-check
MOTIFFLAGS += --enable-motif-check
MOTIFFLAGS += --enable-fontset

NOINTERPFLAGS = --disable-luainterp
NOINTERPFLAGS += --disable-mzschemeinterp
NOINTERPFLAGS += --disable-perlinterp
NOINTERPFLAGS += --enable-python3interp --with-python3-config-dir=$(shell python3-config --configdir)
NOINTERPFLAGS += --disable-pythoninterp
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-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-gtk3
VARIANTS += vim-motif
VARIANTS += vim-nox
VARIANTS += vim-basic

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

CFLAGS += -DSYS_VIMRC_FILE="'\"/etc/vim/vimrc\"'" -DSYS_GVIMRC_FILE="'\"/etc/vim/gvimrc\"'"

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

CFLAGS_vim-tiny = $(CFLAGS) -DTINY_VIMRC -DSYS_TINYRC_FILE="'\"/etc/vim/vimrc.tiny\"'"
CFGFLAGS_vim-tiny = $(CFGFLAGS) $(TINYFLAGS)

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

CFLAGS_vim-motif = $(CFLAGS)
CFGFLAGS_vim-motif = $(CFGFLAGS) $(OPTFLAGS) $(GUIFLAGS) $(MOTIFFLAGS) $(ALLINTERPFLAGS) $(RUBY_CFGFLAGS)

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

NAME = vim
# Convert x.y.z to x.y
VERSION = $(basename $(DEB_VERSION_UPSTREAM))
VIMCUR = $(NAME)$(subst .,,$(VERSION))
LANGS = da de fr it ja pl ru tr

DOT_IN_DEPS = debian/vim-runtime.postrm
DOT_IN_DEPS += debian/vim-runtime.preinst
DOT_IN_DEPS_TINY = debian/tiny/vimrc.tiny

foreach-variant = \
  set -e; for v in $(VARIANTS); do \
    $1; \
  done

%:
	dh $@

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

override_dh_auto_clean:
	[ ! -f src/auto/config.cache ] || make distclean
	[ ! -f debian/configure.dist ] || mv debian/configure.dist src/auto/configure
	find src/testdir -name '*.pyc' -delete
	for v in $(VARIANTS); do \
	  if [ "$${v}" = vim-basic ]; then \
	    [ ! -L src/"$${v}"/po ] || $(MAKE) -C src/"$${v}"/po clean; \
	  fi; \
	  rm -rf src/"$${v}"; \
	done
	rm -f $(DOT_IN_DEPS)
	rm -f $(DOT_IN_DEPS_TINY)

override_dh_auto_configure-indep: autoconf-stamp
	$(MAKE) -f debian/rules configure-vim-basic

override_dh_auto_configure-arch: autoconf-stamp
	$(call foreach-variant, $(MAKE) -f debian/rules configure-"$${v}")

override_dh_auto_build-indep: autoconf-stamp
override_dh_auto_build-indep:
	$(MAKE) -f debian/rules build-vim-basic
	$(MAKE) -C runtime/doc html
	$(MAKE) -C debian/policy text html
	$(MAKE) -C src/po vim.pot VIM=$(CURDIR)/src/vim-basic/vim

override_dh_auto_build-arch: autoconf-stamp
	$(call foreach-variant, $(MAKE) -f debian/rules build-"$${v}")
	$(MAKE) -C src/vim-basic xxd/xxd

override_dh_auto_test-indep:

override_dh_auto_test-arch:
	$(call foreach-variant, $(MAKE) -f debian/rules test-"$${v}")

autoconf-stamp:
	dh_testdir
	[ -f debian/configure.dist ] || cp src/auto/configure debian/configure.dist
# The autoconf target generates a new configure, and touches some other
# configure-related things.  Need to run scratch 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 $@

src/vim-%: VARIANT=vim-$*
src/vim-%:
	$(MAKE) -C src shadow SHADOWDIR=$(VARIANT)

configure-vim-%: VARIANT=vim-$*
configure-vim-%: autoconf-stamp
configure-vim-%:
	$(MAKE) -f debian/rules src/$(VARIANT)
	cd src/$(VARIANT) && LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS_$(VARIANT))" ./configure $(CFGFLAGS_$(VARIANT))

build-vim-%: VARIANT=vim-$*
build-vim-%: configure-$(VARIANT)
build-vim-%:
	$(MAKE) -C src/$(VARIANT)
	$(MAKE) -C runtime/doc tags VIMEXE=$(CURDIR)/src/$(VARIANT)/vim

test-vim-%: VARIANT=vim-$*
test-vim-%:
	:
ifeq (yes,$(MAKETEST))
# Sanitize LC_* env so they don't leak through to child processes and cause problems in build chroots (e.g., missing locales)
# and set sane values for TERM/LC_ALL/LANG
	for e in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MESSAGES MONETARY NAME NUMERIC PAPER TELEPHONE TIME; do \
	  unset LC_$${e}; \
	done; \
	env TERM=xterm LC_ALL=C.UTF-8 LANG=C.UTF-8 $(MAKE) -j1 -C src/$(VARIANT) test
endif

override_dh_auto_install-arch:

# 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

override_dh_auto_install-indep: DESTDIR=$(CURDIR)/debian/tmp
override_dh_auto_install-indep:
	$(MAKE) -f debian/rules build-vim-basic
	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"

override_dh_install-indep: DESTDIR=$(CURDIR)/debian/tmp
override_dh_install-indep:
	$(MAKE) -f debian/rules $(DOT_IN_DEPS)
	$(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
	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/icons/hicolor/scalable/apps/gvim.svg

	env VIMCUR=$(VIMCUR) dh_install -X vim2html.pl -X 'README*.txt' -X README.el.txt -X README.el.cp737.txt
	# 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

override_dh_installchangelogs:
	dh_installchangelogs -A debian/changelog.upstream

install-xxd: DESTDIR=$(CURDIR)/debian/xxd
install-xxd:
	$(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 these languages yet
	for lang in da de tr.ISO8859-9 tr.UTF-8 tr; do \
	  rmdir $(DESTDIR)/usr/share/man/$$lang/man1 $(DESTDIR)/usr/share/man/$$lang; \
	done

override_dh_auto_install-arch:
	$(MAKE) -f debian/rules install-xxd

override_dh_bugfiles:
	$(call foreach-variant, dh_bugfiles -A -p "$${v%-basic}")

install-vim-%: SHADOWDIR=vim-$*
install-vim-%: VARIANT=$*
install-vim-%: BIN=$(subst -,.,vim-$(VARIANT))
install-vim-%:
	cp src/$(SHADOWDIR)/vim src/$(SHADOWDIR)/$(BIN)
	[ $(VARIANT) != tiny ] || $(MAKE) -f debian/rules $(DOT_IN_DEPS_TINY)

override_dh_install-arch:
	$(call foreach-variant, $(MAKE) -f debian/rules install-$${v})
	env VIMCUR=$(VIMCUR) dh_install

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

override_dh_gencontrol:
	dh_gencontrol -- $(RUBY_SUBSTVARS)

.NOTPARALLEL:
# vim: set foldmethod=marker: