xref: /OK3568_Linux_fs/buildroot/package/setools/setools.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# setools
4#
5################################################################################
6
7SETOOLS_VERSION = 4.4.0
8SETOOLS_SITE = $(call github,SELinuxProject,setools,$(SETOOLS_VERSION))
9SETOOLS_DEPENDENCIES = libselinux libsepol python-setuptools host-bison host-flex host-python-cython host-swig
10SETOOLS_INSTALL_STAGING = YES
11SETOOLS_LICENSE = GPL-2.0+, LGPL-2.1+
12SETOOLS_LICENSE_FILES = COPYING COPYING.GPL COPYING.LGPL
13SETOOLS_CPE_ID_VENDOR = selinuxproject
14SETOOLS_SETUP_TYPE = setuptools
15HOST_SETOOLS_DEPENDENCIES = host-python3-cython host-libselinux host-libsepol host-python-networkx
16HOST_SETOOLS_NEEDS_HOST_PYTHON = python3
17
18define SETOOLS_FIX_SETUP
19	# By default, setup.py will look for libsepol.a in the host machines
20	# /usr/lib directory. This needs to be changed to the staging directory.
21	$(SED) "s@lib_dirs =.*@lib_dirs = ['$(STAGING_DIR)/usr/lib']@g" \
22		$(@D)/setup.py
23endef
24SETOOLS_POST_PATCH_HOOKS += SETOOLS_FIX_SETUP
25
26define HOST_SETOOLS_FIX_SETUP
27	# By default, setup.py will look for libsepol.a in the host machines
28	# /usr/lib directory. This needs to be changed to the host directory.
29	$(SED) "s@lib_dirs =.*@lib_dirs = ['$(HOST_DIR)/lib']@g" \
30		$(@D)/setup.py
31endef
32HOST_SETOOLS_POST_PATCH_HOOKS += HOST_SETOOLS_FIX_SETUP
33
34# apol requires pyqt5. However, the setools installation
35# process will install apol even if pyqt5 is missing.
36# Remove these scripts from the target it pyqt5 is not selected.
37ifeq ($(BR2_PACKAGE_PYTHON_PYQT5),)
38define SETOOLS_REMOVE_QT_SCRIPTS
39	$(RM) $(TARGET_DIR)/usr/bin/apol
40	$(RM) -r $(TARGET_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/setoolsgui/
41endef
42SETOOLS_POST_INSTALL_TARGET_HOOKS += SETOOLS_REMOVE_QT_SCRIPTS
43endif
44
45# pyqt5 is not a host-package, remove apol from the host directory.
46define HOST_SETOOLS_REMOVE_BROKEN_SCRIPTS
47	$(RM) $(HOST_DIR)/bin/apol
48endef
49HOST_SETOOLS_POST_INSTALL_HOOKS += HOST_SETOOLS_REMOVE_BROKEN_SCRIPTS
50
51$(eval $(python-package))
52$(eval $(host-python-package))
53