]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/libselinux/libselinux.mk
libselinux: query for python site-packages dir directly
[coffee/buildroot.git] / package / libselinux / libselinux.mk
1 ################################################################################
2 #
3 # libselinux
4 #
5 ################################################################################
6
7 LIBSELINUX_VERSION = 2.6
8 LIBSELINUX_SITE = https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20161014
9 LIBSELINUX_LICENSE = Public Domain
10 LIBSELINUX_LICENSE_FILES = LICENSE
11
12 LIBSELINUX_DEPENDENCIES = libsepol pcre
13
14 LIBSELINUX_INSTALL_STAGING = YES
15
16 # Filter out D_FILE_OFFSET_BITS=64. This fixes errors caused by glibc 2.22.
17 LIBSELINUX_MAKE_OPTS = \
18         $(TARGET_CONFIGURE_OPTS) \
19         CFLAGS="$(filter-out -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS))" \
20         LDFLAGS="$(TARGET_LDFLAGS) -lpcre -lpthread" \
21         ARCH=$(KERNEL_ARCH)
22
23 define LIBSELINUX_BUILD_CMDS
24         # DESTDIR is needed during the compile to compute library and
25         # header paths.
26         $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
27                 $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) all
28 endef
29
30 define LIBSELINUX_INSTALL_STAGING_CMDS
31         $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
32                 $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) install
33 endef
34
35 define LIBSELINUX_INSTALL_TARGET_CMDS
36         $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
37                 $(LIBSELINUX_MAKE_OPTS) DESTDIR=$(TARGET_DIR) install
38         # Create the selinuxfs mount point
39         if [ ! -d "$(TARGET_DIR)/selinux" ]; then mkdir $(TARGET_DIR)/selinux; fi
40         if ! grep -q "selinuxfs" $(TARGET_DIR)/etc/fstab; then \
41                 echo "none /selinux selinuxfs noauto 0 0" >> $(TARGET_DIR)/etc/fstab ; fi
42 endef
43
44 HOST_LIBSELINUX_DEPENDENCIES = \
45         host-libsepol host-pcre host-swig
46
47 ifeq ($(BR2_PACKAGE_PYTHON3),y)
48 HOST_LIBSELINUX_DEPENDENCIES += host-python3
49 HOST_LIBSELINUX_PYINC = -I$(HOST_DIR)/usr/include/python$(PYTHON3_VERSION_MAJOR)m/
50 HOST_LIBSELINUX_PYLIBVER = python$(PYTHON3_VERSION_MAJOR)
51 else
52 HOST_LIBSELINUX_DEPENDENCIES += host-python
53 HOST_LIBSELINUX_PYINC = -I$(HOST_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR)/
54 HOST_LIBSELINUX_PYLIBVER = python$(PYTHON_VERSION_MAJOR)
55 endif
56
57 HOST_LIBSELINUX_MAKE_OPTS = \
58         $(HOST_CONFIGURE_OPTS) \
59         LDFLAGS="$(HOST_LDFLAGS) -lpcre -lpthread" \
60         PYINC="$(HOST_LIBSELINUX_PYINC)" \
61         PYSITEDIR="$(HOST_DIR)/usr/lib/$(HOST_LIBSELINUX_PYLIBVER)/site-packages" \
62         SWIG_LIB="$(HOST_DIR)/usr/share/swig/$(SWIG_VERSION)/"
63
64 define HOST_LIBSELINUX_BUILD_CMDS
65         # DESTDIR is needed during the compile to compute library and
66         # header paths.
67         $(HOST_MAKE_ENV) $(MAKE1) -C $(@D) \
68                 $(HOST_LIBSELINUX_MAKE_OPTS) DESTDIR=$(HOST_DIR) \
69                 SHLIBDIR=$(HOST_DIR)/usr/lib all
70         # Generate python interface wrapper
71         $(HOST_MAKE_ENV) $(MAKE1) -C $(@D) \
72                 $(HOST_LIBSELINUX_MAKE_OPTS) DESTDIR=$(HOST_DIR) swigify pywrap
73 endef
74
75 define HOST_LIBSELINUX_INSTALL_CMDS
76         $(HOST_MAKE_ENV) $(MAKE) -C $(@D) \
77                 $(HOST_LIBSELINUX_MAKE_OPTS) DESTDIR=$(HOST_DIR) \
78                 SHLIBDIR=$(HOST_DIR)/usr/lib SBINDIR=$(HOST_DIR)/usr/sbin install
79         (cd $(HOST_DIR)/usr/lib; $(HOSTLN) -sf libselinux.so.1 libselinux.so)
80         # Install python interface wrapper
81         $(HOST_MAKE_ENV) $(MAKE) -C $(@D) \
82                 $(HOST_LIBSELINUX_MAKE_OPTS) DESTDIR=$(HOST_DIR) install-pywrap
83 endef
84
85 $(eval $(generic-package))
86 $(eval $(host-generic-package))