LDFLAGS="$(TARGET_LDFLAGS) -lpcre -lpthread" \
ARCH=$(KERNEL_ARCH)
+LIBSELINUX_MAKE_TARGETS = all
+LIBSELINUX_MAKE_INSTALL_TARGETS = install
+
+ifeq ($(BR2_PACKAGE_PYTHON)$(BR2_PACKAGE_PYTHON3),y)
+ifeq ($(BR2_PACKAGE_PYTHON3),y)
+LIBSELINUX_DEPENDENCIES += python3 host-swig
+LIBSELINUX_PYINC = -I$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION_MAJOR)m
+LIBSELINUX_PYLIBVER = python$(PYTHON3_VERSION_MAJOR)
+else ifeq ($(BR2_PACKAGE_PYTHON),y)
+LIBSELINUX_DEPENDENCIES += python host-swig
+LIBSELINUX_PYINC = -I$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR)
+LIBSELINUX_PYLIBVER = python$(PYTHON_VERSION_MAJOR)
+endif
+
+LIBSELINUX_MAKE_OPTS += \
+ PYINC="$(LIBSELINUX_PYINC)" \
+ PYSITEDIR=$(TARGET_DIR)/usr/lib/$(LIBSELINUX_PYLIBVER)/site-packages \
+ SWIG_LIB="$(HOST_DIR)/usr/share/swig/$(SWIG_VERSION)/"
+
+LIBSELINUX_MAKE_TARGETS += swigify pywrap
+LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap
+endif # python || python3
+
define LIBSELINUX_BUILD_CMDS
# DESTDIR is needed during the compile to compute library and
# header paths.
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
- $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) all
+ $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) \
+ $(LIBSELINUX_MAKE_TARGETS)
endef
define LIBSELINUX_INSTALL_STAGING_CMDS
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
- $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) install
+ $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) \
+ $(LIBSELINUX_MAKE_INSTALL_TARGETS)
endef
define LIBSELINUX_INSTALL_TARGET_CMDS