Skip to contentSkip to conversation

policycoreutils: honour LINGUAS variable

PATCH In review Jason Zaman 2 participants 8 messages Apr 24, 2017 – Apr 25, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 policycoreutils: honour LINGUAS variable

If the user has the $LINGUAS environment variable set, only translations for those languages should be installed to the system.

The gettext manual [1] says:

"Internationalized packages have usually many ll.po files. Unless translations are disabled, all those available are installed together with the package. However, the environment variable LINGUAS may be set, prior to configuration, to limit the installed set. LINGUAS should then contain a space separated list of two-letter codes, stating which languages are allowed."

[1]: https://www.gnu.org/software/gettext/manual/html_node/Installers.html#Installers

---
 policycoreutils/po/Makefile | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
policycoreutils/po/Makefile +10 -2
index f6069dd..5814861 100644
@@ -20,8 +20,16 @@ MSGMERGE_FLAGS	= -q
 XGETTEXT	= xgettext --default-domain=$(NLSPACKAGE)
 MSGFMT		= msgfmt
 
-# What do we need to do
-POFILES		= $(wildcard *.po)
+# All possible linguas
+PO_LINGUAS := $(sort $(patsubst %.po,%,$(wildcard *.po)))
+
+# Only the files matching what the user has set in LINGUAS
+USER_LINGUAS := $(filter $(patsubst %,%%,$(LINGUAS)),$(PO_LINGUAS))
+
+# if no valid LINGUAS, build all languages
+USE_LINGUAS := $(if $(USER_LINGUAS),$(USER_LINGUAS),$(PO_LINGUAS))
+
+POFILES		= $(patsubst %,%.po,$(USE_LINGUAS))
 MOFILES		= $(patsubst %.po,%.mo,$(POFILES))
 POTFILES = \
 	../run_init/open_init_pty.c \
Signature · 1 line
2.10.2
#1 lore raw

PATCH 2/7 libselinux: get pcre CFLAGS/LDFLAGS from pkg-config

Gentoo-Bug: https://bugs.gentoo.org/500674

---
 libselinux/Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
libselinux/Makefile +5 -3
index 979e225..98776d2 100644
@@ -1,5 +1,6 @@
 SUBDIRS = src include utils man
 
+PKG_CONFIG ?= pkg-config
 DISABLE_SETRANS ?= n
 DISABLE_RPM ?= n
 ANDROID_HOST ?= n
@@ -20,10 +21,11 @@ export DISABLE_SETRANS DISABLE_RPM DISABLE_FLAGS ANDROID_HOST
 
 USE_PCRE2 ?= n
 ifeq ($(USE_PCRE2),y)
-	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8
-	PCRE_LDFLAGS := -lpcre2-8
+	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 $(shell $(PKG_CONFIG) --cflags libpcre2-8)
+	PCRE_LDFLAGS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
 else
-	PCRE_LDFLAGS := -lpcre
+	PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcre)
+	PCRE_LDFLAGS := $(shell $(PKG_CONFIG) --libs libpcre)
 endif
 export PCRE_CFLAGS PCRE_LDFLAGS
 
Signature · 1 line
2.10.2
#2 lore raw

PATCH 3/7 libselinux: PCRE_LDFLAGS is actually LDLIBS

In reply to Jason Zaman
Quoted 1 line

From Make's manual:

LDFLAGS
Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable instead.

LDLIBS
Library flags or names given to compilers when they are supposed to invoke the linker, ‘ld’. Non-library linker flags, such as -L, should go in the LDFLAGS variable.

https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

---
 libselinux/Makefile       | 6 +++---
 libselinux/src/Makefile   | 6 +++---
 libselinux/utils/Makefile | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)
libselinux/Makefile +3 -3
index 98776d2..1ecab17 100644
@@ -22,12 +22,12 @@ export DISABLE_SETRANS DISABLE_RPM DISABLE_FLAGS ANDROID_HOST
 USE_PCRE2 ?= n
 ifeq ($(USE_PCRE2),y)
 	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 $(shell $(PKG_CONFIG) --cflags libpcre2-8)
-	PCRE_LDFLAGS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
+	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
 else
 	PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcre)
