Skip to contentSkip to conversation

Rework of Makefiles v2

PATCH Superseded Marcus Folkesson 3 participants 26 messages Jan 16, 2018 – Jan 24, 2018

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

Hi,

I have updated the patchset.

Please test to compile with:
make DESTDIR=/tmp/myroot PREFIX=/myusr install

Changes:
v2:
- Use separate directories for shared libraries as before( Comment from Stephen Smalley)
- Rework all packages (not just selinux/sepol/semanage)

Best regards
Marcus Folkesson

#1 lore raw

PATCH v2 1/14 libsepol: 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

---
 README                      | 2 +-
 libsepol/include/Makefile   | 4 ++--
 libsepol/man/Makefile       | 5 +++--
 libsepol/src/Makefile       | 7 +++----
 libsepol/src/libsepol.pc.in | 2 +-
 libsepol/utils/Makefile     | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)
README +1 -1
index 7fc7b17b..174551a1 100644
@@ -19,6 +19,6 @@ lacks library functions or other dependencies relied upon by your
 distribution.  If it breaks, you get to keep both pieces.
 
 To install libsepol on macOS (mainly for policy analysis):
-cd libsepol; make DESTDIR=/usr/local PREFIX=/usr/local install
+cd libsepol; make PREFIX=/usr/local install
 
 This requires GNU coreutils (brew install coreutils).
libsepol/include/Makefile +2 -2
index 56b7a114..ad5c34a4 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/sepol
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/sepol
 CILDIR ?= ../cil
 
 all:
libsepol/man/Makefile +3 -2
index 11924334..4f3d9fa2 100644
@@ -1,6 +1,7 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libsepol/src/Makefile +3 -4
index 819d261b..d158398f 100644
@@ -1,10 +1,9 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 INCLUDEDIR ?= $(PREFIX)/include
-LIBDIR ?= $(PREFIX)/lib
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 RANLIB ?= ranlib
-LIBBASE ?= $(shell basename $(LIBDIR))
 CILDIR ?= ../cil
 
 VERSION = $(shell cat ../VERSION)
@@ -52,7 +51,7 @@ $(LIBSO): $(LOBJS) $(LIBMAP)
 	ln -sf $@ $(TARGET) 
 
 $(LIBPC): $(LIBPC).in ../VERSION
-	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
+	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
 
 $(LIBMAP): $(LIBMAP).in
 ifneq ($(DISABLE_CIL),y)
libsepol/src/libsepol.pc.in +1 -1
index e52f5892..f807fec6 100644
@@ -1,6 +1,6 @@
 prefix=@prefix@
 exec_prefix=${prefix}
-libdir=${exec_prefix}/@libdir@
+libdir=@libdir@
 includedir=@includedir@
 
 Name: libsepol
libsepol/utils/Makefile +2 -2
index fba1d8a0..8ce4bf47 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
 
 CFLAGS ?= -Wall -Werror
 override CFLAGS += -I../include
Signature · 1 line
2.15.1
#2 lore raw

PATCH v2 2/14 libselinux: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX	?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +5 -7
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a
 
 %.o:  %.c policy.h
 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
libselinux/src/libselinux.pc.in +1 -1
index 2e90a844..7c66b1fa 100644
@@ -1,6 +1,6 @@
 prefix=@prefix@
 exec_prefix=${prefix}
-libdir=${exec_prefix}/@libdir@
+libdir=@libdir@
 includedir=@includedir@
 
 Name: libselinux
libselinux/utils/Makefile +2 -4
index eb4851a9..9adce6d3 100644
@@ -1,8 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
 
 OS ?= $(shell uname)
 
Signature · 1 line
2.15.1
#10 lore raw

PATCH v2 3/14 libsemanage: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson

This patch solves the following issues:
- 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

---
 libsemanage/include/Makefile      | 4 ++--
 libsemanage/man/Makefile          | 5 +++--
 libsemanage/src/Makefile          | 9 +++------
 libsemanage/src/libsemanage.pc.in | 2 +-
 libsemanage/tests/Makefile        | 3 ---
 libsemanage/utils/Makefile        | 4 ++--
 6 files changed, 11 insertions(+), 16 deletions(-)
libsemanage/include/Makefile +2 -2
index b660660e..f4234b9e 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/semanage
+PREFIX ?= /usr
+INCDIR ?= $(DESTDIR)$(PREFIX)/include/semanage
 
 all:
 
libsemanage/man/Makefile +3 -2
index 852043d4..43c2b3f6 100644
@@ -1,6 +1,7 @@
 # Installation directories.
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
+PREFIX ?= /usr
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
 
 all:
 
libsemanage/src/Makefile +3 -6
index fdb178f5..f66d1b73 100644
@@ -8,9 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SHLIBDIR ?= $(DESTDIR)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
@@ -20,8 +19,6 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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))
-
 DEFAULT_SEMANAGE_CONF_LOCATION=$(DESTDIR)/etc/selinux/semanage.conf
 
 ifeq ($(DEBUG),1)
@@ -95,7 +92,7 @@ $(LIBSO): $(LOBJS)
 	ln -sf $@ $(TARGET)
 
 $(LIBPC): $(LIBPC).in ../VERSION
-	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
+	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
 
 semanageswig_python_exception.i: ../include/semanage/semanage.h
 	bash -e exception.sh > $@ || (rm -f $@ ; false)
libsemanage/src/libsemanage.pc.in +1 -1
index d3eaa062..43681ddb 100644
@@ -1,6 +1,6 @@
 prefix=@prefix@
 exec_prefix=${prefix}
-libdir=${exec_prefix}/@libdir@
+libdir=@libdir@
 includedir=@includedir@
 
 Name: libsemanage
libsemanage/tests/Makefile +0 -3
index 2ef8d30d..324766a0 100644
@@ -1,6 +1,3 @@
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-
 # Add your test source files here:
 SOURCES = $(sort $(wildcard *.c))
 
libsemanage/utils/Makefile +2 -2
index 725f0eec..f527ad07 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBEXECDIR ?= $(PREFIX)/libexec
+PREFIX ?= /usr
+LIBEXECDIR ?= $(DESTDIR)$(PREFIX)/libexec
 SELINUXEXECDIR ?= $(LIBEXECDIR)/selinux/
 
 all:
Signature · 1 line
2.15.1
#11 lore raw

PATCH v2 4/14 checkpolicy: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson

This patch solves the following issues:
- 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

