Skip to content

Commit dcae968

Browse files
Insert -I../../libselinux/include and -L../../libselinux/src into subprograms where needed
These subprograms (sublibraries) use plain #include <selinux/selinux.h> cc ... -lselinux ... &c. which includes/links to the system libselinux. Naturally, this doesn't work if you don't have one. All of these fell out of a plain make invocation, yielding errors like cc -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I../include -D_GNU_SOURCE -c -o boolean_record.o boolean_record.c boolean_record.c:26:10: fatal error: selinux/selinux.h: No such file or directory 26 | #include <selinux/selinux.h> | ^~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: Entering directory '/tmp/selinux/policycoreutils/sestatus' cc -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -D_FILE_OFFSET_BITS=64 -c -o sestatus.o sestatus.c sestatus.c:12:10: fatal error: selinux/selinux.h: No such file or directory 12 | #include <selinux/selinux.h> | ^~~~~~~~~~~~~~~~~~~ compilation terminated.
1 parent edf4812 commit dcae968

File tree

14 files changed

+28
-10
lines changed

14 files changed

+28
-10
lines changed

libsemanage/src/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-
6060
SWIG_CFLAGS += -Wno-error -Wno-unused-but-set-variable -Wno-unused-variable -Wno-shadow \
6161
-Wno-unused-parameter -Wno-missing-prototypes
6262

63-
override CFLAGS += -I../include -D_GNU_SOURCE
63+
override CFLAGS += -I../include -I../../libselinux/include -D_GNU_SOURCE
6464
RANLIB ?= ranlib
6565

6666
SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./
@@ -90,7 +90,7 @@ $(LIBA): $(OBJS)
9090
$(RANLIB) $@
9191

9292
$(LIBSO): $(LOBJS)
93-
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
93+
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L../../libselinux/src -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
9494
ln -sf $@ $(TARGET)
9595

9696
$(LIBPC): $(LIBPC).in ../VERSION

mcstrans/src/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PROG_OBJS= $(patsubst %.c,%.o,$(PROG_SRC))
1616
PROG=mcstransd
1717
INITSCRIPT=mcstrans
1818
CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
19+
override CFLAGS += -I../../libselinux/include
20+
override LDFLAGS+= -L../../libselinux/src
1921

2022
all: $(PROG)
2123

mcstrans/utils/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
PREFIX ?= /usr
33
SBINDIR ?= $(PREFIX)/sbin
44

5+
override CFLAGS += -I../../libselinux/include
6+
override LDFLAGS+= -L../../libselinux/src
7+
58
TARGETS=transcon untranscon
69

710
# If no specific libsepol.a is specified, fall back on LDFLAGS search path

policycoreutils/load_policy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MANDIR ?= $(PREFIX)/share/man
66
LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale
77

88
CFLAGS ?= -Werror -Wall -W
9-
override CFLAGS += $(LDFLAGS) -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
9+
override CFLAGS += $(LDFLAGS) -I../../libselinux/include -L../../libselinux/src -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
1010
override LDLIBS += -lsepol -lselinux
1111

1212
TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))

policycoreutils/newrole/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ VERSION = $(shell cat ../VERSION)
2424

2525
CFLAGS ?= -Werror -Wall -W
2626
EXTRA_OBJS =
27-
override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
27+
override CFLAGS += -I../../libselinux/include -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
28+
override LDFLAGS+= -L../../libselinux/src
2829
override LDLIBS += -lselinux
2930
ifeq ($(PAMH), y)
3031
override CFLAGS += -DUSE_PAM

policycoreutils/run_init/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y)
1010
AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
1111

1212
CFLAGS ?= -Werror -Wall -W
13-
override CFLAGS += -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
13+
override CFLAGS += -I../../libselinux/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
14+
override LDFLAGS+= -L../../libselinux/src
1415
override LDLIBS += -lselinux
1516
ifeq ($(PAMH), y)
1617
override CFLAGS += -DUSE_PAM