-	PCRE_LDFLAGS := $(shell $(PKG_CONFIG) --libs libpcre)
+	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre)
 endif
-export PCRE_CFLAGS PCRE_LDFLAGS
+export PCRE_CFLAGS PCRE_LDLIBS
 
 OS := $(shell uname)
 export OS
libselinux/src/Makefile +3 -3
index a277b87..c685e66 100644
@@ -91,7 +91,7 @@ override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup
 LD_SONAME_FLAGS=-install_name,$(LIBSO)
 endif
 
-PCRE_LDFLAGS ?= -lpcre
+PCRE_LDLIBS ?= -lpcre
 
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
 
@@ -143,8 +143,8 @@ $(LIBA): $(OBJS)
 	$(RANLIB) $@
 
 $(LIBSO): $(LOBJS)
-	$(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS)
-	ln -sf $@ $(TARGET) 
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(PCRE_LDLIBS) -ldl -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS)
+	ln -sf $@ $(TARGET)
 
 $(LIBPC): $(LIBPC).in ../VERSION
 	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
libselinux/utils/Makefile +2 -2
index 954da45..68f7097 100644
@@ -46,7 +46,7 @@ endif
 
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
 LDLIBS += -L../src -lselinux -L$(LIBDIR)
-PCRE_LDFLAGS ?= -lpcre
+PCRE_LDLIBS ?= -lpcre
 
 ifeq ($(ANDROID_HOST),y)
 TARGETS=sefcontext_compile
@@ -54,7 +54,7 @@ else
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
 endif
 
-sefcontext_compile: LDLIBS += $(PCRE_LDFLAGS) ../src/libselinux.a -lsepol
+sefcontext_compile: LDLIBS += $(PCRE_LDLIBS) ../src/libselinux.a -lsepol
 
 sefcontext_compile: sefcontext_compile.o ../src/regex.o
 
Signature · 1 line
2.10.2
#3 lore raw

PATCH 4/7 Makefiles: drop -L/-I to system paths

In reply to Jason Zaman

The toolchain automatically handles them and they break cross compiling.

LDFLAGS should also come before object files, some flags (eg, -Wl,as-needed) can break things if they are in the wrong place)

Gentoo-Bug: https://bugs.gentoo.org/500674

---
 checkpolicy/Makefile                     |  2 +-
 checkpolicy/test/Makefile                |  1 -
 libselinux/src/Makefile                  | 10 +++++-----
 libselinux/utils/Makefile                |  5 +++--
 libsemanage/src/Makefile                 |  8 ++++----
 libsemanage/tests/Makefile               |  8 ++++----
 libsepol/utils/Makefile                  |  4 ++--
 mcstrans/src/Makefile                    |  4 ++--
 mcstrans/utils/Makefile                  |  4 ++--
 policycoreutils/hll/pp/Makefile          |  3 +--
 policycoreutils/load_policy/Makefile     |  4 ++--
 policycoreutils/newrole/Makefile         |  4 ++--
 policycoreutils/run_init/Makefile        |  4 ++--
 policycoreutils/secon/Makefile           |  4 ++--
 policycoreutils/semodule/Makefile        |  3 +--
 policycoreutils/sestatus/Makefile        |  4 ++--
 policycoreutils/setfiles/Makefile        |  3 +--
 policycoreutils/setsebool/Makefile       |  3 +--
 python/audit2allow/Makefile              |  1 -
 python/sepolicy/Makefile                 |  2 +-
 restorecond/Makefile                     |  2 +-
 sandbox/Makefile                         |  4 ++--
 secilc/Makefile                          |  8 ++++----
 semodule-utils/semodule_deps/Makefile    |  1 -
 semodule-utils/semodule_expand/Makefile  |  3 +--
 semodule-utils/semodule_link/Makefile    |  3 +--
 semodule-utils/semodule_package/Makefile |  3 +--
 27 files changed, 48 insertions(+), 57 deletions(-)
checkpolicy/Makefile +1 -1
index 98fa380..68e11f2 100644
@@ -14,7 +14,7 @@ YACC = bison -y
 
 CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -fno-strict-aliasing
 
-override CFLAGS += -I. -I${INCLUDEDIR}
+override CFLAGS += -I.
 
 CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \
 	    policy_define.o
