All of lore.kernel.org
 help / color / mirror / Atom feed
* Rework of makefiles v5
@ 2018-02-14  9:57 Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 01/15] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
                   ` (15 more replies)
  0 siblings, 16 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux

I have updated the patchset.

The biggest change is that $(DESTDIR) is now used in the
install stage only.

Also some overidden CFLAGS/LDFLAGS has been removed since we now have
explicit build rules.

I have moved the changelog into patches.

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

Thanks for all feedback.

Best regards
Marcus Folkesson

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v5 01/15] libsepol: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 02/15] libselinux: " Marcus Folkesson
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, 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>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    v4:
    	- Introduce LDLIBS_LIBSEPOLA if LIBSEPOLA is not defined.
    v2:
    	- Use separate directories for shared libraries as before( Comment from Stephen Smalley)
    	- Rework all packages (not just selinux/sepol/semanage)

 README                      |  2 +-
 libsepol/include/Makefile   | 16 ++++++++--------
 libsepol/man/Makefile       | 13 +++++++------
 libsepol/src/Makefile       | 23 +++++++++++------------
 libsepol/src/libsepol.pc.in |  2 +-
 libsepol/utils/Makefile     |  6 +++---
 6 files changed, 31 insertions(+), 31 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..1ad4ecab 100644
--- a/libsepol/include/Makefile
+++ b/libsepol/include/Makefile
@@ -1,17 +1,17 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/sepol
+PREFIX ?= /usr
+INCDIR = $(PREFIX)/include/sepol
 CILDIR ?= ../cil
 
 all:
 
 install: all
-	test -d $(INCDIR) || install -m 755 -d $(INCDIR)
-	test -d $(INCDIR)/policydb || install -m 755 -d $(INCDIR)/policydb
-	test -d $(INCDIR)/cil || install -m 755 -d $(INCDIR)/cil
-	install -m 644 $(wildcard sepol/*.h) $(INCDIR)
-	install -m 644 $(wildcard sepol/policydb/*.h) $(INCDIR)/policydb
-	install -m 644 $(wildcard $(CILDIR)/include/cil/*.h) $(INCDIR)/cil
+	test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
+	test -d $(DESTDIR)$(INCDIR)/policydb || install -m 755 -d $(DESTDIR)$(INCDIR)/policydb
+	test -d $(DESTDIR)$(INCDIR)/cil || install -m 755 -d $(DESTDIR)$(INCDIR)/cil
+	install -m 644 $(wildcard sepol/*.h) $(DESTDIR)$(INCDIR)
+	install -m 644 $(wildcard sepol/policydb/*.h) $(DESTDIR)$(INCDIR)/policydb
+	install -m 644 $(wildcard $(CILDIR)/include/cil/*.h) $(DESTDIR)$(INCDIR)/cil
 
 indent:
 	../../scripts/Lindent $(wildcard sepol/*.h)
diff --git a/libsepol/man/Makefile b/libsepol/man/Makefile
index 11924334..9b754548 100644
--- a/libsepol/man/Makefile
+++ b/libsepol/man/Makefile
@@ -1,12 +1,13 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX ?= /usr
+MAN8DIR ?= $(PREFIX)/share/man/man8
+MAN3DIR ?= $(PREFIX)/share/man/man3
 
 all:
 
 install: all
-	mkdir -p $(MAN3DIR)
-	mkdir -p $(MAN8DIR)
-	install -m 644 man3/*.3 $(MAN3DIR)
-	install -m 644 man8/*.8 $(MAN8DIR)
+	mkdir -p $(DESTDIR)$(MAN3DIR)
+	mkdir -p $(DESTDIR)$(MAN8DIR)
+	install -m 644 man3/*.3 $(DESTDIR)$(MAN3DIR)
+	install -m 644 man8/*.8 $(DESTDIR)$(MAN8DIR)
 
diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
index 819d261b..ccb70233 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
-SHLIBDIR ?= $(DESTDIR)/lib
+SHLIBDIR ?= /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)
@@ -80,16 +79,16 @@ endif
 	$(CC) $(CFLAGS) -fPIC -DSHARED -c -o $@ $<
 
 install: all
-	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
-	install -m 644 $(LIBA) $(LIBDIR)
-	test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
-	install -m 755 $(LIBSO) $(SHLIBDIR)
-	test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
-	install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
-	$(LN) -sf --relative $(SHLIBDIR)/$(LIBSO) $(LIBDIR)/$(TARGET)
+	test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
+	install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
+	test -d $(DESTDIR)$(SHLIBDIR) || install -m 755 -d $(DESTDIR)$(SHLIBDIR)
+	install -m 755 $(LIBSO) $(DESTDIR)$(SHLIBDIR)
+	test -d $(DESTDIR)$(LIBDIR)/pkgconfig || install -m 755 -d $(DESTDIR)$(LIBDIR)/pkgconfig
+	install -m 644 $(LIBPC) $(DESTDIR)$(LIBDIR)/pkgconfig
+	$(LN) -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
 
 relabel:
-	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
+	/sbin/restorecon $(DESTDIR)$(SHLIBDIR)/$(LIBSO)
 
 clean: 
 	-rm -f $(LIBPC) $(LIBMAP) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) $(CIL_GENERATED)
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..31932c11 100644
--- a/libsepol/utils/Makefile
+++ b/libsepol/utils/Makefile
@@ -1,5 +1,5 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 
 CFLAGS ?= -Wall -Werror
@@ -12,8 +12,8 @@ TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))
 all: $(TARGETS)
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 $(TARGETS) $(BINDIR)
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 $(TARGETS) $(DESTDIR)$(BINDIR)
 
 clean:
 	-rm -f $(TARGETS) *.o 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 02/15] libselinux: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 01/15] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 03/15] libsemanage: " Marcus Folkesson
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, 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>
---

Notes:
    v5:
    	-  Only use $(DESTDIR) in install
    v4:
    	- move platform from platform specific to platform shared installation directory
    	- Introduce LDLIBS_LIBSEPOLA if LIBSEPOLA is not defined.
    
    v3:
    	- keep the possibility to specify LIBSEPOLA to
    	  make depending component recompile on change. If not specified, fall back to
    	  libsepola in LDFLAGS path.
    
    v2:
    	- Use separate directories for shared libraries as before( Comment from Stephen Smalley)
    	- Rework all packages (not just selinux/sepol/semanage)

 libselinux/include/Makefile     |  8 +++----
 libselinux/man/Makefile         | 19 ++++++++--------
 libselinux/src/Makefile         | 49 +++++++++++++++++++++++------------------
 libselinux/src/libselinux.pc.in |  2 +-
 libselinux/utils/Makefile       |  8 +++----
 5 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/libselinux/include/Makefile b/libselinux/include/Makefile
index 757a6c9c..8ab9ce92 100644
--- a/libselinux/include/Makefile
+++ b/libselinux/include/Makefile
@@ -1,12 +1,12 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCDIR ?= $(PREFIX)/include/selinux
+PREFIX ?= /usr
+INCDIR = $(PREFIX)/include/selinux
 
 all:
 
 install: all
-	test -d $(INCDIR) || install -m 755 -d $(INCDIR)
-	install -m 644 $(wildcard selinux/*.h) $(INCDIR)
+	test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
+	install -m 644 $(wildcard selinux/*.h) $(DESTDIR)$(INCDIR)
 
 relabel:
 
diff --git a/libselinux/man/Makefile b/libselinux/man/Makefile
index 0643e6af..f634d1fe 100644
--- a/libselinux/man/Makefile
+++ b/libselinux/man/Makefile
@@ -1,17 +1,18 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
+PREFIX	?= /usr
+MAN8DIR ?= $(PREFIX)/share/man/man8
+MAN5DIR ?= $(PREFIX)/share/man/man5
+MAN3DIR ?= $(PREFIX)/share/man/man3
 
 all:
 
 install: all
-	mkdir -p $(MAN3DIR)
-	mkdir -p $(MAN5DIR)
-	mkdir -p $(MAN8DIR)
-	install -m 644 man3/*.3 $(MAN3DIR)
-	install -m 644 man5/*.5 $(MAN5DIR)
-	install -m 644 man8/*.8 $(MAN8DIR)
+	mkdir -p $(DESTDIR)$(MAN3DIR)
+	mkdir -p $(DESTDIR)$(MAN5DIR)
+	mkdir -p $(DESTDIR)$(MAN8DIR)
+	install -m 644 man3/*.3 $(DESTDIR)$(MAN3DIR)
+	install -m 644 man5/*.5 $(DESTDIR)$(MAN5DIR)
+	install -m 644 man8/*.8 $(DESTDIR)$(MAN8DIR)
 
 relabel:
 
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 18df75c8..18588da5 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -8,19 +8,17 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 LIBDIR ?= $(PREFIX)/lib
-SHLIBDIR ?= $(DESTDIR)/lib
+SHLIBDIR ?= /lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
-PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
+PYSITEDIR ?= $(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
 PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixes() if t == imp.C_EXTENSION][0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
 RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
-RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
-LIBBASE ?= $(shell basename $(LIBDIR))
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
+RUBYINSTALL ?= $(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
 
 VERSION = $(shell cat ../VERSION)
 LIBVERSION = 1
@@ -50,6 +48,13 @@ LIBSO=$(TARGET).$(LIBVERSION)
 AUDIT2WHYLOBJ=$(PYPREFIX)audit2why.lo
 AUDIT2WHYSO=$(PYPREFIX)audit2why.so
 
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
+# is no need to define a value for LDLIBS_LIBSEPOLA
+ifeq ($(LIBSEPOLA),)
+        LDLIBS_LIBSEPOLA := -l:libsepol.a
+endif
+
 GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) selinuxswig_python_exception.i
 SRCS= $(filter-out $(GENERATED) audit2why.c, $(sort $(wildcard *.c)))
 
@@ -148,7 +153,7 @@ $(LIBSO): $(LOBJS)
 	ln -sf $@ $(TARGET)
 
 $(LIBPC): $(LIBPC).in ../VERSION
-	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):; s:@PCRE_MODULE@:$(PCRE_MODULE):' < $< > $@
+	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):; s:@PCRE_MODULE@:$(PCRE_MODULE):' < $< > $@
 
 selinuxswig_python_exception.i: ../include/selinux/selinux.h
 	bash -e exception.sh > $@ || (rm -f $@ ; false)
@@ -157,7 +162,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(LDLIBS_LIBSEPOLA) $(PYLIBS)
 
 %.o:  %.c policy.h
 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
@@ -177,26 +182,26 @@ swigify: $(SWIGIF)
 	$(SWIG) $<
 
 install: all 
-	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
-	install -m 644 $(LIBA) $(LIBDIR)
-	test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
-	install -m 755 $(LIBSO) $(SHLIBDIR)
-	test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
-	install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
-	ln -sf --relative $(SHLIBDIR)/$(LIBSO) $(LIBDIR)/$(TARGET)
+	test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
+	install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
+	test -d $(DESTDIR)$(SHLIBDIR) || install -m 755 -d $(DESTDIR)$(SHLIBDIR)
+	install -m 755 $(LIBSO) $(DESTDIR)$(SHLIBDIR)
+	test -d $(DESTDIR)$(LIBDIR)/pkgconfig || install -m 755 -d $(DESTDIR)$(LIBDIR)/pkgconfig
+	install -m 644 $(LIBPC) $(DESTDIR)$(LIBDIR)/pkgconfig
+	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
 
 install-pywrap: pywrap
-	test -d $(PYSITEDIR)/selinux || install -m 755 -d $(PYSITEDIR)/selinux
-	install -m 755 $(SWIGSO) $(PYSITEDIR)/_selinux$(PYCEXT)
-	install -m 755 $(AUDIT2WHYSO) $(PYSITEDIR)/selinux/audit2why$(PYCEXT)
-	install -m 644 $(SWIGPYOUT) $(PYSITEDIR)/selinux/__init__.py
+	test -d $(DESTDIR)$(PYSITEDIR)/selinux || install -m 755 -d $(DESTDIR)$(PYSITEDIR)/selinux
+	install -m 755 $(SWIGSO) $(DESTDIR)$(PYSITEDIR)/_selinux$(PYCEXT)
+	install -m 755 $(AUDIT2WHYSO) $(DESTDIR)$(PYSITEDIR)/selinux/audit2why$(PYCEXT)
+	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYSITEDIR)/selinux/__init__.py
 
 install-rubywrap: rubywrap
-	test -d $(RUBYINSTALL) || install -m 755 -d $(RUBYINSTALL) 
-	install -m 755 $(SWIGRUBYSO) $(RUBYINSTALL)/selinux.so
+	test -d $(DESTDIR)$(RUBYINSTALL) || install -m 755 -d $(DESTDIR)$(RUBYINSTALL) 
+	install -m 755 $(SWIGRUBYSO) $(DESTDIR)$(RUBYINSTALL)/selinux.so
 
 relabel:
-	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
+	/sbin/restorecon $(DESTDIR)$(SHLIBDIR)/$(LIBSO)
 
 clean-pywrap:
 	-rm -f $(SWIGLOBJ) $(SWIGSO) $(AUDIT2WHYLOBJ) $(AUDIT2WHYSO)
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..d06ffd66 100644
--- a/libselinux/utils/Makefile
+++ b/libselinux/utils/Makefile
@@ -1,8 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
-INCLUDEDIR ?= $(PREFIX)/include
 
 OS ?= $(shell uname)
 
@@ -63,8 +61,8 @@ sefcontext_compile: sefcontext_compile.o ../src/regex.o
 all: $(TARGETS)
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 $(TARGETS) $(SBINDIR)
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
 
 clean:
 	rm -f $(TARGETS) *.o *~
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 03/15] libsemanage: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 01/15] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 02/15] libselinux: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 04/15] checkpolicy: " Marcus Folkesson
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, 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>
---

Notes:
    v5:
    		- Only use $(DESTDIR) in install
    v4:
            - Introduce LDLIBS_LIBSEPOLA if LIBSEPOLA is not defined.
    
    v3:
            - keep the possibility to specify LIBSEPOLA to
              make depending component recompile on change. If not specified, fall back to
              libsepola in LDFLAGS path.
    
    v2:
            - Use separate directories for shared libraries as before( Comment from Stephen Smalley)
            - Rework all packages (not just selinux/sepol/semanage)
    
    v4:
            - Introduce LDLIBS_LIBSEPOLA if LIBSEPOLA is not defined.
    
    v2:
            - Use separate directories for shared libraries as before( Comment from Stephen Smalley)
            - Rework all packages (not just selinux/sepol/semanage)

 libsemanage/include/Makefile      |  6 +++---
 libsemanage/man/Makefile          | 13 +++++++------
 libsemanage/src/Makefile          | 39 ++++++++++++++++++---------------------
 libsemanage/src/libsemanage.pc.in |  2 +-
 libsemanage/tests/Makefile        |  3 ---
 libsemanage/utils/Makefile        |  6 +++---
 6 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/libsemanage/include/Makefile b/libsemanage/include/Makefile
index b660660e..6e44a28a 100644
--- a/libsemanage/include/Makefile
+++ b/libsemanage/include/Makefile
@@ -1,12 +1,12 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 INCDIR ?= $(PREFIX)/include/semanage
 
 all:
 
 install: all
-	test -d $(INCDIR) || install -m 755 -d $(INCDIR)
-	install -m 644 $(wildcard semanage/*.h) $(INCDIR)
+	test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
+	install -m 644 $(wildcard semanage/*.h) $(DESTDIR)$(INCDIR)
 
 indent:
 	../../scripts/Lindent $(wildcard semanage/*.h)
diff --git a/libsemanage/man/Makefile b/libsemanage/man/Makefile
index 852043d4..8667c9b6 100644
--- a/libsemanage/man/Makefile
+++ b/libsemanage/man/Makefile
@@ -1,12 +1,13 @@
 # Installation directories.
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
+PREFIX ?= /usr
+MAN3DIR ?= $(PREFIX)/share/man/man3
+MAN5DIR ?= $(PREFIX)/share/man/man5
 
 all:
 
 install: all
-	mkdir -p $(MAN3DIR)
-	mkdir -p $(MAN5DIR)
-	install -m 644 man3/*.3 $(MAN3DIR)
-	install -m 644 man5/*.5 $(MAN5DIR)
+	mkdir -p $(DESTDIR)$(MAN3DIR)
+	mkdir -p $(DESTDIR)$(MAN5DIR)
+	install -m 644 man3/*.3 $(DESTDIR)$(MAN3DIR)
+	install -m 644 man5/*.5 $(DESTDIR)$(MAN5DIR)
 
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index fdb178f5..e98d8760 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -8,21 +8,18 @@ RUBYPREFIX ?= $(notdir $(RUBY))
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 LIBDIR ?= $(PREFIX)/lib
-SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
-PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
+PYSITEDIR ?= $(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
 PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixes() if t == imp.C_EXTENSION][0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
 RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
-RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
+RUBYINSTALL ?= $(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
 
-LIBBASE=$(shell basename $(LIBDIR))
-
-DEFAULT_SEMANAGE_CONF_LOCATION=$(DESTDIR)/etc/selinux/semanage.conf
+DEFAULT_SEMANAGE_CONF_LOCATION=/etc/selinux/semanage.conf
 
 ifeq ($(DEBUG),1)
 	export CFLAGS = -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror
@@ -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)
@@ -136,26 +133,26 @@ swigify: $(SWIGIF)
 	$(SWIG) $<
 
 install: all 
-	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
-	install -m 644 $(LIBA) $(LIBDIR)
-	install -m 755 $(LIBSO) $(LIBDIR)
-	test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
-	install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
-	test -f $(DEFAULT_SEMANAGE_CONF_LOCATION) || install -m 644 -D semanage.conf $(DEFAULT_SEMANAGE_CONF_LOCATION)
-	cd $(LIBDIR) && ln -sf $(LIBSO) $(TARGET)
+	test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
+	install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
+	install -m 755 $(LIBSO) $(DESTDIR)$(LIBDIR)
+	test -d $(DESTDIR)$(LIBDIR)/pkgconfig || install -m 755 -d $(DESTDIR)$(LIBDIR)/pkgconfig
+	install -m 644 $(LIBPC) $(DESTDIR)$(LIBDIR)/pkgconfig
+	test -f $(DESTDIR)$(DEFAULT_SEMANAGE_CONF_LOCATION) || install -m 644 -D semanage.conf $(DESTDIR)$(DEFAULT_SEMANAGE_CONF_LOCATION)
+	cd $(DESTDIR)$(LIBDIR) && ln -sf $(LIBSO) $(TARGET)
 
 install-pywrap: pywrap 
-	test -d $(PYSITEDIR) || install -m 755 -d $(PYSITEDIR)
-	install -m 755 $(SWIGSO) $(PYSITEDIR)/_semanage$(PYCEXT)
-	install -m 644 semanage.py $(PYSITEDIR)
+	test -d $(DESTDIR)$(PYSITEDIR) || install -m 755 -d $(DESTDIR)$(PYSITEDIR)
+	install -m 755 $(SWIGSO) $(DESTDIR)$(PYSITEDIR)/_semanage$(PYCEXT)
+	install -m 644 semanage.py $(DESTDIR)$(PYSITEDIR)
 
 
 install-rubywrap: rubywrap
-	test -d $(RUBYINSTALL) || install -m 755 -d $(RUBYINSTALL) 
-	install -m 755 $(SWIGRUBYSO) $(RUBYINSTALL)/semanage.so
+	test -d $(DESTDIR)$(RUBYINSTALL) || install -m 755 -d $(DESTDIR)$(RUBYINSTALL) 
+	install -m 755 $(SWIGRUBYSO) $(DESTDIR)$(RUBYINSTALL)/semanage.so
 
 relabel:
-	/sbin/restorecon $(LIBDIR)/$(LIBSO)
+	/sbin/restorecon $(DESTDIR)$(LIBDIR)/$(LIBSO)
 
 clean: 
 	-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(SWIGRUBYSO) $(TARGET) conf-parse.c conf-parse.h conf-scan.c *.o *.lo *~
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..5b8fbb6b 100644
--- a/libsemanage/utils/Makefile
+++ b/libsemanage/utils/Makefile
@@ -1,13 +1,13 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 LIBEXECDIR ?= $(PREFIX)/libexec
 SELINUXEXECDIR ?= $(LIBEXECDIR)/selinux/
 
 all:
 
 install: all
-	-mkdir -p $(SELINUXEXECDIR)
-	install -m 755 semanage_migrate_store $(SELINUXEXECDIR)
+	-mkdir -p $(DESTDIR)$(SELINUXEXECDIR)
+	install -m 755 semanage_migrate_store $(DESTDIR)$(SELINUXEXECDIR)
 
 clean:
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 04/15] checkpolicy: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (2 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 03/15] libsemanage: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 05/15] gui: " Marcus Folkesson
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, 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>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    	- Remove CFLAGS from linking rule
    	- Do not override CFLAGS
    v4:
    	- Introduce LDLIBS_LIBSEPOLA if LIBSEPOLA is not defined.
    
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 checkpolicy/Makefile      | 28 ++++++++++++++++------------
 checkpolicy/test/Makefile | 15 +++++++++------
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/checkpolicy/Makefile b/checkpolicy/Makefile
index 68e11f2a..4c817cd6 100644
--- a/checkpolicy/Makefile
+++ b/checkpolicy/Makefile
@@ -1,12 +1,9 @@
 #
 # Makefile for building the checkpolicy program
 #
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 TARGETS = checkpolicy checkmodule
 
 LEX = flex
@@ -14,7 +11,12 @@ YACC = bison -y
 
 CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -fno-strict-aliasing
 
-override CFLAGS += -I.
+# 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
 
 CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \
 	    policy_define.o
@@ -27,8 +29,10 @@ all:  $(TARGETS)
 	$(MAKE) -C test
 
 checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA)
+	$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA)
 
 checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA)
+	$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS_LIBSEPOLA)
 
 %.o: %.c 
 	$(CC) $(CFLAGS) -o $@ -c $<
@@ -46,15 +50,15 @@ lex.yy.c: policy_scan.l y.tab.c
 	$(LEX) policy_scan.l
 
 install: all
-	-mkdir -p $(BINDIR)
-	-mkdir -p $(MANDIR)/man8
-	install -m 755 $(TARGETS) $(BINDIR)	
-	install -m 644 checkpolicy.8 $(MANDIR)/man8
-	install -m 644 checkmodule.8 $(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 755 $(TARGETS) $(DESTDIR)$(BINDIR)	
+	install -m 644 checkpolicy.8 $(DESTDIR)$(MANDIR)/man8
+	install -m 644 checkmodule.8 $(DESTDIR)$(MANDIR)/man8
 
 relabel: install
-	/sbin/restorecon $(BINDIR)/checkpolicy
-	/sbin/restorecon $(BINDIR)/checkmodule
+	/sbin/restorecon $(DESTDIR)$(BINDIR)/checkpolicy
+	/sbin/restorecon $(DESTDIR)$(BINDIR)/checkmodule
 
 clean:
 	-rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c
diff --git a/checkpolicy/test/Makefile b/checkpolicy/test/Makefile
index 59fa4460..89e7557c 100644
--- a/checkpolicy/test/Makefile
+++ b/checkpolicy/test/Makefile
@@ -1,19 +1,22 @@
 #
 # Makefile for building the dispol program
 #
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
-
 CFLAGS ?= -g -Wall -W -Werror -O2 -pipe
 
+# 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
+
 all: dispol dismod
 
 dispol: dispol.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_LIBSEPOLA)
 
 dismod: dismod.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_LIBSEPOLA)
 
 clean:
 	-rm -f dispol dismod *.o 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 05/15] gui: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (3 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 04/15] checkpolicy: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 06/15] mcstrans: " Marcus Folkesson
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	-  Only use $(DESTDIR) in install
    
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 gui/Makefile | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/gui/Makefile b/gui/Makefile
index cfe47405..d26f0000 100644
--- a/gui/Makefile
+++ b/gui/Makefile
@@ -1,5 +1,5 @@
 # Installation directories.
-PREFIX ?= ${DESTDIR}/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 SHAREDIR ?= $(PREFIX)/share/system-config-selinux
 DATADIR ?= $(PREFIX)/share
@@ -23,29 +23,29 @@ usersPage.py
 all: $(TARGETS) system-config-selinux.py polgengui.py
 
 install: all
-	-mkdir -p $(MANDIR)/man8
-	-mkdir -p $(SHAREDIR)
-	-mkdir -p $(BINDIR)
-	-mkdir -p $(DATADIR)/pixmaps
-	-mkdir -p $(DATADIR)/icons/hicolor/24x24/apps
-	-mkdir -p $(DATADIR)/polkit-1/actions/
-	install -m 755 system-config-selinux.py $(SHAREDIR)
-	install -m 755 system-config-selinux $(BINDIR)
-	install -m 755 polgengui.py $(SHAREDIR)
-	install -m 644 $(TARGETS) $(SHAREDIR)
-	install -m 644 system-config-selinux.8 $(MANDIR)/man8
-	install -m 644 selinux-polgengui.8 $(MANDIR)/man8
-	install -m 644 system-config-selinux.png $(DATADIR)/pixmaps
-	install -m 644 system-config-selinux.png $(DATADIR)/icons/hicolor/24x24/apps
-	install -m 644 system-config-selinux.png $(DATADIR)/system-config-selinux
-	install -m 644 *.desktop $(DATADIR)/system-config-selinux
-	-mkdir -p $(DESTDIR) $(DATADIR)/pixmaps
-	install -m 644 sepolicy_256.png $(DATADIR)/pixmaps/sepolicy.png
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(SHAREDIR)
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	-mkdir -p $(DESTDIR)$(DATADIR)/pixmaps
+	-mkdir -p $(DESTDIR)$(DATADIR)/icons/hicolor/24x24/apps
+	-mkdir -p $(DESTDIR)$(DATADIR)/polkit-1/actions/
+	install -m 755 system-config-selinux.py $(DESTDIR)$(SHAREDIR)
+	install -m 755 system-config-selinux $(DESTDIR)$(BINDIR)
+	install -m 755 polgengui.py $(DESTDIR)$(SHAREDIR)
+	install -m 644 $(TARGETS) $(DESTDIR)$(SHAREDIR)
+	install -m 644 system-config-selinux.8 $(DESTDIR)$(MANDIR)/man8
+	install -m 644 selinux-polgengui.8 $(DESTDIR)$(MANDIR)/man8
+	install -m 644 system-config-selinux.png $(DESTDIR)$(DATADIR)/pixmaps
+	install -m 644 system-config-selinux.png $(DESTDIR)$(DATADIR)/icons/hicolor/24x24/apps
+	install -m 644 system-config-selinux.png $(DESTDIR)$(DATADIR)/system-config-selinux
+	install -m 644 *.desktop $(DESTDIR)$(DATADIR)/system-config-selinux
+	-mkdir -p $(DESTDIR)$(DATADIR)/pixmaps
+	install -m 644 sepolicy_256.png $(DESTDIR)$(DATADIR)/pixmaps/sepolicy.png
 	for i in 16 22 32 48 256; do \
-		mkdir -p $(DESTDIR) $(DATADIR)/icons/hicolor/$${i}x$${i}/apps; \
-		install -m 644 sepolicy_$${i}.png $(DATADIR)/icons/hicolor/$${i}x$${i}/apps/sepolicy.png; \
+		mkdir -p $(DESTDIR)$(DATADIR)/icons/hicolor/$${i}x$${i}/apps; \
+		install -m 644 sepolicy_$${i}.png $(DESTDIR)$(DATADIR)/icons/hicolor/$${i}x$${i}/apps/sepolicy.png; \
 	done
-	install -m 644 org.selinux.config.policy $(DATADIR)/polkit-1/actions/
+	install -m 644 org.selinux.config.policy $(DESTDIR)$(DATADIR)/polkit-1/actions/
 clean:
 
 indent:
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 06/15] mcstrans: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (4 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 05/15] gui: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 07/15] policycoreutils: " Marcus Folkesson
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    	- Remove CFLAGS from linking rule
    	- Do not override CFLAGS
    
    v3:
    	- keep the possibility to specify LIBSEPOLA to
    	make depending component recompile on change. If not specified, fall back to
    	libsepola in LDFLAGS path.
    
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 mcstrans/man/Makefile   |  7 ++++---
 mcstrans/src/Makefile   | 36 ++++++++++++++++++++----------------
 mcstrans/utils/Makefile | 28 ++++++++++++++++++----------
 3 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/mcstrans/man/Makefile b/mcstrans/man/Makefile
index 8e971192..645f6286 100644
--- a/mcstrans/man/Makefile
+++ b/mcstrans/man/Makefile
@@ -1,11 +1,12 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
+PREFIX ?= /usr
+MAN8DIR ?= $(PREFIX)/share/man/man8
 
 all:
 
 install: all
-	mkdir -p $(MAN8DIR)
-	install -m 644 man8/*.8 $(MAN8DIR)
+	mkdir -p $(DESTDIR)$(MAN8DIR)
+	install -m 644 man8/*.8 $(DESTDIR)$(MAN8DIR)
 
 clean:
 	-rm -f *~ \#*
diff --git a/mcstrans/src/Makefile b/mcstrans/src/Makefile
index 3f4a89c3..76ef0557 100644
--- a/mcstrans/src/Makefile
+++ b/mcstrans/src/Makefile
@@ -1,33 +1,37 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(DESTDIR)/sbin
-INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
-SYSTEMDDIR ?= $(DESTDIR)/usr/lib/systemd
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
+PREFIX ?= /usr
+SBINDIR ?= /sbin
+INITDIR ?= /etc/rc.d/init.d
+SYSTEMDDIR ?= $(PREFIX)/lib/systemd
+
+# 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
 
 PROG_SRC=mcstrans.c  mcscolor.c  mcstransd.c  mls_level.c
 PROG_OBJS= $(patsubst %.c,%.o,$(PROG_SRC))
 PROG=mcstransd
 INITSCRIPT=mcstrans
 CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
-override CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 
 all: $(PROG)
 
-$(PROG): $(PROG_OBJS)
-	$(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LIBSEPOLA)
+$(PROG): $(PROG_OBJS) $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LDLIBS_LIBSEPOLA)
 
 %.o:  %.c 
-	$(CC) $(CFLAGS) -fPIE -c -o $@ $<
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o $@ $<
 
 install: all
-	test -d $(SBINDIR) || install -m 755 -d $(SBINDIR)
-	install -m 755 $(PROG) $(SBINDIR)
-	test -d $(INITDIR) || install -m 755 -d $(INITDIR)
-	install -m 755 $(INITSCRIPT).init $(INITDIR)/$(INITSCRIPT)
-	test -d $(SYSTEMDDIR)/system || install -m 755 -d $(SYSTEMDDIR)/system
-	install -m 644 mcstrans.service $(SYSTEMDDIR)/system/
+	test -d $(DESTDIR)$(SBINDIR) || install -m 755 -d $(DESTDIR)$(SBINDIR)
+	install -m 755 $(PROG) $(DESTDIR)$(SBINDIR)
+	test -d $(DESTDIR)$(INITDIR) || install -m 755 -d $(DESTDIR)$(INITDIR)
+	install -m 755 $(INITSCRIPT).init $(DESTDIR)$(INITDIR)/$(INITSCRIPT)
+	test -d $(DESTDIR)$(SYSTEMDDIR)/system || install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system
+	install -m 644 mcstrans.service $(DESTDIR)$(SYSTEMDDIR)/system/
 
 clean: 
 	-rm -f $(OBJS) $(LOBJS) $(TARGET) $(PROG) $(PROG_OBJS) *~ \#*
diff --git a/mcstrans/utils/Makefile b/mcstrans/utils/Makefile
index 4d3cbfcb..9dfe7723 100644
--- a/mcstrans/utils/Makefile
+++ b/mcstrans/utils/Makefile
@@ -1,22 +1,30 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
-CFLAGS ?= -Wall
-override CFLAGS += -I../src -D_GNU_SOURCE
-override LDLIBS += -lselinux -lpcre
+TARGETS=transcon untranscon
 
-TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))
+# 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
 
 all: $(TARGETS)
 
-$(TARGETS): ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
+transcon: transcon.o ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ -lpcre -lselinux $(LDLIBS_LIBSEPOLA)
+
+untranscon: untranscon.o ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ -lpcre -lselinux $(LDLIBS_LIBSEPOLA)
+
+%.o:  %.c 
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -I../src -fPIE -c -o $@ $<
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 $(TARGETS) $(SBINDIR)
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
 
 test:
 	./mlstrans-test-runner.py ../test/*.test
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 07/15] policycoreutils: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (5 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 06/15] mcstrans: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14 19:00   ` Nicolas Iooss
  2018-02-14  9:57 ` [PATCH v5 08/15] python: " Marcus Folkesson
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 policycoreutils/hll/pp/Makefile      |  9 +++------
 policycoreutils/load_policy/Makefile | 16 ++++++++--------
 policycoreutils/man/Makefile         |  7 ++++---
 policycoreutils/newrole/Makefile     | 24 ++++++++++++------------
 policycoreutils/po/Makefile          |  7 ++++---
 policycoreutils/run_init/Makefile    | 22 +++++++++++-----------
 policycoreutils/scripts/Makefile     | 13 ++++++-------
 policycoreutils/secon/Makefile       | 12 +++++-------
 policycoreutils/semodule/Makefile    | 16 +++++++---------
 policycoreutils/sestatus/Makefile    | 21 ++++++++++-----------
 policycoreutils/setfiles/Makefile    | 23 +++++++++++------------
 policycoreutils/setsebool/Makefile   | 18 ++++++++----------
 12 files changed, 89 insertions(+), 99 deletions(-)

diff --git a/policycoreutils/hll/pp/Makefile b/policycoreutils/hll/pp/Makefile
index 3401dcc9..fc8d3c4a 100644
--- a/policycoreutils/hll/pp/Makefile
+++ b/policycoreutils/hll/pp/Makefile
@@ -1,8 +1,5 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
-MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
 LIBEXECDIR ?= $(PREFIX)/libexec
 HLLDIR ?= $(LIBEXECDIR)/selinux/hll
 
@@ -21,8 +18,8 @@ pp: $(PP_OBJS)
 	$(CC) $(CFLAGS) -c -o $@ $^
 
 install: all
-	-mkdir -p $(HLLDIR)
-	install -m 755 pp $(HLLDIR)
+	-mkdir -p $(DESTDIR)$(HLLDIR)
+	install -m 755 pp $(DESTDIR)$(HLLDIR)
 
 relabel:
 
diff --git a/policycoreutils/load_policy/Makefile b/policycoreutils/load_policy/Makefile
index b85833c2..568d5d49 100644
--- a/policycoreutils/load_policy/Makefile
+++ b/policycoreutils/load_policy/Makefile
@@ -1,8 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(DESTDIR)/sbin
+PREFIX ?= /usr
+SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
+LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
 
 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += $(LDFLAGS) -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
@@ -13,10 +13,10 @@ TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))
 all: $(TARGETS)
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 $(TARGETS) $(SBINDIR)
-	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
-	install -m 644 load_policy.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
+	test -d $(DESTDIR)$(MANDIR)/man8 || install -m 755 -d $(DESTDIR)$(MANDIR)/man8
+	install -m 644 load_policy.8 $(DESTDIR)$(MANDIR)/man8/
 
 clean:
 	-rm -f $(TARGETS) *.o 
@@ -25,4 +25,4 @@ indent:
 	../../scripts/Lindent $(wildcard *.[ch])
 
 relabel:
-	/sbin/restorecon $(SBINDIR)/load_policy 
+	/sbin/restorecon $(DESTDIR)$(SBINDIR)/load_policy 
diff --git a/policycoreutils/man/Makefile b/policycoreutils/man/Makefile
index 0d91cd46..8af1520c 100644
--- a/policycoreutils/man/Makefile
+++ b/policycoreutils/man/Makefile
@@ -1,12 +1,13 @@
 # Installation directories.
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
+PREFIX ?= /usr
+MAN5DIR ?= $(PREFIX)/share/man/man5
 
 all:
 
 clean:
 
 install: all
-	mkdir -p $(MAN5DIR)
-	install -m 644 man5/*.5 $(MAN5DIR)
+	mkdir -p $(DESTDIR)$(MAN5DIR)
+	install -m 644 man5/*.5 $(DESTDIR)$(MAN5DIR)
 
 relabel:
diff --git a/policycoreutils/newrole/Makefile b/policycoreutils/newrole/Makefile
index 196af926..a1bfe1a6 100644
--- a/policycoreutils/newrole/Makefile
+++ b/policycoreutils/newrole/Makefile
@@ -1,9 +1,9 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
-ETCDIR ?= $(DESTDIR)/etc
-LOCALEDIR = /usr/share/locale
+ETCDIR ?= /etc
+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.
@@ -61,17 +61,17 @@ newrole: newrole.o $(EXTRA_OBJS)
 	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 install: all
-	test -d $(BINDIR)      || install -m 755 -d $(BINDIR)
-	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
-	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
-	install -m $(MODE) newrole $(BINDIR)
-	install -m 644 newrole.1 $(MANDIR)/man1/
+	test -d $(DESTDIR)$(BINDIR)      || install -m 755 -d $(DESTDIR)$(BINDIR)
+	test -d $(DESTDIR)$(ETCDIR)/pam.d || install -m 755 -d $(DESTDIR)$(ETCDIR)/pam.d
+	test -d $(DESTDIR)$(MANDIR)/man1 || install -m 755 -d $(DESTDIR)$(MANDIR)/man1
+	install -m $(MODE) newrole $(DESTDIR)$(BINDIR)
+	install -m 644 newrole.1 $(DESTDIR)$(MANDIR)/man1/
 ifeq ($(PAMH), y)
-	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
+	test -d $(DESTDIR)$(ETCDIR)/pam.d || install -m 755 -d $(DESTDIR)$(ETCDIR)/pam.d
 ifeq ($(LSPP_PRIV),y)
-	install -m 644 newrole-lspp.pamd $(ETCDIR)/pam.d/newrole
+	install -m 644 newrole-lspp.pamd $(DESTDIR)$(ETCDIR)/pam.d/newrole
 else
-	install -m 644 newrole.pamd $(ETCDIR)/pam.d/newrole
+	install -m 644 newrole.pamd $(DESTDIR)$(ETCDIR)/pam.d/newrole
 endif
 endif
 
@@ -82,4 +82,4 @@ indent:
 	../../scripts/Lindent $(wildcard *.[ch])
 
 relabel: install
-	/sbin/restorecon $(BINDIR)/newrole
+	/sbin/restorecon $(DESTDIR)$(BINDIR)/newrole
diff --git a/policycoreutils/po/Makefile b/policycoreutils/po/Makefile
index 58148613..575e1431 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 = $(PREFIX)/share/locale
 
 # PO catalog handling
 MSGMERGE	= msgmerge
@@ -128,8 +129,8 @@ clean:
 install: $(MOFILES)
 	@for n in $(MOFILES); do \
 	    l=`basename $$n .mo`; \
-	    $(INSTALL_DIR) $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES; \
-	    $(INSTALL_DATA) --verbose $$n $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \
+	    $(INSTALL_DIR) $(DESTDIR)$(INSTALL_NLS_DIR)/$$l/LC_MESSAGES; \
+	    $(INSTALL_DATA) --verbose $$n $(DESTDIR)$(INSTALL_NLS_DIR)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \
 	done
 
 %.mo: %.po
diff --git a/policycoreutils/run_init/Makefile b/policycoreutils/run_init/Makefile
index 921f0b07..1d5de572 100644
--- a/policycoreutils/run_init/Makefile
+++ b/policycoreutils/run_init/Makefile
@@ -1,10 +1,10 @@
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
-ETCDIR ?= $(DESTDIR)/etc
-LOCALEDIR ?= /usr/share/locale
+ETCDIR ?= /etc
+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)
 
@@ -32,14 +32,14 @@ open_init_pty: open_init_pty.c
 
 
 install: all
-	test -d $(SBINDIR)      || install -m 755 -d $(SBINDIR)
-	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
-	install -m 755 run_init $(SBINDIR)
-	install -m 755 open_init_pty $(SBINDIR)
-	install -m 644 run_init.8 $(MANDIR)/man8/
-	install -m 644 open_init_pty.8 $(MANDIR)/man8/
+	test -d $(DESTDIR)$(SBINDIR)      || install -m 755 -d $(DESTDIR)$(SBINDIR)
+	test -d $(DESTDIR)$(MANDIR)/man8 || install -m 755 -d $(DESTDIR)$(MANDIR)/man8
+	install -m 755 run_init $(DESTDIR)$(SBINDIR)
+	install -m 755 open_init_pty $(DESTDIR)$(SBINDIR)
+	install -m 644 run_init.8 $(DESTDIR)$(MANDIR)/man8/
+	install -m 644 open_init_pty.8 $(DESTDIR)$(MANDIR)/man8/
 ifeq ($(PAMH), y)
-	install -m 644 run_init.pamd $(ETCDIR)/pam.d/run_init
+	install -m 644 run_init.pamd $(DESTDIR)$(ETCDIR)/pam.d/run_init
 endif
 
 clean:
@@ -49,4 +49,4 @@ indent:
 	../../scripts/Lindent $(wildcard *.[ch])
 
 relabel: install
-	/sbin/restorecon $(SBINDIR)/run_init $(SBINDIR)/open_init_pty
+	/sbin/restorecon $(DESTDIR)$(SBINDIR)/run_init $(DESTDIR)$(SBINDIR)/open_init_pty
diff --git a/policycoreutils/scripts/Makefile b/policycoreutils/scripts/Makefile
index d9e86ffe..afe5dc49 100644
--- a/policycoreutils/scripts/Makefile
+++ b/policycoreutils/scripts/Makefile
@@ -1,17 +1,16 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(DESTDIR)/sbin
+PREFIX ?= /usr
+SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
 
 .PHONY: all
 all: fixfiles
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 fixfiles $(SBINDIR)
-	-mkdir -p $(MANDIR)/man8
-	install -m 644 fixfiles.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 fixfiles $(DESTDIR)$(SBINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 644 fixfiles.8 $(DESTDIR)$(MANDIR)/man8/
 
 clean:
 
diff --git a/policycoreutils/secon/Makefile b/policycoreutils/secon/Makefile
index 8e491d74..db8ee421 100644
--- a/policycoreutils/secon/Makefile
+++ b/policycoreutils/secon/Makefile
@@ -1,9 +1,7 @@
 # secon tool - command-line context
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(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)
@@ -18,13 +16,13 @@ secon: secon.o
 install-nogui: install
 
 install: all
-	install -m 755 secon $(BINDIR);
+	install -m 755 secon $(DESTDIR)$(BINDIR);
 
-	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
-	install -m 644 secon.1 $(MANDIR)/man1
+	test -d $(DESTDIR)$(MANDIR)/man1 || install -m 755 -d $(DESTDIR)$(MANDIR)/man1
+	install -m 644 secon.1 $(DESTDIR)$(MANDIR)/man1
 
 relabel:
-	/sbin/restorecon $(BINDIR)/secon
+	/sbin/restorecon $(DESTDIR)$(BINDIR)/secon
 
 clean:
 	rm -f *.o core* secon *~ *.bak
diff --git a/policycoreutils/semodule/Makefile b/policycoreutils/semodule/Makefile
index fffb43ac..639d3689 100644
--- a/policycoreutils/semodule/Makefile
+++ b/policycoreutils/semodule/Makefile
@@ -1,9 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol -lselinux -lsemanage
@@ -17,12 +15,12 @@ genhomedircon:
 	ln -sf semodule genhomedircon
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 semodule $(SBINDIR)
-	(cd $(SBINDIR); ln -sf semodule genhomedircon)
-	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
-	install -m 644 semodule.8 $(MANDIR)/man8/
-	install -m 644 genhomedircon.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 semodule $(DESTDIR)$(SBINDIR)
+	(cd $(DESTDIR)$(SBINDIR); ln -sf semodule genhomedircon)
+	test -d $(DESTDIR)$(MANDIR)/man8 || install -m 755 -d $(DESTDIR)$(MANDIR)/man8
+	install -m 644 semodule.8 $(DESTDIR)$(MANDIR)/man8/
+	install -m 644 genhomedircon.8 $(DESTDIR)$(MANDIR)/man8/
 
 relabel:
 
diff --git a/policycoreutils/sestatus/Makefile b/policycoreutils/sestatus/Makefile
index 41ca6832..274ef353 100644
--- a/policycoreutils/sestatus/Makefile
+++ b/policycoreutils/sestatus/Makefile
@@ -1,9 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
-ETCDIR ?= $(DESTDIR)/etc
-LIBDIR ?= $(PREFIX)/lib
+ETCDIR ?= /etc
 
 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += -D_FILE_OFFSET_BITS=64
@@ -14,14 +13,14 @@ all: sestatus
 sestatus: sestatus.o
 
 install: all
-	[ -d $(MANDIR)/man8 ] || mkdir -p $(MANDIR)/man8
-	[ -d $(MANDIR)/man5 ] || mkdir -p $(MANDIR)/man5
-	-mkdir -p $(SBINDIR)
-	install -m 755 sestatus $(SBINDIR)
-	install -m 644 sestatus.8 $(MANDIR)/man8
-	install -m 644 sestatus.conf.5 $(MANDIR)/man5
-	-mkdir -p $(ETCDIR)
-	install -m 644 sestatus.conf $(ETCDIR)
+	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
+	[ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 sestatus $(DESTDIR)$(SBINDIR)
+	install -m 644 sestatus.8 $(DESTDIR)$(MANDIR)/man8
+	install -m 644 sestatus.conf.5 $(DESTDIR)$(MANDIR)/man5
+	-mkdir -p $(DESTDIR)$(ETCDIR)
+	install -m 644 sestatus.conf $(DESTDIR)$(ETCDIR)
 
 clean:
 	rm -f sestatus *.o
diff --git a/policycoreutils/setfiles/Makefile b/policycoreutils/setfiles/Makefile
index c08e2dd1..e9432768 100644
--- a/policycoreutils/setfiles/Makefile
+++ b/policycoreutils/setfiles/Makefile
@@ -1,8 +1,7 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SBINDIR ?= $(DESTDIR)/sbin
+PREFIX ?= /usr
+SBINDIR ?= /sbin
 MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
 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 }')
@@ -29,14 +28,14 @@ man:
 	@sed -i "s/ABORT_ON_ERRORS/$(ABORT_ON_ERRORS)/g" setfiles.8.man
 
 install: all
-	[ -d $(MANDIR)/man8 ] || mkdir -p $(MANDIR)/man8
-	-mkdir -p $(SBINDIR)
-	install -m 755 setfiles $(SBINDIR)
-	(cd $(SBINDIR) && ln -sf setfiles restorecon)
-	install -m 755 restorecon_xattr $(SBINDIR)
-	install -m 644 setfiles.8.man $(MANDIR)/man8/setfiles.8
-	install -m 644 restorecon.8 $(MANDIR)/man8/restorecon.8
-	install -m 644 restorecon_xattr.8 $(MANDIR)/man8/restorecon_xattr.8
+	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 setfiles $(DESTDIR)$(SBINDIR)
+	(cd $(DESTDIR)$(SBINDIR) && ln -sf setfiles restorecon)
+	install -m 755 restorecon_xattr $(DESTDIR)$(SBINDIR)
+	install -m 644 setfiles.8.man $(DESTDIR)$(MANDIR)/man8/setfiles.8
+	install -m 644 restorecon.8 $(DESTDIR)$(MANDIR)/man8/restorecon.8
+	install -m 644 restorecon_xattr.8 $(DESTDIR)$(MANDIR)/man8/restorecon_xattr.8
 
 clean:
 	rm -f setfiles restorecon restorecon_xattr *.o setfiles.8.man
@@ -45,4 +44,4 @@ indent:
 	../../scripts/Lindent $(wildcard *.[ch])
 
 relabel: install
-	$(SBINDIR)/restorecon $(SBINDIR)/setfiles $(SBINDIR)/restorecon_xattr
+	$(DESTDIR)$(SBINDIR)/restorecon $(DESTDIR)$(SBINDIR)/setfiles $(DESTDIR)$(SBINDIR)/restorecon_xattr
diff --git a/policycoreutils/setsebool/Makefile b/policycoreutils/setsebool/Makefile
index bc254dab..3cd58353 100644
--- a/policycoreutils/setsebool/Makefile
+++ b/policycoreutils/setsebool/Makefile
@@ -1,10 +1,8 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
+BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol -lselinux -lsemanage
@@ -17,12 +15,12 @@ all: setsebool
 setsebool: $(SETSEBOOL_OBJS)
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 setsebool $(SBINDIR)
-	-mkdir -p $(MANDIR)/man8
-	install -m 644 setsebool.8 $(MANDIR)/man8/
-	-mkdir -p $(BASHCOMPLETIONDIR)
-	install -m 644 $(BASHCOMPLETIONS) $(BASHCOMPLETIONDIR)/setsebool
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 setsebool $(DESTDIR)$(SBINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 644 setsebool.8 $(DESTDIR)$(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(BASHCOMPLETIONDIR)
+	install -m 644 $(BASHCOMPLETIONS) $(DESTDIR)$(BASHCOMPLETIONDIR)/setsebool
 
 relabel:
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 08/15] python: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (6 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 07/15] policycoreutils: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 09/15] python: build: move modules from platform-specific to platform-shared Marcus Folkesson
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    	- Remove CFLAGS from linking rule
    
    v4:
    	-  move platform from platform specific to platform shared installation directory
    
    v3:
    	- Add missing slash
    	- keep the possibility to specify LIBSEPOLA to
    	  make depending component recompile on change. If not specified, fall back to
    	  libsepola in LDFLAGS path.
    
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 python/audit2allow/Makefile           | 30 +++++++++++++++++-------------
 python/chcat/Makefile                 | 11 +++++------
 python/semanage/Makefile              | 25 ++++++++++++-------------
 python/sepolgen/src/sepolgen/Makefile |  9 +++++----
 python/sepolgen/src/share/Makefile    |  8 ++++----
 python/sepolicy/Makefile              | 24 ++++++++++--------------
 6 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile
index 8db8075f..513bb2b6 100644
--- a/python/audit2allow/Makefile
+++ b/python/audit2allow/Makefile
@@ -1,19 +1,23 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
 MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
-INCLUDEDIR ?= $(PREFIX)/include
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
 
+# 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
+
 all: audit2why sepolgen-ifgen-attr-helper
 
 sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_LIBSEPOLA)
 
 audit2why:
 	ln -sf audit2allow audit2why
@@ -22,14 +26,14 @@ test: all
 	@$(PYTHON) test_audit2allow.py -v
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 audit2allow $(BINDIR)
-	(cd $(BINDIR); ln -sf audit2allow audit2why)
-	install -m 755 sepolgen-ifgen-attr-helper $(BINDIR)
-	install -m 755 sepolgen-ifgen $(BINDIR)
-	-mkdir -p $(MANDIR)/man1
-	install -m 644 audit2allow.1 $(MANDIR)/man1/
-	install -m 644 audit2why.1 $(MANDIR)/man1/
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 audit2allow $(DESTDIR)$(BINDIR)
+	(cd $(DESTDIR)$(BINDIR); ln -sf audit2allow audit2why)
+	install -m 755 sepolgen-ifgen-attr-helper $(DESTDIR)$(BINDIR)
+	install -m 755 sepolgen-ifgen $(DESTDIR)$(BINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man1
+	install -m 644 audit2allow.1 $(DESTDIR)$(MANDIR)/man1/
+	install -m 644 audit2why.1 $(DESTDIR)$(MANDIR)/man1/
 
 clean:
 	rm -f *~ *.o sepolgen-ifgen-attr-helper
diff --git a/python/chcat/Makefile b/python/chcat/Makefile
index 0fd12d6d..290b9a6e 100644
--- a/python/chcat/Makefile
+++ b/python/chcat/Makefile
@@ -1,17 +1,16 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= $(PREFIX)/share/locale
 
 .PHONY: all
 all: chcat
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 chcat $(BINDIR)
-	-mkdir -p $(MANDIR)/man8
-	install -m 644 chcat.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 chcat $(DESTDIR)$(BINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 644 chcat.8 $(DESTDIR)$(MANDIR)/man8/
 
 clean:
 
diff --git a/python/semanage/Makefile b/python/semanage/Makefile
index 132162bc..a8465e62 100644
--- a/python/semanage/Makefile
+++ b/python/semanage/Makefile
@@ -1,13 +1,12 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
 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
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))")
+PACKAGEDIR ?= $(PYTHONLIBDIR)
+BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions
 
 TARGETS=semanage
 
@@ -16,14 +15,14 @@ BASHCOMPLETIONS=semanage-bash-completion.sh
 all: $(TARGETS)
 
 install: all
-	[ -d $(MANDIR)/man8 ] || mkdir -p $(MANDIR)/man8
-	-mkdir -p $(SBINDIR)
-	install -m 755 semanage $(SBINDIR)
-	install -m 644 *.8 $(MANDIR)/man8
-	test -d $(PACKAGEDIR) || install -m 755 -d $(PACKAGEDIR)
-	install -m 755 seobject.py $(PACKAGEDIR)
-	-mkdir -p $(BASHCOMPLETIONDIR)
-	install -m 644 $(BASHCOMPLETIONS) $(BASHCOMPLETIONDIR)/semanage
+	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 semanage $(DESTDIR)$(SBINDIR)
+	install -m 644 *.8 $(DESTDIR)$(MANDIR)/man8
+	test -d $(DESTDIR)/$(PACKAGEDIR) || install -m 755 -d $(DESTDIR)/$(PACKAGEDIR)
+	install -m 755 seobject.py $(DESTDIR)/$(PACKAGEDIR)
+	-mkdir -p $(DESTDIR)$(BASHCOMPLETIONDIR)
+	install -m 644 $(BASHCOMPLETIONS) $(DESTDIR)$(BASHCOMPLETIONDIR)/semanage
 
 test:
 	@$(PYTHON) test-semanage.py -a
diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
index d3aa7715..6d392f5d 100644
--- a/python/sepolgen/src/sepolgen/Makefile
+++ b/python/sepolgen/src/sepolgen/Makefile
@@ -1,12 +1,13 @@
+PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))")
+PACKAGEDIR ?= /$(PYTHONLIBDIR)/sepolgen
 
 all:
 
 install: all
-	-mkdir -p $(PACKAGEDIR)
-	install -m 644 *.py $(PACKAGEDIR)
+	-mkdir -p $(DESTDIR)$(PACKAGEDIR)
+	install -m 644 *.py $(DESTDIR)$(PACKAGEDIR)
 
 clean:
 	rm -f parser.out parsetab.py
diff --git a/python/sepolgen/src/share/Makefile b/python/sepolgen/src/share/Makefile
index abf5e451..1a7133cb 100644
--- a/python/sepolgen/src/share/Makefile
+++ b/python/sepolgen/src/share/Makefile
@@ -1,10 +1,10 @@
-SHAREDIR ?= $(DESTDIR)/var/lib/sepolgen
+SHAREDIR ?= /var/lib/sepolgen
 
 all:
 
 install: all
-	-mkdir -p $(SHAREDIR)
-	install -m 644 perm_map $(SHAREDIR)
+	-mkdir -p $(DESTDIR)$(SHAREDIR)
+	install -m 644 perm_map $(DESTDIR)$(SHAREDIR)
 
 clean:
-	rm -f *~
\ No newline at end of file
+	rm -f *~
diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile
index 5a56e6c8..fb8a1325 100644
--- a/python/sepolicy/Makefile
+++ b/python/sepolicy/Makefile
@@ -1,14 +1,10 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
 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
+BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions
 CFLAGS ?= -Wall -Werror -Wextra -W
 override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 
@@ -30,13 +26,13 @@ test:
 	@$(PYTHON) test_sepolicy.py -v
 
 install:
-	$(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
-	[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
-	install -m 755 sepolicy.py $(BINDIR)/sepolicy
-	(cd $(BINDIR); ln -sf sepolicy sepolgen)
-	-mkdir -p $(MANDIR)/man8
-	install -m 644 *.8 $(MANDIR)/man8
-	-mkdir -p $(BASHCOMPLETIONDIR)
-	install -m 644 $(BASHCOMPLETIONS) $(BASHCOMPLETIONDIR)/sepolicy
+	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)`
+	[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy
+	(cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 644 *.8 $(DESTDIR)$(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(BASHCOMPLETIONDIR)
+	install -m 644 $(BASHCOMPLETIONS) $(DESTDIR)$(BASHCOMPLETIONDIR)/sepolicy
 
 relabel:
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 09/15] python: build: move modules from platform-specific to platform-shared
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (7 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 08/15] python: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 10/15] restorecond: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 python/semanage/Makefile              | 2 +-
 python/sepolgen/src/sepolgen/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/semanage/Makefile b/python/semanage/Makefile
index a8465e62..5fc1998e 100644
--- a/python/semanage/Makefile
+++ b/python/semanage/Makefile
@@ -4,7 +4,7 @@ PYTHON ?= python
 PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= $(PYTHONLIBDIR)
 BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions
 
diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile
index 6d392f5d..c75809ad 100644
--- a/python/sepolgen/src/sepolgen/Makefile
+++ b/python/sepolgen/src/sepolgen/Makefile
@@ -1,6 +1,6 @@
 PREFIX ?= /usr
 PYTHON ?= python
-PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))")
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))")
 PACKAGEDIR ?= /$(PYTHONLIBDIR)/sepolgen
 
 all:
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 10/15] restorecond: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (8 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 09/15] python: build: move modules from platform-specific to platform-shared Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 11/15] sandbox: " Marcus Folkesson
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 restorecond/Makefile | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/restorecond/Makefile b/restorecond/Makefile
index ada94aeb..25be18d4 100644
--- a/restorecond/Makefile
+++ b/restorecond/Makefile
@@ -1,13 +1,12 @@
 PKG_CONFIG ?= pkg-config
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
-LIBDIR ?= $(PREFIX)/lib
 MANDIR = $(PREFIX)/share/man
