Makefiles: override *FLAGS and *LIBS

There were several places in the makefiles where LDLIBS or CFLAGS were
supposed to include options to build. They were missing the override
keyword so would be skipped if these vars were set on the make cmdline.
Add the override directive to fix this.

Signed-off-by: Jason Zaman <jason@perfinion.com>
This commit is contained in:
Jason Zaman 2017-06-20 23:16:41 +08:00 committed by Stephen Smalley
parent 34dc7bcc31
commit 15f2740733
18 changed files with 33 additions and 40 deletions

View File

@ -4,24 +4,19 @@ LIBDIR ?= $(PREFIX)/lib
# Add your test source files here:
SOURCES = $(sort $(wildcard *.c))
# Add the required external object files here:
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
LDLIBS += -lcunit -lbz2 -laudit
override CFLAGS += -I../src -I../include
override LDLIBS += -lcunit -lbz2 -laudit ../src/libsemanage.a -lselinux -lsepol
OBJECTS = $(SOURCES:.c=.o)
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS) ../src/libsemanage.a
$(CC) $(OBJECTS) $(LIBS) $(LDFLAGS) -o $@ $(LDLIBS)
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c -o $*.o
$(CC) $(OBJECTS) $(LDFLAGS) -o $@ $(LDLIBS)
clean distclean:
rm -rf $(OBJECTS) $(EXECUTABLE)

View File

@ -5,7 +5,7 @@ BINDIR ?= $(PREFIX)/bin
CFLAGS ?= -Wall -Werror
override CFLAGS += -I../include
override LDFLAGS += -L../src
LDLIBS += -lsepol
override LDLIBS += -lsepol
TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))

View File

@ -6,7 +6,7 @@ LIBSEPOLA ?= $(LIBDIR)/libsepol.a
CFLAGS ?= -Wall
override CFLAGS += -I../src -D_GNU_SOURCE
LDLIBS += -lselinux -lpcre
override LDLIBS += -lselinux -lpcre
TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))

View File

@ -8,7 +8,7 @@ LIBEXECDIR ?= $(PREFIX)/libexec
HLLDIR ?= $(LIBEXECDIR)/selinux/hll
CFLAGS ?= -Werror -Wall -W
LDLIBS = -lsepol
override LDLIBS += -lsepol
PP_SRCS = $(sort $(wildcard *.c))
PP_OBJS = $(patsubst %.c,%.o,$(PP_SRCS))

View File

@ -7,7 +7,7 @@ LOCALEDIR ?= /usr/share/locale
CFLAGS ?= -Werror -Wall -W
override CFLAGS += $(LDFLAGS) -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
LDLIBS += -lsepol -lselinux
override LDLIBS += -lsepol -lselinux
TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))

View File

@ -23,18 +23,18 @@ VERSION = $(shell cat ../VERSION)
CFLAGS ?= -Werror -Wall -W
EXTRA_OBJS =
override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
LDLIBS += -lselinux
override LDLIBS += -lselinux
ifeq ($(PAMH), y)
override CFLAGS += -DUSE_PAM
EXTRA_OBJS += hashtab.o
LDLIBS += -lpam -lpam_misc
override LDLIBS += -lpam -lpam_misc
else
override CFLAGS += -D_XOPEN_SOURCE=500
LDLIBS += -lcrypt
override LDLIBS += -lcrypt
endif
ifeq ($(AUDITH), y)
override CFLAGS += -DUSE_AUDIT
LDLIBS += -laudit
override LDLIBS += -laudit
endif
ifeq ($(LSPP_PRIV),y)
override AUDIT_LOG_PRIV=y
@ -50,7 +50,7 @@ ifeq ($(NAMESPACE_PRIV),y)
endif
ifeq ($(IS_SUID),y)
MODE := 4555
LDLIBS += -lcap-ng
override LDLIBS += -lcap-ng
else
MODE := 0555
endif

View File

@ -10,17 +10,17 @@ AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
CFLAGS ?= -Werror -Wall -W
override CFLAGS += -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
LDLIBS += -lselinux
override LDLIBS += -lselinux
ifeq ($(PAMH), y)
override CFLAGS += -DUSE_PAM
LDLIBS += -lpam -lpam_misc
override LDLIBS += -lpam -lpam_misc
else
override CFLAGS += -D_XOPEN_SOURCE=500
LDLIBS += -lcrypt
override LDLIBS += -lcrypt
endif
ifeq ($(AUDITH), y)
override CFLAGS += -DUSE_AUDIT
LDLIBS += -laudit
override LDLIBS += -laudit
endif
TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))

