xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH XTF] Correct the usage of $(DESTDIR) and $(prefix)
Date: Wed, 20 Jul 2016 19:21:46 +0100	[thread overview]
Message-ID: <1469038906-27330-1-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1469015759-18516-1-git-send-email-wei.liu2@citrix.com>

The GNU coding standards expect $(DESTDIR) to be the root of everything
installed, and for prefix to then be added to the path.  This is not how XTF
previously behaved.

Replace $(PREFIX) with its more common form $(prefix), and rearange $(DESTDIR)
and $(prefix) to match expectation.

Reported-by:Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
 Makefile     | 15 ++++++++++-----
 build/gen.mk | 22 +++++++++++++++-------
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index e21605d..c86dbb8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,14 @@ MAKEFLAGS += -r
 ROOT := $(abspath $(CURDIR))
 export ROOT
 
-DESTDIR ?= $(ROOT)/dist
-PREFIX ?= $(ROOT)
-export DESTDIR PREFIX
+# $(prefix) defaults to $(ROOT) so development and testing can be done
+# straight out of the working tree
+prefix  ?= $(ROOT)
+DESTDIR ?=
+
+# Provide $(DEST) as the install root
+DEST := $(DESTDIR)$(prefix)
+export DEST DESTDIR prefix
 
 # Programs used
 CC              ?= $(CROSS_COMPILE)gcc
@@ -27,8 +32,8 @@ all:
 
 .PHONY: install
 install:
-	@mkdir -p $(DESTDIR)
-	$(INSTALL_PROGRAM) -p xtf-runner $(DESTDIR)
+	@mkdir -p $(DEST)
+	$(INSTALL_PROGRAM) -p xtf-runner $(DEST)
 	@set -e; for D in $(wildcard tests/*); do \
 		[ ! -e $$D/Makefile ] && continue; \
 		$(MAKE) -C $$D install; \
diff --git a/build/gen.mk b/build/gen.mk
index 790212b..e20fd77 100644
--- a/build/gen.mk
+++ b/build/gen.mk
@@ -21,6 +21,14 @@ ifneq ($(filter-out $(ALL_CATEGORIES),$(CATEGORY)),)
 $(error Unrecognised category '$(filter-out $(ALL_CATEGORIES),$(CATEGORY))')
 endif
 
+ifeq ($(filter /%,$(prefix)),)
+$(error $$(prefix) must be absolute, not '$(prefix)')
+endif
+
+ifeq ($(filter /%,$(DEST)),)
+$(error $$(DEST) must be absolute, not '$(DEST)')
+endif
+
 .PHONY: build
 build: $(foreach env,$(TEST-ENVS),test-$(env)-$(NAME) test-$(env)-$(NAME).cfg)
 build: test-info.json
@@ -31,8 +39,8 @@ test-info.json: $(ROOT)/build/mkinfo.py FORCE
 
 .PHONY: install install-each-env
 install: install-each-env test-info.json
-	@mkdir -p $(DESTDIR)/tests/$(NAME)
-	$(INSTALL_DATA) -p test-info.json $(DESTDIR)/tests/$(NAME)
+	@mkdir -p $(DEST)/tests/$(NAME)
+	$(INSTALL_DATA) -p test-info.json $(DEST)/tests/$(NAME)
 
 define PERENV_build
 
@@ -54,7 +62,7 @@ test-$(1)-$(NAME).cfg: $$(cfg-$(1)) FORCE
 	@{ cat $$< $(TEST-EXTRA-CFG) ;} | \
 	sed -e "s/@@NAME@@/$$(NAME)/g" \
 		-e "s/@@ENV@@/$(1)/g" \
-		-e "s!@@PREFIX@@!$$(PREFIX)!g" \
+		-e "s!@@PREFIX@@!$$(prefix)!g" \
 		> $$@.tmp
 	@if ! cmp -s $$@ $$@.tmp; then mv -f $$@.tmp $$@; else rm -f $$@.tmp; fi
 
@@ -63,12 +71,12 @@ test-$(1)-$(NAME).cfg: $$(cfg-$(1)) FORCE
 
 .PHONY: install-$(1) install-$(1).cfg
 install-$(1): test-$(1)-$(NAME)
-	@mkdir -p $(DESTDIR)/tests/$(NAME)
-	$(INSTALL_PROGRAM) -p $$< $(DESTDIR)/tests/$(NAME)
+	@mkdir -p $(DEST)/tests/$(NAME)
+	$(INSTALL_PROGRAM) -p $$< $(DEST)/tests/$(NAME)
 
 install-$(1).cfg: test-$(1)-$(NAME).cfg
-	@mkdir -p $(DESTDIR)/tests/$(NAME)
-	$(INSTALL_DATA) -p $$< $(DESTDIR)/tests/$(NAME)
+	@mkdir -p $(DEST)/tests/$(NAME)
+	$(INSTALL_DATA) -p $$< $(DEST)/tests/$(NAME)
 
 install-each-env: install-$(1) install-$(1).cfg
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-20 18:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20 11:55 [PATCH XTF] build: introduce a dist target Wei Liu
2016-07-20 12:52 ` Andrew Cooper
2016-07-20 13:10   ` Wei Liu
2016-07-20 13:15     ` Andrew Cooper
2016-07-20 18:21 ` Andrew Cooper [this message]
2016-07-20 18:28   ` [PATCH XTF] Correct the usage of $(DESTDIR) and $(prefix) Doug Goldstein
2016-07-20 18:31   ` Wei Liu
2016-07-21 10:43   ` Ian Jackson
2016-07-21 10:57     ` Andrew Cooper
2016-07-21 11:10       ` Ian Jackson
2016-07-25 16:23 ` [XTF PATCH v3] Correct the usage of $(DESTDIR) and $(PREFIX) Andrew Cooper
2016-07-26  9:09   ` Wei Liu
2016-07-26 10:14   ` Ian Jackson
2016-07-26 10:17     ` Andrew Cooper

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=1469038906-27330-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).