-AUTOSTARTDIR = $(DESTDIR)/etc/xdg/autostart
-DBUSSERVICEDIR = $(DESTDIR)/usr/share/dbus-1/services
-SYSTEMDDIR ?= $(DESTDIR)/usr/lib/systemd
+AUTOSTARTDIR = /etc/xdg/autostart
+DBUSSERVICEDIR = $(PREFIX)/share/dbus-1/services
+SYSTEMDDIR ?= $(PREFIX)/lib/systemd
 
 autostart_DATA = sealertauto.desktop
 INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
@@ -39,23 +38,23 @@ restorecond:  restore.o restorecond.o utmpwatcher.o stringslist.o user.o watch.o
 	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 install: all
-	[ -d $(MANDIR)/man8 ] || mkdir -p $(MANDIR)/man8
-	-mkdir -p $(SBINDIR)
-	install -m 755 restorecond $(SBINDIR)
-	install -m 644 restorecond.8 $(MANDIR)/man8
+	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 restorecond $(DESTDIR)$(SBINDIR)
+	install -m 644 restorecond.8 $(DESTDIR)$(MANDIR)/man8
 	-mkdir -p $(INITDIR)
 	install -m 755 restorecond.init $(INITDIR)/restorecond
 	-mkdir -p $(SELINUXDIR)
 	install -m 644 restorecond.conf $(SELINUXDIR)/restorecond.conf
 	install -m 644 restorecond_user.conf $(SELINUXDIR)/restorecond_user.conf
