Improve make targets

This commit is contained in:
Darko Poljak 2019-04-25 12:01:42 +02:00
parent cdcab934fc
commit db2cd88660

View file

@ -16,18 +16,19 @@ CDIST_MAKE_VERSION=make -C "$(CDIST_DIR)" version
CDIST_MAKE_HTML=make -C "$(CDIST_DIR)" html CDIST_MAKE_HTML=make -C "$(CDIST_DIR)" html
CDIST_CLEAN_HTML=make -C "$(CDIST_DOCS_DIR)/src" clean CDIST_CLEAN_HTML=make -C "$(CDIST_DOCS_DIR)/src" clean
SPHINXW=make -C $(WEBSITE_SRC_DIR) html SPHINXH=make -C $(WEBSITE_SRC_DIR) html
SPHINXWC=make -C $(WEBSITE_SRC_DIR) clean SPHINXC=make -C $(WEBSITE_SRC_DIR) clean
.PHONY: help .PHONY: help
help: help:
@echo "Please use \`make <target>' where <target> is one of" @echo "Please use \`make <target>' where <target> is one of"
@echo " website" @echo " build only build static web"
@echo " website-no-latest" @echo " publish only publish built web"
@echo " website-publish" @echo " release update web with latest cdist release and build static web"
@echo " website-publish-no-latest" @echo " release-publish do release and then publish"
@echo " website-publish-only" @echo " release-no-latest update web without latest cdist release and build static web"
@echo " clean" @echo " release-publish-no-latest do release-no-latest and then publish"
@echo " clean clean generated files"
################################################################################ ################################################################################
@ -40,24 +41,25 @@ help:
# Copy target version manual directory to website. # Copy target version manual directory to website.
# Add latest manual page. # Add latest manual page.
# Update latest manual link. # Update latest manual link.
website-prepare: release-prepare:
$(CDIST_MAKE_VERSION) $(CDIST_MAKE_VERSION)
$(CDIST_MAKE_HTML) $(CDIST_MAKE_HTML)
@awk '/^[0-9a-z.]+: [0-9-]+$$/ { print; for(i = 0; i < length; ++i) { printf "~"; }; printf "\n"; next; } { print; }' "$(CDIST_CHANGELOG_FILE)" > "$(WEBSITE_SRC_DIR)/cdist-changelog.rst" @awk '/^[0-9a-z.]+: [0-9-]+$$/ { print; for(i = 0; i < length; ++i) { printf "~"; }; printf "\n"; next; } { print; }' "$(CDIST_CHANGELOG_FILE)" > "$(WEBSITE_SRC_DIR)/cdist-changelog.rst"
@mkdir -p "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/" @mkdir -p "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/"
@rsync -a "$(CDIST_DOCS_HTML_DIST_DIR)/" "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/" @rsync -a "$(CDIST_DOCS_HTML_DIST_DIR)/" "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/"
website-prepare-latest: website-prepare release-prepare-latest: release-prepare
@grep '$(CDIST_CHANGELOG_VERSION)' "$(WEBSITE_MAN_PAGE)" || awk 'FNR == 11 { print "* `$(CDIST_CHANGELOG_VERSION) <manuals/$(CDIST_CHANGELOG_VERSION)>`_"; print; next; } /^\* `Latest manual/ { print "* `Latest manual <manuals/$(CDIST_CHANGELOG_VERSION)>`_"; next; } { print; }' "$(WEBSITE_MAN_PAGE)" > "$(WEBSITE_MAN_PAGE)-new" && mv "$(WEBSITE_MAN_PAGE)-new" "$(WEBSITE_MAN_PAGE)" || exit 0 @grep '$(CDIST_CHANGELOG_VERSION)' "$(WEBSITE_MAN_PAGE)" || awk 'FNR == 11 { print "* `$(CDIST_CHANGELOG_VERSION) <manuals/$(CDIST_CHANGELOG_VERSION)>`_"; print; next; } /^\* `Latest manual/ { print "* `Latest manual <manuals/$(CDIST_CHANGELOG_VERSION)>`_"; next; } { print; }' "$(WEBSITE_MAN_PAGE)" > "$(WEBSITE_MAN_PAGE)-new" && mv "$(WEBSITE_MAN_PAGE)-new" "$(WEBSITE_MAN_PAGE)" || exit 0
# Build website. # Build website.
website: website-prepare-latest build:
$(SPHINXW) $(SPHINXH)
website-no-latest: website-prepare release: release-prepare-latest build
$(SPHINXW)
website-publish-only: release-no-latest: release-prepare build
publish:
@cd "$(WEBSITE_HTML_DIST_DIR)" \ @cd "$(WEBSITE_HTML_DIST_DIR)" \
&& tar -c -z -f "../$(WEBSITE_ARCHIVE)" . \ && tar -c -z -f "../$(WEBSITE_ARCHIVE)" . \
&& scp "../$(WEBSITE_ARCHIVE)" "$(WEBSITE_REMOTE_HOST):$(WEBSITE_REMOTE_DIR)" \ && scp "../$(WEBSITE_ARCHIVE)" "$(WEBSITE_REMOTE_HOST):$(WEBSITE_REMOTE_DIR)" \
@ -65,10 +67,10 @@ website-publish-only:
@ssh "$(WEBSITE_REMOTE_HOST)" "cd $(WEBSITE_REMOTE_DIR) && tar -x -f $(WEBSITE_ARCHIVE) && rm -f $(WEBSITE_ARCHIVE)" @ssh "$(WEBSITE_REMOTE_HOST)" "cd $(WEBSITE_REMOTE_DIR) && tar -x -f $(WEBSITE_ARCHIVE) && rm -f $(WEBSITE_ARCHIVE)"
# Publish static website # Publish static website
website-publish: website website-publish-only release-publish: release publish
website-publish-no-latest: website-no-latest website-publish-only release-publish-no-latest: release-no-latest publish
clean: clean:
$(CDIST_CLEAN_HTML) $(CDIST_CLEAN_HTML)
$(SPHINXWC) $(SPHINXC)