Skip to contentSkip to conversation

libsepol: allow specifying SUBDIRS when building

PATCH In review [email protected] 2 participants 3 messages Nov 13, 2024 – Dec 4, 2024 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libsepol: allow specifying SUBDIRS when building

From: Dmitry Sharshakov <[email protected]>

Allow building without utils and man for minimalist builds which do not need those.

Also make the Makefile modular as in libselinux.

---
 libsepol/Makefile         | 27 +++++----------------------
 libsepol/include/Makefile |  2 +-
 libsepol/man/Makefile     |  2 +-
 3 files changed, 7 insertions(+), 24 deletions(-)
libsepol/Makefile +5 -22
index 5b5d03e2..e354d3cb 100644
@@ -1,29 +1,12 @@
+SUBDIRS = include src utils man
 DISABLE_CIL ?= n
 
 export DISABLE_CIL
 
-all: 
-	$(MAKE) -C src 
-	$(MAKE) -C utils
-
-install: 
-	$(MAKE) -C include install
-	$(MAKE) -C src install
-	$(MAKE) -C utils install
-	$(MAKE) -C man install
-
-relabel:
-	$(MAKE) -C src relabel
-
-clean:
-	$(MAKE) -C src clean
-	$(MAKE) -C utils clean
-	$(MAKE) -C tests clean
-
-indent:
-	$(MAKE) -C src $@
-	$(MAKE) -C include $@
-	$(MAKE) -C utils $@
+all install relabel clean indent:
+	@for subdir in $(SUBDIRS); do \
+		(cd $$subdir && $(MAKE) $@) || exit 1; \
+	done
 
 test:
 	$(MAKE) -C tests test
libsepol/include/Makefile +1 -1
index 1ad4ecab..8d64e846 100644
@@ -3,7 +3,7 @@ PREFIX ?= /usr
 INCDIR = $(PREFIX)/include/sepol
 CILDIR ?= ../cil
 
-all:
+all relabel clean:
 
 install: all
 	test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
libsepol/man/Makefile +1 -1
index 0b410c19..6017ff51 100644
@@ -7,7 +7,7 @@ MAN8SUBDIR ?= man8
 MAN3DIR ?= $(MANDIR)/$(MAN3SUBDIR)
 MAN8DIR ?= $(MANDIR)/$(MAN8SUBDIR)
 
-all:
+all relabel clean indent:
 
 install: all
 	mkdir -p $(DESTDIR)$(MAN3DIR)
Signature · 1 line
2.47.0
#1 lore raw

PATCH 2/2 libsemanage: allow specifying SUBDIRS when building

From: Dmitry Sharshakov <[email protected]>

Allow building without utils and man for minimalist builds which do not need those.

Also make the Makefile modular as in libselinux.

---
 libsemanage/Makefile         | 25 ++++++-------------------
 libsemanage/include/Makefile |  2 +-
 libsemanage/man/Makefile     |  2 +-
 3 files changed, 8 insertions(+), 21 deletions(-)
libsemanage/Makefile +6 -19
index 390176fe..66c45c5a 100644
@@ -1,5 +1,9 @@
-all: 
-	$(MAKE) -C src all
+SUBDIRS = include src utils man
+
+all install relabel clean distclean indent:
+	@for subdir in $(SUBDIRS); do \
+		(cd $$subdir && $(MAKE) $@) || exit 1; \
+	done
 
 swigify:
 	$(MAKE) -C src swigify
@@ -10,28 +14,11 @@ pywrap:
 rubywrap:
 	$(MAKE) -C src rubywrap
 
-install: 
-	$(MAKE) -C include install
-	$(MAKE) -C src install
-	$(MAKE) -C man install
-	$(MAKE) -C utils install
-
 install-pywrap: 
 	$(MAKE) -C src install-pywrap
 
 install-rubywrap:
 	$(MAKE) -C src install-rubywrap
 