-	-mkdir -p $(AUTOSTARTDIR)
-	install -m 644 restorecond.desktop $(AUTOSTARTDIR)/restorecond.desktop
-	-mkdir -p $(DBUSSERVICEDIR)
-	install -m 600 org.selinux.Restorecond.service  $(DBUSSERVICEDIR)/org.selinux.Restorecond.service
-	-mkdir -p $(SYSTEMDDIR)/system
-	install -m 644 restorecond.service $(SYSTEMDDIR)/system/
+	-mkdir -p $(DESTDIR)$(AUTOSTARTDIR)
+	install -m 644 restorecond.desktop $(DESTDIR)$(AUTOSTARTDIR)/restorecond.desktop
+	-mkdir -p $(DESTDIR)$(DBUSSERVICEDIR)
+	install -m 600 org.selinux.Restorecond.service  $(DESTDIR)$(DBUSSERVICEDIR)/org.selinux.Restorecond.service
+	-mkdir -p $(DESTDIR)$(SYSTEMDDIR)/system
+	install -m 644 restorecond.service $(DESTDIR)$(SYSTEMDDIR)/system/
 relabel: install
-	/sbin/restorecon $(SBINDIR)/restorecond 
+	/sbin/restorecon $(DESTDIR)$(SBINDIR)/restorecond 
 
 clean:
 	-rm -f restorecond *.o *~
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 11/15] sandbox: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (9 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 10/15] restorecond: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 12/15] secilc: " Marcus Folkesson
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 sandbox/Makefile | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/sandbox/Makefile b/sandbox/Makefile
index 05c3d658..49c1d3f6 100644
--- a/sandbox/Makefile
+++ b/sandbox/Makefile
@@ -1,13 +1,11 @@
 PYTHON ?= python
 
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-SYSCONFDIR ?= $(DESTDIR)/etc/sysconfig
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
+SYSCONFDIR ?= /etc/sysconfig
 BINDIR ?= $(PREFIX)/bin
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
-LOCALEDIR ?= /usr/share/locale
 SHAREDIR ?= $(PREFIX)/share/sandbox
 override CFLAGS += -DPACKAGE="\"policycoreutils\"" -Wall -Werror -Wextra -W
 override LDLIBS += -lselinux -lcap-ng
