* Rework of Makefiles v2
@ 2018-01-16 20:23 Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 01/14] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
` (13 more replies)
0 siblings, 14 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 01/14] libsepol: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 02/14] libselinux: " Marcus Folkesson
` (12 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: 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
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
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(-)
diff --git a/README b/README
index 7fc7b17b..174551a1 100644
--- a/README
+++ b/README
@@ -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).
diff --git a/libsepol/include/Makefile b/libsepol/include/Makefile
index 56b7a114..ad5c34a4 100644
--- a/libsepol/include/Makefile
+++ b/libsepol/include/Makefile
@@ -1,6 +1,6 @@
# Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/sepol
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/sepol
CILDIR ?= ../cil
all:
diff --git a/libsepol/man/Makefile b/libsepol/man/Makefile
index 11924334..4f3d9fa2 100644
--- a/libsepol/man/Makefile
+++ b/libsepol/man/Makefile
@@ -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:
diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
index 819d261b..d158398f 100644
--- a/libsepol/src/Makefile
+++ b/libsepol/src/Makefile
@@ -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)
diff --git a/libsepol/src/libsepol.pc.in b/libsepol/src/libsepol.pc.in
index e52f5892..f807fec6 100644
--- a/libsepol/src/libsepol.pc.in
+++ b/libsepol/src/libsepol.pc.in
@@ -1,6 +1,6 @@
prefix=@prefix@
exec_prefix=${prefix}
-libdir=${exec_prefix}/@libdir@
+libdir=@libdir@
includedir=@includedir@
Name: libsepol
diff --git a/libsepol/utils/Makefile b/libsepol/utils/Makefile
index fba1d8a0..8ce4bf47 100644
--- a/libsepol/utils/Makefile
+++ b/libsepol/utils/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 01/14] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-17 22:12 ` Nicolas Iooss
2018-01-16 20:23 ` [PATCH v2 03/14] libsemanage: " Marcus Folkesson
` (11 subsequent siblings)
13 siblings, 1 reply; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: 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
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
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(-)
diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
index 757a6c9c..3b51f5ce 100644
--- a/libselinux/include/Makefile
+++ b/libselinux/include/Makefile
@@ -1,6 +1,6 @@
# Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
all:
diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
index 0643e6af..233bfaa9 100644
--- a/libselinux/man/Makefile
+++ b/libselinux/man/Makefile
@@ -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:
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 18df75c8..18a58164 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -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 $@ $<
diff --git a/libselinux/src/libselinux.pc.in b/libselinux/src/libselinux.pc.in
index 2e90a844..7c66b1fa 100644
--- a/libselinux/src/libselinux.pc.in
+++ b/libselinux/src/libselinux.pc.in
@@ -1,6 +1,6 @@
prefix=@prefix@
exec_prefix=${prefix}
-libdir=${exec_prefix}/@libdir@
+libdir=@libdir@
includedir=@includedir@
Name: libselinux
diff --git a/libselinux/utils/Makefile b/libselinux/utils/Makefile
index eb4851a9..9adce6d3 100644
--- a/libselinux/utils/Makefile
+++ b/libselinux/utils/Makefile
@@ -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)
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 03/14] libsemanage: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 01/14] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 02/14] libselinux: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 04/14] checkpolicy: " Marcus Folkesson
` (10 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: 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
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
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(-)
diff --git a/libsemanage/include/Makefile b/libsemanage/include/Makefile
index b660660e..f4234b9e 100644
--- a/libsemanage/include/Makefile
+++ b/libsemanage/include/Makefile
@@ -1,6 +1,6 @@
# Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/semanage
+PREFIX ?= /usr
+INCDIR ?= $(DESTDIR)$(PREFIX)/include/semanage
all:
diff --git a/libsemanage/man/Makefile b/libsemanage/man/Makefile
index 852043d4..43c2b3f6 100644
--- a/libsemanage/man/Makefile
+++ b/libsemanage/man/Makefile
@@ -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:
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index fdb178f5..f66d1b73 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -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)
diff --git a/libsemanage/src/libsemanage.pc.in b/libsemanage/src/libsemanage.pc.in
index d3eaa062..43681ddb 100644
--- a/libsemanage/src/libsemanage.pc.in
+++ b/libsemanage/src/libsemanage.pc.in
@@ -1,6 +1,6 @@
prefix=@prefix@
exec_prefix=${prefix}
-libdir=${exec_prefix}/@libdir@
+libdir=@libdir@
includedir=@includedir@
Name: libsemanage
diff --git a/libsemanage/tests/Makefile b/libsemanage/tests/Makefile
index 2ef8d30d..324766a0 100644
--- a/libsemanage/tests/Makefile
+++ b/libsemanage/tests/Makefile
@@ -1,6 +1,3 @@
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-
# Add your test source files here:
SOURCES = $(sort $(wildcard *.c))
diff --git a/libsemanage/utils/Makefile b/libsemanage/utils/Makefile
index 725f0eec..f527ad07 100644
--- a/libsemanage/utils/Makefile
+++ b/libsemanage/utils/Makefile
@@ -1,6 +1,6 @@
# Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBEXECDIR ?= $(PREFIX)/libexec
+PREFIX ?= /usr
+LIBEXECDIR ?= $(DESTDIR)$(PREFIX)/libexec
SELINUXEXECDIR ?= $(LIBEXECDIR)/selinux/
all:
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 04/14] checkpolicy: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (2 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 03/14] libsemanage: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 05/14] gui: " Marcus Folkesson
` (9 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: 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
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
checkpolicy/Makefile | 9 ++++-----
checkpolicy/test/Makefile | 7 +++----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/checkpolicy/Makefile b/checkpolicy/Makefile
index 68e11f2a..0c341d02 100644
--- a/checkpolicy/Makefile
+++ b/checkpolicy/Makefile
@@ -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
diff --git a/checkpolicy/test/Makefile b/checkpolicy/test/Makefile
index 59fa4460..8f4393d2 100644
--- a/checkpolicy/test/Makefile
+++ b/checkpolicy/test/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 05/14] gui: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (3 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 04/14] checkpolicy: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 06/14] mcstrans: " Marcus Folkesson
` (8 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
gui/Makefile | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gui/Makefile b/gui/Makefile
index cfe47405..5efd17d7 100644
--- a/gui/Makefile
+++ b/gui/Makefile
@@ -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 \
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 06/14] mcstrans: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (4 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 05/14] gui: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 07/14] policycoreutils: " Marcus Folkesson
` (7 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
mcstrans/man/Makefile | 3 ++-
mcstrans/src/Makefile | 6 +++---
mcstrans/utils/Makefile | 6 +++---
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/mcstrans/man/Makefile b/mcstrans/man/Makefile
index 8e971192..5030fa81 100644
--- a/mcstrans/man/Makefile
+++ b/mcstrans/man/Makefile
@@ -1,5 +1,6 @@
# Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
+PREFIX ?= /usr
+MAN8DIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
all:
diff --git a/mcstrans/src/Makefile b/mcstrans/src/Makefile
index 3f4a89c3..26423c29 100644
--- a/mcstrans/src/Makefile
+++ b/mcstrans/src/Makefile
@@ -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
diff --git a/mcstrans/utils/Makefile b/mcstrans/utils/Makefile
index 4d3cbfcb..79eb8438 100644
--- a/mcstrans/utils/Makefile
+++ b/mcstrans/utils/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 07/14] policycoreutils: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (5 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 06/14] mcstrans: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 08/14] python: " Marcus Folkesson
` (6 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
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(-)
diff --git a/policycoreutils/hll/pp/Makefile b/policycoreutils/hll/pp/Makefile
index 3401dcc9..ce58e0cf 100644
--- a/policycoreutils/hll/pp/Makefile
+++ b/policycoreutils/hll/pp/Makefile
@@ -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
diff --git a/policycoreutils/load_policy/Makefile b/policycoreutils/load_policy/Makefile
index b85833c2..720bf45f 100644
--- a/policycoreutils/load_policy/Makefile
+++ b/policycoreutils/load_policy/Makefile
@@ -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\""
diff --git a/policycoreutils/man/Makefile b/policycoreutils/man/Makefile
index 0d91cd46..8a8fbd49 100644
--- a/policycoreutils/man/Makefile
+++ b/policycoreutils/man/Makefile
@@ -1,5 +1,6 @@
# Installation directories.
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
+PREFIX ?= /usr
+MAN5DIR ?= $(DESTDIR)$(PREFIX)/share/man/man5
all:
diff --git a/policycoreutils/newrole/Makefile b/policycoreutils/newrole/Makefile
index 196af926..4dbe6f52 100644
--- a/policycoreutils/newrole/Makefile
+++ b/policycoreutils/newrole/Makefile
@@ -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.
diff --git a/policycoreutils/po/Makefile b/policycoreutils/po/Makefile
index 58148613..c583d23a 100644
--- a/policycoreutils/po/Makefile
+++ b/policycoreutils/po/Makefile
@@ -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
diff --git a/policycoreutils/run_init/Makefile b/policycoreutils/run_init/Makefile
index 921f0b07..4178493e 100644
--- a/policycoreutils/run_init/Makefile
+++ b/policycoreutils/run_init/Makefile
@@ -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)
diff --git a/policycoreutils/scripts/Makefile b/policycoreutils/scripts/Makefile
index d9e86ffe..cfd841ec 100644
--- a/policycoreutils/scripts/Makefile
+++ b/policycoreutils/scripts/Makefile
@@ -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
diff --git a/policycoreutils/secon/Makefile b/policycoreutils/secon/Makefile
index 8e491d74..4ecbd57d 100644
--- a/policycoreutils/secon/Makefile
+++ b/policycoreutils/secon/Makefile
@@ -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)
diff --git a/policycoreutils/semodule/Makefile b/policycoreutils/semodule/Makefile
index fffb43ac..9d47e7e1 100644
--- a/policycoreutils/semodule/Makefile
+++ b/policycoreutils/semodule/Makefile
@@ -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
diff --git a/policycoreutils/sestatus/Makefile b/policycoreutils/sestatus/Makefile
index 41ca6832..15443800 100644
--- a/policycoreutils/sestatus/Makefile
+++ b/policycoreutils/sestatus/Makefile
@@ -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
diff --git a/policycoreutils/setfiles/Makefile b/policycoreutils/setfiles/Makefile
index c08e2dd1..2a384234 100644
--- a/policycoreutils/setfiles/Makefile
+++ b/policycoreutils/setfiles/Makefile
@@ -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 }')
diff --git a/policycoreutils/setsebool/Makefile b/policycoreutils/setsebool/Makefile
index bc254dab..cf300336 100644
--- a/policycoreutils/setsebool/Makefile
+++ b/policycoreutils/setsebool/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (6 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 07/14] policycoreutils: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-17 10:11 ` Petr Lautrbach
2018-01-16 20:23 ` [PATCH v2 09/14] restorecond: " Marcus Folkesson
` (5 subsequent siblings)
13 siblings, 1 reply; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
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(-)
diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile
index 8db8075f..a73c8c68 100644
--- a/python/audit2allow/Makefile
+++ b/python/audit2allow/Makefile
@@ -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
diff --git a/python/chcat/Makefile b/python/chcat/Makefile
index 0fd12d6d..947734a0 100644
--- a/python/chcat/Makefile
+++ b/python/chcat/Makefile
@@ -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
diff --git a/python/semanage/Makefile b/python/semanage/Makefile
index 132162bc..70759087 100644
--- a/python/semanage/Makefile
+++ b/python/semanage/Makefile
@@ -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
diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
index d3aa7715..2121a955 100644
--- a/python/sepolgen/src/sepolgen/Makefile
+++ b/python/sepolgen/src/sepolgen/Makefile
@@ -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:
diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile
index 5a56e6c8..c528ae43 100644
--- a/python/sepolicy/Makefile
+++ b/python/sepolicy/Makefile
@@ -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)
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 09/14] restorecond: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (7 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 08/14] python: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 10/14] sandbox: " Marcus Folkesson
` (4 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
restorecond/Makefile | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/restorecond/Makefile b/restorecond/Makefile
index ada94aeb..a2316947 100644
--- a/restorecond/Makefile
+++ b/restorecond/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 10/14] sandbox: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (8 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 09/14] restorecond: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 11/14] secilc: " Marcus Folkesson
` (3 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
sandbox/Makefile | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sandbox/Makefile b/sandbox/Makefile
index 05c3d658..5a6b707a 100644
--- a/sandbox/Makefile
+++ b/sandbox/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 11/14] secilc: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (9 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 10/14] sandbox: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 12/14] semodule-utils: " Marcus Folkesson
` (2 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
secilc/Makefile | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/secilc/Makefile b/secilc/Makefile
index 1cac53e4..5b0a4852 100644
--- a/secilc/Makefile
+++ b/secilc/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 12/14] semodule-utils: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (10 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 11/14] secilc: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 13/14] dbus: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 14/14] build: add prefix for includes in top Makefile Marcus Folkesson
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
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(-)
diff --git a/semodule-utils/semodule_expand/Makefile b/semodule-utils/semodule_expand/Makefile
index 072f2137..c2ab3f65 100644
--- a/semodule-utils/semodule_expand/Makefile
+++ b/semodule-utils/semodule_expand/Makefile
@@ -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
diff --git a/semodule-utils/semodule_link/Makefile b/semodule-utils/semodule_link/Makefile
index cc4687bd..bcf98765 100644
--- a/semodule-utils/semodule_link/Makefile
+++ b/semodule-utils/semodule_link/Makefile
@@ -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
diff --git a/semodule-utils/semodule_package/Makefile b/semodule-utils/semodule_package/Makefile
index 96dd7c4f..33a95e16 100644
--- a/semodule-utils/semodule_package/Makefile
+++ b/semodule-utils/semodule_package/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 13/14] dbus: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (11 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 12/14] semodule-utils: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 14/14] build: add prefix for includes in top Makefile Marcus Folkesson
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
dbus/Makefile | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/dbus/Makefile b/dbus/Makefile
index 9a6cc90e..53143aff 100644
--- a/dbus/Makefile
+++ b/dbus/Makefile
@@ -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:
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 14/14] build: add prefix for includes in top Makefile
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
` (12 preceding siblings ...)
2018-01-16 20:23 ` [PATCH v2 13/14] dbus: " Marcus Folkesson
@ 2018-01-16 20:23 ` Marcus Folkesson
13 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-16 20:23 UTC (permalink / raw)
To: selinux, nicolas.iooss, sds; +Cc: Marcus Folkesson
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 6da7f7b7..74d662d4 100644
--- a/Makefile
+++ b/Makefile
@@ -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
--
2.15.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 ` [PATCH v2 08/14] python: " Marcus Folkesson
@ 2018-01-17 10:11 ` Petr Lautrbach
2018-01-17 10:43 ` Marcus Folkesson
0 siblings, 1 reply; 26+ messages in thread
From: Petr Lautrbach @ 2018-01-17 10:11 UTC (permalink / raw)
To: Marcus Folkesson; +Cc: selinux, nicolas.iooss, sds
[-- Attachment #1: Type: text/plain, Size: 5187 bytes --]
On Tue, Jan 16, 2018 at 09:23:21PM +0100, Marcus Folkesson wrote:
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
> 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(-)
>
> diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile
> index 8db8075f..a73c8c68 100644
> --- a/python/audit2allow/Makefile
> +++ b/python/audit2allow/Makefile
> @@ -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
> diff --git a/python/chcat/Makefile b/python/chcat/Makefile
> index 0fd12d6d..947734a0 100644
> --- a/python/chcat/Makefile
> +++ b/python/chcat/Makefile
> @@ -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
> diff --git a/python/semanage/Makefile b/python/semanage/Makefile
> index 132162bc..70759087 100644
> --- a/python/semanage/Makefile
> +++ b/python/semanage/Makefile
> @@ -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
>
> diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
> index d3aa7715..2121a955 100644
> --- a/python/sepolgen/src/sepolgen/Makefile
> +++ b/python/sepolgen/src/sepolgen/Makefile
> @@ -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:
> diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile
> index 5a56e6c8..c528ae43 100644
> --- a/python/sepolicy/Makefile
> +++ b/python/sepolicy/Makefile
> @@ -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)`
--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
> [ -d $(BINDIR) ] || mkdir -p $(BINDIR)
> install -m 755 sepolicy.py $(BINDIR)/sepolicy
> (cd $(BINDIR); ln -sf sepolicy sepolgen)
> --
> 2.15.1
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
2018-01-17 10:11 ` Petr Lautrbach
@ 2018-01-17 10:43 ` Marcus Folkesson
2018-01-17 16:38 ` Petr Lautrbach
0 siblings, 1 reply; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-17 10:43 UTC (permalink / raw)
To: Petr Lautrbach; +Cc: selinux, nicolas.iooss, sds
Hi,
On Wed, Jan 17, 2018 at 11:11:35AM +0100, Petr Lautrbach wrote:
> On Tue, Jan 16, 2018 at 09:23:21PM +0100, Marcus Folkesson wrote:
> > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > ---
> > 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(-)
> >
> > diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile
> > index 8db8075f..a73c8c68 100644
> > --- a/python/audit2allow/Makefile
> > +++ b/python/audit2allow/Makefile
> > @@ -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
> > diff --git a/python/chcat/Makefile b/python/chcat/Makefile
> > index 0fd12d6d..947734a0 100644
> > --- a/python/chcat/Makefile
> > +++ b/python/chcat/Makefile
> > @@ -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
> > diff --git a/python/semanage/Makefile b/python/semanage/Makefile
> > index 132162bc..70759087 100644
> > --- a/python/semanage/Makefile
> > +++ b/python/semanage/Makefile
> > @@ -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
> >
> > diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
> > index d3aa7715..2121a955 100644
> > --- a/python/sepolgen/src/sepolgen/Makefile
> > +++ b/python/sepolgen/src/sepolgen/Makefile
> > @@ -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:
> > diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile
> > index 5a56e6c8..c528ae43 100644
> > --- a/python/sepolicy/Makefile
> > +++ b/python/sepolicy/Makefile
> > @@ -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)`
>
> --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
>
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
> > [ -d $(BINDIR) ] || mkdir -p $(BINDIR)
> > install -m 755 sepolicy.py $(BINDIR)/sepolicy
> > (cd $(BINDIR); ln -sf sepolicy sepolgen)
> > --
> > 2.15.1
> >
> >
Best regards
Marcus Folkesson
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
2018-01-17 10:43 ` Marcus Folkesson
@ 2018-01-17 16:38 ` Petr Lautrbach
2018-01-17 19:37 ` Marcus Folkesson
0 siblings, 1 reply; 26+ messages in thread
From: Petr Lautrbach @ 2018-01-17 16:38 UTC (permalink / raw)
To: Marcus Folkesson; +Cc: selinux, nicolas.iooss, sds
[-- Attachment #1: Type: text/plain, Size: 6624 bytes --]
On Wed, Jan 17, 2018 at 11:43:58AM +0100, Marcus Folkesson wrote:
> Hi,
>
> On Wed, Jan 17, 2018 at 11:11:35AM +0100, Petr Lautrbach wrote:
> > On Tue, Jan 16, 2018 at 09:23:21PM +0100, Marcus Folkesson wrote:
> > > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > > ---
> > > 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(-)
> > >
> > > diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile
> > > index 8db8075f..a73c8c68 100644
> > > --- a/python/audit2allow/Makefile
> > > +++ b/python/audit2allow/Makefile
> > > @@ -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
> > > diff --git a/python/chcat/Makefile b/python/chcat/Makefile
> > > index 0fd12d6d..947734a0 100644
> > > --- a/python/chcat/Makefile
> > > +++ b/python/chcat/Makefile
> > > @@ -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
> > > diff --git a/python/semanage/Makefile b/python/semanage/Makefile
> > > index 132162bc..70759087 100644
> > > --- a/python/semanage/Makefile
> > > +++ b/python/semanage/Makefile
> > > @@ -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
> > >
> > > diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
> > > index d3aa7715..2121a955 100644
> > > --- a/python/sepolgen/src/sepolgen/Makefile
> > > +++ b/python/sepolgen/src/sepolgen/Makefile
> > > @@ -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:
> > > diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile
> > > index 5a56e6c8..c528ae43 100644
> > > --- a/python/sepolicy/Makefile
> > > +++ b/python/sepolicy/Makefile
> > > @@ -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)`
> >
> > --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
> >
>
> 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?
>
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.
>
>
> > > [ -d $(BINDIR) ] || mkdir -p $(BINDIR)
> > > install -m 755 sepolicy.py $(BINDIR)/sepolicy
> > > (cd $(BINDIR); ln -sf sepolicy sepolgen)
> > > --
> > > 2.15.1
> > >
> > >
>
>
> Best regards
> Marcus Folkesson
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
2018-01-17 16:38 ` Petr Lautrbach
@ 2018-01-17 19:37 ` Marcus Folkesson
0 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-17 19:37 UTC (permalink / raw)
To: Petr Lautrbach; +Cc: selinux, nicolas.iooss, sds
[-- Attachment #1: Type: text/plain, Size: 8165 bytes --]
On Wed, Jan 17, 2018 at 05:38:06PM +0100, Petr Lautrbach wrote:
> On Wed, Jan 17, 2018 at 11:43:58AM +0100, Marcus Folkesson wrote:
> > Hi,
> >
> > On Wed, Jan 17, 2018 at 11:11:35AM +0100, Petr Lautrbach wrote:
> > > On Tue, Jan 16, 2018 at 09:23:21PM +0100, Marcus Folkesson wrote:
> > > > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > > > ---
> > > > 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(-)
> > > >
> > > > diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile
> > > > index 8db8075f..a73c8c68 100644
> > > > --- a/python/audit2allow/Makefile
> > > > +++ b/python/audit2allow/Makefile
> > > > @@ -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
> > > > diff --git a/python/chcat/Makefile b/python/chcat/Makefile
> > > > index 0fd12d6d..947734a0 100644
> > > > --- a/python/chcat/Makefile
> > > > +++ b/python/chcat/Makefile
> > > > @@ -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
> > > > diff --git a/python/semanage/Makefile b/python/semanage/Makefile
> > > > index 132162bc..70759087 100644
> > > > --- a/python/semanage/Makefile
> > > > +++ b/python/semanage/Makefile
> > > > @@ -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
> > > >
> > > > diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
> > > > index d3aa7715..2121a955 100644
> > > > --- a/python/sepolgen/src/sepolgen/Makefile
> > > > +++ b/python/sepolgen/src/sepolgen/Makefile
> > > > @@ -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:
> > > > diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile
> > > > index 5a56e6c8..c528ae43 100644
> > > > --- a/python/sepolicy/Makefile
> > > > +++ b/python/sepolicy/Makefile
> > > > @@ -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)`
> > >
> > > --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
> > >
> >
> > 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?
> >
>
> 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
> >
> >
> > > > [ -d $(BINDIR) ] || mkdir -p $(BINDIR)
> > > > install -m 755 sepolicy.py $(BINDIR)/sepolicy
> > > > (cd $(BINDIR); ln -sf sepolicy sepolgen)
> > > > --
> > > > 2.15.1
> > > >
> > > >
> >
> >
> > Best regards
> > Marcus Folkesson
> >
> >
Best regards
Marcus Folkesson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-16 20:23 ` [PATCH v2 02/14] libselinux: " Marcus Folkesson
@ 2018-01-17 22:12 ` Nicolas Iooss
2018-01-19 12:07 ` Marcus Folkesson
0 siblings, 1 reply; 26+ messages in thread
From: Nicolas Iooss @ 2018-01-17 22:12 UTC (permalink / raw)
To: Marcus Folkesson; +Cc: selinux, Stephen Smalley
On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
<marcus.folkesson@gmail.com> wrote:
> This patch solves the following issues:
> - The pkg-config files generates odd paths when using DESTDIR without PREFIX
> - DESTDIR is needed during compile time to compute library and header paths which it should not.
> - Installing with both DESTDIR and PREFIX set gives us odd paths
> - Make usage of DESTDIR and PREFIX more standard
>
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
> 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(-)
>
> diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
> index 757a6c9c..3b51f5ce 100644
> --- a/libselinux/include/Makefile
> +++ b/libselinux/include/Makefile
> @@ -1,6 +1,6 @@
> # Installation directories.
> -PREFIX ?= $(DESTDIR)/usr
> -INCDIR ?= $(PREFIX)/include/selinux
> +PREFIX ?= /usr
> +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
>
> all:
>
> diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
> index 0643e6af..233bfaa9 100644
> --- a/libselinux/man/Makefile
> +++ b/libselinux/man/Makefile
> @@ -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:
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 18df75c8..18a58164 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -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
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-17 22:12 ` Nicolas Iooss
@ 2018-01-19 12:07 ` Marcus Folkesson
2018-01-22 20:50 ` Nicolas Iooss
0 siblings, 1 reply; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-19 12:07 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: selinux, Stephen Smalley
[-- Attachment #1: Type: text/plain, Size: 6521 bytes --]
Hi Nicolas!
On Wed, Jan 17, 2018 at 11:12:56PM +0100, Nicolas Iooss wrote:
> On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
> <marcus.folkesson@gmail.com> wrote:
> > This patch solves the following issues:
> > - The pkg-config files generates odd paths when using DESTDIR without PREFIX
> > - DESTDIR is needed during compile time to compute library and header paths which it should not.
> > - Installing with both DESTDIR and PREFIX set gives us odd paths
> > - Make usage of DESTDIR and PREFIX more standard
> >
> > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > ---
> > 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(-)
> >
> > diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
> > index 757a6c9c..3b51f5ce 100644
> > --- a/libselinux/include/Makefile
> > +++ b/libselinux/include/Makefile
> > @@ -1,6 +1,6 @@
> > # Installation directories.
> > -PREFIX ?= $(DESTDIR)/usr
> > -INCDIR ?= $(PREFIX)/include/selinux
> > +PREFIX ?= /usr
> > +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
> >
> > all:
> >
> > diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
> > index 0643e6af..233bfaa9 100644
> > --- a/libselinux/man/Makefile
> > +++ b/libselinux/man/Makefile
> > @@ -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:
> >
> > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > index 18df75c8..18a58164 100644
> > --- a/libselinux/src/Makefile
> > +++ b/libselinux/src/Makefile
> > @@ -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
>
> 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).
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<--------------------------------------------
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 18df75c8..b722a584 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -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.
>
> Best regards,
> Nicolas
>
> [1] https://github.com/SELinuxProject/selinux/commit/dcd135cc06abd8cd662d2d7a896e368f09380dd2
>
Best regards
Marcus Folkesson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-19 12:07 ` Marcus Folkesson
@ 2018-01-22 20:50 ` Nicolas Iooss
2018-01-23 19:34 ` Marcus Folkesson
0 siblings, 1 reply; 26+ messages in thread
From: Nicolas Iooss @ 2018-01-22 20:50 UTC (permalink / raw)
To: Marcus Folkesson; +Cc: selinux, Stephen Smalley
[-- Attachment #1.1: Type: text/plain, Size: 7791 bytes --]
On 19/01/18 13:07, Marcus Folkesson wrote:
> Hi Nicolas!
>
> On Wed, Jan 17, 2018 at 11:12:56PM +0100, Nicolas Iooss wrote:
>> On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
>> <marcus.folkesson@gmail.com> wrote:
>>> This patch solves the following issues:
>>> - The pkg-config files generates odd paths when using DESTDIR without PREFIX
>>> - DESTDIR is needed during compile time to compute library and header paths which it should not.
>>> - Installing with both DESTDIR and PREFIX set gives us odd paths
>>> - Make usage of DESTDIR and PREFIX more standard
>>>
>>> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
>>> ---
>>> 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(-)
>>>
>>> diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
>>> index 757a6c9c..3b51f5ce 100644
>>> --- a/libselinux/include/Makefile
>>> +++ b/libselinux/include/Makefile
>>> @@ -1,6 +1,6 @@
>>> # Installation directories.
>>> -PREFIX ?= $(DESTDIR)/usr
>>> -INCDIR ?= $(PREFIX)/include/selinux
>>> +PREFIX ?= /usr
>>> +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
>>>
>>> all:
>>>
>>> diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
>>> index 0643e6af..233bfaa9 100644
>>> --- a/libselinux/man/Makefile
>>> +++ b/libselinux/man/Makefile
>>> @@ -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:
>>>
>>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>>> index 18df75c8..18a58164 100644
>>> --- a/libselinux/src/Makefile
>>> +++ b/libselinux/src/Makefile
>>> @@ -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
>>
>> 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).
>
> 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<--------------------------------------------
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 18df75c8..b722a584 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -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.
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 878 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-22 20:50 ` Nicolas Iooss
@ 2018-01-23 19:34 ` Marcus Folkesson
2018-01-23 19:55 ` Petr Lautrbach
0 siblings, 1 reply; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-23 19:34 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: selinux, Stephen Smalley
[-- Attachment #1: Type: text/plain, Size: 8331 bytes --]
On Mon, Jan 22, 2018 at 09:50:36PM +0100, Nicolas Iooss wrote:
> On 19/01/18 13:07, Marcus Folkesson wrote:
> > Hi Nicolas!
> >
> > On Wed, Jan 17, 2018 at 11:12:56PM +0100, Nicolas Iooss wrote:
> >> On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
> >> <marcus.folkesson@gmail.com> wrote:
> >>> This patch solves the following issues:
> >>> - The pkg-config files generates odd paths when using DESTDIR without PREFIX
> >>> - DESTDIR is needed during compile time to compute library and header paths which it should not.
> >>> - Installing with both DESTDIR and PREFIX set gives us odd paths
> >>> - Make usage of DESTDIR and PREFIX more standard
> >>>
> >>> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> >>> ---
> >>> 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(-)
> >>>
> >>> diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
> >>> index 757a6c9c..3b51f5ce 100644
> >>> --- a/libselinux/include/Makefile
> >>> +++ b/libselinux/include/Makefile
> >>> @@ -1,6 +1,6 @@
> >>> # Installation directories.
> >>> -PREFIX ?= $(DESTDIR)/usr
> >>> -INCDIR ?= $(PREFIX)/include/selinux
> >>> +PREFIX ?= /usr
> >>> +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
> >>>
> >>> all:
> >>>
> >>> diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
> >>> index 0643e6af..233bfaa9 100644
> >>> --- a/libselinux/man/Makefile
> >>> +++ b/libselinux/man/Makefile
> >>> @@ -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:
> >>>
> >>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> >>> index 18df75c8..18a58164 100644
> >>> --- a/libselinux/src/Makefile
> >>> +++ b/libselinux/src/Makefile
> >>> @@ -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
> >>
> >> 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).
> >
> > 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<--------------------------------------------
> >
> > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > index 18df75c8..b722a584 100644
> > --- a/libselinux/src/Makefile
> > +++ b/libselinux/src/Makefile
> > @@ -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.
>
> 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).
Good points.
>
> 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?
That is much better. I will take this with me to v4.
Thank you!
>
> Best regards,
> Nicolas
>
Best regards
Marcus Folkesson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-23 19:34 ` Marcus Folkesson
@ 2018-01-23 19:55 ` Petr Lautrbach
2018-01-23 23:00 ` Nicolas Iooss
0 siblings, 1 reply; 26+ messages in thread
From: Petr Lautrbach @ 2018-01-23 19:55 UTC (permalink / raw)
To: Marcus Folkesson; +Cc: Nicolas Iooss, Stephen Smalley, selinux
[-- Attachment #1: Type: text/plain, Size: 9545 bytes --]
On Tue, Jan 23, 2018 at 08:34:09PM +0100, Marcus Folkesson wrote:
> On Mon, Jan 22, 2018 at 09:50:36PM +0100, Nicolas Iooss wrote:
> > On 19/01/18 13:07, Marcus Folkesson wrote:
> > > Hi Nicolas!
> > >
> > > On Wed, Jan 17, 2018 at 11:12:56PM +0100, Nicolas Iooss wrote:
> > >> On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
> > >> <marcus.folkesson@gmail.com> wrote:
> > >>> This patch solves the following issues:
> > >>> - The pkg-config files generates odd paths when using DESTDIR without PREFIX
> > >>> - DESTDIR is needed during compile time to compute library and header paths which it should not.
> > >>> - Installing with both DESTDIR and PREFIX set gives us odd paths
> > >>> - Make usage of DESTDIR and PREFIX more standard
> > >>>
> > >>> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > >>> ---
> > >>> 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(-)
> > >>>
> > >>> diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
> > >>> index 757a6c9c..3b51f5ce 100644
> > >>> --- a/libselinux/include/Makefile
> > >>> +++ b/libselinux/include/Makefile
> > >>> @@ -1,6 +1,6 @@
> > >>> # Installation directories.
> > >>> -PREFIX ?= $(DESTDIR)/usr
> > >>> -INCDIR ?= $(PREFIX)/include/selinux
> > >>> +PREFIX ?= /usr
> > >>> +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
> > >>>
> > >>> all:
> > >>>
> > >>> diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
> > >>> index 0643e6af..233bfaa9 100644
> > >>> --- a/libselinux/man/Makefile
> > >>> +++ b/libselinux/man/Makefile
> > >>> @@ -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:
> > >>>
> > >>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > >>> index 18df75c8..18a58164 100644
> > >>> --- a/libselinux/src/Makefile
> > >>> +++ b/libselinux/src/Makefile
> > >>> @@ -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
> > >>
> > >> 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).
> > >
> > > 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<--------------------------------------------
> > >
> > > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > > index 18df75c8..b722a584 100644
> > > --- a/libselinux/src/Makefile
> > > +++ b/libselinux/src/Makefile
> > > @@ -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.
> >
> > 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).
>
> Good points.
>
> >
> > 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?
>
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-23 19:55 ` Petr Lautrbach
@ 2018-01-23 23:00 ` Nicolas Iooss
2018-01-24 8:23 ` Marcus Folkesson
0 siblings, 1 reply; 26+ messages in thread
From: Nicolas Iooss @ 2018-01-23 23:00 UTC (permalink / raw)
To: Petr Lautrbach; +Cc: Marcus Folkesson, Stephen Smalley, selinux
On Tue, Jan 23, 2018 at 8:55 PM, Petr Lautrbach <plautrba@redhat.com> wrote:
> On Tue, Jan 23, 2018 at 08:34:09PM +0100, Marcus Folkesson wrote:
>> On Mon, Jan 22, 2018 at 09:50:36PM +0100, Nicolas Iooss wrote:
>> > On 19/01/18 13:07, Marcus Folkesson wrote:
>> > > Hi Nicolas!
>> > >
>> > > On Wed, Jan 17, 2018 at 11:12:56PM +0100, Nicolas Iooss wrote:
>> > >> On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
>> > >> <marcus.folkesson@gmail.com> wrote:
>> > >>> This patch solves the following issues:
>> > >>> - The pkg-config files generates odd paths when using DESTDIR without PREFIX
>> > >>> - DESTDIR is needed during compile time to compute library and header paths which it should not.
>> > >>> - Installing with both DESTDIR and PREFIX set gives us odd paths
>> > >>> - Make usage of DESTDIR and PREFIX more standard
>> > >>>
>> > >>> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
>> > >>> ---
>> > >>> 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(-)
>> > >>>
>> > >>> diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
>> > >>> index 757a6c9c..3b51f5ce 100644
>> > >>> --- a/libselinux/include/Makefile
>> > >>> +++ b/libselinux/include/Makefile
>> > >>> @@ -1,6 +1,6 @@
>> > >>> # Installation directories.
>> > >>> -PREFIX ?= $(DESTDIR)/usr
>> > >>> -INCDIR ?= $(PREFIX)/include/selinux
>> > >>> +PREFIX ?= /usr
>> > >>> +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
>> > >>>
>> > >>> all:
>> > >>>
>> > >>> diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
>> > >>> index 0643e6af..233bfaa9 100644
>> > >>> --- a/libselinux/man/Makefile
>> > >>> +++ b/libselinux/man/Makefile
>> > >>> @@ -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:
>> > >>>
>> > >>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>> > >>> index 18df75c8..18a58164 100644
>> > >>> --- a/libselinux/src/Makefile
>> > >>> +++ b/libselinux/src/Makefile
>> > >>> @@ -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
>> > >>
>> > >> 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).
>> > >
>> > > 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<--------------------------------------------
>> > >
>> > > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>> > > index 18df75c8..b722a584 100644
>> > > --- a/libselinux/src/Makefile
>> > > +++ b/libselinux/src/Makefile
>> > > @@ -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.
>> >
>> > 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).
>>
>> Good points.
>>
>> >
>> > 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?
>>
>> 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
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 02/14] libselinux: build: follow standard semantics for DESTDIR and PREFIX
2018-01-23 23:00 ` Nicolas Iooss
@ 2018-01-24 8:23 ` Marcus Folkesson
0 siblings, 0 replies; 26+ messages in thread
From: Marcus Folkesson @ 2018-01-24 8:23 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: Petr Lautrbach, Stephen Smalley, selinux
[-- Attachment #1: Type: text/plain, Size: 11263 bytes --]
On Wed, Jan 24, 2018 at 12:00:28AM +0100, Nicolas Iooss wrote:
> On Tue, Jan 23, 2018 at 8:55 PM, Petr Lautrbach <plautrba@redhat.com> wrote:
> > On Tue, Jan 23, 2018 at 08:34:09PM +0100, Marcus Folkesson wrote:
> >> On Mon, Jan 22, 2018 at 09:50:36PM +0100, Nicolas Iooss wrote:
> >> > On 19/01/18 13:07, Marcus Folkesson wrote:
> >> > > Hi Nicolas!
> >> > >
> >> > > On Wed, Jan 17, 2018 at 11:12:56PM +0100, Nicolas Iooss wrote:
> >> > >> On Tue, Jan 16, 2018 at 9:23 PM, Marcus Folkesson
> >> > >> <marcus.folkesson@gmail.com> wrote:
> >> > >>> This patch solves the following issues:
> >> > >>> - The pkg-config files generates odd paths when using DESTDIR without PREFIX
> >> > >>> - DESTDIR is needed during compile time to compute library and header paths which it should not.
> >> > >>> - Installing with both DESTDIR and PREFIX set gives us odd paths
> >> > >>> - Make usage of DESTDIR and PREFIX more standard
> >> > >>>
> >> > >>> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> >> > >>> ---
> >> > >>> 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(-)
> >> > >>>
> >> > >>> diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
> >> > >>> index 757a6c9c..3b51f5ce 100644
> >> > >>> --- a/libselinux/include/Makefile
> >> > >>> +++ b/libselinux/include/Makefile
> >> > >>> @@ -1,6 +1,6 @@
> >> > >>> # Installation directories.
> >> > >>> -PREFIX ?= $(DESTDIR)/usr
> >> > >>> -INCDIR ?= $(PREFIX)/include/selinux
> >> > >>> +PREFIX ?= /usr
> >> > >>> +INCDIR = $(DESTDIR)$(PREFIX)/include/selinux
> >> > >>>
> >> > >>> all:
> >> > >>>
> >> > >>> diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
> >> > >>> index 0643e6af..233bfaa9 100644
> >> > >>> --- a/libselinux/man/Makefile
> >> > >>> +++ b/libselinux/man/Makefile
> >> > >>> @@ -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:
> >> > >>>
> >> > >>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> >> > >>> index 18df75c8..18a58164 100644
> >> > >>> --- a/libselinux/src/Makefile
> >> > >>> +++ b/libselinux/src/Makefile
> >> > >>> @@ -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
> >> > >>
> >> > >> 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).
> >> > >
> >> > > 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<--------------------------------------------
> >> > >
> >> > > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> >> > > index 18df75c8..b722a584 100644
> >> > > --- a/libselinux/src/Makefile
> >> > > +++ b/libselinux/src/Makefile
> >> > > @@ -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.
> >> >
> >> > 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).
> >>
> >> Good points.
> >>
> >> >
> >> > 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?
> >>
> >> 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
>
> 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?
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!
>
> Nicolas
>
Best regards
Marcus Folkesson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2018-01-24 8:23 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 20:23 Rework of Makefiles v2 Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 01/14] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 02/14] libselinux: " Marcus Folkesson
2018-01-17 22:12 ` Nicolas Iooss
2018-01-19 12:07 ` Marcus Folkesson
2018-01-22 20:50 ` Nicolas Iooss
2018-01-23 19:34 ` Marcus Folkesson
2018-01-23 19:55 ` Petr Lautrbach
2018-01-23 23:00 ` Nicolas Iooss
2018-01-24 8:23 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 03/14] libsemanage: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 04/14] checkpolicy: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 05/14] gui: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 06/14] mcstrans: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 07/14] policycoreutils: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 08/14] python: " Marcus Folkesson
2018-01-17 10:11 ` Petr Lautrbach
2018-01-17 10:43 ` Marcus Folkesson
2018-01-17 16:38 ` Petr Lautrbach
2018-01-17 19:37 ` Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 09/14] restorecond: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 10/14] sandbox: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 11/14] secilc: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 12/14] semodule-utils: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 13/14] dbus: " Marcus Folkesson
2018-01-16 20:23 ` [PATCH v2 14/14] build: add prefix for includes in top Makefile Marcus Folkesson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.