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

# DEB_BUILD_OPTIONS supported:
#   noopt       Compile with gcc -O0 rather than -O2
#   nostrip     Do not strip binaries and libraries
#   debug       Enable additional debug support
#   nocheck     Skip test suites (synonym 'notest')
#   with-javahl, no-javahl |
#   with-apache, no-apache | enable/disable certain packages
#   with-ruby, no-ruby     |

DEB_BUILD_MAINT_OPTIONS=hardening=+all
include /usr/share/dpkg/default.mk

# Fully functional Java support is still a bit spotty on some Debian
# architectures.  DISABLE_JAVAHL_ARCHS overrides ENABLE_JAVAHL=yes.
# Note: the Build-Depends line in debian/control must be kept in sync
# with DISABLE_JAVAHL_ARCHS.

ENABLE_JAVAHL        = yes
DISABLE_JAVAHL_ARCHS = hurd-i386 hppa sparc
ifneq (,$(filter $(DEB_HOST_ARCH), $(DISABLE_JAVAHL_ARCHS)))
  ENABLE_JAVAHL =
endif

# We may need to disable libapache2-mod-svn and/or libsvn-ruby*.
ENABLE_APACHE        = yes
ENABLE_RUBY          = yes

DEB_BUILDDIR     = $(CURDIR)/BUILD
MAKE_B           = $(MAKE) -C $(DEB_BUILDDIR)
AUTH_LIB_DIRS    = $(DEB_BUILDDIR)/subversion/libsvn_auth_gnome_keyring/.libs:$(DEB_BUILDDIR)/subversion/libsvn_auth_kwallet/.libs
BASH_COMPL_DIR   = $(shell pkg-config --variable=completionsdir bash-completion)

export LANG = C
export HOME = $(DEB_BUILDDIR)/dummy_home

# ENABLE_FOO -> DEB_OPT_WITH_FOO=1
# DEB_BUILD_OPTIONS='foo bar' -> DEB_OPT_FOO=1, DEB_OPT_BAR=1
# DEB_BUILD_OPTIONS='no-foo' -> DEB_OPT_WITH_FOO=""
$(foreach o, JAVAHL APACHE RUBY, $(if $(filter y yes 1,$(ENABLE_$o)), \
    $(eval DEB_OPT_WITH_$o := 1),$(eval DEB_OPT_WITH_$o :=)))
d_b_o:=$(shell echo "$$DEB_BUILD_OPTIONS" | tr 'a-z-,' 'A-Z_ ')
$(foreach o, $(d_b_o), \
  $(if $(findstring =,$o), $(eval DEB_OPT_$o), $(eval DEB_OPT_$o := 1)))
$(foreach o, $(filter NO_%,$(d_b_o)), $(eval DEB_OPT_$(subst NO_,WITH_,$o) :=))
$(if $(DEB_OPT_PARALLEL),$(eval MAKEFLAGS += -j$(DEB_OPT_PARALLEL)))

ifndef DEB_OPT_TERSE
  MAKE_B += LTFLAGS="--tag=CC" LTCXXFLAGS="--tag=CXX"
endif

# How to fix "#!/usr/bin/env " lines:  $(call fix_shebangs_in, /your/dir)
fix_shebangs_in = \
	find $1 -type f | xargs -r egrep -m1 -c '^\#! ?/' | sed -n 's/:1//p' |\
	xargs -r sed -i -e 's:^\#! */usr/bin/env perl.*:\#!/usr/bin/perl -w:' \
			-e 's:^\#! */usr/bin/env pyth.*:\#!/usr/bin/python:' \
			-e 's:^\#! */usr/bin/env ruby.*:\#!/usr/bin/$(RUBY):'

PERL_DIR = $(DEB_BUILDDIR)/subversion/bindings/swig/perl/native
PY_DIR = $(DEB_BUILDDIR)/subversion/bindings/swig/python
PYVERSIONS = $(shell pyversions -vi)
PYDEFAULT =$(shell pyversions -vd)

allpy = \
	set -e; for v in $(PYVERSIONS); do \
		$(RM) $(PY_DIR); \
		ln -sfT python$$v $(PY_DIR); \
		pyinc=$$(python$$v-config --includes); \
		pylib=$$(python$$v -c 'from distutils import sysconfig; print sysconfig.get_python_lib()'); \
		$1; \
		ln -sfT python$(PYDEFAULT) $(PY_DIR); \
	done

