File: rules

package info (click to toggle)
libselinux 3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,348 kB
  • sloc: ansic: 17,687; makefile: 401; sh: 78; python: 21
file content (92 lines) | stat: -rwxr-xr-x 3,008 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
#! /usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_BUILD_MAINT_OPTIONS := hardening=+all optimize=+lto

include /usr/share/dpkg/architecture.mk
libdir := /usr/lib/$(DEB_HOST_MULTIARCH)

include /usr/share/dpkg/buildtools.mk
# for cross compilation
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_MULTIARCH)
  # When ruby_env is expanded, $* is the ruby interpreter.
  ruby_env = RUBYLIB=$(libdir)/ruby-crossbuild/$$($* -e "puts RbConfig::CONFIG['ruby_version']")
endif

include /usr/share/dpkg/buildopts.mk
MAKEFLAGS += $(DEB_BUILD_OPTION_PARALLEL:%=-j%)

# Use of lstat64 requires this macro.
export DEB_CPPFLAGS_MAINT_APPEND += -D_LARGEFILE64_SOURCE

# Upstream recommends using this flag
DEB_CFLAGS_MAINT_APPEND := -fno-semantic-interposition
# Enable Wall and Wextra to spot basic irregularities.
DEB_CFLAGS_MAINT_APPEND += -Wall -Wextra
DPKG_EXPORT_BUILDFLAGS := 1
include /usr/share/dpkg/buildflags.mk
# The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable
# the missing (hardening) flags.
export CFLAGS += $(CPPFLAGS)

DOPACKAGES := $(shell dh_listpackages)
ifneq ($(filter python3-selinux,$(DOPACKAGES)),)
  PY3VERSIONS := $(shell py3versions -rv)
endif
ifneq ($(filter ruby-selinux,$(DOPACKAGES)),)
  RUBY_VERSIONS := $(shell dh_ruby --print-supported)
endif

%:
	dh $@

## Set up some variables to be passed to the upstream Makefile
extra_make_args := ARCH=$(patsubst i%86,i386,$(DEB_HOST_GNU_CPU))
extra_make_args += USE_PCRE2=y

override_dh_auto_build: $(PY3VERSIONS:%=build-python-%) $(RUBY_VERSIONS:%=build-ruby-%) build-all

build-all:
	$(MAKE) all $(extra_make_args)

build-python-%: build-all
	$(MAKE) pywrap $(extra_make_args) PYTHON=python$*

build-ruby-%: build-all
	$(ruby_env) $(MAKE) rubywrap $(extra_make_args) RUBY=$*

destdir := '$(CURDIR)/debian/tmp'

override_dh_auto_install: $(PY3VERSIONS:%=install-python-%) \
                          $(RUBY_VERSIONS:%=install-ruby-%)
	$(MAKE) install $(extra_make_args) DESTDIR=$(destdir) \
	  LIBDIR=$(libdir) \
	  SHLIBDIR=$(libdir)
  # Patch the python installations.
	find $(destdir) -name direct_url.json -delete
	find $(destdir) -name RECORD -exec sed -i '/\/direct_url.json,/d' {} +

install-python-%:
	$(MAKE) install-pywrap $(extra_make_args) PYTHON=python$* DESTDIR=$(destdir) DEB_PYTHON_INSTALL_LAYOUT=deb

install-ruby-%:
	$(ruby_env) \
	$(MAKE) install-rubywrap $(extra_make_args) RUBY=$* DESTDIR=$(destdir)

execute_before_dh_installdeb-arch:
	sed -e"s/#DEB_HOST_MULTIARCH#/$(DEB_HOST_MULTIARCH)/g" debian/libselinux1.triggers.in > debian/libselinux1.triggers

override_dh_auto_clean: $(PY3VERSIONS:%=clean-python-%) \
                        $(RUBY_VERSIONS:%=clean-ruby-%)
	rm -f utils/getpolicyload
	$(MAKE) distclean $(extra_make_args) PYTHON=true

clean-python-%:
	$(MAKE) clean-pywrap $(extra_make_args) PYTHON=python$*

clean-ruby-%:
	$(ruby_env) \
	$(MAKE) clean-rubywrap $(extra_make_args) RUBY=$*