---
 checkpolicy/Makefile      | 9 ++++-----
 checkpolicy/test/Makefile | 7 +++----
 2 files changed, 7 insertions(+), 9 deletions(-)
checkpolicy/Makefile +4 -5
index 68e11f2a..0c341d02 100644
@@ -1,11 +1,10 @@
 #
 # Makefile for building the checkpolicy program
 #
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 TARGETS = checkpolicy checkmodule
 
checkpolicy/test/Makefile +3 -4
index 59fa4460..8f4393d2 100644
@@ -1,10 +1,9 @@
 #
 # Makefile for building the dispol program
 #
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -g -Wall -W -Werror -O2 -pipe
Signature · 1 line
2.15.1
#12 lore raw

PATCH v2 5/14 gui: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 gui/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
gui/Makefile +5 -5
index cfe47405..5efd17d7 100644
@@ -1,9 +1,9 @@
 # Installation directories.
-PREFIX ?= ${DESTDIR}/usr
-BINDIR ?= $(PREFIX)/bin
-SHAREDIR ?= $(PREFIX)/share/system-config-selinux
-DATADIR ?= $(PREFIX)/share
-MANDIR ?= $(PREFIX)/share/man
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/system-config-selinux
+DATADIR ?= $(DESTDIR)$(PREFIX)/share
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 
 TARGETS= \
 booleansPage.py \
Signature · 1 line
2.15.1
#13 lore raw

PATCH v2 6/14 mcstrans: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 mcstrans/man/Makefile   | 3 ++-
 mcstrans/src/Makefile   | 6 +++---
 mcstrans/utils/Makefile | 6 +++---
 3 files changed, 8 insertions(+), 7 deletions(-)
mcstrans/man/Makefile +2 -1
index 8e971192..5030fa81 100644
@@ -1,5 +1,6 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
 
 all:
 
mcstrans/src/Makefile +3 -3
index 3f4a89c3..26423c29 100644
@@ -1,9 +1,9 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SBINDIR ?= $(DESTDIR)/sbin
 INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
-SYSTEMDDIR ?= $(DESTDIR)/usr/lib/systemd
+SYSTEMDDIR ?= $(DESTDIR)$(PREFIX)/lib/systemd
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 PROG_SRC=mcstrans.c  mcscolor.c  mcstransd.c  mls_level.c
mcstrans/utils/Makefile +3 -3
index 4d3cbfcb..79eb8438 100644
@@ -1,7 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Wall
Signature · 1 line
2.15.1
#14 lore raw

PATCH v2 7/14 policycoreutils: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 policycoreutils/hll/pp/Makefile      |  7 ++-----
 policycoreutils/load_policy/Makefile |  8 ++++----
 policycoreutils/man/Makefile         |  3 ++-
 policycoreutils/newrole/Makefile     |  8 ++++----
 policycoreutils/po/Makefile          |  3 ++-
 policycoreutils/run_init/Makefile    |  8 ++++----
 policycoreutils/scripts/Makefile     |  8 ++++----
 policycoreutils/secon/Makefile       |  9 ++++-----
 policycoreutils/semodule/Makefile    |  8 +++-----
 policycoreutils/sestatus/Makefile    |  8 ++++----
 policycoreutils/setfiles/Makefile    |  5 ++---
 policycoreutils/setsebool/Makefile   | 10 ++++------
 12 files changed, 39 insertions(+), 46 deletions(-)
policycoreutils/hll/pp/Makefile +2 -5
index 3401dcc9..ce58e0cf 100644
@@ -1,9 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-LIBEXECDIR ?= $(PREFIX)/libexec
+PREFIX ?= /usr
+LIBEXECDIR ?= $(DESTDIR)$(PREFIX)/libexec
 HLLDIR ?= $(LIBEXECDIR)/selinux/hll
 
 CFLAGS ?= -Werror -Wall -W
policycoreutils/load_policy/Makefile +4 -4
index b85833c2..720bf45f 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(DESTDIR)/sbin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += $(LDFLAGS) -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
policycoreutils/man/Makefile +2 -1
index 0d91cd46..8a8fbd49 100644
@@ -1,5 +1,6 @@
 # Installation directories.
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
+PREFIX ?= /usr
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
 
 all:
 
policycoreutils/newrole/Makefile +4 -4
index 196af926..4dbe6f52 100644
@@ -1,9 +1,9 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
-LOCALEDIR = /usr/share/locale
+LOCALEDIR = $(DESTDIR)$(PREFIX)/share/locale
 PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y)
 AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
 # Enable capabilities to permit newrole to generate audit records.
policycoreutils/po/Makefile +2 -1
index 58148613..c583d23a 100644
@@ -2,6 +2,7 @@
 # Makefile for the PO files (translation) catalog
 #
 
+PREFIX ?= /usr
 TOP	 = ../..
 
 # What is this package?
@@ -12,7 +13,7 @@ INSTALL_DATA	= $(INSTALL) -m 644
 INSTALL_DIR	= /usr/bin/install -d
 
 # destination directory
-INSTALL_NLS_DIR = $(DESTDIR)/usr/share/locale
+INSTALL_NLS_DIR = $(DESTDIR)$(PREFIX)/share/locale
 
 # PO catalog handling
 MSGMERGE	= msgmerge
policycoreutils/run_init/Makefile +4 -4
index 921f0b07..4178493e 100644
@@ -1,10 +1,10 @@
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR ?= $(PREFIX)/share/man
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
-LOCALEDIR ?= /usr/share/locale
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y)
 AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
 
policycoreutils/scripts/Makefile +4 -4
index d9e86ffe..cfd841ec 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(DESTDIR)/sbin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 .PHONY: all
 all: fixfiles
policycoreutils/secon/Makefile +4 -5
index 8e491d74..4ecbd57d 100644
@@ -1,9 +1,8 @@
 # secon tool - command-line context
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 
 WARNS=-Werror -W -Wall -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-format-zero-length -Wformat-nonliteral -Wformat-security -Wfloat-equal
 VERSION = $(shell cat ../VERSION)
policycoreutils/semodule/Makefile +3 -5
index fffb43ac..9d47e7e1 100644
@@ -1,9 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol -lselinux -lsemanage
policycoreutils/sestatus/Makefile +4 -4
index 41ca6832..15443800 100644
@@ -1,9 +1,9 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
-LIBDIR ?= $(PREFIX)/lib
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 
 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += -D_FILE_OFFSET_BITS=64