View File

@ -9,7 +9,7 @@ WARNS=-Werror -W -Wall -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wca
VERSION = $(shell cat ../VERSION)
CFLAGS ?= $(WARNS) -O1
override CFLAGS += -DVERSION=\"$(VERSION)\"
LDLIBS = -lselinux
override LDLIBS += -lselinux
all: secon

View File

@ -6,13 +6,12 @@ MANDIR = $(PREFIX)/share/man
LIBDIR ?= $(PREFIX)/lib
CFLAGS ?= -Werror -Wall -W
LDLIBS = -lsepol -lselinux -lsemanage
override LDLIBS += -lsepol -lselinux -lsemanage
SEMODULE_OBJS = semodule.o
all: semodule genhomedircon
semodule: $(SEMODULE_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
genhomedircon:
ln -sf semodule genhomedircon

View File

@ -7,7 +7,7 @@ LIBDIR ?= $(PREFIX)/lib
CFLAGS ?= -Werror -Wall -W
override CFLAGS += -D_FILE_OFFSET_BITS=64
LDLIBS = -lselinux
override LDLIBS += -lselinux
all: sestatus

View File

@ -8,11 +8,11 @@ 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
override LDLIBS += -lselinux -lsepol
ifeq ($(AUDITH), y)
override CFLAGS += -DUSE_AUDIT
LDLIBS += -laudit
override LDLIBS += -laudit
endif
all: setfiles restorecon restorecon_xattr man

View File

@ -7,7 +7,7 @@ LIBDIR ?= $(PREFIX)/lib
BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions
CFLAGS ?= -Werror -Wall -W
LDLIBS = -lsepol -lselinux -lsemanage
override LDLIBS += -lsepol -lselinux -lsemanage
SETSEBOOL_OBJS = setsebool.o
BASHCOMPLETIONS=setsebool-bash-completion.sh

View File

@ -29,7 +29,7 @@ else
endif
export PCRE_CFLAGS PCRE_LDLIBS
LDLIBS += -lselinux $(PCRE_LDLIBS) $(DBUSLIB)
override LDLIBS += -lselinux $(PCRE_LDLIBS) $(DBUSLIB)
all: restorecond

View File

@ -10,7 +10,7 @@ MANDIR ?= $(PREFIX)/share/man
LOCALEDIR ?= /usr/share/locale
SHAREDIR ?= $(PREFIX)/share/sandbox
override CFLAGS += -DPACKAGE="\"policycoreutils\"" -Wall -Werror -Wextra -W
LDLIBS += -lselinux -lcap-ng
override LDLIBS += -lselinux -lcap-ng
SEUNSHARE_OBJS = seunshare.o
all: sandbox seunshare sandboxX.sh start

View File

@ -4,8 +4,6 @@ MANDIR ?= $(PREFIX)/share/man
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
LDLIBS = -lsepol
SECILC = secilc
SECILC_SRCS := secilc.c
SECILC_OBJS := $(patsubst %.c,%.o,$(SECILC_SRCS))
@ -21,6 +19,7 @@ XMLTO = xmlto
CFLAGS ?= -Wall -Wshadow -Wextra -Wundef -Wmissing-format-attribute -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wunused
override CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
override LDLIBS += -lsepol
all: $(SECILC) $(SECIL2CONF) man

View File

@ -6,7 +6,7 @@ LIBDIR ?= $(PREFIX)/lib
MANDIR ?= $(PREFIX)/share/man
CFLAGS ?= -Werror -Wall -W
LDLIBS = -lsepol
override LDLIBS += -lsepol
all: semodule_expand

View File

@ -6,7 +6,7 @@ MANDIR ?= $(PREFIX)/share/man
LIBDIR ?= $(PREFIX)/lib
CFLAGS ?= -Werror -Wall -W
LDLIBS = -lsepol
override LDLIBS += -lsepol
all: semodule_link

View File

@ -6,7 +6,7 @@ LIBDIR ?= $(PREFIX)/lib
MANDIR ?= $(PREFIX)/share/man
CFLAGS ?= -Werror -Wall -W
LDLIBS = -lsepol
override LDLIBS += -lsepol
all: semodule_package semodule_unpackage