[PATCH 3/3] Makefile: dist: Add target to create distribution archives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Other subtargets are also created, with the obvious results:
dist-tar, dist-gz, and dist-xz.

Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
---
 Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/Makefile b/Makefile
index 38ea89c69..d7935ccae 100644
--- a/Makefile
+++ b/Makefile
@@ -316,6 +316,55 @@ uninstall-man: $(_mandir_rmdir) $(uninstall_manX)
 	@:
 
 
+########################################################################
+# dist
+#
+# Do NOT use `make -j` with dist targets:
+# <https://www.gnu.org/software/make/manual/html_node/Archive-Pitfalls.html#Archive-Pitfalls>.
+
+PKGNAME     := man-pages
+DISTVERSION := $(shell git describe | sed 's/^man-pages-//')
+DISTNAME    := $(PKGNAME)-$(DISTVERSION)
+DISTSRC     := $(sort $(shell git ls-files $(srcdir)))
+DISTFILE    := $(builddir)/$(DISTNAME).tar
+compression := gz xz
+dist        := $(sort $(foreach x,$(compression),dist-$(x)))
+
+
+$(DISTFILE): $(DISTSRC) | $$(@D)/.
+	$(info TAR	$@)
+	tar cf $@ -T /dev/null
+
+$(DISTFILE)($(DISTSRC)): $% $(DISTFILE) | $$(@D)/.
+	$(info TAR	$@($%))
+	tar rf $@ $%
+
+$(DISTFILE).gz: $(DISTFILE)($(DISTSRC)) | $$(@D)/.
+	$(info GZIP	$@)
+	gzip -kn $<
+
+$(DISTFILE).xz: $(DISTFILE)($(DISTSRC)) | $$(@D)/.
+	$(info XZ	$@)
+	xz -k $<
+
+
+.PHONY: dist-tar
+dist-tar: $(DISTFILE)($(DISTSRC)) | builddirs-dist
+	@:
+
+.PHONY: $(dist)
+$(dist): dist-%: $(DISTFILE).% | builddirs-dist
+	@:
+
+.PHONY: builddirs-dist
+builddirs-dist: $(builddir)/.
+	@:
+
+.PHONY: dist
+dist: $(dist)
+	@:
+
+
 ########################################################################
 # src
 
-- 
2.30.2




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux