Skip to contentSkip to conversation

libsemanage/tests: fix linking

PATCH Applied Nicolas Iooss 2 participants 4 messages Jun 20, 2017 – Jun 21, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 libsemanage/tests: fix linking

When -lbz2 is written before libsemanage.a in the linker command line, the linker may fail to find all needed symbols. This occurs for example when building on Ubuntu 14.04 without the gold linker (cf. Travis build result https://travis-ci.org/fishilico/selinux/builds/245072498):

    gcc libsemanage-tests.o test_semanage_store.o test_utilities.o utilities.o
    -L/home/travis/build/fishilico/selinux/installdir/usr/lib -o libsemanage-tests
    -lcunit -lbz2 -laudit ../src/libsemanage.a -lselinux -lsepol
    ../src/libsemanage.a(direct_api.o): In function `bzip':
    direct_api.c:(.text+0xee6): undefined reference to `BZ2_bzWriteOpen'
    direct_api.c:(.text+0xf11): undefined reference to `BZ2_bzWriteClose'
    direct_api.c:(.text+0xf79): undefined reference to `BZ2_bzWrite'
    direct_api.c:(.text+0xfa1): undefined reference to `BZ2_bzWriteClose'
    direct_api.c:(.text+0xfe0): undefined reference to `BZ2_bzWriteClose'
    ../src/libsemanage.a(direct_api.o): In function `bunzip':
    direct_api.c:(.text+0x114e): undefined reference to `BZ2_bzReadOpen'
    direct_api.c:(.text+0x1249): undefined reference to `BZ2_bzRead'
    direct_api.c:(.text+0x13b4): undefined reference to `BZ2_bzReadClose'
    ../src/libsemanage.a(seusers_local.o): In function `semanage_seuser_audit':
    seusers_local.c:(.text+0x4c5): undefined reference to `audit_open'
    seusers_local.c:(.text+0x5b6): undefined reference to `audit_log_semanage_message'
    seusers_local.c:(.text+0x5cd): undefined reference to `audit_close'

As ../src/libsemanage.a is a dependency of $(EXECUTABLE) in the Makefile, use $^ to include it in the command line. While at it, put $^ after $(LDFLAGS) as other Makefiles do.

---
 libsemanage/tests/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libsemanage/tests/Makefile +2 -2
index fcd616fabf52..2ef8d30d92af 100644
@@ -9,14 +9,14 @@ SOURCES = $(sort $(wildcard *.c))
 EXECUTABLE = libsemanage-tests
 CFLAGS += -g -O0 -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
 override CFLAGS += -I../src -I../include
-override LDLIBS += -lcunit -lbz2 -laudit ../src/libsemanage.a -lselinux -lsepol
+override LDLIBS += -lcunit -lbz2 -laudit -lselinux -lsepol
 
 OBJECTS = $(SOURCES:.c=.o) 
 
 all: $(EXECUTABLE) 
 
 $(EXECUTABLE): $(OBJECTS) ../src/libsemanage.a
-	$(CC) $(OBJECTS) $(LDFLAGS) -o $@ $(LDLIBS)
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 clean distclean: 
 	rm -rf $(OBJECTS) $(EXECUTABLE)
Signature · 1 line
2.13.1
#1 lore raw

PATCH 2/3 gui: do not create /etc

selinux-gui does not install anything in /etc. Do not create this directory when building a package with "make install".

---
 gui/Makefile | 2 --
 1 file changed, 2 deletions(-)
gui/Makefile +0 -2
index d49a7ce048c1..4fc2c1a133be 100644
@@ -1,6 +1,5 @@
 # Installation directories.
 PREFIX ?= ${DESTDIR}/usr
-SYSCONFDIR ?= ${DESTDIR}/etc
 BINDIR ?= $(PREFIX)/bin
 SHAREDIR ?= $(PREFIX)/share/system-config-selinux
 DATADIR ?= $(PREFIX)/share
@@ -30,7 +29,6 @@ install: all
 	-mkdir -p $(BINDIR)
 	-mkdir -p $(DATADIR)/pixmaps
 	-mkdir -p $(DATADIR)/icons/hicolor/24x24/apps
-	-mkdir -p $(SYSCONFDIR)
 	-mkdir -p $(DATADIR)/polkit-1/actions/
 	install -m 755 system-config-selinux.py $(SHAREDIR)
 	install -m 755 system-config-selinux $(BINDIR)
Signature · 1 line
2.13.1
#2 lore raw

PATCH 3/3 python/sepolicy: remove definition of SYSCONFDIR

In reply to Nicolas Iooss

This variable is not used in any Makefile in python/.

---
 python/sepolicy/Makefile | 1 -
 1 file changed, 1 deletion(-)
python/sepolicy/Makefile +0 -1
index 0d2bec2042b0..5a56e6c8122e 100644
@@ -2,7 +2,6 @@ PYTHON ?= python
 
 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
-SYSCONFDIR ?= $(DESTDIR)/etc/sysconfig
 LIBDIR ?= $(PREFIX)/lib
 BINDIR ?= $(PREFIX)/bin
 DATADIR ?= $(PREFIX)/share
Signature · 1 line
2.13.1
#3 lore raw

Re: [PATCH 3/3] python/sepolicy: remove definition of SYSCONFDIR

Quoted 3 lines · Nicolas Iooss

This variable is not used in any Makefile in python/.

Thanks, applied all three.

Quoted 16 lines

---
 python/sepolicy/Makefile | 1 -

 1 file changed, 1 deletion(-)
python/sepolicy/Makefile +0 -0
index 0d2bec2042b0..5a56e6c8122e 100644
@@ -2,7 +2,6 @@ PYTHON ?= python


 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
-SYSCONFDIR ?= $(DESTDIR)/etc/sysconfig
 LIBDIR ?= $(PREFIX)/lib
 BINDIR ?= $(PREFIX)/bin
 DATADIR ?= $(PREFIX)/share