libdir = /usr/lib/$(DEB_HOST_MULTIARCH)
# ~max(min required sqlite, stable's sqlite)
MIN_SQLITE_VER = 3.8.7

confflags = \
		--prefix=/usr \
		--libdir=$(libdir) \
		--mandir=\$${prefix}/share/man \
		--with-apr=/usr \
		--with-apr-util=/usr \
		--with-serf=/usr \
		--enable-sqlite-compatibility-version=$(MIN_SQLITE_VER) \
		--with-berkeley-db=:::db \
		--with-sasl=/usr \
		--with-editor=/usr/bin/editor \
		--with-ruby-sitedir=/usr/lib/ruby \
		--with-swig=/usr/bin/swig \
		--with-kwallet=/usr/include:$(libdir) \
		--with-lz4 \
		--with-utf8proc \
		CFLAGS="$(CFLAGS)" \
		CXXFLAGS="$(CXXFLAGS)" \
		CPPFLAGS="$(CPPFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		--with-gnome-keyring

ifdef DEB_OPT_DEBUG
  confflags+= --enable-debug
endif

export DH_OPTIONS
ifdef DEB_OPT_WITH_JAVAHL
  # jikes 1.22 cannot compile javahl.
  confflags += --enable-javahl --without-jikes \
               --with-jdk=/usr/lib/jvm/default-java \
               --with-junit=/usr/share/java/junit.jar
else
  DH_OPTIONS += -Nlibsvn-java
  confflags += --disable-javahl
endif

ifdef DEB_OPT_WITH_APACHE
  confflags += --with-apxs=/usr/bin/apxs2 --disable-mod-activation --with-apache-libexecdir=/usr/lib/apache2/modules
else
  confflags += --without-apxs
  DH_OPTIONS += -Nlibapache2-mod-svn
endif

ifdef DEB_OPT_WITH_RUBY
  RUBY = ruby
  RUBY_ARCH_DIR = $(shell $(RUBY) -rrbconfig -e "print RbConfig::CONFIG['vendorarchdir']")
  rb_defs = SWIG_RB_SITE_LIB_DIR=$(shell $(RUBY) -rrbconfig -e "print RbConfig::CONFIG['vendordir']")
  rb_defs += SWIG_RB_SITE_ARCH_DIR=$(RUBY_ARCH_DIR)
else
  DH_OPTIONS += -Nruby-svn
  RUBY = fooby
endif


# Set autoconf cross-compile mode correctly.
# Also disable testsuite if cross-compiling.
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  confflags += --build $(DEB_HOST_GNU_TYPE)
else
  confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
  DEB_OPT_NOCHECK = 1
endif


# I'm not trying to be difficult: this check exists because building as
# root really _does_ fail.  The failure mode as of 1.4.0 is test 17
# from switch_tests.py.  Upstream response is "so don't build as root".
# (fakeroot does not fail, as it does not wrap the access(2) syscall.)
#
# We run this code from build-arch, since that's what actually fails as
# root, but also from autogen, since that will halt the build earlier.
define DONT_BE_ROOT
	@if [ $$(id -u) = 0 ] && [ -z "$(FAKEROOTKEY)" ]; then \
		echo >&2 "***"; \
		echo >&2 "*** Building as root is not supported ***"; \
		false; \
	fi
endef

debian/stamp-autogen:
	$(DONT_BE_ROOT)
	dh_update_autotools_config
	./autogen.sh
	touch $@

debian/stamp-configure: debian/stamp-autogen
	dh_testdir

	mkdir -p $(DEB_BUILDDIR) $(HOME)
	cd $(DEB_BUILDDIR) && \
		PYTHON=/usr/bin/python RUBY=/usr/bin/$(RUBY) \
		  $(CURDIR)/configure $(confflags) || (cat $(DEB_BUILDDIR)/config.log; false)

	# Subversion upstream ships with Swig 1.3.25 pregenerated
	# files, which may interact badly with the build if Debian swig
	# is not version 1.3.25 - particularly with swig 1.3.24.
	# Thus we unconditionally delete the pregenerated files.
	+$(MAKE_B) mkdir-init
	+$(MAKE_B) extraclean-bindings
	for v in $(PYVERSIONS); do \
		cp -la $(PY_DIR) $(PY_DIR)$$v; \
	done
	$(RM) -r $(PY_DIR)
	# $(PY_DIR) always needs to exist to avoid the upstream Makefiles from
	# trying to re-create it
	ln -sfT python$(PYDEFAULT) $(PY_DIR)

	touch $@

