mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-27 05:20:50 +00:00
libselinux: build: follow standard semantics for DESTDIR and PREFIX
This patch solves the following issues: - The pkg-config files generates odd paths when using DESTDIR without PREFIX - DESTDIR is needed during compile time to compute library and header paths which it should not. - Installing with both DESTDIR and PREFIX set gives us odd paths - Make usage of DESTDIR and PREFIX more standard Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
This commit is contained in:
parent
f8532f1773
commit
b24980ec07
@ -1,12 +1,12 @@
|
||||
# Installation directories.
|
||||
PREFIX ?= $(DESTDIR)/usr
|
||||
INCDIR ?= $(PREFIX)/include/selinux
|
||||
PREFIX ?= /usr
|
||||
INCDIR = $(PREFIX)/include/selinux
|
||||
|
||||
all:
|
||||
|
||||
install: all
|
||||
test -d $(INCDIR) || install -m 755 -d $(INCDIR)
|
||||
install -m 644 $(wildcard selinux/*.h) $(INCDIR)
|
||||
test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
|
||||
install -m 644 $(wildcard selinux/*.h) $(DESTDIR)$(INCDIR)
|
||||
|
||||
relabel:
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
# Installation directories.
|
||||
MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
|
||||
MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
|
||||
MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
|
||||
PREFIX ?= /usr
|
||||
MAN8DIR ?= $(PREFIX)/share/man/man8
|
||||
MAN5DIR ?= $(PREFIX)/share/man/man5
|
||||
MAN3DIR ?= $(PREFIX)/share/man/man3
|
||||
|
||||
all:
|
||||
|
||||
install: all
|
||||
mkdir -p $(MAN3DIR)
|
||||
mkdir -p $(MAN5DIR)
|
||||
mkdir -p $(MAN8DIR)
|
||||
install -m 644 man3/*.3 $(MAN3DIR)
|
||||
install -m 644 man5/*.5 $(MAN5DIR)
|
||||
install -m 644 man8/*.8 $(MAN8DIR)
|
||||
mkdir -p $(DESTDIR)$(MAN3DIR)
|
||||
mkdir -p $(DESTDIR)$(MAN5DIR)
|
||||
mkdir -p $(DESTDIR)$(MAN8DIR)
|
||||
install -m 644 man3/*.3 $(DESTDIR)$(MAN3DIR)
|
||||
install -m 644 man5/*.5 $(DESTDIR)$(MAN5DIR)
|
||||
install -m 644 man8/*.8 $(DESTDIR)$(MAN8DIR)
|
||||
|
||||
relabel:
|
||||
|
||||
|
@ -8,19 +8,17 @@ RUBYPREFIX ?= $(notdir $(RUBY))
|
||||
PKG_CONFIG ?= pkg-config
|
||||
|
||||
# Installation directories.
|
||||
PREFIX ?= $(DESTDIR)/usr
|
||||
PREFIX ?= /usr
|
||||
LIBDIR ?= $(PREFIX)/lib
|
||||
SHLIBDIR ?= $(DESTDIR)/lib
|
||||
SHLIBDIR ?= /lib
|
||||
INCLUDEDIR ?= $(PREFIX)/include
|
||||
PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
|
||||
PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
|
||||
PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
|
||||
PYSITEDIR ?= $(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
|
||||
PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixes() if t == imp.C_EXTENSION][0])')
|
||||
RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
|
||||
RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
|
||||
RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
|
||||
LIBBASE ?= $(shell basename $(LIBDIR))
|
||||
LIBSEPOLA ?= $(LIBDIR)/libsepol.a
|
||||
RUBYINSTALL ?= $(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
|
||||
|
||||
VERSION = $(shell cat ../VERSION)
|
||||
LIBVERSION = 1
|
||||
@ -50,6 +48,13 @@ LIBSO=$(TARGET).$(LIBVERSION)
|
||||
AUDIT2WHYLOBJ=$(PYPREFIX)audit2why.lo
|
||||
AUDIT2WHYSO=$(PYPREFIX)audit2why.so
|
||||
|
||||
# If no specific libsepol.a is specified, fall back on LDFLAGS search path
|
||||
# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
|
||||
# is no need to define a value for LDLIBS_LIBSEPOLA
|
||||
ifeq ($(LIBSEPOLA),)
|
||||
LDLIBS_LIBSEPOLA := -l:libsepol.a
|
||||
endif
|
||||
|
||||
GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) selinuxswig_python_exception.i
|
||||
SRCS= $(filter-out $(GENERATED) audit2why.c, $(sort $(wildcard *.c)))
|
||||
|
||||
@ -148,7 +153,7 @@ $(LIBSO): $(LOBJS)
|
||||
ln -sf $@ $(TARGET)
|
||||
|
||||
$(LIBPC): $(LIBPC).in ../VERSION
|
||||
sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):; s:@PCRE_MODULE@:$(PCRE_MODULE):' < $< > $@
|
||||
sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):; s:@PCRE_MODULE@:$(PCRE_MODULE):' < $< > $@
|
||||
|
||||
selinuxswig_python_exception.i: ../include/selinux/selinux.h
|
||||
bash -e exception.sh > $@ || (rm -f $@ ; false)
|
||||
@ -157,7 +162,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
|
||||
$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
|
||||
|
||||
$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(LDLIBS_LIBSEPOLA) $(PYLIBS)
|
||||
|
||||
%.o: %.c policy.h
|
||||
$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
|
||||
@ -177,26 +182,26 @@ swigify: $(SWIGIF)
|
||||
$(SWIG) $<
|
||||
|
||||
install: all
|
||||
test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
|
||||
install -m 644 $(LIBA) $(LIBDIR)
|
||||
test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
|
||||
install -m 755 $(LIBSO) $(SHLIBDIR)
|
||||
test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
|
||||
install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
|
||||
ln -sf --relative $(SHLIBDIR)/$(LIBSO) $(LIBDIR)/$(TARGET)
|
||||
test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
|
||||
install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
|
||||
test -d $(DESTDIR)$(SHLIBDIR) || install -m 755 -d $(DESTDIR)$(SHLIBDIR)
|
||||
install -m 755 $(LIBSO) $(DESTDIR)$(SHLIBDIR)
|
||||
test -d $(DESTDIR)$(LIBDIR)/pkgconfig || install -m 755 -d $(DESTDIR)$(LIBDIR)/pkgconfig
|
||||
install -m 644 $(LIBPC) $(DESTDIR)$(LIBDIR)/pkgconfig
|
||||
ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
|
||||
|
||||
install-pywrap: pywrap
|
||||
test -d $(PYSITEDIR)/selinux || install -m 755 -d $(PYSITEDIR)/selinux
|
||||
install -m 755 $(SWIGSO) $(PYSITEDIR)/_selinux$(PYCEXT)
|
||||
install -m 755 $(AUDIT2WHYSO) $(PYSITEDIR)/selinux/audit2why$(PYCEXT)
|
||||
install -m 644 $(SWIGPYOUT) $(PYSITEDIR)/selinux/__init__.py
|
||||
test -d $(DESTDIR)$(PYSITEDIR)/selinux || install -m 755 -d $(DESTDIR)$(PYSITEDIR)/selinux
|
||||
install -m 755 $(SWIGSO) $(DESTDIR)$(PYSITEDIR)/_selinux$(PYCEXT)
|
||||
install -m 755 $(AUDIT2WHYSO) $(DESTDIR)$(PYSITEDIR)/selinux/audit2why$(PYCEXT)
|
||||
install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYSITEDIR)/selinux/__init__.py
|
||||
|
||||
install-rubywrap: rubywrap
|
||||
test -d $(RUBYINSTALL) || install -m 755 -d $(RUBYINSTALL)
|
||||
install -m 755 $(SWIGRUBYSO) $(RUBYINSTALL)/selinux.so
|
||||
test -d $(DESTDIR)$(RUBYINSTALL) || install -m 755 -d $(DESTDIR)$(RUBYINSTALL)
|
||||
install -m 755 $(SWIGRUBYSO) $(DESTDIR)$(RUBYINSTALL)/selinux.so
|
||||
|
||||
relabel:
|
||||
/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
|
||||
/sbin/restorecon $(DESTDIR)$(SHLIBDIR)/$(LIBSO)
|
||||
|
||||
clean-pywrap:
|
||||
-rm -f $(SWIGLOBJ) $(SWIGSO) $(AUDIT2WHYLOBJ) $(AUDIT2WHYSO)
|
||||
|
@ -1,6 +1,6 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/@libdir@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: libselinux
|
||||
|
@ -1,8 +1,6 @@
|
||||
# Installation directories.
|
||||
PREFIX ?= $(DESTDIR)/usr
|
||||
LIBDIR ?= $(PREFIX)/lib
|
||||
PREFIX ?= /usr
|
||||
SBINDIR ?= $(PREFIX)/sbin
|
||||
INCLUDEDIR ?= $(PREFIX)/include
|
||||
|
||||
OS ?= $(shell uname)
|
||||
|
||||
@ -63,8 +61,8 @@ sefcontext_compile: sefcontext_compile.o ../src/regex.o
|
||||
all: $(TARGETS)
|
||||
|
||||
install: all
|
||||
-mkdir -p $(SBINDIR)
|
||||
install -m 755 $(TARGETS) $(SBINDIR)
|
||||
-mkdir -p $(DESTDIR)$(SBINDIR)
|
||||
install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS) *.o *~
|
||||
|
Loading…
Reference in New Issue
Block a user