policycoreutils/setfiles/Makefile +2 -3
index c08e2dd1..2a384234 100644
@@ -1,8 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 SBINDIR ?= $(DESTDIR)/sbin
-MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
 AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
 
 ABORT_ON_ERRORS=$(shell grep "^\#define ABORT_ON_ERRORS" setfiles.c | awk -S '{ print $$3 }')
policycoreutils/setsebool/Makefile +4 -6
index bc254dab..cf300336 100644
@@ -1,10 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol -lselinux -lsemanage
Signature · 1 line
2.15.1
#15 lore raw

PATCH v2 8/14 python: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 python/audit2allow/Makefile           | 10 ++++------
 python/chcat/Makefile                 |  8 ++++----
 python/semanage/Makefile              | 13 ++++++-------
 python/sepolgen/src/sepolgen/Makefile |  3 ++-
 python/sepolicy/Makefile              | 18 +++++++++---------
 5 files changed, 25 insertions(+), 27 deletions(-)
python/audit2allow/Makefile +4 -6
index 8db8075f..a73c8c68 100644
@@ -1,12 +1,10 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
python/chcat/Makefile +4 -4
index 0fd12d6d..947734a0 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 .PHONY: all
 all: chcat
python/semanage/Makefile +6 -7
index 132162bc..70759087 100644
@@ -1,13 +1,12 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
+PACKAGEDIR ?= $(DESTDIR)$(PYTHONLIBDIR)
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 TARGETS=semanage
 
python/sepolgen/src/sepolgen/Makefile +2 -1
index d3aa7715..2121a955 100644
@@ -1,5 +1,6 @@
+PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen
 
 all:
python/sepolicy/Makefile +9 -9
index 5a56e6c8..c528ae43 100644
@@ -1,14 +1,14 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-BINDIR ?= $(PREFIX)/bin
-DATADIR ?= $(PREFIX)/share
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
-SHAREDIR ?= $(PREFIX)/share/sandbox
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+DATADIR ?= $(DESTDIR)$(PREFIX)/share
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox
 CFLAGS ?= -Wall -Werror -Wextra -W
 override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 
@@ -30,7 +30,7 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)$(PREFIX)" && echo --root $(DESTDIR)$(PREFIX)`
 	[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
 	install -m 755 sepolicy.py $(BINDIR)/sepolicy
 	(cd $(BINDIR); ln -sf sepolicy sepolgen)
Signature · 1 line
2.15.1
#20 lore raw

PATCH v2 9/14 restorecond: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 restorecond/Makefile | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
restorecond/Makefile +5 -6
index ada94aeb..a2316947 100644
@@ -1,13 +1,12 @@
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(PREFIX)/sbin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR = $(PREFIX)/share/man
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
 AUTOSTARTDIR = $(DESTDIR)/etc/xdg/autostart
-DBUSSERVICEDIR = $(DESTDIR)/usr/share/dbus-1/services
-SYSTEMDDIR ?= $(DESTDIR)/usr/lib/systemd
+DBUSSERVICEDIR = $(DESTDIR)$(PREFIX)/share/dbus-1/services
+SYSTEMDDIR ?= $(DESTDIR)$(PREFIX)/lib/systemd
 
 autostart_DATA = sealertauto.desktop
 INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
Signature · 1 line
2.15.1
#21 lore raw

PATCH v2 10/14 sandbox: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 sandbox/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
sandbox/Makefile +6 -6
index 05c3d658..5a6b707a 100644
@@ -1,14 +1,14 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 SYSCONFDIR ?= $(DESTDIR)/etc/sysconfig
-LIBDIR ?= $(PREFIX)/lib
-BINDIR ?= $(PREFIX)/bin
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR ?= $(PREFIX)/share/man
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 LOCALEDIR ?= /usr/share/locale
-SHAREDIR ?= $(PREFIX)/share/sandbox
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox
 override CFLAGS += -DPACKAGE="\"policycoreutils\"" -Wall -Werror -Wextra -W
 override LDLIBS += -lselinux -lcap-ng
 SEUNSHARE_OBJS = seunshare.o
Signature · 1 line
2.15.1
#22 lore raw

PATCH v2 11/14 secilc: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 secilc/Makefile | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
secilc/Makefile +3 -5
index 1cac53e4..5b0a4852 100644
@@ -1,8 +1,6 @@
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 
 SECILC = secilc
 SECILC_SRCS := secilc.c
Signature · 1 line
2.15.1
#23 lore raw

PATCH v2 12/14 semodule-utils: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 semodule-utils/semodule_expand/Makefile  | 8 +++-----
 semodule-utils/semodule_link/Makefile    | 8 +++-----
 semodule-utils/semodule_package/Makefile | 8 +++-----
 3 files changed, 9 insertions(+), 15 deletions(-)
semodule-utils/semodule_expand/Makefile +3 -5
index 072f2137..c2ab3f65 100644
@@ -1,9 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol
semodule-utils/semodule_link/Makefile +3 -5
index cc4687bd..bcf98765 100644
@@ -1,9 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol
semodule-utils/semodule_package/Makefile +3 -5
index 96dd7c4f..33a95e16 100644
@@ -1,9 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol
Signature · 1 line
2.15.1
#24 lore raw

PATCH v2 13/14 dbus: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
---
 dbus/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
dbus/Makefile +8 -6
index 9a6cc90e..53143aff 100644
@@ -1,3 +1,5 @@
+PREFIX ?= /usr
+
 all:
 
 clean:
@@ -5,12 +7,12 @@ clean:
 install:
 	-mkdir -p $(DESTDIR)/etc/dbus-1/system.d/
 	install -m 644 org.selinux.conf $(DESTDIR)/etc/dbus-1/system.d/
-	-mkdir -p $(DESTDIR)/usr/share/dbus-1/system-services
-	install -m 644 org.selinux.service $(DESTDIR)/usr/share/dbus-1/system-services
-	-mkdir -p $(DESTDIR)/usr/share/polkit-1/actions/
-	install -m 644 org.selinux.policy $(DESTDIR)/usr/share/polkit-1/actions/
-	-mkdir -p $(DESTDIR)/usr/share/system-config-selinux
-	install -m 755 selinux_server.py $(DESTDIR)/usr/share/system-config-selinux
+	-mkdir -p $(DESTDIR)$(PREFIX)/share/dbus-1/system-services
+	install -m 644 org.selinux.service $(DESTDIR)$(PREFIX)/share/dbus-1/system-services
+	-mkdir -p $(DESTDIR)$(PREFIX)/share/polkit-1/actions/
+	install -m 644 org.selinux.policy $(DESTDIR)$(PREFIX)/share/polkit-1/actions/
+	-mkdir -p $(DESTDIR)$(PREFIX)/share/system-config-selinux
+	install -m 755 selinux_server.py $(DESTDIR)$(PREFIX)/share/system-config-selinux
 
 relabel:
 
Signature · 1 line
2.15.1
#25 lore raw

PATCH v2 14/14 build: add prefix for includes in top Makefile

In reply to Marcus Folkesson
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index 6da7f7b7..74d662d4 100644
@@ -19,8 +19,8 @@ else
 endif
 
 ifneq ($(DESTDIR),)
-	CFLAGS += -I$(DESTDIR)/usr/include
-	LDFLAGS += -L$(DESTDIR)/usr/lib
+	CFLAGS += -I$(DESTDIR)$(PREFIX)/include
+	LDFLAGS += -L$(DESTDIR)$(PREFIX)/lib
 	export CFLAGS
 	export LDFLAGS
 endif
Signature · 1 line
2.15.1
#16 lore raw

Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
Quoted 111 lines · Marcus Folkesson
---
 python/audit2allow/Makefile           | 10 ++++------
 python/chcat/Makefile                 |  8 ++++----
 python/semanage/Makefile              | 13 ++++++-------
 python/sepolgen/src/sepolgen/Makefile |  3 ++-
 python/sepolicy/Makefile              | 18 +++++++++---------
 5 files changed, 25 insertions(+), 27 deletions(-)
python/audit2allow/Makefile +4 -6
index 8db8075f..a73c8c68 100644
@@ -1,12 +1,10 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
python/chcat/Makefile +4 -4
index 0fd12d6d..947734a0 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 .PHONY: all
 all: chcat
python/semanage/Makefile +6 -7
index 132162bc..70759087 100644
@@ -1,13 +1,12 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
+PACKAGEDIR ?= $(DESTDIR)$(PYTHONLIBDIR)
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 TARGETS=semanage
 
python/sepolgen/src/sepolgen/Makefile +2 -1
index d3aa7715..2121a955 100644
@@ -1,5 +1,6 @@
+PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen
 
 all:
python/sepolicy/Makefile +8 -8
index 5a56e6c8..c528ae43 100644
@@ -1,14 +1,14 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-BINDIR ?= $(PREFIX)/bin
-DATADIR ?= $(PREFIX)/share
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
-SHAREDIR ?= $(PREFIX)/share/sandbox
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+DATADIR ?= $(DESTDIR)$(PREFIX)/share
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox
 CFLAGS ?= -Wall -Werror -Wextra -W
 override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 

python/sepolicy/Makefile test: · line 33

Quoted 5 lines
python/sepolicy/Makefile +1 -1
@@ -30,7 +30,7 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)$(PREFIX)" && echo --root $(DESTDIR)$(PREFIX)`