checkpolicy/test/Makefile +0 -1
index 54d07f8..0a31c5e 100644
@@ -8,7 +8,6 @@ INCLUDEDIR ?= $(PREFIX)/include
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -g -Wall -W -Werror -O2 -pipe
-override CFLAGS += -I$(INCLUDEDIR)
 
 all: dispol dismod
 
libselinux/src/Makefile +5 -5
index c685e66..f1b8bd9 100644
@@ -93,7 +93,7 @@ endif
 
 PCRE_LDLIBS ?= -lpcre
 
-override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
+override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
 
 SWIG_CFLAGS += -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter \
 		-Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations
@@ -133,17 +133,17 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
 	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(SWIGSO): $(SWIGLOBJ)
-	$(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) $(PYLIBS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $< -lselinux $(PYLIBS)
 
 $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
-	$(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) $(RUBYLIBS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(RUBYLIBS)
 
 $(LIBA): $(OBJS)
 	$(AR) rcs $@ $^
 	$(RANLIB) $@
 
 $(LIBSO): $(LOBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(PCRE_LDLIBS) -ldl -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(PCRE_LDLIBS) -ldl -Wl,$(LD_SONAME_FLAGS)
 	ln -sf $@ $(TARGET)
 
 $(LIBPC): $(LIBPC).in ../VERSION
@@ -156,7 +156,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
-	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(PYLIBS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
 
 %.o:  %.c policy.h
 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
libselinux/utils/Makefile +3 -2
index 68f7097..995f444 100644
@@ -44,8 +44,9 @@ override CFLAGS += -I/opt/local/include -I../../libsepol/include
 override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup
 endif
 
-override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
-LDLIBS += -L../src -lselinux -L$(LIBDIR)
+override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
+LDFLAGS += -L../src
+LDLIBS += -lselinux
 PCRE_LDLIBS ?= -lpcre
 
 ifeq ($(ANDROID_HOST),y)
libsemanage/src/Makefile +4 -4
index 77f6efc..dba50c8 100644
@@ -61,7 +61,7 @@ CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-
 SWIG_CFLAGS += -Wno-error -Wno-unused-but-set-variable -Wno-unused-variable -Wno-shadow \
 		-Wno-unused-parameter
 
-override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE 
+override CFLAGS += -I../include -D_GNU_SOURCE
 RANLIB ?= ranlib
 
 SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./
@@ -81,17 +81,17 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
 	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(SWIGSO): $(SWIGLOBJ)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage $(PYLIBS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $< -lsemanage $(PYLIBS)
 
 $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lsemanage $(RUBYLIBS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lsemanage $(RUBYLIBS)
 
 $(LIBA): $(OBJS)
 	$(AR) rcs $@ $^
 	$(RANLIB) $@
 
 $(LIBSO): $(LOBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
 	ln -sf $@ $(TARGET)
 
 $(LIBPC): $(LIBPC).in ../VERSION
libsemanage/tests/Makefile +4 -4
index 885b544..9b27224 100644
@@ -5,20 +5,20 @@ LIBDIR ?= $(PREFIX)/lib
 SOURCES = $(wildcard *.c)
 
 # Add the required external object files here:
-LIBS = ../src/libsemanage.a -L$(LIBDIR) -lselinux -lsepol
+LIBS = ../src/libsemanage.a -lselinux -lsepol
 
 ###########################################################################
 
 EXECUTABLE = libsemanage-tests
 CFLAGS += -g -O0 -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
-INCLUDE = -I../src -I../include -I$(PREFIX)/include
-LDFLAGS += -lcunit -lbz2 -laudit
+INCLUDE = -I../src -I../include
+LDLIBS += -lcunit -lbz2 -laudit
 OBJECTS = $(SOURCES:.c=.o) 
 
 all: $(EXECUTABLE) 
 
 $(EXECUTABLE): $(OBJECTS) ../src/libsemanage.a
-	$(CC) $(OBJECTS) $(LIBS) $(LDFLAGS) -o $@
+	$(CC) $(OBJECTS) $(LIBS) $(LDFLAGS) -o $@ $(LDLIBS)
 
 %.o: %.c
 	$(CC) $(CFLAGS) $(INCLUDE) -c $*.c -o $*.o
libsepol/utils/Makefile +2 -2
index 6864114..a13164e 100644
@@ -3,8 +3,8 @@ PREFIX ?= $(DESTDIR)/usr
 BINDIR ?= $(PREFIX)/bin
 
 CFLAGS ?= -Wall -Werror
-override CFLAGS += -I../include
-LDLIBS += -L../src -lsepol 
+LDFLAGS += -L../src
+LDLIBS += -lsepol
 
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
 
mcstrans/src/Makefile +2 -2
index ea463bc..709e1e0 100644
@@ -10,12 +10,12 @@ PROG_OBJS= $(patsubst %.c,%.o,$(PROG_SRC))
 PROG=mcstransd
 INITSCRIPT=mcstrans
 CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
-override CFLAGS += -I$(PREFIX)/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
+override CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 
 all: $(PROG)
 
 $(PROG): $(PROG_OBJS)
-	$(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LIBDIR)/libsepol.a -L$(LIBDIR)
+	$(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LIBDIR)/libsepol.a
 
 %.o:  %.c 
 	$(CC) $(CFLAGS) -fPIE -c -o $@ $<
mcstrans/utils/Makefile +2 -2
index 043d001..e6f329b 100644
@@ -5,8 +5,8 @@ BINDIR ?= $(PREFIX)/sbin
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Wall
-override CFLAGS += -I../src -I$(PREFIX)/include -D_GNU_SOURCE
-LDLIBS += -L$(LIBDIR) -lselinux -lpcre
+override CFLAGS += -I../src -D_GNU_SOURCE
+LDLIBS += -lselinux -lpcre
 
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
 
policycoreutils/hll/pp/Makefile +1 -2
index 09168bc..1ca6c9d 100644
@@ -8,8 +8,7 @@ LIBEXECDIR ?= $(PREFIX)/libexec
 HLLDIR ?= $(LIBEXECDIR)/selinux/hll
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lsepol -L$(LIBDIR)
+LDLIBS = -lsepol
 
 PP_SRCS = $(wildcard *.c)
 PP_OBJS = $(patsubst %.c,%.o,$(PP_SRCS))
policycoreutils/load_policy/Makefile +2 -2
index 7c5bab0..6ab0f9d 100644
@@ -6,8 +6,8 @@ MANDIR ?= $(PREFIX)/share/man
 LOCALEDIR ?= /usr/share/locale
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
-LDLIBS += -lsepol -lselinux -L$(PREFIX)/lib
+override CFLAGS += $(LDFLAGS) -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+LDLIBS += -lsepol -lselinux
 
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
 
policycoreutils/newrole/Makefile +2 -2
index 8b41428..8bfbd5f 100644
@@ -22,8 +22,8 @@ VERSION = $(shell cat ../VERSION)
 
 CFLAGS ?= -Werror -Wall -W
 EXTRA_OBJS =
-override CFLAGS += -DVERSION=\"$(VERSION)\" -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
-LDLIBS += -lselinux -L$(PREFIX)/lib
+override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+LDLIBS += -lselinux
 ifeq ($(PAMH), /usr/include/security/pam_appl.h)
 	override CFLAGS += -DUSE_PAM
 	EXTRA_OBJS += hashtab.o
policycoreutils/run_init/Makefile +2 -2
index 5815a08..a3beef7 100644
@@ -9,8 +9,8 @@ PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
 AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
-LDLIBS += -lselinux -L$(PREFIX)/lib
+override CFLAGS += -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
+LDLIBS += -lselinux
 ifeq ($(PAMH), /usr/include/security/pam_appl.h)
 	override CFLAGS += -DUSE_PAM
 	LDLIBS += -lpam -lpam_misc
policycoreutils/secon/Makefile +2 -2
index a2d9ca6..1f074ff 100644
@@ -8,8 +8,8 @@ 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)
 CFLAGS ?= $(WARNS) -O1
-override CFLAGS += -DVERSION=\"$(VERSION)\" -I$(INCLUDEDIR) 
-LDLIBS = -lselinux -L$(LIBDIR)
+override CFLAGS += -DVERSION=\"$(VERSION)\"
+LDLIBS = -lselinux
 
 all: secon
 
policycoreutils/semodule/Makefile +1 -2
index 5b1c026..39ff6a9 100644
@@ -6,8 +6,7 @@ MANDIR = $(PREFIX)/share/man
 LIBDIR ?= $(PREFIX)/lib
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lsepol -lselinux -lsemanage -L$(LIBDIR)
+LDLIBS = -lsepol -lselinux -lsemanage
 SEMODULE_OBJS = semodule.o
 
 all: semodule genhomedircon
policycoreutils/sestatus/Makefile +2 -2
index c04ff00..8dbbc01 100644
@@ -6,8 +6,8 @@ ETCDIR ?= $(DESTDIR)/etc
 LIBDIR ?= $(PREFIX)/lib
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include -D_FILE_OFFSET_BITS=64
-LDLIBS = -lselinux -L$(LIBDIR)
+override CFLAGS += -D_FILE_OFFSET_BITS=64
+LDLIBS = -lselinux
 
 all: sestatus
 
policycoreutils/setfiles/Makefile +1 -2
index 92300c9..f7089f9 100644
@@ -8,8 +8,7 @@ AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
 ABORT_ON_ERRORS=$(shell grep "^\#define ABORT_ON_ERRORS" setfiles.c | awk -S '{ print $$3 }')
 
 CFLAGS ?= -g -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include
-LDLIBS = -lselinux -lsepol -L$(LIBDIR)
+LDLIBS = -lselinux -lsepol
 
 ifeq ($(AUDITH), /usr/include/libaudit.h)
 	override CFLAGS += -DUSE_AUDIT
policycoreutils/setsebool/Makefile +1 -2
index 45d6538..3295963 100644
@@ -7,8 +7,7 @@ LIBDIR ?= $(PREFIX)/lib
 BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lsepol -lselinux -lsemanage -L$(LIBDIR)
+LDLIBS = -lsepol -lselinux -lsemanage
 SETSEBOOL_OBJS = setsebool.o
 
 BASHCOMPLETIONS=setsebool-bash-completion.sh 
python/audit2allow/Makefile +0 -1
index 4f03e95..8db8075 100644
@@ -10,7 +10,6 @@ INCLUDEDIR ?= $(PREFIX)/include
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
 
 all: audit2why sepolgen-ifgen-attr-helper
 
python/sepolicy/Makefile +1 -1
index bff8acc..647c540 100644
@@ -12,7 +12,7 @@ LOCALEDIR ?= /usr/share/locale
 BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
 SHAREDIR ?= $(PREFIX)/share/sandbox
 CFLAGS ?= -Wall -Werror -Wextra -W
-override CFLAGS += -I$(PREFIX)/include -DPACKAGE="policycoreutils" -DSHARED -shared
+override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared
 
 BASHCOMPLETIONS=sepolicy-bash-completion.sh
 
restorecond/Makefile +1 -1
index 9f163f5..5016753 100644
@@ -17,7 +17,7 @@ DBUSFLAGS = -DHAVE_DBUS $(shell $(PKG_CONFIG) --cflags dbus-glib-1)
 DBUSLIB = $(shell $(PKG_CONFIG) --libs dbus-glib-1)
 
 CFLAGS ?= -g -Werror -Wall -W
-override CFLAGS += -I$(PREFIX)/include $(DBUSFLAGS)
+override CFLAGS += $(DBUSFLAGS)
 
 USE_PCRE2 ?= n
 ifeq ($(USE_PCRE2),y)
sandbox/Makefile +2 -2
index 2716d69..b12fb77 100644
@@ -9,8 +9,8 @@ SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
 LOCALEDIR ?= /usr/share/locale
 SHAREDIR ?= $(PREFIX)/share/sandbox
-override CFLAGS += -I$(PREFIX)/include -DPACKAGE="\"policycoreutils\"" -Wall -Werror -Wextra -W
-LDLIBS += -lselinux -lcap-ng -L$(LIBDIR)
+override CFLAGS += -DPACKAGE="\"policycoreutils\"" -Wall -Werror -Wextra -W
+LDLIBS += -lselinux -lcap-ng
 SEUNSHARE_OBJS = seunshare.o
 
 all: sandbox seunshare sandboxX.sh start
secilc/Makefile +4 -4
index e714a84..1e36c6e 100644
@@ -4,7 +4,7 @@ MANDIR ?= $(PREFIX)/share/man
 LIBDIR ?= $(PREFIX)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 
-LDLIBS = -lsepol -L$(LIBDIR)
+LDLIBS = -lsepol
 
 SECILC = secilc
 SECILC_SRCS := secilc.c
@@ -20,18 +20,18 @@ XMLTO = xmlto
 
 CFLAGS ?= -Wall -Wshadow -Wextra -Wundef -Wmissing-format-attribute -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wunused
 
-override CFLAGS += -I$(INCLUDEDIR) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
+override CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 
 all: $(SECILC) $(SECIL2CONF) man
 
 $(SECILC): $(SECILC_OBJS)
-	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 test: $(SECILC)
 	./$(SECILC) test/policy.cil
 
 $(SECIL2CONF): $(SECIL2CONF_OBJS)
-	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 man: $(SECILC_MANPAGE) $(SECIL2CONF_MANPAGE)
 
semodule-utils/semodule_deps/Makefile +0 -1
index 7d8490f..328a503 100644
@@ -7,7 +7,6 @@ MANDIR ?= $(PREFIX)/share/man
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
 
 all: semodule_deps
 
semodule-utils/semodule_expand/Makefile +1 -2
index dcbd6d6..22e3579 100644
@@ -6,8 +6,7 @@ LIBDIR ?= $(PREFIX)/lib
 MANDIR ?= $(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lsepol -L$(LIBDIR)
+LDLIBS = -lsepol
 
 all: semodule_expand
 
semodule-utils/semodule_link/Makefile +1 -2
index 4e8e828..1e4e278 100644
@@ -6,8 +6,7 @@ MANDIR ?= $(PREFIX)/share/man
 LIBDIR ?= $(PREFIX)/lib
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lsepol -L$(LIBDIR)
+LDLIBS = -lsepol
 
 all: semodule_link
 
semodule-utils/semodule_package/Makefile +1 -2
index ca08bc4..5b0d2cc 100644
@@ -6,8 +6,7 @@ LIBDIR ?= $(PREFIX)/lib
 MANDIR ?= $(PREFIX)/share/man
 
 CFLAGS ?= -Werror -Wall -W
-override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lsepol -L$(LIBDIR)
+LDLIBS = -lsepol
 
 all: semodule_package semodule_unpackage
 
Signature · 1 line
2.10.2
#4 lore raw

PATCH 5/7 restorecond: get pcre cflags/libs from pkg-config

In reply to Jason Zaman
---
 restorecond/Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
restorecond/Makefile +6 -3
index 5016753..b1df89f 100644
@@ -21,12 +21,15 @@ override CFLAGS += $(DBUSFLAGS)
 
 USE_PCRE2 ?= n
 ifeq ($(USE_PCRE2),y)
-	PCRE_LDFLAGS := -lpcre2-8
+	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 $(shell $(PKG_CONFIG) --cflags libpcre2-8)
+	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
 else
-	PCRE_LDFLAGS := -lpcre
+	PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcre)
+	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre)
 endif
+export PCRE_CFLAGS PCRE_LDLIBS
 
-LDLIBS += -lselinux $(PCRE_LDFLAGS) $(DBUSLIB) -L$(LIBDIR)
+LDLIBS += -lselinux $(PCRE_LDLIBS) $(DBUSLIB)
 
 all: restorecond
 
Signature · 1 line
2.10.2
#5 lore raw

PATCH 6/7 Add includes for DESTDIR only in root Makefile

In reply to Jason Zaman
---
 Makefile | 7 +++++++
 1 file changed, 7 insertions(+)
Makefile +7 -0
index 8df4ce3..7701e16 100644
@@ -8,6 +8,13 @@ ifeq ($(DEBUG),1)
 	export LDFLAGS = -g
 endif
 
+ifneq ($(DESTDIR),)
+	CFLAGS += -I$(DESTDIR)/usr/include
+	LDFLAGS += -L$(DESTDIR)/usr/lib
+	export CFLAGS
+	export LDFLAGS
+endif
+
 all install relabel clean test indent:
 	@for subdir in $(SUBDIRS); do \
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
Signature · 1 line
2.10.2
#6 lore raw

PATCH 7/7 policycoreutils: make audit and pam support configurable

In reply to Jason Zaman
---
 policycoreutils/newrole/Makefile  | 10 +++++-----
 policycoreutils/run_init/Makefile | 10 +++++-----
 policycoreutils/setfiles/Makefile |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)
policycoreutils/newrole/Makefile +5 -5
index 8bfbd5f..bdefbb8 100644
@@ -4,8 +4,8 @@ BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
 LOCALEDIR = /usr/share/locale
-PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
-AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+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.
 # This will make newrole a setuid root program.
 # The capabilities used are: CAP_AUDIT_WRITE.
@@ -24,7 +24,7 @@ CFLAGS ?= -Werror -Wall -W
 EXTRA_OBJS =
 override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
 LDLIBS += -lselinux
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)
 	override CFLAGS += -DUSE_PAM
 	EXTRA_OBJS += hashtab.o
 	LDLIBS += -lpam -lpam_misc
@@ -32,7 +32,7 @@ else
 	override CFLAGS += -D_XOPEN_SOURCE=500
 	LDLIBS += -lcrypt
 endif
-ifeq ($(AUDITH), /usr/include/libaudit.h)
+ifeq ($(AUDITH), y)
 	override CFLAGS += -DUSE_AUDIT
 	LDLIBS += -laudit
 endif
@@ -66,7 +66,7 @@ install: all
 	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
 	install -m $(MODE) newrole $(BINDIR)
 	install -m 644 newrole.1 $(MANDIR)/man1/
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)
 	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
 ifeq ($(LSPP_PRIV),y)
 	install -m 644 newrole-lspp.pamd $(ETCDIR)/pam.d/newrole
policycoreutils/run_init/Makefile +5 -5
index a3beef7..6f5ee13 100644
@@ -5,20 +5,20 @@ SBINDIR ?= $(PREFIX)/sbin
 MANDIR ?= $(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
 LOCALEDIR ?= /usr/share/locale
-PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
-AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y)
+AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
 
 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
 LDLIBS += -lselinux
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)
 	override CFLAGS += -DUSE_PAM
 	LDLIBS += -lpam -lpam_misc
 else
 	override CFLAGS += -D_XOPEN_SOURCE=500
 	LDLIBS += -lcrypt
 endif
-ifeq ($(AUDITH), /usr/include/libaudit.h)
+ifeq ($(AUDITH), y)
 	override CFLAGS += -DUSE_AUDIT
 	LDLIBS += -laudit
 endif
@@ -38,7 +38,7 @@ install: all
 	install -m 755 open_init_pty $(SBINDIR)
 	install -m 644 run_init.8 $(MANDIR)/man8/
 	install -m 644 open_init_pty.8 $(MANDIR)/man8/
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)
 	install -m 644 run_init.pamd $(ETCDIR)/pam.d/run_init
 endif
 