@@ -18,20 +16,20 @@ all: sandbox seunshare sandboxX.sh start
 seunshare: $(SEUNSHARE_OBJS)
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 sandbox $(BINDIR)
-	-mkdir -p $(MANDIR)/man8
-	install -m 644 sandbox.8 $(MANDIR)/man8/
-	install -m 644 seunshare.8 $(MANDIR)/man8/
-	-mkdir -p $(MANDIR)/man5
-	install -m 644 sandbox.5 $(MANDIR)/man5/
-	-mkdir -p $(SBINDIR)
-	install -m 4755 seunshare $(SBINDIR)/
-	-mkdir -p $(SHAREDIR)
-	install -m 755 sandboxX.sh $(SHAREDIR)
-	install -m 755 start $(SHAREDIR)
-	-mkdir -p $(SYSCONFDIR)
-	install -m 644 sandbox.conf $(SYSCONFDIR)/sandbox
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 sandbox $(DESTDIR)$(BINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 644 sandbox.8 $(DESTDIR)$(MANDIR)/man8/
+	install -m 644 seunshare.8 $(DESTDIR)$(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(MANDIR)/man5
+	install -m 644 sandbox.5 $(DESTDIR)$(MANDIR)/man5/
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 4755 seunshare $(DESTDIR)$(SBINDIR)/
+	-mkdir -p $(DESTDIR)$(SHAREDIR)
+	install -m 755 sandboxX.sh $(DESTDIR)$(SHAREDIR)
+	install -m 755 start $(DESTDIR)$(SHAREDIR)
+	-mkdir -p $(DESTDIR)$(SYSCONFDIR)
+	install -m 644 sandbox.conf $(DESTDIR)$(SYSCONFDIR)/sandbox
 
 test:
 	@$(PYTHON) test_sandbox.py -v
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 12/15] secilc: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (10 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 11/15] sandbox: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 13/15] semodule-utils: " Marcus Folkesson
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 secilc/Makefile | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/secilc/Makefile b/secilc/Makefile
index 1cac53e4..dfd79cef 100644
--- a/secilc/Makefile
+++ b/secilc/Makefile
@@ -1,8 +1,6 @@
-PREFIX ?= $(DESTDIR)/usr
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
 
 SECILC = secilc
 SECILC_SRCS := secilc.c