build: debian/stamp-build-arch debian/stamp-build-indep

check_defs = CLEANUP=1 LC_ALL=C
check_swig = check-swig-py check-swig-pl $(if $(DEB_OPT_WITH_RUBY),check-swig-rb)
check_all = $(check_swig) $(if $(DEB_OPT_WITH_JAVAHL),check-javahl) check
check-help:
	@echo "$(MAKE) $(check_all)"

check check-swig-rb check-javahl: debian/stamp-build-arch
	+$(MAKE_B) $@ $(check_defs)

check-swig-pl: debian/stamp-build-arch
	+$(MAKE_B) $@ MAN3EXT=3perl $(check_defs)
	$(MAKE) -C $(PERL_DIR) test MAN3EXT=3perl LC_ALL=C

check-swig-py: debian/stamp-build-arch
	$(call allpy, \
	  $(MAKE_B) $@ PYTHON=python$$v PYVER=$$v $(check_defs))

build-arch: debian/stamp-build-arch
debian/stamp-build-arch: debian/stamp-configure
	dh_testdir
	$(DONT_BE_ROOT)

	# note: autogen-swig does not support -jN
	$(call allpy, $(MAKE_B) -j1 autogen-swig)
	+$(MAKE_B) all tools
	# Run svn once, to make sure it populates $(HOME)/.subversion/*
	env LD_LIBRARY_PATH="$(AUTH_LIB_DIRS):$(LD_LIBRARY_PATH)" $(DEB_BUILDDIR)/subversion/svn/svn --version > /dev/null
	$(call allpy, \
	  $(MAKE_B) swig-py PYTHON=python$$v PYVER=$$v \
	            PYTHON_INCLUDES="$$pyinc" \
	            swig_pydir=$$pylib/libsvn swig_pydir_extra=$$pylib/svn)
	# note: swig-pl seems to have trouble with -jN
	+$(MAKE_B) -j1 swig-pl MAN3EXT=3perl
	$(MAKE) -C $(PERL_DIR) all \
		MAN3EXT=3perl OPTIMIZE="-g -Wall $(CFLAGS)"
ifdef DEB_OPT_WITH_RUBY
	+$(MAKE_B) swig-rb $(rb_defs)
endif
ifdef DEB_OPT_WITH_JAVAHL
	+$(MAKE_B) -j1 javahl
endif

	# Need to touch the stamp file here so the check-* targets
	# don't try to build this target again
	touch $@

ifndef DEB_OPT_NOCHECK
	@echo "###################################################"
	@echo "Running testsuite - may take a while.  To disable,"
	@echo "use DEB_BUILD_OPTIONS=nocheck or edit debian/rules."
	@echo
	$(MAKE) -f debian/rules $(check_swig)

  ifdef DEB_OPT_WITH_JAVAHL
	# This fails on current free JVMs, according to Blair Zajac.
	# Thus the "-" prefix, to ignore failure, for now.
	-$(MAKE) -f debian/rules check-javahl
  endif

	# Run 'check' last, as it takes longest.  'cat tests.log' is for
	# obtaining diagnostics from buildd logs.
	@if ! $(MAKE) -f debian/rules check; then \
	  echo "###################################################"; \
	  echo "Testsuite failed, 'tests.log' follows:"; echo; \
	  cat $(DEB_BUILDDIR)/tests.log; \
	  exit 1; \
	fi
endif
	touch $@

build-indep: debian/stamp-build-indep
debian/stamp-build-indep: debian/stamp-configure
	mkdir -p $(DEB_BUILDDIR)/doc/doxygen
	+$(MAKE_B) doc-api
	+$(MAKE_B) locale-gnu-pot
	touch $@