--root $(DESTDIR)$(PREFIX) seems to duplicate prefix from --prefix=$(PREFIX)

$ cd python
$ make \
  DESTDIR=/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64 \
  LIBSEPOLA=/usr/lib64/libsepol.a install
$ find /home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64/usr/ -type d -name sepolicy
/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64//usr/usr/lib/python2.7/site-packages/sepolicy
Quoted 7 lines
python/sepolicy/Makefile +0 -0
 	[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
 	install -m 755 sepolicy.py $(BINDIR)/sepolicy
 	(cd $(BINDIR); ln -sf sepolicy sepolgen)
Signature · 1 line
2.15.1
#17 lore raw

Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX

Hi,

Quoted 120 lines · Petr Lautrbach
Quoted 111 lines · Marcus Folkesson
---
 python/audit2allow/Makefile           | 10 ++++------
 python/chcat/Makefile                 |  8 ++++----
 python/semanage/Makefile              | 13 ++++++-------
 python/sepolgen/src/sepolgen/Makefile |  3 ++-
 python/sepolicy/Makefile              | 18 +++++++++---------
 5 files changed, 25 insertions(+), 27 deletions(-)
python/audit2allow/Makefile +4 -6
index 8db8075f..a73c8c68 100644
@@ -1,12 +1,10 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
python/chcat/Makefile +4 -4
index 0fd12d6d..947734a0 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 .PHONY: all
 all: chcat
python/semanage/Makefile +6 -7
index 132162bc..70759087 100644
@@ -1,13 +1,12 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
+PACKAGEDIR ?= $(DESTDIR)$(PYTHONLIBDIR)
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 TARGETS=semanage
 
python/sepolgen/src/sepolgen/Makefile +2 -1
index d3aa7715..2121a955 100644
@@ -1,5 +1,6 @@
+PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen
 
 all:
python/sepolicy/Makefile +8 -8
index 5a56e6c8..c528ae43 100644
@@ -1,14 +1,14 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-BINDIR ?= $(PREFIX)/bin
-DATADIR ?= $(PREFIX)/share
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
-SHAREDIR ?= $(PREFIX)/share/sandbox
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+DATADIR ?= $(DESTDIR)$(PREFIX)/share
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox
 CFLAGS ?= -Wall -Werror -Wextra -W
 override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 

python/sepolicy/Makefile test: · line 33

Quoted 5 lines
python/sepolicy/Makefile +1 -1
@@ -30,7 +30,7 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)$(PREFIX)" && echo --root $(DESTDIR)$(PREFIX)`

--root $(DESTDIR)$(PREFIX) seems to duplicate prefix from --prefix=$(PREFIX)

Quoted 8 lines
$ cd python
$ make \
  DESTDIR=/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64 \
  LIBSEPOLA=/usr/lib64/libsepol.a install
$ find /home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64/usr/ -type d -name sepolicy
/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64//usr/usr/lib/python2.7/site-packages/sepolicy

Thank you for discovering this!
I take it with me to v3.

Another thing;
I have tried to get rid of the LIBSEPOLA variable and instead let the linker look in default locations after libsepol.a.
This to get rid of DESTDIR during compile time.

For example:

	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Do you think we should keep LIBSEPOLA as variable (but default to $(PREFIX)/lib/libsepol.a) or let it go with default path?

Thank you

