Skip to content

Commit c8d504b

Browse files
authored
Allow to build SELinux even /sbun/selinuxenabled fails
1 parent 5c15d79 commit c8d504b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

GNUmakefile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,15 @@ TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER)
6969
#------------------------------------------------------------------------
7070
OS ?= $(shell uname -s)
7171

72-
ifdef SELINUX_ENABLED
73-
override SELINUX_ENABLED := 0
74-
# Now check if we should enable it (only on non-Windows)
75-
ifneq ($(OS),Windows_NT)
76-
ifeq ($(shell if [ -x /sbin/selinuxenabled ] && /sbin/selinuxenabled 2>/dev/null; then echo 0; else echo 1; fi),0)
77-
override SELINUX_ENABLED := 1
78-
$(info /sbin/selinuxenabled successful)
79-
else
80-
$(info SELINUX_ENABLED=1 but /sbin/selinuxenabled failed)
81-
endif
82-
endif
72+
# Allow to build SELinux even /sbun/selinuxenabled fails.
73+
ifundef SELINUX_ENABLED
74+
# Non Linux does not have libselinux. So SELINUX_ENABLED=0
75+
SELINUX_ENABLED := $(shell pkgconf --libs libselinux > /dev/null 2>&1; echo $$((!$$?)))
76+
ifeq ($(SELINUX_ENABLED), 1)
77+
$(info libselinux found. Enabling SELinux.)
78+
else
79+
$(info libselinux was not found.)
80+
endif
8381
endif
8482

8583
# Possible programs

0 commit comments

Comments
 (0)