All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: nicolas.iooss@m4x.org, sds@tycho.nsa.gov
Cc: selinux@tycho.nsa.gov, Marcus Folkesson <marcus.folkesson@gmail.com>
Subject: [PATCH v5 06/15] mcstrans: build: follow standard semantics for DESTDIR and PREFIX
Date: Wed, 14 Feb 2018 10:57:08 +0100	[thread overview]
Message-ID: <20180214095717.1050-7-marcus.folkesson@gmail.com> (raw)
In-Reply-To: <20180214095717.1050-1-marcus.folkesson@gmail.com>

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

Notes:
    v5:
    	- Only use $(DESTDIR) in install
    	- Remove CFLAGS from linking rule
    	- Do not override CFLAGS
    
    v3:
    	- keep the possibility to specify LIBSEPOLA to
    	make depending component recompile on change. If not specified, fall back to
    	libsepola in LDFLAGS path.
    
    v2:
    	- Rework all packages (not just selinux/sepol/semanage)

 mcstrans/man/Makefile   |  7 ++++---
 mcstrans/src/Makefile   | 36 ++++++++++++++++++++----------------
 mcstrans/utils/Makefile | 28 ++++++++++++++++++----------
 3 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/mcstrans/man/Makefile b/mcstrans/man/Makefile
index 8e971192..645f6286 100644
--- a/mcstrans/man/Makefile
+++ b/mcstrans/man/Makefile
@@ -1,11 +1,12 @@
 # Installation directories.
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
+PREFIX ?= /usr
+MAN8DIR ?= $(PREFIX)/share/man/man8
 
 all:
 
 install: all