Quoted 7 lines
Quoted 7 lines
python/sepolicy/Makefile +0 -0
 	[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
 	install -m 755 sepolicy.py $(BINDIR)/sepolicy
 	(cd $(BINDIR); ln -sf sepolicy sepolgen)
Signature · 1 line
2.15.1

Best regards
Marcus Folkesson

#18 lore raw

Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX

Quoted 140 lines · Marcus Folkesson

Hi,

Quoted 120 lines · Petr Lautrbach
Quoted 111 lines · Marcus Folkesson
---
 python/audit2allow/Makefile           | 10 ++++------
 python/chcat/Makefile                 |  8 ++++----
 python/semanage/Makefile              | 13 ++++++-------
 python/sepolgen/src/sepolgen/Makefile |  3 ++-
 python/sepolicy/Makefile              | 18 +++++++++---------
 5 files changed, 25 insertions(+), 27 deletions(-)
python/audit2allow/Makefile +4 -6
index 8db8075f..a73c8c68 100644
@@ -1,12 +1,10 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
python/chcat/Makefile +4 -4
index 0fd12d6d..947734a0 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 .PHONY: all
 all: chcat
python/semanage/Makefile +6 -7
index 132162bc..70759087 100644
@@ -1,13 +1,12 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
+PACKAGEDIR ?= $(DESTDIR)$(PYTHONLIBDIR)
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 TARGETS=semanage
 
python/sepolgen/src/sepolgen/Makefile +2 -1
index d3aa7715..2121a955 100644
@@ -1,5 +1,6 @@
+PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen
 
 all:
python/sepolicy/Makefile +8 -8
index 5a56e6c8..c528ae43 100644
@@ -1,14 +1,14 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-BINDIR ?= $(PREFIX)/bin
-DATADIR ?= $(PREFIX)/share
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
-SHAREDIR ?= $(PREFIX)/share/sandbox
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+DATADIR ?= $(DESTDIR)$(PREFIX)/share
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox
 CFLAGS ?= -Wall -Werror -Wextra -W
 override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 

python/sepolicy/Makefile test: · line 33

Quoted 5 lines
python/sepolicy/Makefile +1 -1
@@ -30,7 +30,7 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)$(PREFIX)" && echo --root $(DESTDIR)$(PREFIX)`

--root $(DESTDIR)$(PREFIX) seems to duplicate prefix from --prefix=$(PREFIX)

Quoted 8 lines
$ cd python
$ make \
  DESTDIR=/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64 \
  LIBSEPOLA=/usr/lib64/libsepol.a install
$ find /home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64/usr/ -type d -name sepolicy
/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64//usr/usr/lib/python2.7/site-packages/sepolicy

Thank you for discovering this!
I take it with me to v3.

Another thing;
I have tried to get rid of the LIBSEPOLA variable and instead let the linker look in default locations after libsepol.a.
This to get rid of DESTDIR during compile time.

Quoted 6 lines

For example:

	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Do you think we should keep LIBSEPOLA as variable (but default to $(PREFIX)/lib/libsepol.a) or let it go with default path?

I think that the default LIBSEPOLA should be connected to DESTDIR as 'make DESTDIR=~/obj' is the documented way how to build and install everything under a private directory.

Quoted 15 lines
Quoted 9 lines
Quoted 9 lines
python/sepolicy/Makefile +0 -0
 	[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
 	install -m 755 sepolicy.py $(BINDIR)/sepolicy
 	(cd $(BINDIR); ln -sf sepolicy sepolgen)
Signature · 1 line
2.15.1

Best regards
Marcus Folkesson

#19 lore raw

Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX

Quoted 144 lines · Petr Lautrbach
Quoted 143 lines · Marcus Folkesson

Hi,

Quoted 120 lines · Petr Lautrbach
Quoted 111 lines · Marcus Folkesson
---
 python/audit2allow/Makefile           | 10 ++++------
 python/chcat/Makefile                 |  8 ++++----
 python/semanage/Makefile              | 13 ++++++-------
 python/sepolgen/src/sepolgen/Makefile |  3 ++-
 python/sepolicy/Makefile              | 18 +++++++++---------
 5 files changed, 25 insertions(+), 27 deletions(-)
python/audit2allow/Makefile +4 -6
index 8db8075f..a73c8c68 100644
@@ -1,12 +1,10 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
python/chcat/Makefile +4 -4
index 0fd12d6d..947734a0 100644
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 .PHONY: all
 all: chcat
python/semanage/Makefile +6 -7
index 132162bc..70759087 100644
@@ -1,13 +1,12 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(PREFIX)/sbin
-MANDIR = $(PREFIX)/share/man
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+PREFIX ?= /usr
+SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
+MANDIR = $(DESTDIR)$(PREFIX)/share/man
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
+PACKAGEDIR ?= $(DESTDIR)$(PYTHONLIBDIR)
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 TARGETS=semanage
 
python/sepolgen/src/sepolgen/Makefile +2 -1
index d3aa7715..2121a955 100644
@@ -1,5 +1,6 @@
+PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen
 
 all:
python/sepolicy/Makefile +8 -8
index 5a56e6c8..c528ae43 100644
@@ -1,14 +1,14 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-BINDIR ?= $(PREFIX)/bin
-DATADIR ?= $(PREFIX)/share
-MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
-SHAREDIR ?= $(PREFIX)/share/sandbox
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+DATADIR ?= $(DESTDIR)$(PREFIX)/share
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
+SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox
 CFLAGS ?= -Wall -Werror -Wextra -W
 override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 

python/sepolicy/Makefile test: · line 33

Quoted 5 lines
python/sepolicy/Makefile +1 -1
@@ -30,7 +30,7 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)$(PREFIX)" && echo --root $(DESTDIR)$(PREFIX)`

--root $(DESTDIR)$(PREFIX) seems to duplicate prefix from --prefix=$(PREFIX)

Quoted 8 lines
$ cd python
$ make \
  DESTDIR=/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64 \
  LIBSEPOLA=/usr/lib64/libsepol.a install
$ find /home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64/usr/ -type d -name sepolicy
/home/build/rpmbuild/BUILDROOT/policycoreutils-2.7-99.fc28.20180117103354.x86_64//usr/usr/lib/python2.7/site-packages/sepolicy

Thank you for discovering this!
I take it with me to v3.

Another thing;
I have tried to get rid of the LIBSEPOLA variable and instead let the linker look in default locations after libsepol.a.
This to get rid of DESTDIR during compile time.

For example:

	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a
