Skip to content

Commit

Permalink
external/gard: Fix make dist target
Browse files Browse the repository at this point in the history
Several problems:
Firstly, it could never have worked, it was using the wrong variable.

Secondly, if it was using GARD_VERSION it produced a broken tarball that
still looked into the skiboot source for files despite them having been
copied into the tarball.

Lastly (and not really a make dist issue) the current way of symlinking
make_version.sh was racey. Get around the issue by refering to it in its
actual location (if we know it will be there) or by looking at .version
if building from tarball.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
cyrilbur-ibm authored and stewartsmith committed Feb 23, 2017
1 parent 18cbb7a commit 8ab0caf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion external/common/rules.mk
Expand Up @@ -49,7 +49,7 @@ ARCH_OBJS := $(addprefix common-,$(ARCH_FILES:.c=.o))
# Arch links are like this so we can have dependencies work (so that we don't
# run the rule when the links exist), pretty build output (knowing the target
# name) and a list of the files so we can clean them up.
ARCH_LINKS := common/ast-sf-ctrl.c common/ast.h common/io.h
ARCH_LINKS ?= common/ast-sf-ctrl.c common/ast.h common/io.h

arch_links: $(ARCH_LINKS)
common/ast.h : ../../include/ast.h | common
Expand Down
1 change: 1 addition & 0 deletions external/gard/.gitignore
Expand Up @@ -8,3 +8,4 @@ gard
test/test.sh
libflash
make_version.sh
gard-*.tar
19 changes: 9 additions & 10 deletions external/gard/Makefile
Expand Up @@ -8,32 +8,31 @@ all: links arch_links $(EXE)
#Rebuild version.o so that the the version always matches
#what the test suite will get from ./make_version.sh
check: version.o all
@ln -sf ../../make_version.sh make_version.sh
@ln -sf ../../test/test.sh test/test.sh
@test/test-gard

links += make_version.sh

.PHONY: VERSION-always
.version: VERSION-always
@echo $(GARD_VERSION) > $@.tmp
@cmp -s $@ $@.tmp || cp $@.tmp $@
@rm -f $@.tmp

.PHONY: dist
#File is named $(PFLASH_VERSION).tar because the expectation is that pflash-
#File is named $(GARD_VERSION).tar because the expectation is that gard-
#is always at the start of the verion. This remains consistent with skiboot
#version strings
dist: links .version
find -L ../pflash/ -iname '*.[ch]' -print0 | xargs -0 tar -rhf $(PFLASH_VERSION).tar
tar --transform 's/Makefile.dist/Makefile/' -rhf $(PFLASH_VERSION).tar \
../pflash/Makefile.dist ../pflash/rules.mk \
../pflash/.version ../pflash/make_version.sh \
../pflash/common/*
dist: arch_links links .version
@find -L ../gard/ -iname '*.[ch]' -print0 | xargs -0 tar -rhf $(GARD_VERSION).tar
@tar --transform 's/Makefile.dist/Makefile/' -rhf $(GARD_VERSION).tar \
../gard/Makefile.dist ../gard/rules.mk \
../gard/.version ../gard/common/*

clean: arch_clean
rm -f $(OBJS) $(EXE) *.o *.d .version .version.tmp

distclean: clean
rm -f *.c~ *.h~ *.sh~ Makefile~ config.mk~ libflash/*.c~ libflash/*.h~
rm -f libflash ccan common io.h make_version.sh
rm -f libflash ccan common io.h version.c make_version.sh
rm -f gard-*.tar

6 changes: 6 additions & 0 deletions external/gard/Makefile.dist
@@ -1,3 +1,9 @@
#Prevent make from trying to remake arch links symlinks
#which are fixed files now
ARCH_LINKS :=

GARD_VERSION := $(shell cat .version)

include rules.mk
GET_ARCH = common/get_arch.sh
include common/rules.mk
Expand Down
6 changes: 4 additions & 2 deletions external/gard/rules.mk
Expand Up @@ -14,9 +14,11 @@ sbindir = $(prefix)/sbin
datadir = $(prefix)/share
mandir = $(datadir)/man

GARD_VERSION ?= $(shell ./make_version.sh $(EXE))
#This will only be unset if we're running out of git tree,
#../../make_version.sh is garanteed to exist that way
GARD_VERSION ?= $(shell ../../make_version.sh $(EXE))

version.c: make_version.sh .version
version.c: .version
@(if [ "a$(GARD_VERSION)" = "a" ]; then \
echo "#error You need to set GARD_VERSION environment variable" > $@ ;\
else \
Expand Down

0 comments on commit 8ab0caf

Please sign in to comment.