Re-link programs after libsepol.a is updated
PATCH 1/1 Re-link programs after libsepol.a is updated
After libsepol is modified (for example while developing new features or fixing bugs), running "make install" in the top-level directory does not update the programs which use libsepol.a. Add this static library to the target dependencies in order to force their updates. This makes "make" use libsepol.a in the linking command without using LDLIBS.
While at it, copy what commit 14d706434846 ("libselinux: Allow overriding libsepol.a location during build") introduced in libselinux Makefile by using a new LIBSEPOLA variable in all Makefiles.
--- checkpolicy/Makefile | 7 +++---- checkpolicy/test/Makefile | 7 +++---- libselinux/src/Makefile | 4 ++-- mcstrans/utils/Makefile | 7 +++++-- python/audit2allow/Makefile | 4 ++-- semodule-utils/semodule_deps/Makefile | 4 ++-- 6 files changed, 17 insertions(+), 16 deletions(-)
checkpolicy/Makefile +3 -4
@@ -6,6 +6,7 @@ BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man LIBDIR ?= $(PREFIX)/lib INCLUDEDIR ?= $(PREFIX)/include +LIBSEPOLA ?= $(LIBDIR)/libsepol.a TARGETS = checkpolicy checkmodule LEX = flex
@@ -20,16 +21,14 @@ CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \ CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o CHECKMODOBJS = $(CHECKOBJS) checkmodule.o -LDLIBS=$(LIBDIR)/libsepol.a - GENERATED=lex.yy.c y.tab.c y.tab.h all: $(TARGETS) $(MAKE) -C test -checkpolicy: $(CHECKPOLOBJS) +checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA) -checkmodule: $(CHECKMODOBJS) +checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA) %.o: %.c $(CC) $(CFLAGS) -o $@ -c $<
checkpolicy/test/Makefile +3 -4
@@ -5,17 +5,16 @@ PREFIX ?= $(DESTDIR)/usr BINDIR=$(PREFIX)/bin LIBDIR ?= $(PREFIX)/lib INCLUDEDIR ?= $(PREFIX)/include +LIBSEPOLA ?= $(LIBDIR)/libsepol.a CFLAGS ?= -g -Wall -W -Werror -O2 -pipe override CFLAGS += -I$(INCLUDEDIR) -LDLIBS=$(LIBDIR)/libsepol.a -L$(LIBDIR) - all: dispol dismod -dispol: dispol.o +dispol: dispol.o $(LIBSEPOLA) -dismod: dismod.o +dismod: dismod.o $(LIBSEPOLA) clean: -rm -f dispol dismod *.o
libselinux/src/Makefile +2 -2
@@ -155,8 +155,8 @@ selinuxswig_python_exception.i: ../include/selinux/selinux.h $(AUDIT2WHYLOBJ): audit2why.c $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $< -$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) - $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLA) $(PYLIBS) -L$(LIBDIR) +$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA) + $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(PYLIBS) -L$(LIBDIR) %.o: %.c policy.h $(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
mcstrans/utils/Makefile +5 -2
@@ -2,14 +2,17 @@ PREFIX ?= $(DESTDIR)/usr LIBDIR ?= $(PREFIX)/lib BINDIR ?= $(PREFIX)/sbin +LIBSEPOLA ?= $(LIBDIR)/libsepol.a CFLAGS ?= -Wall override CFLAGS += -I../src -I$(PREFIX)/include -D_GNU_SOURCE -LDLIBS += -L$(LIBDIR) ../src/mcstrans.o ../src/mls_level.o -lselinux -lpcre $(LIBDIR)/libsepol.a +LDLIBS += -L$(LIBDIR) -lselinux -lpcre TARGETS=$(patsubst %.c,%,$(wildcard *.c)) -all: $(TARGETS) +all: $(TARGETS) + +$(TARGETS): ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA) install: all -mkdir -p $(BINDIR)
python/audit2allow/Makefile +2 -2
@@ -7,14 +7,14 @@ LIBDIR ?= $(PREFIX)/lib MANDIR ?= $(PREFIX)/share/man LOCALEDIR ?= /usr/share/locale INCLUDEDIR ?= $(PREFIX)/include +LIBSEPOLA ?= $(LIBDIR)/libsepol.a CFLAGS ?= -Werror -Wall -W override CFLAGS += -I$(INCLUDEDIR) -LDLIBS = $(LIBDIR)/libsepol.a all: audit2why sepolgen-ifgen-attr-helper -sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o +sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o $(LIBSEPOLA) audit2why: ln -sf audit2allow audit2why
semodule-utils/semodule_deps/Makefile +2 -2
@@ -4,14 +4,14 @@ INCLUDEDIR ?= $(PREFIX)/include BINDIR ?= $(PREFIX)/bin LIBDIR ?= $(PREFIX)/lib MANDIR ?= $(PREFIX)/share/man +LIBSEPOLA ?= $(LIBDIR)/libsepol.a CFLAGS ?= -Werror -Wall -W override CFLAGS += -I$(INCLUDEDIR) -LDLIBS = $(LIBDIR)/libsepol.a all: semodule_deps -semodule_deps: semodule_deps.o +semodule_deps: semodule_deps.o $(LIBSEPOLA) install: all -mkdir -p $(BINDIR)
Signature · 1 line
2.11.0
Quoted 97 lines · Nicolas Iooss
After libsepol is modified (for example while developing new features or
fixing bugs), running "make install" in the top-level directory does not
update the programs which use libsepol.a. Add this static library to the
target dependencies in order to force their updates. This makes "make"
use libsepol.a in the linking command without using LDLIBS.While at it, copy what commit
14d706434846("libselinux: Allow overriding libsepol.a location during build") introduced in libselinuxMakefileby using a new LIBSEPOLA variable in all Makefiles.Signed-off-by Nicolas Iooss <[email protected]>---
checkpolicy/Makefile | 7 +++---- checkpolicy/test/Makefile | 7 +++---- libselinux/src/Makefile | 4 ++-- mcstrans/utils/Makefile | 7 +++++-- python/audit2allow/Makefile | 4 ++-- semodule-utils/semodule_deps/Makefile | 4 ++--6 files changed, 17 insertions(+), 16 deletions(-)checkpolicy/Makefile +0
-0@@ -6,6 +6,7 @@ BINDIR ?= $(PREFIX)/binMANDIR ?= $(PREFIX)/share/man
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
+LIBSEPOLA ?= $(LIBDIR)/libsepol.a
TARGETS = checkpolicy checkmodule
LEX = flexcheckpolicy/Makefile +0
-0@@ -20,16 +21,14 @@ CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o
CHECKMODOBJS = $(CHECKOBJS) checkmodule.ocheckpolicy/Makefile +0
-2-LDLIBS=$(LIBDIR)/libsepol.a -GENERATED=lex.yy.c
y.tab.cy.tab.h
all: $(TARGETS)
$(MAKE) -C testcheckpolicy/Makefile +1
-1-checkpolicy: $(CHECKPOLOBJS) +checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA)checkpolicy/Makefile +1
-1-checkmodule: $(CHECKMODOBJS) +checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA)
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<checkpolicy/test/Makefile +0
-0@@ -5,17 +5,16 @@ PREFIX ?= $(DESTDIR)/usrBINDIR=$(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
+LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS ?= -g -Wall -W -Werror -O2 -pipe
override CFLAGS += -I$(INCLUDEDIR)checkpolicy/test/Makefile +0
-2-LDLIBS=$(LIBDIR)/libsepol.a -L$(LIBDIR) -all: dispol dismod
checkpolicy/test/Makefile +1
-1-dispol: dispol.o +dispol: dispol.o $(LIBSEPOLA)checkpolicy/test/Makefile +1
-1-dismod: dismod.o +dismod: dismod.o $(LIBSEPOLA)
clean:
-rm -f dispol dismod *.olibselinux/src/Makefile +0
-0@@ -155,8 +155,8 @@ selinuxswig_python_exception.i:
../include/selinux/selinux.h
$(AUDIT2WHYLOBJ):audit2why.c
$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)libselinux/src/Makefile +0
-1- $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux$(LIBSEPOLA) $(PYLIBS) -L$(LIBDIR)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)libselinux/src/Makefile +1
-0+ $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux
Quoted 1 line
$(PYLIBS) -L$(LIBDIR)
Why did you change this?
Quoted 73 lines
%.o: %.cpolicy.h
$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<mcstrans/utils/Makefile +0
-0@@ -2,14 +2,17 @@PREFIX ?= $(DESTDIR)/usr
LIBDIR ?= $(PREFIX)/lib
BINDIR ?= $(PREFIX)/sbin
+LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS ?= -Wall
override CFLAGS += -I../src -I$(PREFIX)/include -D_GNU_SOURCEmcstrans/utils/Makefile +1
-2-LDLIBS += -L$(LIBDIR) ../src/mcstrans.o ../src/mls_level.o -lselinux -lpcre $(LIBDIR)/libsepol.a +LDLIBS += -L$(LIBDIR) -lselinux -lpcre
TARGETS=$(patsubst %.c,%,$(wildcard *.c))mcstrans/utils/Makefile +3
-1-all: $(TARGETS) +all: $(TARGETS) + +$(TARGETS): ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
install: all
-mkdir -p $(BINDIR)python/audit2allow/Makefile +0
-0@@ -7,14 +7,14 @@ LIBDIR ?= $(PREFIX)/libMANDIR ?= $(PREFIX)/share/man
LOCALEDIR ?=/usr/share/locale
INCLUDEDIR ?= $(PREFIX)/include
+LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS ?= -Werror -Wall -W
override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = $(LIBDIR)/libsepol.a
all: audit2why sepolgen-ifgen-attr-helperpython/audit2allow/Makefile +1
-1-sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o +sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o$(LIBSEPOLA)
audit2why:
ln -sf audit2allow audit2whysemodule- renamed from semodule-utils/semodule_deps/Makefile +0
-0utils/semodule_deps/Makefile
index28d667e9f4b8..7d8490f2f1a8100644semodule-utils/semodule_deps/Makefile +0
-0@@ -4,14 +4,14 @@ INCLUDEDIR ?= $(PREFIX)/includeBINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
MANDIR ?= $(PREFIX)/share/man
+LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS ?= -Werror -Wall -W
override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = $(LIBDIR)/libsepol.a
all:semodule_depssemodule-utils/semodule_deps/Makefile +1
-1-semodule_deps: semodule_deps.o +semodule_deps: semodule_deps.o $(LIBSEPOLA)
install: all
-mkdir -p $(BINDIR)
Quoted 27 lines · Stephen Smalley
Quoted 14 lines · Nicolas Iooss
After libsepol is modified (for example while developing new features or
fixing bugs), running "make install" in the top-level directory does not
update the programs which use libsepol.a. Add this static library to the
target dependencies in order to force their updates. This makes "make"
use libsepol.a in the linking command without using LDLIBS.While at it, copy what commit
14d706434846("libselinux: Allow overriding libsepol.a location during build") introduced in libselinuxMakefileby using a new LIBSEPOLA variable in all Makefiles.libselinux/src/Makefile +0
-0Quoted 9 lines
index
d17792c13350..5640a57d2768100644libselinux/src/Makefile +0
-0@@ -155,8 +155,8 @@ selinuxswig_python_exception.i:
../include/selinux/selinux.h
$(AUDIT2WHYLOBJ):audit2why.c$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC-DSHARED -c -o $@ $<
Quoted 8 lines
Quoted 6 lines
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
- $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux
$(LIBSEPOLA) $(PYLIBS) -L$(LIBDIR)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
+ $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux
$(PYLIBS) -L$(LIBDIR)Why did you change this?
When libsepol.a is updated, $(AUDIT2WHYSO) (which is a Python extension, named something like python3audit2why.so and installed as module "selinux.audit2why") was not rebuilt. Adding $(LIBSEPOLA) to the dependencies (in order to fix this) makes libsepol.a appear in the command line through $^ so I removed $(LIBSEPOLA) from the "$(CC)..." line.
Thanks for your review,
Nicolas
Quoted 41 lines · Nicolas Iooss
Quoted 30 lines · Stephen Smalley
Quoted 1 line · Nicolas Iooss
After libsepol is modified (for example while developing new
features
Quoted 2 lines
or
fixing bugs), running "make install" in the top-level directorydoes
Quoted 2 lines
not
update the programs which use libsepol.a. Add this static libraryto
Quoted 21 lines
the
target dependencies in order to force their updates. This makes "make"
use libsepol.a in the linking command without using LDLIBS.While at it, copy what commit
14d706434846("libselinux: Allow overriding libsepol.a location during build") introduced in libselinuxMakefileby using a new LIBSEPOLA variable in all Makefiles.libselinux/src/Makefile +0
-0@@ -155,8 +155,8 @@ selinuxswig_python_exception.i:
../include/selinux/selinux.h
$(AUDIT2WHYLOBJ):audit2why.c
$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<Quoted 8 lines
Quoted 6 lines
-$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
- $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLA) $(PYLIBS) -L$(LIBDIR)
+$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
+ $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(PYLIBS) -L$(LIBDIR)Why did you change this?
Quoted 6 lines
When libsepol.a is updated, $(AUDIT2WHYSO) (which is a Python extension, named something like python3audit2why.so and installed as module "selinux.audit2why") was not rebuilt. Adding $(LIBSEPOLA) to the dependencies (in order to fix this) makes libsepol.a appear in the command line through $^ so I removed $(LIBSEPOLA) from the "$(CC)..." line.
Ok, thanks. Applied.