Quoted 8 lines
Quoted 3 lines

Do you think we should keep LIBSEPOLA as variable (but default to $(PREFIX)/lib/libsepol.a) or let it go with default path?

I think that the default LIBSEPOLA should be connected to DESTDIR as 'make DESTDIR=~/obj' is the documented way how to build and install everything under a private directory.

I can see why it may seems like a good idea. But.. What i object to is that:

- DESTDIR should not be part of the compile stage according to the GNU Coding Standard [1]. It is only part of the install stage.

- The current usage of PREFIX and DESTDIR is not working as expected. For example, this does not compile at all:
make DESTDIR=/tmp/myroot PREFIX=/selinux install

- All components does not compile with 'make DESTDIR=~/obj'. For example libselinux:
make DESTDIR=/tmp/obj install
cd libselinux
make clean
make DESTDIR=/tmp/obj

It all depends on running from the top Makefile

- 'make DESTDIR=~/obj' from the top Makefile still works in the case of these patches.

I really think as much as possible should follow standards. And it would be really nice if we could make it work with SELinux.

I will come up with a v3 later tonight including fixes for your input. But I let the LIBSEPOLA be 'as is' until I have heard your (and others of cause) thoughs about it.

Thanks

[1] https://www.gnu.org/prep/standards/html_node/DESTDIR.html

Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
python/sepolicy/Makefile +0 -0
 	[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
 	install -m 755 sepolicy.py $(BINDIR)/sepolicy
 	(cd $(BINDIR); ln -sf sepolicy sepolgen)
Signature · 1 line
2.15.1
Quoted 4 lines
Quoted 4 lines

Best regards
Marcus Folkesson

Best regards
Marcus Folkesson

#3 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

In reply to Marcus Folkesson
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).
By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

Best regards,
Nicolas

[1] https://github.com/SELinuxProject/selinux/commit/dcd135cc06abd8cd662d2d7a896e368f09380dd2

#4 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

Hi Nicolas!

Quoted 94 lines · Nicolas Iooss
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).

Quoted 8 lines

By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

First of all, thank you for your review.

Actually, I do not have any "good" way to address this issue. Is $(LIBSEPOLA) mostly used during debug/development?

What do you think about this change:

-----------------8<--------------------------------------------

libselinux/src/Makefile +5 -1
index 18df75c8..b722a584 100644
@@ -20,7 +20,11 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+       LDFLAGS += -l:libsepol.a
+endif
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1

-----------------8<--------------------------------------------

This will search for libsepol.a in paths specified in LDFLAGS, but keep the possibility to "track" a specific libsepol.a to make dependent subprojects recompile if libsepol.a is changed.

Quoted 6 lines

Best regards,
Nicolas

[1] https://github.com/SELinuxProject/selinux/commit/dcd135cc06abd8cd662d2d7a896e368f09380dd2

Best regards
Marcus Folkesson

#5 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

Quoted 135 lines · Marcus Folkesson

Hi Nicolas!

Quoted 94 lines · Nicolas Iooss
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).

Quoted 8 lines

By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

First of all, thank you for your review.

Actually, I do not have any "good" way to address this issue. Is $(LIBSEPOLA) mostly used during debug/development?

What do you think about this change:

-----------------8<--------------------------------------------

libselinux/src/Makefile +5 -2
index 18df75c8..b722a584 100644
@@ -20,7 +20,11 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+       LDFLAGS += -l:libsepol.a
+endif
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
 
-----------------8<--------------------------------------------
Quoted 3 lines

This will search for libsepol.a in paths specified in LDFLAGS, but keep the possibility to "track" a specific libsepol.a to make dependent subprojects recompile if libsepol.a is changed.

Adding "-l:libsepol.a" to LDFLAGS breaks compiling with "make 'LDFLAGS=-Wl,--as-needed,--no-undefined'" (which helps detecting shared libraries linking issues), because of two issues:

* "LDFLAGS += ..." does nothing when LDFLAGS is defined on the command line. This is why "override LDFLAGS += ..." is used in other places in the Makefile.
* After adding "override", -l:libsepol.a appears before $(AUDIT2WHYLOBJ) in the linker invocation, so its objects get ignored because of --as-needed (which is why LDLIBS exists independently of LDFLAGS).

This issue can be easily reproduced by running in libselinux/src the following command:

make clean && make 'LDFLAGS=-Wl,--as-needed,--no-undefined' pywrap

In order to address this issue, I suggest defining a new variable, LDLIBS_LIBSEPOLA, defined by something like:

# 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

#....

$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)

	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux

$(LDLIBS_LIBSEPOLA) $(PYLIBS)

What do you think of this?

Best regards,
Nicolas

#6 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

Quoted 144 lines · Nicolas Iooss
Quoted 135 lines · Marcus Folkesson

Hi Nicolas!

Quoted 94 lines · Nicolas Iooss
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).

Quoted 8 lines

By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

First of all, thank you for your review.

Actually, I do not have any "good" way to address this issue. Is $(LIBSEPOLA) mostly used during debug/development?

What do you think about this change:

-----------------8<--------------------------------------------

libselinux/src/Makefile +5 -2
index 18df75c8..b722a584 100644
@@ -20,7 +20,11 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+       LDFLAGS += -l:libsepol.a
+endif
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
 
-----------------8<--------------------------------------------
Quoted 3 lines

This will search for libsepol.a in paths specified in LDFLAGS, but keep the possibility to "track" a specific libsepol.a to make dependent subprojects recompile if libsepol.a is changed.

Adding "-l:libsepol.a" to LDFLAGS breaks compiling with "make 'LDFLAGS=-Wl,--as-needed,--no-undefined'" (which helps detecting shared libraries linking issues), because of two issues:

Quoted 6 lines

* "LDFLAGS += ..." does nothing when LDFLAGS is defined on the command line. This is why "override LDFLAGS += ..." is used in other places in the Makefile.
* After adding "override", -l:libsepol.a appears before $(AUDIT2WHYLOBJ) in the linker invocation, so its objects get ignored because of --as-needed (which is why LDLIBS exists independently of LDFLAGS).

Good points.

Quoted 16 lines

This issue can be easily reproduced by running in libselinux/src the following command:

make clean && make 'LDFLAGS=-Wl,--as-needed,--no-undefined' pywrap

In order to address this issue, I suggest defining a new variable, LDLIBS_LIBSEPOLA, defined by something like:

# 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

Quoted 7 lines

