diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2016-03-31 14:23:49 +0200 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-04-01 13:03:14 +1100 |
commit | 629424505e1b13c18f0646c22a44d415bb021e0b (patch) | |
tree | 38886e7ff44ffda556e814cb98d6e65219f14e1c /external | |
parent | 7c3786192de47fe34a4a777f758a12ae10ced98f (diff) | |
download | skiboot-629424505e1b13c18f0646c22a44d415bb021e0b.zip skiboot-629424505e1b13c18f0646c22a44d415bb021e0b.tar.gz skiboot-629424505e1b13c18f0646c22a44d415bb021e0b.tar.bz2 |
external: improve xscom commands Makefile
The current Makefile is a bit rustic compared to other skiboot
tools. This patch adds a proper install target and a new versioning
target.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/xscom-utils/Makefile | 54 | ||||
-rw-r--r-- | external/xscom-utils/getscom.c | 4 | ||||
-rw-r--r-- | external/xscom-utils/getsram.c | 4 | ||||
-rw-r--r-- | external/xscom-utils/putscom.c | 4 |
4 files changed, 53 insertions, 13 deletions
diff --git a/external/xscom-utils/Makefile b/external/xscom-utils/Makefile index f944ff3..3fee247 100644 --- a/external/xscom-utils/Makefile +++ b/external/xscom-utils/Makefile @@ -1,23 +1,57 @@ -all: getscom putscom getsram +CC = $(CROSS_COMPILE)gcc XSCOM_VERSION ?= $(shell ../../make_version.sh xscom-utils) -CFLAGS?=-O2 -g -Wall -m64 -override CFLAGS += -DVERSION=\"$(XSCOM_VERSION)\" +CFLAGS += -O2 -g -Wall -m64 + +prefix = /usr/local/ +sbindir = $(prefix)/sbin +datadir = $(prefix)/share +mandir = $(datadir)/man + +%.o: %.c + $(Q_CC)$(COMPILE.c) $< -o $@ + +# Use make V=1 for a verbose build. +ifndef V + Q_CC= @echo ' CC ' $@; + Q_LINK= @echo ' LINK ' $@; + Q_LN= @echo ' LN ' $@; + Q_MKDIR=@echo ' MKDIR ' $@; +endif -getscom: getscom.c xscom.c - $(CC) $(CFLAGS) -o $@ $^ +all: getscom putscom getsram + +getscom: getscom.c xscom.o version.o + $(Q_LINK)$(LINK.o) -o $@ $^ -getsram: getsram.c xscom.c sram.c - $(CC) $(CFLAGS) -o $@ $^ +getsram: getsram.o xscom.o sram.o version.o + $(Q_LINK)$(LINK.o) -o $@ $^ -putscom: putscom.c xscom.c - $(CC) $(CFLAGS) -o $@ $^ +putscom: putscom.o xscom.o version.o + $(Q_LINK)$(LINK.o) -o $@ $^ + +install: all + install -D getscom $(DESTDIR)$(sbindir)/getscom + install -D putscom $(DESTDIR)$(sbindir)/putscom + install -D getsram $(DESTDIR)$(sbindir)/getsram .PHONY: clean clean: - rm -rf getscom putscom getsram + rm -rf *.[od] getscom putscom getsram .PHONY: distclean distclean: clean rm -rf *.c~ *.h~ *.i *.s Makefile~ +version.c: ../../make_version.sh .version + @(if [ "a$(XSCOM_VERSION)" = "a" ]; then \ + echo "#error You need to set XSCOM_VERSION environment variable" > $@ ;\ + else \ + echo "const char version[] = \"$(XSCOM_VERSION)\";" ;\ + fi) > $@ + +.PHONY: VERSION-always +.version: VERSION-always + @echo $(XSCOM_VERSION) > $@.tmp + @cmp -s $@ $@.tmp || cp $@.tmp $@ + @rm -f $@.tmp diff --git a/external/xscom-utils/getscom.c b/external/xscom-utils/getscom.c index 4edb096..30afab7 100644 --- a/external/xscom-utils/getscom.c +++ b/external/xscom-utils/getscom.c @@ -74,6 +74,8 @@ static void print_chip_info(uint32_t chip_id) } +extern const char version[]; + int main(int argc, char *argv[]) { uint64_t val, addr = -1ull; @@ -108,7 +110,7 @@ int main(int argc, char *argv[]) list_chips = true; break; case 'v': - printf("xscom utils version %s\n", VERSION); + printf("xscom utils version %s\n", version); exit(0); default: exit(1); diff --git a/external/xscom-utils/getsram.c b/external/xscom-utils/getsram.c index 37aea47..569f60e 100644 --- a/external/xscom-utils/getsram.c +++ b/external/xscom-utils/getsram.c @@ -32,6 +32,8 @@ static void print_usage(int code) exit(code); } +extern const char version[]; + int main(int argc, char *argv[]) { uint64_t val, addr = -1ull; @@ -69,7 +71,7 @@ int main(int argc, char *argv[]) print_usage(0); break; case 'v': - printf("xscom utils version %s\n", VERSION); + printf("xscom utils version %s\n", version); exit(0); default: exit(1); diff --git a/external/xscom-utils/putscom.c b/external/xscom-utils/putscom.c index faebe7d..116fef4 100644 --- a/external/xscom-utils/putscom.c +++ b/external/xscom-utils/putscom.c @@ -30,6 +30,8 @@ static void print_usage(int code) exit(code); } +extern const char version[]; + int main(int argc, char *argv[]) { uint64_t val = -1ull, addr = -1ull; @@ -62,7 +64,7 @@ int main(int argc, char *argv[]) chip_id = strtoul(optarg, NULL, 0); break; case 'v': - printf("xscom utils version %s\n", VERSION); + printf("xscom utils version %s\n", version); exit(0); case 'h': print_usage(0); |