@@ -41,12 +39,12 @@ $(SECIL2CONF_MANPAGE): $(SECIL2CONF_MANPAGE).xml
 	$(XMLTO) man $(SECIL2CONF_MANPAGE).xml
 
 install: all man
-	-mkdir -p $(BINDIR)
-	-mkdir -p $(MANDIR)/man8
-	install -m 755 $(SECILC) $(BINDIR)
-	install -m 755 $(SECIL2CONF) $(BINDIR)
-	install -m 644 $(SECILC_MANPAGE) $(MANDIR)/man8
-	install -m 644 $(SECIL2CONF_MANPAGE) $(MANDIR)/man8
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	-mkdir -p $(DESTDIR)$(MANDIR)/man8
+	install -m 755 $(SECILC) $(DESTDIR)$(BINDIR)
+	install -m 755 $(SECIL2CONF) $(DESTDIR)$(BINDIR)
+	install -m 644 $(SECILC_MANPAGE) $(DESTDIR)$(MANDIR)/man8
+	install -m 644 $(SECIL2CONF_MANPAGE) $(DESTDIR)$(MANDIR)/man8
 
 doc:
 	$(MAKE) -C docs
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 13/15] semodule-utils: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (11 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 12/15] secilc: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 14/15] dbus: " Marcus Folkesson
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 semodule-utils/semodule_expand/Makefile  | 12 +++++-------
 semodule-utils/semodule_link/Makefile    | 12 +++++-------
 semodule-utils/semodule_package/Makefile | 16 +++++++---------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/semodule-utils/semodule_expand/Makefile b/semodule-utils/semodule_expand/Makefile