#....

$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)

	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux

$(LDLIBS_LIBSEPOLA) $(PYLIBS)

What do you think of this?

That is much better. I will take this with me to v4.

Thank you!

Quoted 4 lines

Best regards,
Nicolas

Best regards
Marcus Folkesson

#7 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

Quoted 172 lines · Marcus Folkesson
Quoted 144 lines · Nicolas Iooss
Quoted 135 lines · Marcus Folkesson

Hi Nicolas!

Quoted 94 lines · Nicolas Iooss
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).

Quoted 8 lines

By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

First of all, thank you for your review.

Actually, I do not have any "good" way to address this issue. Is $(LIBSEPOLA) mostly used during debug/development?

What do you think about this change:

-----------------8<--------------------------------------------

libselinux/src/Makefile +5 -2
index 18df75c8..b722a584 100644
@@ -20,7 +20,11 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+       LDFLAGS += -l:libsepol.a
+endif
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
 
-----------------8<--------------------------------------------
Quoted 3 lines

This will search for libsepol.a in paths specified in LDFLAGS, but keep the possibility to "track" a specific libsepol.a to make dependent subprojects recompile if libsepol.a is changed.

Adding "-l:libsepol.a" to LDFLAGS breaks compiling with "make 'LDFLAGS=-Wl,--as-needed,--no-undefined'" (which helps detecting shared libraries linking issues), because of two issues:

Quoted 6 lines

* "LDFLAGS += ..." does nothing when LDFLAGS is defined on the command line. This is why "override LDFLAGS += ..." is used in other places in the Makefile.
* After adding "override", -l:libsepol.a appears before $(AUDIT2WHYLOBJ) in the linker invocation, so its objects get ignored because of --as-needed (which is why LDLIBS exists independently of LDFLAGS).

Good points.

Quoted 18 lines

This issue can be easily reproduced by running in libselinux/src the following command:

make clean && make 'LDFLAGS=-Wl,--as-needed,--no-undefined' pywrap

In order to address this issue, I suggest defining a new variable, LDLIBS_LIBSEPOLA, defined by something like:

# 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

#....

Quoted 7 lines
Quoted 5 lines

$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)

	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux

$(LDLIBS_LIBSEPOLA) $(PYLIBS)

What do you think of this?

That is much better. I will take this with me to v4.

LIBDIR seems not propagated to LDFLAGS. It means that when I try to build everything using

DESTDIR=/home/vagrant/build SBINDIR=/home/vagrant/build/usr/sbin LIBDIR=/home/vagrant/build/usr/lib64

and without libsepol.a in standard library paths, it doesn't find libsepol.a

e.g. checkpolicy fails:

cc -O2 -Werror -Wall -Wextra -Wmissing-format-attribute -Wmissing-noreturn -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -I/home/vagrant/build/usr/include -I. -o policy_define.o -c policy_define.c make[1]: *** No rule to make target '/usr/lib64/libsepol.a', needed by 'checkpolicy'. Stop.

Or if I had /usr/lib64/libsepol.a, checkpolicy and probably audit2why.so would be linked to the system version not the version installed into $DESTDIR.

Would it make sense to propagate LIBDIR to LDFLAGS?

Petr

#8 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

Quoted 194 lines · Petr Lautrbach
Quoted 172 lines · Marcus Folkesson
Quoted 144 lines · Nicolas Iooss
Quoted 135 lines · Marcus Folkesson

Hi Nicolas!

Quoted 94 lines · Nicolas Iooss
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).

Quoted 8 lines

By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

First of all, thank you for your review.

Actually, I do not have any "good" way to address this issue. Is $(LIBSEPOLA) mostly used during debug/development?

What do you think about this change:

-----------------8<--------------------------------------------

libselinux/src/Makefile +5 -2
index 18df75c8..b722a584 100644
@@ -20,7 +20,11 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+       LDFLAGS += -l:libsepol.a
+endif
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
 
-----------------8<--------------------------------------------
Quoted 3 lines

This will search for libsepol.a in paths specified in LDFLAGS, but keep the possibility to "track" a specific libsepol.a to make dependent subprojects recompile if libsepol.a is changed.

Adding "-l:libsepol.a" to LDFLAGS breaks compiling with "make 'LDFLAGS=-Wl,--as-needed,--no-undefined'" (which helps detecting shared libraries linking issues), because of two issues:

Quoted 6 lines

* "LDFLAGS += ..." does nothing when LDFLAGS is defined on the command line. This is why "override LDFLAGS += ..." is used in other places in the Makefile.
* After adding "override", -l:libsepol.a appears before $(AUDIT2WHYLOBJ) in the linker invocation, so its objects get ignored because of --as-needed (which is why LDLIBS exists independently of LDFLAGS).

Good points.

Quoted 18 lines

This issue can be easily reproduced by running in libselinux/src the following command:

make clean && make 'LDFLAGS=-Wl,--as-needed,--no-undefined' pywrap

In order to address this issue, I suggest defining a new variable, LDLIBS_LIBSEPOLA, defined by something like:

# 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

#....

Quoted 7 lines
Quoted 5 lines

$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)

    $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux

$(LDLIBS_LIBSEPOLA) $(PYLIBS)

What do you think of this?

That is much better. I will take this with me to v4.

LIBDIR seems not propagated to LDFLAGS. It means that when I try to build everything using

DESTDIR=/home/vagrant/build SBINDIR=/home/vagrant/build/usr/sbin LIBDIR=/home/vagrant/build/usr/lib64

and without libsepol.a in standard library paths, it doesn't find libsepol.a

e.g. checkpolicy fails:

cc -O2 -Werror -Wall -Wextra -Wmissing-format-attribute -Wmissing-noreturn -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -I/home/vagrant/build/usr/include -I. -o policy_define.o -c policy_define.c make[1]: *** No rule to make target '/usr/lib64/libsepol.a', needed by 'checkpolicy'. Stop.

Quoted 7 lines

Or if I had /usr/lib64/libsepol.a, checkpolicy and probably audit2why.so would be linked to the system version not the version installed into $DESTDIR.

Would it make sense to propagate LIBDIR to LDFLAGS?

Petr

Indeed the main Makefile already performs "LDFLAGS += -L$(DESTDIR)$(PREFIX)/lib" when DESTDIR is defined, buy this does not take into account cases when LIBDIR is overridden too. This can be updated to something like:

LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
LDFLAGS += -L$(LIBDIR)