policycoreutils/setfiles/Makefile +2 -2
index f7089f9..4b8cd81 100644
@@ -3,14 +3,14 @@ PREFIX ?= $(DESTDIR)/usr
 SBINDIR ?= $(DESTDIR)/sbin
 MANDIR = $(PREFIX)/share/man
 LIBDIR ?= $(PREFIX)/lib
-AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+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 }')
 
 CFLAGS ?= -g -Werror -Wall -W
 LDLIBS = -lselinux -lsepol
 
-ifeq ($(AUDITH), /usr/include/libaudit.h)
+ifeq ($(AUDITH), y)
 	override CFLAGS += -DUSE_AUDIT
 	LDLIBS += -laudit
 endif
Signature · 1 line
2.10.2
#7 lore raw

Re: [PATCH 7/7] policycoreutils: make audit and pam support configurable

Quoted 1 line · Jason Zaman

Thanks, all seven applied.

Quoted 113 lines

---
 policycoreutils/newrole/Makefile  | 10 +++++----- policycoreutils/run_init/Makefile | 10 +++++----- policycoreutils/setfiles/Makefile |  4 ++--

 3 files changed, 12 insertions(+), 12 deletions(-)
policycoreutils/newrole/Makefile +0 -0
index 8bfbd5f..bdefbb8 100644
@@ -4,8 +4,8 @@ BINDIR ?= $(PREFIX)/bin

 MANDIR ?= $(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
 LOCALEDIR = /usr/share/locale

policycoreutils/newrole/Makefile +2 -2
-PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
-AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+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. # This will make newrole a setuid root program.
 # The capabilities used are: CAP_AUDIT_WRITE.

policycoreutils/newrole/Makefile +0 -0
@@ -24,7 +24,7 @@ CFLAGS ?= -Werror -Wall -W

 EXTRA_OBJS =
 override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\"" LDLIBS += -lselinux

policycoreutils/newrole/Makefile +1 -1
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)

  override CFLAGS += -DUSE_PAM
  EXTRA_OBJS += hashtab.o
  LDLIBS += -lpam -lpam_misc

