Skip to contentSkip to conversation

libsepol: Add INCLUDEDIR to utils/Makefile

PATCH In review Petr Lautrbach 2 participants 6 messages May 4, 2017 – May 5, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: Add INCLUDEDIR to utils/Makefile

fcb5d5c removed ../include from CFLAGS from libsepol/utils/Makefile so that a build tool can't find sepol/sepol.h when libsepol is built on a system without sepol.h in standard paths.

Fixes:
chkcon.c:1:10: fatal error: sepol/sepol.h: No such file or directory
#include <sepol/sepol.h>

---
 libsepol/utils/Makefile | 1 +
 1 file changed, 1 insertion(+)
libsepol/utils/Makefile +1 -0
index a13164e1..f5097be7 100644
@@ -1,6 +1,7 @@
 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
 BINDIR ?= $(PREFIX)/bin
+INCLUDEDIR ?= $(PREFIX)/include
 
 CFLAGS ?= -Wall -Werror
 LDFLAGS += -L../src
Signature · 1 line
2.12.2
#1 lore raw

The patch is wrong, please disregard.

I'm not sure about the right fix in order not to break gentoo use case. I'd just revert fcb5d5c change in libsepol/utils/Makefile for now.

Quoted 26 lines · Petr Lautrbach

fcb5d5c removed ../include from CFLAGS from libsepol/utils/Makefile so that a build tool can't find sepol/sepol.h when libsepol is built on a system without sepol.h in standard paths.

Fixes:
chkcon.c:1:10: fatal error: sepol/sepol.h: No such file or directory
#include <sepol/sepol.h>

---
 libsepol/utils/Makefile | 1 +
 1 file changed, 1 insertion(+)
libsepol/utils/Makefile +1 -0
index a13164e1..f5097be7 100644
@@ -1,6 +1,7 @@
 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
 BINDIR ?= $(PREFIX)/bin
+INCLUDEDIR ?= $(PREFIX)/include
 
 CFLAGS ?= -Wall -Werror
 LDFLAGS += -L../src
#2 lore raw
Quoted 5 lines · Petr Lautrbach

The patch is wrong, please disregard.

I'm not sure about the right fix in order not to break gentoo use case.
I'd just revert fcb5d5c change in libsepol/utils/Makefile for now.

Can't you just specify CFLAGS to make, similar to what is done in the top-level Makefile for building with DESTDIR set?

Quoted 35 lines · Petr Lautrbach
Quoted 29 lines

fcb5d5c removed ../include from CFLAGS from libsepol/utils/Makefile so
that a build tool can't find sepol/sepol.h when libsepol is built on a
system without sepol.h in standard paths.

Fixes:
chkcon.c:1:10: fatal error: sepol/sepol.h: No such file or directory
 #include <sepol/sepol.h>

---
 libsepol/utils/Makefile | 1 +

 1 file changed, 1 insertion(+)
libsepol/utils/Makefile +0 -0
index a13164e1..f5097be7 100644
@@ -1,6 +1,7 @@
  # Installation directories.

 PREFIX ?= $(DESTDIR)/usr
 BINDIR ?= $(PREFIX)/bin
+INCLUDEDIR ?= $(PREFIX)/include

 CFLAGS ?= -Wall -Werror
 LDFLAGS += -L../src

#3 lore raw
In reply to Petr Lautrbach

Dne 4.5.2017 v 22:49 Stephen Smalley napsal(a):

Quoted 10 lines · Petr Lautrbach
Quoted 5 lines

The patch is wrong, please disregard.

I'm not sure about the right fix in order not to break gentoo use case.
I'd just revert fcb5d5c change in libsepol/utils/Makefile for now.

Can't you just specify CFLAGS to make, similar to what is done in the top-level Makefile for building with DESTDIR set?

I believe that ../include and ../src paths should be always added to CFLAGS and LDFLAGS in this case to prevent cases when LDFLAGS and CFLAGS are overriden on a command line without setting paths containing sepol.h and sepol.so.

This way it's already used in libsepol/src/Makefile

Petr

#4 lore raw

PATCH 1/1 libsepol/utils: Fix build without system sepol.h

fcb5d5c removed ../include from CFLAGS from libsepol/utils/Makefile so that a build tool can't find sepol/sepol.h when only libsepol is built and a system is without sepol.h in standard paths. It should use its own sepol.h file during build. oveeride needs to be used in order not to be overridden by values provided on a command line. Same problem applies to LDFLAGS.

Fixes:

$ make CFLAGS="" LDFLAGS=""
make[1]: Entering directory '/root/selinux/libsepol/utils'
cc     chkcon.c  -lsepol -o chkcon
chkcon.c:1:25: fatal error: sepol/sepol.h: No such file or directory
 #include <sepol/sepol.h>
$ make CFLAGS="" LDFLAGS=""
...
make -C utils
make[1]: Entering directory '/root/selinux/libsepol/utils'
cc  -I../include    chkcon.c  -lsepol -o chkcon
/usr/bin/ld: cannot find -lsepol
collect2: error: ld returned 1 exit status
---
 libsepol/utils/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/utils/Makefile +2 -1
index a13164e1..3b2fb771 100644
@@ -3,7 +3,8 @@ PREFIX ?= $(DESTDIR)/usr
 BINDIR ?= $(PREFIX)/bin
 
 CFLAGS ?= -Wall -Werror
-LDFLAGS += -L../src
+override CFLAGS += -I../include
+override LDFLAGS += -L../src
 LDLIBS += -lsepol
 
 TARGETS=$(patsubst %.c,%,$(wildcard *.c))
Signature · 1 line
2.12.2
#5 lore raw

Re: [PATCH] libsepol/utils: Fix build without system sepol.h

Quoted 19 lines · Petr Lautrbach

fcb5d5c removed ../include from CFLAGS from libsepol/utils/Makefile so
that a build tool can't find sepol/sepol.h when only libsepol is built
and a system is without sepol.h in standard paths. It should use its own
sepol.h file during build. oveeride needs to be used in order not to
be overridden by values provided on a command line. Same problem applies
to LDFLAGS.

Fixes:

$ make CFLAGS="" LDFLAGS=""
make[1]: Entering directory '/root/selinux/libsepol/utils'
cc     chkcon.c  -lsepol -o chkcon
chkcon.c:1:25: fatal error: sepol/sepol.h: No such file or directory
 #include <sepol/sepol.h>
Quoted 7 lines
$ make CFLAGS="" LDFLAGS=""
...
make -C utils
make[1]: Entering directory '/root/selinux/libsepol/utils'
cc  -I../include    chkcon.c  -lsepol -o chkcon
/usr/bin/ld: cannot find -lsepol
collect2: error: ld returned 1 exit status

Thanks, applied

Quoted 20 lines

---
 libsepol/utils/Makefile | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/utils/Makefile +0 -0
index a13164e1..3b2fb771 100644
@@ -3,7 +3,8 @@ PREFIX ?= $(DESTDIR)/usr

 BINDIR ?= $(PREFIX)/bin

 CFLAGS ?= -Wall -Werror

libsepol/utils/Makefile +2 -1
-LDFLAGS += -L../src
+override CFLAGS += -I../include
+override LDFLAGS += -L../src

 LDLIBS += -lsepol

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