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 14d7064348 ("libselinux: Allow
overriding libsepol.a location during build") introduced in libselinux
Makefile by using a new LIBSEPOLA variable in all Makefiles.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2017-01-14 15:38:25 +01:00 committed by Stephen Smalley
parent baee7238b8
commit dcd135cc06
6 changed files with 17 additions and 16 deletions

View File

@ -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 $<

View File

@ -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

View File

@ -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 $@ $<

View File

@ -2,15 +2,18 @@
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)
$(TARGETS): ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
install: all
-mkdir -p $(BINDIR)
install -m 755 $(TARGETS) $(BINDIR)

View File

@ -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

View File

@ -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)