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
|
#! /usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
## Figure out some variables
DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_GNU_CPU := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR_LIBSEPOL := $(shell pkg-config --variable=libdir libsepol)
PREFIX = /usr
BUILT_USING=$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W "libsepol1-dev")
## Default target
binary:
## Sanity check
ifneq ($(DEB_HOST_ARCH_OS),linux)
$(error This is a linux only package. Aborting build.)
endif
## The build system doesn't use CPPFLAGS, pass them to CFLAGS to enable the
## missing (hardening) flags.
export DEB_CFLAGS_MAINT_APPEND = $(shell dpkg-buildflags --get CPPFLAGS)
## Unconditionally run debhelper command targets
.PHONY: FORCE
FORCE:
## By default, pass everything through debhelper automatically
export DH_OPTIONS
%: FORCE
ifeq ($(DEB_STAGE),stage1)
@dh $@
else
@dh $@ --with=python2,python3,ruby
endif
## Don't try to rebuild the debian/rules file
debian/rules:
@touch $@
## Skip python/ruby packages during stage1 build
ifeq ($(DEB_STAGE),stage1)
DH_OPTIONS += -Npython-selinux -Nruby-selinux -Npython3-selinux
endif
## Set up some variables to be passed to the upstream Makefile
extra_make_args = LIBSEPOLA=$(LIBDIR_LIBSEPOL)/libsepol.a
extra_make_args += ARCH=$(DEB_HOST_GNU_CPU)
extra_make_args += CC=$(DEB_HOST_GNU_TYPE)-gcc
override_dh_auto_build: FORCE
+$(MAKE) PREFIX="$(PREFIX)" LIBBASE="lib/${DEB_HOST_MULTIARCH}" $(extra_make_args) all
## Work around the very limited SELinux build-system
DESTDIR = $(CURDIR)/debian/tmp
base_extra_install_args = $(extra_make_args)
base_extra_install_args += DESTDIR=$(DESTDIR)
extra_install_args = $(base_extra_install_args) LIBDIR=$(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)
extra_install_args += SHLIBDIR=$(DESTDIR)/lib/$(DEB_HOST_MULTIARCH)
python_extra_install_args = $(base_extra_install_args) LIBDIR=$(DESTDIR)/usr/lib
override_dh_auto_install: FORCE
+$(MAKE) PREFIX="$(DESTDIR)$(PREFIX)" $(extra_install_args) install
@# Fix up the broken library symlink
rm -f $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/libselinux.so
ln -s /lib/$(DEB_HOST_MULTIARCH)/libselinux.so.1 $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/libselinux.so
ifneq ($(DEB_STAGE),stage1)
+$(MAKE) PREFIX="$(PREFIX)" $(python_extra_install_args) -f debian/python.mk
+$(MAKE) PREFIX="$(PREFIX)" $(extra_install_args) -f debian/ruby.mk
else
@echo "Detected stage-1 bootstrap, skipping python/ruby bindings..."
endif
## Generate a hard error for any upstream files we don't install
override_dh_install: FORCE
dh_install --fail-missing
override_dh_gencontrol:
dh_gencontrol -- -VBuilt-Using="$(BUILT_USING)"
override_dh_makeshlibs:
dh_makeshlibs -plibselinux1 --add-udeb="libselinux1-udeb"
dh_makeshlibs --remaining-packages
|