-relabel:
-	$(MAKE) -C src relabel
-
-clean distclean:
-	$(MAKE) -C src $@
-	$(MAKE) -C tests $@
-
-indent:
-	$(MAKE) -C src $@
-	$(MAKE) -C include $@
-
 test: all
 	$(MAKE) -C tests test
libsemanage/include/Makefile +1 -1
index 6e44a28a..c08aafec 100644
@@ -2,7 +2,7 @@
 PREFIX ?= /usr
 INCDIR ?= $(PREFIX)/include/semanage
 
-all:
+all relabel clean distclean:
 
 install: all
 	test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
libsemanage/man/Makefile +1 -1
index 5e21a65e..88143db8 100644
@@ -7,7 +7,7 @@ MAN5SUBDIR ?= man5
 MAN3DIR ?= $(MANDIR)/$(MAN3SUBDIR)
 MAN5DIR ?= $(MANDIR)/$(MAN5SUBDIR)
 
-all:
+all relabel clean distclean indent:
 
 install: all
 	mkdir -p $(DESTDIR)$(MAN3DIR)
Signature · 1 line
2.47.0
#2 lore raw
In reply to [email protected]
Quoted 19 lines · On Wed, Nov 13, 2024 at 2:52 AM <[email protected]> wrote:

From: Dmitry Sharshakov <[email protected]>

Allow building without utils and man for minimalist builds which do not need those.

Also make the Makefile modular as in libselinux.

---
 libsepol/Makefile         | 27 +++++----------------------
 libsepol/include/Makefile |  2 +-
 libsepol/man/Makefile     |  2 +-
 3 files changed, 7 insertions(+), 24 deletions(-)
libsepol/Makefile +0 -0
index 5b5d03e2..e354d3cb 100644

libsepol/Makefile line 1

Quoted 1 line
libsepol/Makefile +1 -0
@@ -1,29 +1,12 @@
+SUBDIRS = include src utils man

To allow specifying only some of the subdirectories wouldn't you have to use "SUBDIRS ?= include src utils man"?
This seems to always set SUBDIRS to include those subdirectories, but I am definitely not a Makefile guru.

Thanks,
Jim

Quoted 63 lines
libsepol/Makefile +4 -22
 DISABLE_CIL ?= n
 
 export DISABLE_CIL
 
-all:
-       $(MAKE) -C src
-       $(MAKE) -C utils
-
-install:
-       $(MAKE) -C include install
-       $(MAKE) -C src install
-       $(MAKE) -C utils install
-       $(MAKE) -C man install
-
-relabel:
-       $(MAKE) -C src relabel
-
-clean:
-       $(MAKE) -C src clean
-       $(MAKE) -C utils clean
-       $(MAKE) -C tests clean
-
-indent:
-       $(MAKE) -C src $@
-       $(MAKE) -C include $@
-       $(MAKE) -C utils $@
+all install relabel clean indent:
+       @for subdir in $(SUBDIRS); do \
+               (cd $$subdir && $(MAKE) $@) || exit 1; \
+       done
 
 test:
        $(MAKE) -C tests test
libsepol/include/Makefile +1 -1
index 1ad4ecab..8d64e846 100644
@@ -3,7 +3,7 @@ PREFIX ?= /usr
 INCDIR = $(PREFIX)/include/sepol
 CILDIR ?= ../cil
 
-all:
+all relabel clean:
 
 install: all
        test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
libsepol/man/Makefile +1 -2
index 0b410c19..6017ff51 100644
@@ -7,7 +7,7 @@ MAN8SUBDIR ?= man8
 MAN3DIR ?= $(MANDIR)/$(MAN3SUBDIR)
 MAN8DIR ?= $(MANDIR)/$(MAN8SUBDIR)
 
-all:
+all relabel clean indent:
 
 install: all
        mkdir -p $(DESTDIR)$(MAN3DIR)
--

2.47.0