policycoreutils/newrole/Makefile +0 -0
@@ -32,7 +32,7 @@ else

  override CFLAGS += -D_XOPEN_SOURCE=500
  LDLIBS += -lcrypt
 endif

policycoreutils/newrole/Makefile +1 -1
-ifeq ($(AUDITH), /usr/include/libaudit.h)
+ifeq ($(AUDITH), y)

  override CFLAGS += -DUSE_AUDIT
  LDLIBS += -laudit
 endif

policycoreutils/newrole/Makefile +0 -0
@@ -66,7 +66,7 @@ install: all

  test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1 install -m $(MODE) newrole $(BINDIR)
  install -m 644 newrole.1 $(MANDIR)/man1/

policycoreutils/newrole/Makefile +1 -1
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)

  test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d ifeq ($(LSPP_PRIV),y)
  install -m 644 newrole-lspp.pamd $(ETCDIR)/pam.d/newrole

policycoreutils/run_init/Makefile +0 -0
index a3beef7..6f5ee13 100644
@@ -5,20 +5,20 @@ SBINDIR ?= $(PREFIX)/sbin

 MANDIR ?= $(PREFIX)/share/man
 ETCDIR ?= $(DESTDIR)/etc
 LOCALEDIR ?= /usr/share/locale

policycoreutils/run_init/Makefile +2 -2
-PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
-AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y)
+AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)


 CFLAGS ?= -Werror -Wall -W
 override CFLAGS += -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
 LDLIBS += -lselinux

