makefile: Add dist target.

* Makefile (dist): Create reproducible tarball.
This commit is contained in:
Jan Nieuwenhuizen 2019-11-17 12:02:55 +01:00
parent 17df781f70
commit 6e62e0e58b
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 24 additions and 0 deletions

View File

@ -390,3 +390,27 @@ help:
# --------------------------------------------------------------------------
endif # ($(INCLUDED),no)
### dist
.PHONY: dist
PACKAGE=tcc
COMMIT=$(shell git describe --dirty)
CVS_VERSION=$(COMMIT:release_%=%)
TARBALL_VERSION=$(subst _,.,$(CVS_VERSION))
TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
TARBALL=$(TARBALL_DIR).tar.gz
# Be friendly to Debian; avoid using EPOCH
MTIME=$(shell git show HEAD --format=%ct --no-patch)
# Reproducible tarball
TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
$(TARBALL):
(git ls-files \
--exclude=$(TARBALL_DIR); \
echo $^ | tr ' ' '\n') \
| tar $(TAR_FLAGS) \
--transform=s,^,$(TARBALL_DIR)/,S -T- -cf- \
| gzip -c --no-name > $@
dist: $(TARBALL)