Skip to content

Inconsistent installation path for libsepol.so breaks DESTDIR-based cross-compilation #494

@Sdup1dXXY

Description

@Sdup1dXXY

Hi SELinux maintainers,

While cross-compiling libsepol for an embedded target, I noticed an inconsistency in the installation paths defined in the top-level Makefile:

  • Static library (libsepol.a) and .pc file are installed to:
    $(DESTDIR)$(LIBDIR) → typically /usr/lib under PREFIX
  • Shared library (libsepol.so.X.Y) is installed to:
    $(DESTDIR)$(SHLIBDIR) → hardcoded as /lib, outside of PREFIX

This causes the actual .so file to be installed into my host system’s /lib, rather than under the intended staging directory ($(PREFIX)/lib), which breaks packaging and pollutes the host system during cross-compilation.

Here's the Makefile in the src directory of the libsepol source:

PREFIX ?= /usr
INCLUDEDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
SHLIBDIR ?= /lib
RANLIB ?= ranlib
CILDIR ?= ../cil

......

install: all
        test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
        install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
        test -d $(DESTDIR)$(LIBDIR)/pkgconfig || install -m 755 -d $(DESTDIR)$(LIBDIR)/pkgconfig
        install -m 644 $(LIBPC) $(DESTDIR)$(LIBDIR)/pkgconfig
ifneq ($(DISABLE_SHARED),y)
        test -d $(DESTDIR)$(SHLIBDIR) || install -m 755 -d $(DESTDIR)$(SHLIBDIR)
        install -m 755 $(LIBSO) $(DESTDIR)$(SHLIBDIR)
        $(LN) -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions