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

# The versions of python currently supported
PYVERS=$(shell pyversions -s)
# The current default version of python
PYVER=$(shell pyversions -d)

CFLAGS = -Wall -g

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

TARGETS := main $(PYVERS) $(PYVERS:%=%-dbg)

override_dh_auto_configure: $(TARGETS:%=configure-%)

configure-main:
	dh_auto_configure --builddirectory=build -- --with-history --without-python CC="gcc -Wl,--as-needed" CFLAGS="$(CFLAGS)" --cache-file="$(CURDIR)/build/config.cache"

configure-python%: configure-main
	dh_auto_configure --builddirectory=build_python$* -- --with-history --with-python=/usr/bin/python$* CC="gcc -Wl,--as-needed" CFLAGS="$(CFLAGS)" --cache-file="$(CURDIR)/build/config.cache"
	mv build_python$*/python build/python$*

override_dh_auto_build: $(TARGETS:%=build-%)

build-main:
	dh_auto_build --builddirectory=build

build-python%-dbg:
	dh_auto_build --builddirectory=build/python$*-dbg -- PYTHON_INCLUDES=/usr/include/python$*_d LDFLAGS="-L$(CURDIR)/debian/tmp/usr/lib" CFLAGS="-Wall -g -O0" libxml2mod_la_LIBADD='$$(mylibs)'

build-python%:
	dh_auto_build --builddirectory=build/python$* -- libxml2mod_la_LIBADD='$$(mylibs)'

override_dh_auto_clean:
	rm -rf build build_python* debian/tmp-dbg

	-test -r /usr/share/misc/config.sub && \
	cp -f /usr/share/misc/config.sub config.sub
	-test -r /usr/share/misc/config.guess && \
	cp -f /usr/share/misc/config.guess config.guess

override_dh_auto_install: $(TARGETS:%=install-%)

install-main:
	dh_auto_install --builddirectory=build
	mv debian/tmp/usr/share/aclocal/libxml.m4 debian/tmp/usr/share/aclocal/libxml2.m4

	# Properly install documentation in /usr/share/doc/libxml2-doc
	install -d debian/tmp/usr/share/doc/libxml2-doc/examples
	install -m 644 \
		doc/*.html \
		doc/*.gif \
		doc/*.png \
		doc/libxml2-api.xml debian/tmp/usr/share/doc/libxml2-doc
	install -m 644 \
		doc/examples/*.c \
		doc/examples/*.res \
		doc/examples/index.html \
		doc/examples/[tw]*.xml debian/tmp/usr/share/doc/libxml2-doc/examples
	cp -a \
		doc/html \
		doc/tutorial debian/tmp/usr/share/doc/libxml2-doc

install-python%-dbg:
	$(MAKE) -C build/python$*-dbg DESTDIR=$(CURDIR)/debian/tmp-dbg install-pythonLTLIBRARIES
	prename s/.so$$/_d.so/ debian/tmp-dbg/usr/lib/python$*/*-packages/*.so

install-python%:
	dh_auto_install --builddirectory=build/python$*

override_dh_installdocs:
	dh_installdocs -A AUTHORS TODO README NEWS
	dh_installdocs -ppython-libxml2 python/TODO

override_dh_compress:
	dh_compress -Xexamples/ -Xtutorial/ -Xhtml/ -X.html

override_dh_installchangelogs:
	dh_installchangelogs -plibxml2 ChangeLog
	dh_installchangelogs -Nlibxml2 -XChangeLog

override_dh_install:
	dh_install -Npython-libxml2-dbg
	dh_install -ppython-libxml2-dbg --sourcedir=debian/tmp-dbg
	sed "/dependency_libs/ s/'.*'/''/" debian/tmp/usr/lib/libxml2.la > debian/libxml2-dev/usr/lib/libxml2.la

override_dh_strip:
	dh_strip -a --dbg-package=libxml2-dbg -Npython-libxml2 -Npython-libxml2-dbg
	dh_strip -ppython-libxml2 --dbg-package=python-libxml2-dbg
	$(foreach python, $(filter-out $(PYVER), $(PYVERS)),\
		cd $(CURDIR)/debian/python-libxml2/usr/lib/pyshared; \
		if diff $(python)/libxml2mod.so $(PYVER)/libxml2mod.so > /dev/null 2>&1; then \
			rm -f $(python)/libxml2mod.so; \
			ln -s ../$(PYVER)/libxml2mod.so $(python)/libxml2mod.so; \
		fi;)

override_dh_makeshlibs:
	dh_makeshlibs -a -V 'libxml2 (>= 2.7.4)' -- -c4

%:
	dh $@