policycoreutils/run_init/Makefile +1 -1
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)

  override CFLAGS += -DUSE_PAM
  LDLIBS += -lpam -lpam_misc
 else
  override CFLAGS += -D_XOPEN_SOURCE=500
  LDLIBS += -lcrypt
 endif

policycoreutils/run_init/Makefile +1 -1
-ifeq ($(AUDITH), /usr/include/libaudit.h)
+ifeq ($(AUDITH), y)

  override CFLAGS += -DUSE_AUDIT
  LDLIBS += -laudit
 endif

policycoreutils/run_init/Makefile +0 -0
@@ -38,7 +38,7 @@ install: all
  	install -m 755 open_init_pty $(SBINDIR)

  install -m 644 run_init.8 $(MANDIR)/man8/ install -m 644 open_init_pty.8 $(MANDIR)/man8/

policycoreutils/run_init/Makefile +1 -1
-ifeq ($(PAMH), /usr/include/security/pam_appl.h)
+ifeq ($(PAMH), y)

  install -m 644 run_init.pamd $(ETCDIR)/pam.d/run_init endif

policycoreutils/setfiles/Makefile +0 -0
index f7089f9..4b8cd81 100644
@@ -3,14 +3,14 @@ PREFIX ?= $(DESTDIR)/usr

 SBINDIR ?= $(DESTDIR)/sbin
 MANDIR = $(PREFIX)/share/man
 LIBDIR ?= $(PREFIX)/lib

policycoreutils/setfiles/Makefile +1 -1
-AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
+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 }')

 CFLAGS ?= -g -Werror -Wall -W
 LDLIBS = -lselinux -lsepol

policycoreutils/setfiles/Makefile +1 -1
-ifeq ($(AUDITH), /usr/include/libaudit.h)
+ifeq ($(AUDITH), y)

  override CFLAGS += -DUSE_AUDIT
  LDLIBS += -laudit
 endif