selinux/libsemanage/tests/Makefile

24 lines
597 B
Makefile
Raw Normal View History

# Add your test source files here:
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
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. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-06-20 20:29:53 +00:00
override LDLIBS += -lcunit -lbz2 -laudit -lselinux -lsepol
OBJECTS = $(SOURCES:.c=.o)
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS) ../src/libsemanage.a
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. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-06-20 20:29:53 +00:00
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
clean distclean:
rm -rf $(OBJECTS) $(EXECUTABLE)
test: all
./$(EXECUTABLE)