-	mkdir -p $(MAN8DIR)
-	install -m 644 man8/*.8 $(MAN8DIR)
+	mkdir -p $(DESTDIR)$(MAN8DIR)
+	install -m 644 man8/*.8 $(DESTDIR)$(MAN8DIR)
 
 clean:
 	-rm -f *~ \#*
diff --git a/mcstrans/src/Makefile b/mcstrans/src/Makefile
index 3f4a89c3..76ef0557 100644
--- a/mcstrans/src/Makefile
+++ b/mcstrans/src/Makefile
@@ -1,33 +1,37 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
-SBINDIR ?= $(DESTDIR)/sbin
-INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
-SYSTEMDDIR ?= $(DESTDIR)/usr/lib/systemd
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
+PREFIX ?= /usr
+SBINDIR ?= /sbin
+INITDIR ?= /etc/rc.d/init.d
+SYSTEMDDIR ?= $(PREFIX)/lib/systemd
+
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
+# is no need to define a value for LDLIBS_LIBSEPOLA
+ifeq ($(LIBSEPOLA),)
+        LDLIBS_LIBSEPOLA := -l:libsepol.a
+endif
 
 PROG_SRC=mcstrans.c  mcscolor.c  mcstransd.c  mls_level.c
 PROG_OBJS= $(patsubst %.c,%.o,$(PROG_SRC))
 PROG=mcstransd
 INITSCRIPT=mcstrans
 CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
-override CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
 
 all: $(PROG)
 
-$(PROG): $(PROG_OBJS)
-	$(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LIBSEPOLA)
+$(PROG): $(PROG_OBJS) $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LDLIBS_LIBSEPOLA)
 
 %.o:  %.c 
-	$(CC) $(CFLAGS) -fPIE -c -o $@ $<
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o $@ $<
 
 install: all
-	test -d $(SBINDIR) || install -m 755 -d $(SBINDIR)
-	install -m 755 $(PROG) $(SBINDIR)
-	test -d $(INITDIR) || install -m 755 -d $(INITDIR)
-	install -m 755 $(INITSCRIPT).init $(INITDIR)/$(INITSCRIPT)
-	test -d $(SYSTEMDDIR)/system || install -m 755 -d $(SYSTEMDDIR)/system
-	install -m 644 mcstrans.service $(SYSTEMDDIR)/system/
+	test -d $(DESTDIR)$(SBINDIR) || install -m 755 -d $(DESTDIR)$(SBINDIR)
+	install -m 755 $(PROG) $(DESTDIR)$(SBINDIR)
+	test -d $(DESTDIR)$(INITDIR) || install -m 755 -d $(DESTDIR)$(INITDIR)
+	install -m 755 $(INITSCRIPT).init $(DESTDIR)$(INITDIR)/$(INITSCRIPT)
+	test -d $(DESTDIR)$(SYSTEMDDIR)/system || install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system
+	install -m 644 mcstrans.service $(DESTDIR)$(SYSTEMDDIR)/system/
 
 clean: 
 	-rm -f $(OBJS) $(LOBJS) $(TARGET) $(PROG) $(PROG_OBJS) *~ \#*
diff --git a/mcstrans/utils/Makefile b/mcstrans/utils/Makefile
index 4d3cbfcb..9dfe7723 100644
--- a/mcstrans/utils/Makefile
+++ b/mcstrans/utils/Makefile
@@ -1,22 +1,30 @@
 # Installation directories.
-PREFIX ?= $(DESTDIR)/usr
-LIBDIR ?= $(PREFIX)/lib
+PREFIX ?= /usr
 SBINDIR ?= $(PREFIX)/sbin
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
 
-CFLAGS ?= -Wall
-override CFLAGS += -I../src -D_GNU_SOURCE
-override LDLIBS += -lselinux -lpcre
+TARGETS=transcon untranscon
 
-TARGETS=$(patsubst %.c,%,$(sort $(wildcard *.c)))
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
+# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
+# is no need to define a value for LDLIBS_LIBSEPOLA
+ifeq ($(LIBSEPOLA),)
+        LDLIBS_LIBSEPOLA := -l:libsepol.a
+endif
 
 all: $(TARGETS)
 
-$(TARGETS): ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
+transcon: transcon.o ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ -lpcre -lselinux $(LDLIBS_LIBSEPOLA)
+
+untranscon: untranscon.o ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
+	$(CC) $(LDFLAGS) -o $@ $^ -lpcre -lselinux $(LDLIBS_LIBSEPOLA)
+
+%.o:  %.c 
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -I../src -fPIE -c -o $@ $<
 
 install: all
-	-mkdir -p $(SBINDIR)
-	install -m 755 $(TARGETS) $(SBINDIR)
+	-mkdir -p $(DESTDIR)$(SBINDIR)
+	install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
 
 test:
 	./mlstrans-test-runner.py ../test/*.test
-- 
2.15.1

  parent reply	other threads:[~2018-02-14  9:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  9:57 Rework of makefiles v5 Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 01/15] libsepol: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 02/15] libselinux: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 03/15] libsemanage: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 04/15] checkpolicy: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 05/15] gui: " Marcus Folkesson
2018-02-14  9:57 ` Marcus Folkesson [this message]
2018-02-14  9:57 ` [PATCH v5 07/15] policycoreutils: " Marcus Folkesson
2018-02-14 19:00   ` Nicolas Iooss
2018-02-14  9:57 ` [PATCH v5 08/15] python: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 09/15] python: build: move modules from platform-specific to platform-shared Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 10/15] restorecond: build: follow standard semantics for DESTDIR and PREFIX Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 11/15] sandbox: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 12/15] secilc: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 13/15] semodule-utils: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 14/15] dbus: " Marcus Folkesson
2018-02-14  9:57 ` [PATCH v5 15/15] build: setup buildpaths if DESTDIR is specified Marcus Folkesson
2018-02-14 19:19 ` Rework of makefiles v5 Nicolas Iooss
2018-02-15 13:04   ` Marcus Folkesson
2018-02-21 21:46     ` Nicolas Iooss
2018-02-22 19:19       ` 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=20180214095717.1050-7-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.