mcstrans/utils: make "make all" use $DESTDIR
PATCH 1/4 mcstrans/utils: make "make all" use $DESTDIR
When running "make all" in the root directory on a system where SELinux is not installed and where $DESTDIR targets a directory where the libraries have been installed, the build fails in mcstrans/utils with the following error:
transcon.c:7:10: fatal error: 'selinux/selinux.h' file not found
and then:
/usr/bin/ld: cannot find -lselinux
Fix this by adding -I$(PREFIX)/include to CFLAGS and -L$(LIBDIR) to LDLIBS like other subdirectories do.
While at it, remove the useless -L../src parameter.
--- mcstrans/utils/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mcstrans/utils/Makefile +2 -2
@@ -4,8 +4,8 @@ LIBDIR ?= $(PREFIX)/lib BINDIR ?= $(PREFIX)/sbin CFLAGS ?= -Wall -override CFLAGS += -I../src -D_GNU_SOURCE -LDLIBS += -L../src ../src/mcstrans.o ../src/mls_level.o -lselinux -lpcre $(LIBDIR)/libsepol.a +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 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
Signature · 1 line
2.10.2
PATCH 2/4 libsepol/tests: use LDFLAGS when linking
--- libsepol/tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/tests/Makefile +1 -1
@@ -32,7 +32,7 @@ all: $(EXE) $(policies) policies: $(policies) $(EXE): $(objs) $(parserobjs) $(LIBSEPOL) - $(CC) $(CFLAGS) $(CPPFLAGS) $(objs) $(parserobjs) -lfl -lcunit -lcurses $(LIBSEPOL) -o $@ + $(CC) $(LDFLAGS) $(objs) $(parserobjs) -lcunit -lcurses $(LIBSEPOL) -o $@ %.conf.std: $(m4support) %.conf $(M4) $(M4PARAMS) $^ > $@
Signature · 1 line
2.10.2
PATCH 3/4 checkpolicy: remove -lfl from LDLIBS
In reply to Nicolas IoossWhen building checkpolicy/test, the linker reports the following error:
cc dispol.o -lfl /usr/src/selinux/DESTDIR/usr/lib/libsepol.a
-L/usr/src/selinux/DESTDIR/usr/lib -o dispol
/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib/libfl.so:
undefined reference to `yylex'
collect2: error: ld returned 1 exit status
According to flex documentation
(https://github.com/westes/flex/blob/master/doc/flex.texi), -lfl is used to provide an implementation for yywrap(). However every flex file now uses "%option noyywrap", which makes -lfl no longer mandatory. Remove this option from checkpolicy Makefiles.
--- checkpolicy/Makefile | 2 +- checkpolicy/test/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
checkpolicy/Makefile +1 -1
@@ -20,7 +20,7 @@ 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 -lfl +LDLIBS=$(LIBDIR)/libsepol.a GENERATED=lex.yy.c y.tab.c y.tab.h
checkpolicy/test/Makefile +1 -1
@@ -9,7 +9,7 @@ INCLUDEDIR ?= $(PREFIX)/include CFLAGS ?= -g -Wall -W -Werror -O2 -pipe override CFLAGS += -I$(INCLUDEDIR) -LDLIBS=-lfl $(LIBDIR)/libsepol.a -L$(LIBDIR) +LDLIBS=$(LIBDIR)/libsepol.a -L$(LIBDIR) all: dispol dismod
Signature · 1 line
2.10.2
PATCH 4/4 libsepol,libsemanage: write file name in flex output
In reply to Nicolas IoossTools like lcov (for code coverage) does not like files named "<stdout>". For example it reports errors like:
genhtml: ERROR: cannot read
/usr/src/selinux/libsemanage/src/<stdout>
When using flex -o option, the output file name gets written in the generated C code, which solves this issue.
--- libsemanage/src/Makefile | 2 +- libsepol/src/Makefile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
libsemanage/src/Makefile +1 -1
@@ -101,7 +101,7 @@ semanageswig_python_exception.i: ../include/semanage/semanage.h bash -e exception.sh > $@ || (rm -f $@ ; false) conf-scan.c: conf-scan.l conf-parse.h - $(LEX) $(LFLAGS) -t $< > $@ + $(LEX) $(LFLAGS) -o $@ $< conf-parse.c: conf-parse.y $(YACC) $(YFLAGS) -o $@ $<
libsepol/src/Makefile +2 -1
@@ -67,7 +67,8 @@ $(CILDIR)/src/cil_lexer.lo: $(CILDIR)/src/cil_lexer.c $(CC) $(filter-out -Werror, $(CFLAGS)) -fPIC -DSHARED -c -o $@ $< $(CILDIR)/src/cil_lexer.c: $(CILDIR)/src/cil_lexer.l - $(LEX) -t $< > $@ + $(LEX) -o $@ $< + endif %.o: %.c
Signature · 1 line
2.10.2
Stephen Smalley
AppliedRe: [PATCH 4/4] libsepol,libsemanage: write file name in flex output
Quoted 10 lines · Nicolas Iooss
Tools like lcov (for code coverage) does not like files named "<stdout>". For example it reports errors like:
genhtml: ERROR: cannot read
/usr/src/selinux/libsemanage/src/<stdout>When using flex -o option, the output file name gets written in the generated C code, which solves this issue.
Signed-off-by Nicolas Iooss <[email protected]>
Thanks, applied all four.
Quoted 33 lines
--- libsemanage/src/Makefile | 2 +- libsepol/src/Makefile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)libsemanage/src/Makefile +1
-1@@ -101,7 +101,7 @@ semanageswig_python_exception.i: ../include/semanage/semanage.h bash -e exception.sh > $@ || (rm -f $@ ; false) conf-scan.c: conf-scan.l conf-parse.h - $(LEX) $(LFLAGS) -t $< > $@ + $(LEX) $(LFLAGS) -o $@ $< conf-parse.c: conf-parse.y $(YACC) $(YFLAGS) -o $@ $<libsepol/src/Makefile +2
-1@@ -67,7 +67,8 @@ $(CILDIR)/src/cil_lexer.lo: $(CILDIR)/src/cil_lexer.c $(CC) $(filter-out -Werror, $(CFLAGS)) -fPIC -DSHARED -c -o $@ $< $(CILDIR)/src/cil_lexer.c: $(CILDIR)/src/cil_lexer.l - $(LEX) -t $< > $@ + $(LEX) -o $@ $< + endif %.o: %.c