From: Andrew Cooper Date: Wed, 20 Jul 2016 15:26:33 +0000 (+0100) Subject: Introduce makefile variable for commands in use per the GNU coding standards X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=793f46a0994327c8868a9e63ab7884c602cea142;p=xtf.git Introduce makefile variable for commands in use per the GNU coding standards Use the suggested defaults, and replace all open-coded examples. Signed-off-by: Andrew Cooper --- diff --git a/Makefile b/Makefile index 4d8fffc..0478221 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,18 @@ ROOT := $(abspath $(CURDIR)) DESTDIR ?= $(ROOT)/dist PREFIX ?= $(ROOT) +# Programs used +CC ?= $(CROSS_COMPILE)gcc +CPP ?= $(CC) -E +INSTALL ?= install +INSTALL_DATA ?= $(INSTALL) -m 644 +INSTALL_PROGRAM ?= $(INSTALL) +LD ?= $(CROSS_COMPILE)ld +OBJCOPY ?= $(CROSS_COMPILE)objcopy +PYTHON ?= python + +export CC CPP INSTALL INSTALL_DATA INSTALL_PROGRAM LD OBJCOPY PYTHON + .PHONY: all all: @set -e; for D in $(wildcard tests/*); do \ @@ -13,7 +25,7 @@ all: .PHONY: install install: @mkdir -p $(DESTDIR) - install -m775 xtf-runner $(DESTDIR) + $(INSTALL_PROGRAM) -p xtf-runner $(DESTDIR) @set -e; for D in $(wildcard tests/*); do \ [ ! -e $$D/Makefile ] && continue; \ $(MAKE) -C $$D install; \ diff --git a/build/common.mk b/build/common.mk index 6d4c8e8..9f97003 100644 --- a/build/common.mk +++ b/build/common.mk @@ -1,7 +1,5 @@ DESTDIR ?= $(ROOT)/dist PREFIX ?= $(ROOT) -CC ?= gcc -OBJCOPY ?= objcopy ALL_CATEGORIES := special functional xsa utility @@ -87,7 +85,7 @@ endif # Generate .lds with approprate flags %/link-$(1).lds: %/link.lds.S - $$(CC) -E $$(AFLAGS_$(1)) -P -C $$< -o $$@ + $$(CPP) $$(AFLAGS_$(1)) -P -C $$< -o $$@ # Generate a per-arch .o from .S %-$($(1)_arch).o: %.S diff --git a/build/gen.mk b/build/gen.mk index 839c5a0..790212b 100644 --- a/build/gen.mk +++ b/build/gen.mk @@ -26,13 +26,13 @@ build: $(foreach env,$(TEST-ENVS),test-$(env)-$(NAME) test-$(env)-$(NAME).cfg) build: test-info.json test-info.json: $(ROOT)/build/mkinfo.py FORCE - @python $< $@.tmp "$(NAME)" "$(CATEGORY)" "$(TEST-ENVS)" + @$(PYTHON) $< $@.tmp "$(NAME)" "$(CATEGORY)" "$(TEST-ENVS)" @if ! cmp -s $@ $@.tmp; then mv -f $@.tmp $@; else rm -f $@.tmp; fi .PHONY: install install-each-env install: install-each-env test-info.json @mkdir -p $(DESTDIR)/tests/$(NAME) - install -m664 -p test-info.json $(DESTDIR)/tests/$(NAME) + $(INSTALL_DATA) -p test-info.json $(DESTDIR)/tests/$(NAME) define PERENV_build @@ -64,11 +64,11 @@ test-$(1)-$(NAME).cfg: $$(cfg-$(1)) FORCE .PHONY: install-$(1) install-$(1).cfg install-$(1): test-$(1)-$(NAME) @mkdir -p $(DESTDIR)/tests/$(NAME) - install -m775 -p $$< $(DESTDIR)/tests/$(NAME) + $(INSTALL_PROGRAM) -p $$< $(DESTDIR)/tests/$(NAME) install-$(1).cfg: test-$(1)-$(NAME).cfg @mkdir -p $(DESTDIR)/tests/$(NAME) - install -m664 -p $$< $(DESTDIR)/tests/$(NAME) + $(INSTALL_DATA) -p $$< $(DESTDIR)/tests/$(NAME) install-each-env: install-$(1) install-$(1).cfg diff --git a/selftests/Makefile b/selftests/Makefile index 603b1b3..5806562 100644 --- a/selftests/Makefile +++ b/selftests/Makefile @@ -1,6 +1,5 @@ MAKEFLAGS += -r ROOT := $(abspath $(CURDIR)/..) -CC = gcc COMMON_CFLAGS := -Wall -Werror -Wextra -MMD -MP