index 072f2137..f1a1c8f3 100644
--- a/semodule-utils/semodule_expand/Makefile
+++ b/semodule-utils/semodule_expand/Makefile
@@ -1,8 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
 MANDIR ?= $(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
@@ -13,10 +11,10 @@ all: semodule_expand
 semodule_expand:  semodule_expand.o 
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 semodule_expand $(BINDIR)
-	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
-	install -m 644 semodule_expand.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 semodule_expand $(DESTDIR)$(BINDIR)
+	test -d $(DESTDIR)$(MANDIR)/man8 || install -m 755 -d $(DESTDIR)$(MANDIR)/man8
+	install -m 644 semodule_expand.8 $(DESTDIR)$(MANDIR)/man8/
 
 relabel:
 
diff --git a/semodule-utils/semodule_link/Makefile b/semodule-utils/semodule_link/Makefile
index cc4687bd..692cb026 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
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
 
 CFLAGS ?= -Werror -Wall -W
 override LDLIBS += -lsepol
@@ -13,10 +11,10 @@ all: semodule_link
 semodule_link:  semodule_link.o 
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 semodule_link $(BINDIR)
-	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
-	install -m 644 semodule_link.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 semodule_link $(DESTDIR)$(BINDIR)
+	test -d $(DESTDIR)$(MANDIR)/man8 || install -m 755 -d $(DESTDIR)$(MANDIR)/man8
+	install -m 644 semodule_link.8 $(DESTDIR)$(MANDIR)/man8/
 
 relabel:
 
diff --git a/semodule-utils/semodule_package/Makefile b/semodule-utils/semodule_package/Makefile
index 96dd7c4f..da170267 100644
--- a/semodule-utils/semodule_package/Makefile
+++ b/semodule-utils/semodule_package/Makefile
@@ -1,8 +1,6 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-INCLUDEDIR ?= $(PREFIX)/include
+PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
 MANDIR ?= $(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
@@ -13,12 +11,12 @@ all: semodule_package semodule_unpackage
 semodule_package:  semodule_package.o 
 
 install: all
-	-mkdir -p $(BINDIR)
-	install -m 755 semodule_package $(BINDIR)
-	install -m 755 semodule_unpackage $(BINDIR)
-	test -d $(MANDIR)/man8 || install -m 755 -d $(MANDIR)/man8
-	install -m 644 semodule_package.8 $(MANDIR)/man8/
-	install -m 644 semodule_unpackage.8 $(MANDIR)/man8/
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 semodule_package $(DESTDIR)$(BINDIR)
+	install -m 755 semodule_unpackage $(DESTDIR)$(BINDIR)
+	test -d $(DESTDIR)$(MANDIR)/man8 || install -m 755 -d $(DESTDIR)$(MANDIR)/man8
+	install -m 644 semodule_package.8 $(DESTDIR)$(MANDIR)/man8/
+	install -m 644 semodule_unpackage.8 $(DESTDIR)$(MANDIR)/man8/
 
 relabel:
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v5 14/15] dbus: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (12 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 13/15] semodule-utils: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14  9:57 ` [PATCH v5 15/15] build: setup buildpaths if DESTDIR is specified Marcus Folkesson
  2018-02-14 19:19 ` Rework of makefiles v5 Nicolas Iooss
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, 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] 21+ messages in thread