And while at it, adding a default LIBSEPOLA definition there should not hurt too (and it is useful in the dependencies of some Makefile targets like python...audit2why.so). The result would be (in the main Makefile):

ifneq ($(DESTDIR),)
LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS += -I$(DESTDIR)$(PREFIX)/include
LDFLAGS += -L$(LIBDIR)
export LIBSEPOLA
export CFLAGS
export LDFLAGS
endif

Would this fix your issue?

Nicolas

#9 lore raw

Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX

Quoted 226 lines · Nicolas Iooss
Quoted 194 lines · Petr Lautrbach
Quoted 172 lines · Marcus Folkesson
Quoted 144 lines · Nicolas Iooss
Quoted 135 lines · Marcus Folkesson

Hi Nicolas!

Quoted 94 lines · Nicolas Iooss
Quoted 78 lines · Marcus Folkesson

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

---
 libselinux/include/Makefile     |  4 ++--
 libselinux/man/Makefile         |  7 ++++---
 libselinux/src/Makefile         | 12 +++++-------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  6 ++----
 5 files changed, 14 insertions(+), 17 deletions(-)
libselinux/include/Makefile +2 -2
index 757a6c9c..3b51f5ce 100644
@@ -1,6 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
 
 all:
 
libselinux/man/Makefile +4 -3
index 0643e6af..233bfaa9 100644
@@ -1,7 +1,8 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
+MAN3DIR ?= $(DESTDIR)$(PREFIX)/share/man/man3
 
 all:
 
libselinux/src/Makefile +3 -5
index 18df75c8..18a58164 100644
@@ -8,8 +8,8 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
@@ -19,8 +19,6 @@ PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixe
 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
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -148,7 +146,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)

libselinux/src/Makefile selinuxswig_python_exception.i: ../include/selinux/selinux.h · line 158

Quoted 7 lines
libselinux/src/Makefile +2 -2
@@ -156,8 +154,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h
 $(AUDIT2WHYLOBJ): audit2why.c
        $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
+       $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS) -l:libsepol.a

Hello,
This change makes audit2why.so no longer being rebuilt when libsepol's code change. This is an issue when debugging issues in libsepol, which is why I added $(LIBSEPOLA) to the dependencies of $(AUDIT2WHYSO) in commit dcd135cc06ab ("Re-link programs after libsepol.a is updated" [1]).

Quoted 8 lines

By the way, I like the change from using a "hardcoded" path to libsepol.a to telling the compiler to look into directories specified with option -L in LDFLAGS. This would ease the packaging a little bit, as it makes defining LIBSEPOLA no longer necessary (if I understood the changes correctly, I have not tested this point). Is there a way to ask the compiler for the resolved location of a static library, in a way which can be used to compute the value of LIBSEPOLA? ("gcc -Wl,--trace ..." displays it but it is not easily usable).

First of all, thank you for your review.

Actually, I do not have any "good" way to address this issue. Is $(LIBSEPOLA) mostly used during debug/development?

What do you think about this change:

-----------------8<--------------------------------------------

libselinux/src/Makefile +5 -2
index 18df75c8..b722a584 100644
@@ -20,7 +20,11 @@ RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] +
 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
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+       LDFLAGS += -l:libsepol.a
+endif
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
 
-----------------8<--------------------------------------------
Quoted 3 lines

This will search for libsepol.a in paths specified in LDFLAGS, but keep the possibility to "track" a specific libsepol.a to make dependent subprojects recompile if libsepol.a is changed.

Adding "-l:libsepol.a" to LDFLAGS breaks compiling with "make 'LDFLAGS=-Wl,--as-needed,--no-undefined'" (which helps detecting shared libraries linking issues), because of two issues:

Quoted 6 lines

* "LDFLAGS += ..." does nothing when LDFLAGS is defined on the command line. This is why "override LDFLAGS += ..." is used in other places in the Makefile.
* After adding "override", -l:libsepol.a appears before $(AUDIT2WHYLOBJ) in the linker invocation, so its objects get ignored because of --as-needed (which is why LDLIBS exists independently of LDFLAGS).

Good points.

Quoted 18 lines

This issue can be easily reproduced by running in libselinux/src the following command:

make clean && make 'LDFLAGS=-Wl,--as-needed,--no-undefined' pywrap

In order to address this issue, I suggest defining a new variable, LDLIBS_LIBSEPOLA, defined by something like:

# 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

#....

Quoted 7 lines
Quoted 5 lines

$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)

    $(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux

$(LDLIBS_LIBSEPOLA) $(PYLIBS)

What do you think of this?

That is much better. I will take this with me to v4.

LIBDIR seems not propagated to LDFLAGS. It means that when I try to build everything using

DESTDIR=/home/vagrant/build SBINDIR=/home/vagrant/build/usr/sbin LIBDIR=/home/vagrant/build/usr/lib64

and without libsepol.a in standard library paths, it doesn't find libsepol.a

e.g. checkpolicy fails:

cc -O2 -Werror -Wall -Wextra -Wmissing-format-attribute -Wmissing-noreturn -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -I/home/vagrant/build/usr/include -I. -o policy_define.o -c policy_define.c make[1]: *** No rule to make target '/usr/lib64/libsepol.a', needed by 'checkpolicy'. Stop.

Quoted 7 lines

Or if I had /usr/lib64/libsepol.a, checkpolicy and probably audit2why.so would be linked to the system version not the version installed into $DESTDIR.

Would it make sense to propagate LIBDIR to LDFLAGS?

Petr

Indeed the main Makefile already performs "LDFLAGS += -L$(DESTDIR)$(PREFIX)/lib" when DESTDIR is defined, buy this does not take into account cases when LIBDIR is overridden too. This can be updated to something like:

LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
LDFLAGS += -L$(LIBDIR)

And while at it, adding a default LIBSEPOLA definition there should not hurt too (and it is useful in the dependencies of some Makefile targets like python...audit2why.so). The result would be (in the main Makefile):

ifneq ($(DESTDIR),)
LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS += -I$(DESTDIR)$(PREFIX)/include
LDFLAGS += -L$(LIBDIR)
export LIBSEPOLA
export CFLAGS
export LDFLAGS
endif

Quoted 1 line

Would this fix your issue?

This would probably fix the issue, and I don't think it is a bad idea either.

I will take this with me to v4 as well.

Thanks!

Quoted 3 lines

Nicolas

Best regards
Marcus Folkesson