policycoreutils/secon/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ MANDIR ?= $(PREFIX)/share/man
77
WARNS=-Werror -W -Wall -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-format-zero-length -Wformat-nonliteral -Wformat-security -Wfloat-equal
88
VERSION = $(shell cat ../VERSION)
99
CFLAGS ?= $(WARNS) -O1
10-
override CFLAGS += -DVERSION=\"$(VERSION)\"
10+
override CFLAGS += -I../../libselinux/include -DVERSION=\"$(VERSION)\"
11+
override LDFLAGS+= -L../../libselinux/src
1112
override LDLIBS += -lselinux
1213

1314
all: secon

policycoreutils/semodule/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ SBINDIR ?= $(PREFIX)/sbin
55
MANDIR = $(PREFIX)/share/man
66

77
CFLAGS ?= -Werror -Wall -W
8+
override CFLAGS += -I../../libselinux/include -I../../libsemanage/include
9+
override LDFLAGS+= -L../../libselinux/src -L../../libsemanage/src
810
override LDLIBS += -lsepol -lselinux -lsemanage
911
SEMODULE_OBJS = semodule.o
1012

policycoreutils/sestatus/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ MANDIR = $(PREFIX)/share/man
77
ETCDIR ?= /etc
88

99
CFLAGS ?= -Werror -Wall -W
10-
override CFLAGS += -D_FILE_OFFSET_BITS=64
10+
override CFLAGS += -I../../libselinux/include -D_FILE_OFFSET_BITS=64
11+
override LDFLAGS+= -L../../libselinux/src
1112
override LDLIBS += -lselinux
1213

1314
all: sestatus

policycoreutils/setfiles/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ MANDIR = $(PREFIX)/share/man
66
AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
77

88
CFLAGS ?= -g -Werror -Wall -W
9+
override CFLAGS += -I../../libselinux/include
10+
override LDFLAGS+= -L../../libselinux/src
911
override LDLIBS += -lselinux -lsepol -lpthread
1012

1113
ifeq ($(AUDITH), y)

policycoreutils/setsebool/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ MANDIR = $(PREFIX)/share/man
66
BASHCOMPLETIONDIR ?= $(PREFIX)/share/bash-completion/completions
77

88
CFLAGS ?= -Werror -Wall -W
9+
override CFLAGS += -I../../libselinux/include -I../../libsemanage/include
10+
override LDFLAGS+= -L../../libselinux/src -L../../libsemanage/src
911
override LDLIBS += -lselinux -lsemanage
1012
SETSEBOOL_OBJS = setsebool.o
1113

policycoreutils/unsetfiles/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ PREFIX ?= /usr
22
SBINDIR ?= $(PREFIX)/sbin
33
MANDIR ?= $(PREFIX)/share/man
44

5-
override CFLAGS += -D_GNU_SOURCE
5+
override CFLAGS += -I../../libselinux/include -D_GNU_SOURCE
6+
override LDFLAGS+= -L../../libselinux/src
67
override LDLIBS += -lselinux
78

89

python/audit2allow/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ BINDIR ?= $(PREFIX)/bin
88
MANDIR ?= $(PREFIX)/share/man
99

1010
CFLAGS ?= -Werror -Wall -W
11+
override CFLAGS += -I../../libselinux/include
12+
override LDFLAGS+= -L../../libselinux/src
1113

1214
# If no specific libsepol.a is specified, fall back on LDFLAGS search path
1315
# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there

restorecond/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ GIO_CFLAGS = -DHAVE_DBUS $(shell $(PKG_CONFIG) --cflags gio-2.0)
1818
GIO_LIBS = $(shell $(PKG_CONFIG) --libs gio-2.0)
1919

2020
CFLAGS ?= -g -Werror -Wall -W
21-
override CFLAGS += $(GIO_CFLAGS)
22-
21+
override CFLAGS += -I../../libselinux/include $(GIO_CFLAGS)
22+
override LDFLAGS+= -L../../libselinux/src
2323
override LDLIBS += -lselinux $(GIO_LIBS)
2424

2525
all: restorecond

0 commit comments

Comments
 (0)