* [PATCH v5 15/15] build: setup buildpaths if DESTDIR is specified
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (13 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 14/15] dbus: " Marcus Folkesson
@ 2018-02-14  9:57 ` Marcus Folkesson
  2018-02-14 19:19 ` Rework of makefiles v5 Nicolas Iooss
  15 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-14  9:57 UTC (permalink / raw)
  To: nicolas.iooss, sds; +Cc: selinux, Marcus Folkesson

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v4:
    	- add LIBDIR to LDFLAGS if DESTDIR is specified
    	- export LIBSEPOLA  if DESTDIR is specified
    
    v3:
    	- Add default prefix

 Makefile | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 6da7f7b7..c238dbc8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+PREFIX ?= /usr
 OPT_SUBDIRS ?= dbus gui mcstrans python restorecond sandbox semodule-utils
 SUBDIRS=libsepol libselinux libsemanage checkpolicy secilc policycoreutils $(OPT_SUBDIRS)
 PYSUBDIRS=libselinux libsemanage
@@ -19,10 +20,14 @@ else
 endif
 
 ifneq ($(DESTDIR),)
-	CFLAGS += -I$(DESTDIR)/usr/include
-	LDFLAGS += -L$(DESTDIR)/usr/lib
+	LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
+	LIBSEPOLA ?= $(LIBDIR)/libsepol.a
+
+	CFLAGS += -I$(DESTDIR)$(PREFIX)/include
+	LDFLAGS += -L$(DESTDIR)$(PREFIX)/lib -L$(LIBDIR)
 	export CFLAGS
 	export LDFLAGS
+	export LIBSEPOLA
 endif
 
 all install relabel clean test indent:
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v5 07/15] policycoreutils: build: follow standard semantics for DESTDIR and PREFIX
  2018-02-14  9:57 ` [PATCH v5 07/15] policycoreutils: " Marcus Folkesson
@ 2018-02-14 19:00   ` Nicolas Iooss
  0 siblings, 0 replies; 21+ messages in thread
From: Nicolas Iooss @ 2018-02-14 19:00 UTC (permalink / raw)
  To: Marcus Folkesson; +Cc: Stephen Smalley, selinux

On Wed, Feb 14, 2018 at 10:57 AM, Marcus Folkesson
<marcus.folkesson@gmail.com> wrote:
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
>
> Notes:
>     v5:
>         - Only use $(DESTDIR) in install
>     v2:
>         - Rework all packages (not just selinux/sepol/semanage)
>
>  policycoreutils/hll/pp/Makefile      |  9 +++------
>  policycoreutils/load_policy/Makefile | 16 ++++++++--------
>  policycoreutils/man/Makefile         |  7 ++++---
>  policycoreutils/newrole/Makefile     | 24 ++++++++++++------------
>  policycoreutils/po/Makefile          |  7 ++++---
>  policycoreutils/run_init/Makefile    | 22 +++++++++++-----------
>  policycoreutils/scripts/Makefile     | 13 ++++++-------
>  policycoreutils/secon/Makefile       | 12 +++++-------
>  policycoreutils/semodule/Makefile    | 16 +++++++---------
>  policycoreutils/sestatus/Makefile    | 21 ++++++++++-----------
>  policycoreutils/setfiles/Makefile    | 23 +++++++++++------------
>  policycoreutils/setsebool/Makefile   | 18 ++++++++----------
>  12 files changed, 89 insertions(+), 99 deletions(-)
>
[...]
> diff --git a/policycoreutils/setsebool/Makefile b/policycoreutils/setsebool/Makefile
> index bc254dab..3cd58353 100644
> --- a/policycoreutils/setsebool/Makefile
> +++ b/policycoreutils/setsebool/Makefile
> @@ -1,10 +1,8 @@
>  # Installation directories.
> -PREFIX ?= $(DESTDIR)/usr
> -INCLUDEDIR ?= $(PREFIX)/include
> +PREFIX ?= /usr
>  SBINDIR ?= $(PREFIX)/sbin
>  MANDIR = $(PREFIX)/share/man
> -LIBDIR ?= $(PREFIX)/lib
> -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
> +BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions

You forgot to remove $(DESTDIR) here, so setsebool's bash completion
file gets installed in $DESTDIR/$DESTDIR/usr/... All the other
modifications on variables look good to me.
Thanks!
Nicolas

>
>  CFLAGS ?= -Werror -Wall -W
>  override LDLIBS += -lsepol -lselinux -lsemanage
> @@ -17,12 +15,12 @@ all: setsebool
>  setsebool: $(SETSEBOOL_OBJS)
>
>  install: all
> -       -mkdir -p $(SBINDIR)
> -       install -m 755 setsebool $(SBINDIR)
> -       -mkdir -p $(MANDIR)/man8
> -       install -m 644 setsebool.8 $(MANDIR)/man8/
> -       -mkdir -p $(BASHCOMPLETIONDIR)
> -       install -m 644 $(BASHCOMPLETIONS) $(BASHCOMPLETIONDIR)/setsebool
> +       -mkdir -p $(DESTDIR)$(SBINDIR)
> +       install -m 755 setsebool $(DESTDIR)$(SBINDIR)
> +       -mkdir -p $(DESTDIR)$(MANDIR)/man8
> +       install -m 644 setsebool.8 $(DESTDIR)$(MANDIR)/man8/
> +       -mkdir -p $(DESTDIR)$(BASHCOMPLETIONDIR)
> +       install -m 644 $(BASHCOMPLETIONS) $(DESTDIR)$(BASHCOMPLETIONDIR)/setsebool
>
>  relabel:
>
> --
> 2.15.1
>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Rework of makefiles v5
  2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
                   ` (14 preceding siblings ...)
  2018-02-14  9:57 ` [PATCH v5 15/15] build: setup buildpaths if DESTDIR is specified Marcus Folkesson
