Skip to contentSkip to conversation

mcstrans/utils: make "make all" use $DESTDIR

PATCH Applied Nicolas Iooss 2 participants 5 messages Nov 28, 2016 – Nov 29, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

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
index 43608dbb5331..a0f93f548557 100644
@@ -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
#1 lore raw

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
index 60b3e836cc94..6ae8ad2a507d 100644
@@ -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
#2 lore raw

PATCH 3/4 checkpolicy: remove -lfl from LDLIBS

In reply to Nicolas Iooss

When 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
index 53a307453282..875cf008cae0 100644
@@ -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
index c2367e191fe3..e7bd717a7c9a 100644
@@ -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
#3 lore raw

PATCH 4/4 libsepol,libsemanage: write file name in flex output

In reply to 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.

---
 libsemanage/src/Makefile | 2 +-
 libsepol/src/Makefile    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
libsemanage/src/Makefile +1 -1
index ef25902bb019..df5809645a00 100644
@@ -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
index 72724580eb98..497cd5675bd9 100644
@@ -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
#4 lore raw

Re: [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.

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
index ef25902bb019..df5809645a00 100644
@@ -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
index 72724580eb98..497cd5675bd9 100644
@@ -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