File: rules

package info (click to toggle)
marisa 0.2.6-18
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,560 kB
  • sloc: cpp: 21,422; perl: 370; python: 307; makefile: 228; ruby: 129; ansic: 119; sh: 65
file content (103 lines) | stat: -rwxr-xr-x 3,744 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
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=+lto
export DEB_LDFLAGS_MAINT_APPEND =

# Retrieve package version information
include /usr/share/dpkg/pkg-info.mk

# Retrieve variables like DEB_HOST_MULTIARCH
include /usr/share/dpkg/architecture.mk

# These commands build the list of supported Python 3 versions
# The last version should be just “python3” so that the scripts
# get a correct shebang.
# Use just “PYTHON3 := $(shell py3versions -r)” if your package
# doesn’t contain scripts
PY3REQUESTED := $(shell py3versions -r)
PY3DEFAULT := $(shell py3versions -d)
PYTHON3 := $(filter-out $(PY3DEFAULT),$(PY3REQUESTED)) python3

# For set install path of perl modules.
PERL_VENDOR_ARCH=$(shell perl -V:vendorarch|cut -d\' -f2)


%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure
	make -C bindings
	cd bindings/python; sed -i "s/__version__/$(DEB_VERSION_UPSTREAM)/" setup.py

override_dh_auto_build:
	dh_auto_build
	cd bindings/perl; perl Makefile.PL \
	    INSTALL_BASE=$(CURDIR)/debian/libmarisa-perl/usr \
	    INSTALLARCHLIB=$(CURDIR)/debian/libmarisa-perl$(PERL_VENDOR_ARCH) \
	    INSTALLSITEARCH=$(CURDIR)/debian/libmarisa-perl$(PERL_VENDOR_ARCH) \
	    INSTALLVENDORARCH=$(CURDIR)/debian/libmarisa-perl$(PERL_VENDOR_ARCH) \
	    INC="-I../../include" \
	    LIBS="-L../../lib/marisa/.libs -lmarisa" \
	    CCFLAGS="$(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)" \
	    LDDLFLAGS="-shared -L/usr/local/lib -fstack-protector $(shell dpkg-buildflags --get LDFLAGS)"
	# Build for each Python 3 version
	cd bindings/python; \
	    set -ex; for python in $(PYTHON3); do \
	    $$python setup.py build_ext --include-dirs=../../include \
	        --library-dirs=../../lib/marisa/.libs; \
	    done
	cd bindings/perl; make
	# extconf.rb needs to exist library when configure
	cd bindings/ruby; ruby extconf.rb --with-opt-include=../../include \
	    --with-opt-lib=../../lib/marisa/.libs
	# set verbose option for compiling
	sed -i 's/^V = 0/V = 1/' bindings/ruby/Makefile
	sed -i 's%^sitearchdir = .*%sitearchdir = $$(exec_prefix)/lib/$(DEB_HOST_MULTIARCH)/ruby/$$(ruby_version)%' bindings/ruby/Makefile
	cd bindings/ruby; make

override_dh_auto_install:
	dh_auto_install
	# Remove .la files
	rm debian/tmp/usr/lib/*/libmarisa.la
	# The same for install; note the --install-layout=deb option
	cd bindings/python; \
	    set -ex; for python in $(PYTHON3); do \
	    $$python setup.py install \
	        --root=$(CURDIR)/debian/python3-marisa --install-layout=deb; \
	    done
	# install perl modules
	# remove RPATH in perl-related so file
	( cd bindings/perl; find . -name "*.so*" -type f -exec chrpath --delete {} \; )
	( cd bindings/perl ; make install )
	rm $(CURDIR)/debian/libmarisa-perl$(PERL_VENDOR_ARCH)/auto/marisa/.packlist
	rm $(CURDIR)/debian/libmarisa-perl$(PERL_VENDOR_ARCH)/perllocal.pod
	rm $(CURDIR)/debian/libmarisa-perl$(PERL_VENDOR_ARCH)/sample.pl
	# install ruby modules
	cd bindings/ruby; make install DESTDIR=$(CURDIR)/debian/ruby-marisa

# record minimum ruby version requirement
# see https://bugs.debian.org/1006289
override_dh_gencontrol:
	dh_gencontrol -- \
	        -V"ruby:Build-Version=$$(dpkg-query -f='$${Version}' -W ruby)"

# hack to allow one to build twice
# see https://bugs.debian.org/1047554, https://bugs.debian.org/1049679
execute_before_dh_autoreconf:
	cp -pR bindings bindings.bak
	cp -pR tests tests.bak

execute_after_dh_clean:
	if [ -e bindings.bak ]; then \
		rm -rf bindings; \
		mv bindings.bak bindings; \
	fi
	if [ -e tests.bak ]; then \
		rm -rf tests; \
		mv tests.bak tests; \
	fi