From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: selinux@tycho.nsa.gov, nicolas.iooss@m4x.org, sds@tycho.nsa.gov
Cc: Marcus Folkesson <marcus.folkesson@gmail.com>
Subject: [PATCH v3 04/14] checkpolicy: build: follow standard semantics for DESTDIR and PREFIX
Date: Sun, 21 Jan 2018 22:46:07 +0100 [thread overview]
Message-ID: <20180121214617.8975-5-marcus.folkesson@gmail.com> (raw)
In-Reply-To: <20180121214617.8975-1-marcus.folkesson@gmail.com>
This patch solves the following issues:
- DESTDIR is needed during compile time to compute library
and header paths which it should not.
- Installing with both DESTDIR and PREFIX set gives us odd paths
- Make usage of DESTDIR and PREFIX more standard
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
checkpolicy/Makefile | 19 ++++++++++++-------
checkpolicy/test/Makefile | 15 ++++++++++-----
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/checkpolicy/Makefile b/checkpolicy/Makefile
index 68e11f2a..78a8a43b 100644
--- a/checkpolicy/Makefile
+++ b/checkpolicy/Makefile
@@ -1,12 +1,10 @@
#
# Makefile for building the checkpolicy program
#
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-MANDIR ?= $(PREFIX)/share/man
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
TARGETS = checkpolicy checkmodule
LEX = flex
@@ -14,6 +12,11 @@ YACC = bison -y
CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -fno-strict-aliasing
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+ LDFLAGS += -l:libsepol.a
+endif
+
override CFLAGS += -I.
CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o parse_util.o \
@@ -27,11 +30,13 @@ all: $(TARGETS)
$(MAKE) -C test
checkpolicy: $(CHECKPOLOBJS) $(LIBSEPOLA)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
checkmodule: $(CHECKMODOBJS) $(LIBSEPOLA)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c
- $(CC) $(CFLAGS) -o $@ -c $<
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
y.tab.o: y.tab.c
$(CC) $(filter-out -Werror, $(CFLAGS)) -o $@ -c $<
diff --git a/checkpolicy/test/Makefile b/checkpolicy/test/Makefile
index 59fa4460..3eb1c512 100644
--- a/checkpolicy/test/Makefile
+++ b/checkpolicy/test/Makefile
@@ -1,19 +1,24 @@
#
# Makefile for building the dispol program
#
-PREFIX ?= $(DESTDIR)/usr
-BINDIR ?= $(PREFIX)/bin
-LIBDIR ?= $(PREFIX)/lib
-INCLUDEDIR ?= $(PREFIX)/include
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
+PREFIX ?= /usr
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
CFLAGS ?= -g -Wall -W -Werror -O2 -pipe
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+ifeq ($(LIBSEPOLA),)
+ LDFLAGS += -l:libsepol.a
+endif
+
all: dispol dismod
dispol: dispol.o $(LIBSEPOLA)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
dismod: dismod.o $(LIBSEPOLA)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
clean:
-rm -f dispol dismod *.o
--
2.15.1
next prev parent reply other threads:[~2018-01-21 21:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-21 21:46 Rework of Makefiles v3 Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 01/14] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 02/14] libselinux: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 03/14] libsemanage: " Marcus Folkesson
2018-01-21 21:46 ` Marcus Folkesson [this message]
2018-01-21 21:46 ` [PATCH v3 05/14] gui: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 06/14] mcstrans: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 07/14] policycoreutils: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 08/14] python: " Marcus Folkesson
2018-01-23 10:24 ` Petr Lautrbach
2018-01-23 19:22 ` Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 09/14] restorecond: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 10/14] sandbox: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 11/14] secilc: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 12/14] semodule-utils: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 13/14] dbus: " Marcus Folkesson
2018-01-21 21:46 ` [PATCH v3 14/14] build: add prefix for includes in top Makefile Marcus Folkesson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180121214617.8975-5-marcus.folkesson@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=nicolas.iooss@m4x.org \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.