diff options
Diffstat (limited to 'share/mk/dist')
-rw-r--r-- | share/mk/dist/_.mk | 25 | ||||
-rw-r--r-- | share/mk/dist/check/_.mk | 41 | ||||
-rw-r--r-- | share/mk/dist/check/diffoscope.mk | 26 | ||||
-rw-r--r-- | share/mk/dist/check/dist.mk | 28 | ||||
-rw-r--r-- | share/mk/dist/check/tar.mk | 32 | ||||
-rw-r--r-- | share/mk/dist/files.mk | 62 | ||||
-rw-r--r-- | share/mk/dist/tar.mk | 37 | ||||
-rw-r--r-- | share/mk/dist/z.mk | 44 |
8 files changed, 295 insertions, 0 deletions
diff --git a/share/mk/dist/_.mk b/share/mk/dist/_.mk new file mode 100644 index 0000000..f6d8669 --- /dev/null +++ b/share/mk/dist/_.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_INCLUDED +MAKEFILE_DIST_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk + + +_DISTDIR := $(builddir)/dist + + +$(builddir)/dist/%/: + +$(info $(INFO_)MKDIR $@) + +$(INSTALL_DIR) $@ + + +.PHONY: dist +dist: dist-tar dist-z; + + +endif # include guard diff --git a/share/mk/dist/check/_.mk b/share/mk/dist/check/_.mk new file mode 100644 index 0000000..a24b8f8 --- /dev/null +++ b/share/mk/dist/check/_.mk @@ -0,0 +1,41 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_INCLUDED +MAKEFILE_DIST_CHECK_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/configure/version.mk + + +_DISTCHECKDIR := $(shell $(REALPATH) -m $(builddir)/distcheck) +_DISTCHECKSRCDIR := $(_DISTCHECKDIR)/$(DISTNAME) +_DISTCHECKBUILDDIR := $(_DISTCHECKDIR)/$(DISTNAME)_builddir +_DISTCHECKDESTDIR := $(_DISTCHECKDIR)/$(DISTNAME)_destdir +_DISTCHECK_MANDIR := $(_DISTCHECKBUILDDIR)/man + + +_MAKE_OPTS = \ + -C $< \ + 'builddir=$(_DISTCHECKBUILDDIR)' \ + 'DESTDIR=$(_DISTCHECKDESTDIR)' + + +distcheck-%: $(_DISTCHECKSRCDIR) $(MK) | $$(@D)/ + $(info $(INFO_)MAKE $@) + $(MAKE) $(_MAKE_OPTS) $* \ + 'INFO_= $*: ' + + +.PHONY: distcheck +distcheck: distcheck-diffoscope +distcheck: $(_DISTCHECKSRCDIR) $(MK) + $(info $(INFO_)MAKE lint build check install dist) + $(MAKE) $(_MAKE_OPTS) lint build check install dist \ + 'INFO_= distcheck: ' + + +endif # include guard diff --git a/share/mk/dist/check/diffoscope.mk b/share/mk/dist/check/diffoscope.mk new file mode 100644 index 0000000..33bcf30 --- /dev/null +++ b/share/mk/dist/check/diffoscope.mk @@ -0,0 +1,26 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_DIFFOSCOPE_INCLUDED +MAKEFILE_DIST_CHECK_DIFFOSCOPE_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/diffoscope.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/dist/check/dist.mk +include $(MAKEFILEDIR)/dist/tar.mk + + +$(builddir)/distcheck.diffoscope.touch: $(_DISTFILE) $(REDIST) | $$(@D)/ + $(info $(INFO_)DIFFOSCOPE $^) + $(DIFFOSCOPE) $^ + $(TOUCH) $@ + + +.PHONY: distcheck-diffoscope +distcheck-diffoscope: $(builddir)/distcheck.diffoscope.touch; + + +endif # include guard diff --git a/share/mk/dist/check/dist.mk b/share/mk/dist/check/dist.mk new file mode 100644 index 0000000..ecd565b --- /dev/null +++ b/share/mk/dist/check/dist.mk @@ -0,0 +1,28 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_DIST_INCLUDED +MAKEFILE_DIST_CHECK_DIST_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/check/_.mk +include $(MAKEFILEDIR)/dist/check/tar.mk + + +REDIST := $(_DISTCHECKBUILDDIR)/$(DISTNAME).tar + + +$(REDIST): $(_DISTCHECKSRCDIR) $(MK) | $$(@D)/ + $(info $(INFO_)MAKE dist-tar) + $(MAKE) $(_MAKE_OPTS) dist-tar \ + 'INFO_= dist-tar: ' + + +.PHONY: distcheck-dist-tar +distcheck-dist-tar: $(REDIST); + + +endif # include guard diff --git a/share/mk/dist/check/tar.mk b/share/mk/dist/check/tar.mk new file mode 100644 index 0000000..bd28ce5 --- /dev/null +++ b/share/mk/dist/check/tar.mk @@ -0,0 +1,32 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_TAR_INCLUDED +MAKEFILE_DIST_CHECK_TAR_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/tar.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/check/_.mk +include $(MAKEFILEDIR)/dist/tar.mk + + +$(_DISTCHECKDIR)/$(DISTFILE): $(_DISTFILE) $(MK) | $$(@D)/ + $(info $(INFO_)CP $@) + $(CP) -T $< $@ + +$(_DISTCHECKSRCDIR): %: %.tar $(MK) | $$(@D)/ + $(info $(INFO_)TAR xf $<) + $(RM) -rf $@ + cd $(dir $<) \ + && $(TAR) xf $(notdir $<) + $(TOUCH) $@ + + +.PHONY: distcheck-tar +distcheck-tar: $(_DISTCHECKSRCDIR); + + +endif # include guard diff --git a/share/mk/dist/files.mk b/share/mk/dist/files.mk new file mode 100644 index 0000000..bc3f7ff --- /dev/null +++ b/share/mk/dist/files.mk @@ -0,0 +1,62 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_FILES_INCLUDED +MAKEFILE_DIST_FILES_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/git.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/verbose.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/_.mk + + +DISTFILES := $(shell $(DISTFILESCMD) | $(SED) 's,:,\\:,g') +_DISTFILES := $(patsubst $(srcdir)/%,$(_DISTDIR)/%,$(DISTFILES)) +_DISTPAGES := $(filter $(_DISTDIR)/man%,$(_DISTFILES)) +_DISTVERSION := $(_DISTDIR)/share/mk/configure/version.mk +_DISTOTHERS := $(filter-out $(_DISTPAGES) $(_DISTVERSION), $(_DISTFILES)) + + +FORCE_DISTVERSION := \ + $(shell \ + if $(TEST) -f $(_DISTVERSION); then \ + <$(_DISTVERSION) \ + $(GREP) \ + -e '^DISTVERSION :=' \ + -e '^DISTNAME :=' \ + -e '^DISTDATE :=' \ + | $(SED) '/^DISTVERSION := $(DISTVERSION)$$/d' \ + | $(SED) '/^DISTNAME := $(DISTNAME)$$/d' \ + | $(SED) '/^DISTDATE := $(DISTDATE)$$/d' \ + | $(GREP) ^ $(HIDE_ERR) >&2 \ + && $(ECHO) FORCE; \ + fi; \ + ) + + +$(_DISTPAGES): $(_DISTDIR)/man%: $(srcdir)/man% $(MK) | $$(@D)/ + $(info $(INFO_)SED $@) + <$< \ + $(SED) "/^.TH/s/(date)/$$($(GIT) log --format=%cs -1 -- $< $(HIDE_ERR))/" \ + | $(SED) '/^.TH/s/(unreleased)/$(DISTVERSION)/' \ + | $(INSTALL_DATA) -T /dev/stdin $@ + +$(_DISTVERSION): $(MAKEFILEDIR)/configure/version.mk $(MK) $(FORCE_DISTVERSION) | $$(@D)/ + $(info $(INFO_)SED $@) + <$< \ + $(SED) 's/^DISTVERSION *:=.*/DISTVERSION := $(DISTVERSION)/' \ + | $(SED) 's/^DISTNAME *:=.*/DISTNAME := $(DISTNAME)/' \ + | $(SED) 's/^DISTDATE *:=.*/DISTDATE := $(DISTDATE)/' \ + | $(INSTALL_DATA) -T /dev/stdin $@ + +$(_DISTOTHERS): $(_DISTDIR)/%: $(srcdir)/% $(MK) | $$(@D)/ + $(info $(INFO_)CP $@) + $(CP) -dT $< $@ + + +endif # include guard diff --git a/share/mk/dist/tar.mk b/share/mk/dist/tar.mk new file mode 100644 index 0000000..a87557f --- /dev/null +++ b/share/mk/dist/tar.mk @@ -0,0 +1,37 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_TAR_INCLUDED +MAKEFILE_DIST_TAR_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils.mk +include $(MAKEFILEDIR)/configure/build-depends/git.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/build-depends/tar.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/_.mk +include $(MAKEFILEDIR)/dist/files.mk + + +DISTFILE := $(DISTNAME).tar +_DISTFILE := $(builddir)/$(DISTFILE) + + +$(_DISTFILE): $(_DISTFILES) $(MK) | $$(@D)/ + $(info $(INFO_)TAR $@) + $(TAR) $(TARFLAGS) -cf $@ -T /dev/null + $(DISTFILESCMD) \ + | $(SED) 's,^$(srcdir)/,$(_DISTDIR)/,' \ + | $(SORT) \ + | $(XARGS) $(TAR) $(TARFLAGS) -rf $@ -C $(srcdir) \ + --transform 's,^$(patsubst /%,%,$(_DISTDIR)),$(DISTNAME),' + + +.PHONY: dist-tar +dist-tar: $(_DISTFILE); + + +endif # include guard diff --git a/share/mk/dist/z.mk b/share/mk/dist/z.mk new file mode 100644 index 0000000..b4b34fc --- /dev/null +++ b/share/mk/dist/z.mk @@ -0,0 +1,44 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_Z_INCLUDED +MAKEFILE_DIST_Z_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/bzip2.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/gzip.mk +include $(MAKEFILEDIR)/configure/build-depends/lzip.mk +include $(MAKEFILEDIR)/configure/build-depends/xz-utils.mk +include $(MAKEFILEDIR)/dist/tar.mk + + +compression := bz2 gz lz xz + + +define _DISTFILE_z_rule +$(_DISTFILE).$(2): %.$(2): % $(MK) | $$$$(@D)/ + $$(info $(INFO_)$(1) $$@) + $($(1)) $($(1)FLAGS) -kf $$< + $(TOUCH) $$@ +endef + + +$(eval $(call _DISTFILE_z_rule,BZIP2,bz2)) +$(eval $(call _DISTFILE_z_rule,GZIP,gz)) +$(eval $(call _DISTFILE_z_rule,LZIP,lz)) +$(eval $(call _DISTFILE_z_rule,XZ,xz)) + + +$(foreach z, $(compression), \ + $(eval .PHONY: dist-z-$(z))) +$(foreach z, $(compression), \ + $(eval dist-z-$(z): $(_DISTFILE).$(z);)) + + +.PHONY: dist-z +dist-z: $(foreach z, $(compression), dist-z-$(z)); + + +endif # include guard |