clean:
	dh_testdir
	dh_clean
	! [ -f $(DEB_BUILDDIR)/Makefile ] || $(MAKE_B) extraclean-bindings distclean
	$(RM) -r $(DEB_BUILDDIR)
	$(RM) -r subversion/bindings/swig/ruby/test/.test-result
	$(RM) build-outputs.mk gen-make.opts subversion/svn_private_config.h.in
	$(RM) build/transform_libtool_scripts.sh
	$(RM) subversion/libsvn_fs_fs/rep-cache-db.h subversion/libsvn_fs_x/rep-cache-db.h
	$(RM) subversion/libsvn_client/libsvn_client.pc.in subversion/libsvn_ra/libsvn_ra.pc.in
	$(RM) subversion/libsvn_subr/internal_statements.h subversion/libsvn_subr/errorcode.inc subversion/libsvn_subr/config_keys.inc
	$(RM) subversion/libsvn_wc/wc-queries.h subversion/tests/libsvn_wc/wc-test-queries.h
	find -name \*.pyc -exec $(RM) {} +
	# these are (re)generated by autogen.sh
	$(RM) subversion/bindings/swig/proxy/*.swg
	$(RM) configure build/ltmain.sh build/libtool.m4 build/lt*.m4
	$(RM) subversion/po/subversion.pot
	$(RM) debian/stamp-*

debian/stamp-install-indep: debian/stamp-build-indep
	dh_prep -i
	dh_installdirs -i

	dh_install -i
	dh_installdocs -i NOTICE

	$(RM) debian/libsvn-doc/usr/share/doc/libsvn1/html/jquery.js
	dh_installexamples -i
	$(call fix_shebangs_in, debian/*/usr/share/doc/*/examples)
	dh_installman -i
	dh_installchangelogs -i CHANGES

	dh_lintian -i
	dh_compress -i
	dh_fixperms -i
	dh_perl -i
	dh_link -i
	dh_missing -i --list-missing

	touch $@

debian/stamp-install-arch: debian/stamp-build-arch
	dh_prep -a
	dh_installdirs -a

	$(MAKE_B) -j1 local-install install-tools \
		DESTDIR=$(CURDIR)/debian/tmp toolsdir=/usr/bin pkgconfig_dir=$(libdir)/pkgconfig
	sed -i 's:/usr/lib/\([^/]*/\)?lib\([^ ]*\).la:-l\1:g' debian/tmp/usr/lib/*/*.la

	$(call allpy, \
	  $(MAKE_B) install-swig-py DESTDIR=$(CURDIR)/debian/tmp \
	            PYTHON=python$$v PYVER=$$v \
	            swig_pydir=$$pylib/libsvn swig_pydir_extra=$$pylib/svn)
	$(RM) debian/tmp/usr/lib/python*/*-packages/libsvn/*.la
	$(RM) debian/tmp/usr/lib/python*/*-packages/libsvn/*.a

ifdef DEB_OPT_WITH_JAVAHL
	$(MAKE_B) install-javahl install-javahl-java \
		DESTDIR=$(CURDIR)/debian/tmp \
		javahl_javadir=/usr/share/java \
		javahl_javahdir=/usr/include/svn-javahl
endif

	$(MAKE_B) install-swig-pl-lib \
		DESTDIR=$(CURDIR)/debian/tmp
	$(MAKE) -C $(PERL_DIR) install \
		MAN3EXT=3perl DESTDIR=$(CURDIR)/debian/tmp INSTALLDIRS=vendor

ifdef DEB_OPT_WITH_RUBY
	$(MAKE_B) install-swig-rb $(rb_defs) \
		DESTDIR=$(CURDIR)/debian/tmp
	find debian/tmp$(RUBY_ARCH_DIR) \( -name \*.a -o -name \*.la \) -exec $(RM) {} +
	dh_install --autodest -pruby-svn debian/tmp$(RUBY_ARCH_DIR)
endif

	rm -f debian/tmp/usr/lib/apache2/modules/mod_dontdothat*
	rm -f debian/tmp/usr/bin/diff*

	cd debian/tmp/$(libdir); for lib in fs auth swig; do \
	    $(RM) libsvn_$${lib}_*.so libsvn_$${lib}_*.la; \
	done
	# libsvn_ra_svn is public, although deprecated, so we can't blindly
	# remove all libsvn_ra_*
	cd debian/tmp/$(libdir); \
	    $(RM) libsvn_ra_serf-*.so libsvn_ra_serf-*.la \
	          libsvn_ra_local-*.so libsvn_ra_local-*.la
	cd debian/tmp/$(libdir); $(RM) libsvn_swig*.a libsvnjavahl-1.a libsvnjavahl-1.la
	# Intermediate hack, until we can remove the rest of the .la files.
	sed -i  "/dependency_libs/s/=.*/=''/" debian/tmp/$(libdir)/*.la

	# There are some non-ELF files in /usr/bin, so ignore errors
	chrpath --keepgoing --delete "$(CURDIR)/debian/tmp/usr/bin/"* || true
	find "$(CURDIR)/debian/tmp$(libdir)" -type f -name '*.so' -exec chmod u+w '{}' + -exec chrpath --delete '{}' +
	dh_install -a

	# Install files for 'subversion-tools' package.
	install $(DEB_BUILDDIR)/tools/backup/hot-backup.py \
		debian/subversion-tools/usr/bin/svn-hot-backup
	install -t debian/subversion-tools/usr/share/subversion/hook-scripts \
		$(DEB_BUILDDIR)/tools/hook-scripts/commit-access-control.pl

	rm debian/subversion-tools/usr/share/subversion/hook-scripts/*.in
	rm -r debian/subversion-tools/usr/share/subversion/hook-scripts/mailer/tests
ifndef DEB_OPT_WITH_RUBY
	rm debian/subversion-tools/usr/share/subversion/hook-scripts/*.rb
endif

	# Fix some scripts not to use #!/usr/bin/env.
	$(call fix_shebangs_in, debian/*/usr/bin \
		debian/subversion-tools/usr/share/subversion/hook-scripts)
	cd debian/subversion-tools/usr/share/subversion/hook-scripts; \
		chmod 0755 commit-email.pl commit-access-control.pl \
			   mailer/mailer.py verify-po.py svnperms.py;

	# Remove suffixes from binaries in /usr/bin
	rename 's/\.(sh|pl|rb|py)$$//' debian/*/usr/bin/*

	pod2man -c 'User Commands' -r "" debian/contrib/svn-clean \
		$(DEB_BUILDDIR)/svn-clean.1

ifdef DEB_OPT_WITH_JAVAHL
	mkdir -p debian/libsvn-java/$(libdir)
	mv debian/libsvn-java/usr/lib/jni debian/libsvn-java/$(libdir)/
	$(RM) debian/libsvn-dev/$(libdir)/libsvnjavahl-1.so
endif

	install -d "debian/subversion/$(BASH_COMPL_DIR)"
	install -m644 tools/client-side/bash_completion \
		"debian/subversion/$(BASH_COMPL_DIR)/svn"
	cd "debian/subversion/$(BASH_COMPL_DIR)" \
	  && ln -s svn svnadmin \
	  && ln -s svn svndumpfilter \
	  && ln -s svn svnlook \
	  && ln -s svn svnversion

	dh_apache2 -a
ifdef DEB_OPT_WITH_APACHE
	install subversion/mod_authz_svn/INSTALL \
		debian/libapache2-mod-svn/usr/share/doc/libapache2-mod-svn/INSTALL.authz
endif

	cp tools/examples/svnshell.py debian/python-subversion/usr/bin/svnshell
	$(call fix_shebangs_in, debian/python-subversion/usr/bin/svnshell)

	dh_installdocs -a NOTICE
	dh_installexamples -a
	$(call fix_shebangs_in, debian/*/usr/share/doc/*/examples)
	dh_installman -a
	dh_installchangelogs -a CHANGES
	dh_perl -a
	dh_python2 -a
	dh_link -a
	dh_lintian -a
	dh_fixperms -a
	dh_missing -a --list-missing

	touch $@

binary-indep: debian/stamp-install-indep
	dh_testdir
	dh_testroot
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: debian/stamp-install-arch
	dh_testdir
	dh_testroot
	dh_strip -a
	dh_compress -a

	# dh_makeshlibs (1) creates shlibs/symbols files and (2) generates
	# calls to 'ldconfig' in postinst/postrm.  We want (1) only for
	# libsvn1, but (2) for the swig packages too.
	dh_makeshlibs -a -Xjava -X_auth_ -X_ra_serf -X_ra_local -X_fs_
	$(RM) debian/libsvn-*/DEBIAN/shlibs debian/python-subversion/DEBIAN/shlibs
	$(RM) debian/libsvn-*/DEBIAN/symbols debian/python-subversion/DEBIAN/symbols
	dh_installdeb -a
	dh_shlibdeps -a -X_auth_
	sed -i 's:libsvn-private\(, *\)\?::' debian/*.substvars
ifeq ($(DEB_VENDOR),Ubuntu)
	dh_gencontrol -a -- -V"subversion-tools:Suggests=svn2cl"
else
	dh_gencontrol -a -- -V"subversion-tools:Recommends=svn2cl"
endif
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

.NOTPARALLEL:
.PHONY: build build-arch build-indep binary binary-arch binary-indep
.PHONY: clean check-help $(check_all)