@ 2018-02-14 19:19 ` Nicolas Iooss
  2018-02-15 13:04   ` Marcus Folkesson
  15 siblings, 1 reply; 21+ messages in thread
From: Nicolas Iooss @ 2018-02-14 19:19 UTC (permalink / raw)
  To: Marcus Folkesson; +Cc: Stephen Smalley, selinux

On Wed, Feb 14, 2018 at 10:57 AM, Marcus Folkesson
<marcus.folkesson@gmail.com> wrote:
> I have updated the patchset.
>
> The biggest change is that $(DESTDIR) is now used in the
> install stage only.
>
> Also some overidden CFLAGS/LDFLAGS has been removed since we now have
> explicit build rules.
>
> I have moved the changelog into patches.
>
> Please test to compile with:
> make DESTDIR=/tmp/myroot PREFIX=/myusr install
> or
> make DESTDIR=/tmp/myroot install
>
> Thanks for all feedback.
>
> Best regards
> Marcus Folkesson
>

Hi,
Thanks for this update! Here are three comments on this patchset:

* you forgot a $(DESTDIR) occurrence in patch 7.
* .travis.yml needs a simple patch to fix the value of PYSITEDIR. I
will send it later.
* While reading the Makefile after patch 15, I have been surprised by
"LIBDIR ?= $(DESTDIR)$(PREFIX)/lib", with DESTDIR. As this variable is
not exported, it works fine as it is, but it might be cleaner to
define it as "LIBDIR ?= $(PREFIX)/lib" and to use $(DESTDIR) in the
following lines. This point may be addressed in a follow-up commit
after the patchset has been merged.

As the patchset looks almost ready to be merged, I have created
https://github.com/SELinuxProject/selinux/pull/79 with a modified
patch 7 and my patch for .travis.yml. This pull request holds the
commits I plan to apply in a few days if no other maintainer disagrees
with this.

Best,
Nicolas

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Rework of makefiles v5
  2018-02-14 19:19 ` Rework of makefiles v5 Nicolas Iooss
@ 2018-02-15 13:04   ` Marcus Folkesson
  2018-02-21 21:46     ` Nicolas Iooss
  0 siblings, 1 reply; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-15 13:04 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: Stephen Smalley, selinux

[-- Attachment #1: Type: text/plain, Size: 1910 bytes --]

Hi Nicolas,

First of all, thank you for your review.

On Wed, Feb 14, 2018 at 08:19:44PM +0100, Nicolas Iooss wrote:
> On Wed, Feb 14, 2018 at 10:57 AM, Marcus Folkesson
> <marcus.folkesson@gmail.com> wrote:
> > I have updated the patchset.
> >
> > The biggest change is that $(DESTDIR) is now used in the
> > install stage only.
> >
> > Also some overidden CFLAGS/LDFLAGS has been removed since we now have
> > explicit build rules.
> >
> > I have moved the changelog into patches.
> >
> > Please test to compile with:
> > make DESTDIR=/tmp/myroot PREFIX=/myusr install
> > or
> > make DESTDIR=/tmp/myroot install
> >
> > Thanks for all feedback.
> >
> > Best regards
> > Marcus Folkesson
> >
> 
> Hi,
> Thanks for this update! Here are three comments on this patchset:
> 
> * you forgot a $(DESTDIR) occurrence in patch 7.

Good catch!

> * .travis.yml needs a simple patch to fix the value of PYSITEDIR. I
> will send it later.

Please do.

> * While reading the Makefile after patch 15, I have been surprised by
> "LIBDIR ?= $(DESTDIR)$(PREFIX)/lib", with DESTDIR. As this variable is
> not exported, it works fine as it is, but it might be cleaner to
> define it as "LIBDIR ?= $(PREFIX)/lib" and to use $(DESTDIR) in the
> following lines. This point may be addressed in a follow-up commit
> after the patchset has been merged.

I agree.
I also think it could be part of a follow-up commit. I will take a note.

> 
> As the patchset looks almost ready to be merged, I have created
> https://github.com/SELinuxProject/selinux/pull/79 with a modified
> patch 7 and my patch for .travis.yml. This pull request holds the
> commits I plan to apply in a few days if no other maintainer disagrees
> with this.

Ok, then I will not come up with a v6 that fixes your feedback for patch
#7.

> 
> Best,
> Nicolas
> 

Best regards
Marcus Folkesson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Rework of makefiles v5
  2018-02-15 13:04   ` Marcus Folkesson
@ 2018-02-21 21:46     ` Nicolas Iooss
  2018-02-22 19:19       ` Marcus Folkesson
  0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Iooss @ 2018-02-21 21:46 UTC (permalink / raw)
  To: Marcus Folkesson; +Cc: Stephen Smalley, selinux

On Thu, Feb 15, 2018 at 2:04 PM, Marcus Folkesson
<marcus.folkesson@gmail.com> wrote:
> Hi Nicolas,
>
> First of all, thank you for your review.
>
> On Wed, Feb 14, 2018 at 08:19:44PM +0100, Nicolas Iooss wrote:
>> On Wed, Feb 14, 2018 at 10:57 AM, Marcus Folkesson
>> <marcus.folkesson@gmail.com> wrote:
>> > I have updated the patchset.
>> >
>> > The biggest change is that $(DESTDIR) is now used in the
>> > install stage only.
>> >
>> > Also some overidden CFLAGS/LDFLAGS has been removed since we now have
>> > explicit build rules.
>> >
>> > I have moved the changelog into patches.
>> >
>> > Please test to compile with:
>> > make DESTDIR=/tmp/myroot PREFIX=/myusr install
>> > or
>> > make DESTDIR=/tmp/myroot install
>> >
>> > Thanks for all feedback.
>> >
>> > Best regards
>> > Marcus Folkesson
>> >
>>
>> Hi,
>> Thanks for this update! Here are three comments on this patchset:
>>
>> * you forgot a $(DESTDIR) occurrence in patch 7.
>
> Good catch!
>
>> * .travis.yml needs a simple patch to fix the value of PYSITEDIR. I
>> will send it later.
>
> Please do.
>
>> * While reading the Makefile after patch 15, I have been surprised by
>> "LIBDIR ?= $(DESTDIR)$(PREFIX)/lib", with DESTDIR. As this variable is
>> not exported, it works fine as it is, but it might be cleaner to
>> define it as "LIBDIR ?= $(PREFIX)/lib" and to use $(DESTDIR) in the
>> following lines. This point may be addressed in a follow-up commit
>> after the patchset has been merged.
>
> I agree.
> I also think it could be part of a follow-up commit. I will take a note.
>
>>
>> As the patchset looks almost ready to be merged, I have created
>> https://github.com/SELinuxProject/selinux/pull/79 with a modified
>> patch 7 and my patch for .travis.yml. This pull request holds the
>> commits I plan to apply in a few days if no other maintainer disagrees
>> with this.
>
> Ok, then I will not come up with a v6 that fixes your feedback for patch
> #7.

I have merged this patchset. Thanks!

Nicolas

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Rework of makefiles v5
  2018-02-21 21:46     ` Nicolas Iooss
@ 2018-02-22 19:19       ` Marcus Folkesson
  0 siblings, 0 replies; 21+ messages in thread
From: Marcus Folkesson @ 2018-02-22 19:19 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: Stephen Smalley, selinux

[-- Attachment #1: Type: text/plain, Size: 2349 bytes --]

On Wed, Feb 21, 2018 at 10:46:45PM +0100, Nicolas Iooss wrote:
> On Thu, Feb 15, 2018 at 2:04 PM, Marcus Folkesson
> <marcus.folkesson@gmail.com> wrote:
> > Hi Nicolas,
> >
> > First of all, thank you for your review.
> >
> > On Wed, Feb 14, 2018 at 08:19:44PM +0100, Nicolas Iooss wrote:
> >> On Wed, Feb 14, 2018 at 10:57 AM, Marcus Folkesson
> >> <marcus.folkesson@gmail.com> wrote:
> >> > I have updated the patchset.
> >> >
> >> > The biggest change is that $(DESTDIR) is now used in the
> >> > install stage only.
> >> >
> >> > Also some overidden CFLAGS/LDFLAGS has been removed since we now have
> >> > explicit build rules.
> >> >
> >> > I have moved the changelog into patches.
> >> >
> >> > Please test to compile with:
> >> > make DESTDIR=/tmp/myroot PREFIX=/myusr install
> >> > or
> >> > make DESTDIR=/tmp/myroot install
> >> >
> >> > Thanks for all feedback.
> >> >
> >> > Best regards
> >> > Marcus Folkesson
> >> >
> >>
> >> Hi,
> >> Thanks for this update! Here are three comments on this patchset:
> >>
> >> * you forgot a $(DESTDIR) occurrence in patch 7.
> >
> > Good catch!
> >
> >> * .travis.yml needs a simple patch to fix the value of PYSITEDIR. I
> >> will send it later.
> >
> > Please do.
> >
> >> * While reading the Makefile after patch 15, I have been surprised by
> >> "LIBDIR ?= $(DESTDIR)$(PREFIX)/lib", with DESTDIR. As this variable is
> >> not exported, it works fine as it is, but it might be cleaner to
> >> define it as "LIBDIR ?= $(PREFIX)/lib" and to use $(DESTDIR) in the
> >> following lines. This point may be addressed in a follow-up commit
> >> after the patchset has been merged.
> >
> > I agree.
> > I also think it could be part of a follow-up commit. I will take a note.
> >
> >>
> >> As the patchset looks almost ready to be merged, I have created
> >> https://github.com/SELinuxProject/selinux/pull/79 with a modified
> >> patch 7 and my patch for .travis.yml. This pull request holds the
> >> commits I plan to apply in a few days if no other maintainer disagrees
> >> with this.
> >
> > Ok, then I will not come up with a v6 that fixes your feedback for patch
> > #7.
> 
> I have merged this patchset. Thanks!

Thank you.

Do you know when the next release is planned?
> 
> Nicolas
> 

Best regards
Marcus Folkesson



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2018-02-22 19:19 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 01/15] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 02/15] libselinux: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 03/15] libsemanage: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 04/15] checkpolicy: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 05/15] gui: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 06/15] mcstrans: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 07/15] policycoreutils: " Marcus Folkesson
2018-02-14 19:00   ` Nicolas Iooss
2018-02-14  9:57 ` [PATCH v5 08/15] python: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 09/15] python: build: move modules from platform-specific to platform-shared Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 10/15] restorecond: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 11/15] sandbox: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 12/15] secilc: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 13/15] semodule-utils: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 14/15] dbus: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 15/15] build: setup buildpaths if DESTDIR is specified Marcus Folkesson
2018-02-14 19:19 ` Rework of makefiles v5 Nicolas Iooss
2018-02-15 13:04   ` Marcus Folkesson
2018-02-21 21:46     ` Nicolas Iooss
2018-02-22 19:19       ` 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.