WEBSITE_SRC_DIR=src WEBSITE_MAN_PAGE="$(WEBSITE_SRC_DIR)/cdist-manual.rst" WEBSITE_HTML_DIST_DIR=dist/html WEBSITE_ARCHIVE=cdist-www.tar.gz WEBSITE_REMOTE_HOST=staticweb.ungleich.ch WEBSITE_REMOTE_DIR=/home/services/www/nico/www.cdi.st/www/ WEBSITE_MANUALS_DIR="$(WEBSITE_SRC_DIR)/extra/manuals" CDIST_DIR=../cdist CDIST_DOCS_DIR="$(CDIST_DIR)/docs" CDIST_HELPER="$(CDIST_DIR)/bin/build-helper" CDIST_CHANGELOG_VERSION=$(shell $(CDIST_HELPER) changelog-version) CDIST_CHANGELOG_FILE="$(CDIST_DOCS_DIR)/changelog" CDIST_DOCS_HTML_DIST_DIR="$(CDIST_DOCS_DIR)/dist/html" CDIST_MAKE_VERSION=make -C "$(CDIST_DIR)" version CDIST_MAKE_HTML=make -C "$(CDIST_DIR)" html CDIST_CLEAN_HTML=make -C "$(CDIST_DOCS_DIR)/src" clean SPHINXW=make -C $(WEBSITE_SRC_DIR) html SPHINXWC=make -C $(WEBSITE_SRC_DIR) clean .PHONY: help help: @echo "Please use \`make ' where is one of" @echo " website" @echo " website-no-latest" @echo " website-publish" @echo " website-publish-no-latest" @echo " website-publish-only" @echo " clean" ################################################################################ # Website # # Make cdist html manual. # Generate rst changelog. # Create target version manual directory. # Copy target version manual directory to website. # Add latest manual page. # Update latest manual link. website-prepare: $(CDIST_MAKE_VERSION) $(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" @mkdir -p "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/" @rsync -a "$(CDIST_DOCS_HTML_DIST_DIR)/" "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/" website-prepare-latest: website-prepare @grep '$(CDIST_CHANGELOG_VERSION)' "$(WEBSITE_MAN_PAGE)" || awk 'FNR == 11 { print "* `$(CDIST_CHANGELOG_VERSION) `_"; print; next; } /^\* `Latest manual/ { print "* `Latest manual `_"; next; } { print; }' "$(WEBSITE_MAN_PAGE)" > "$(WEBSITE_MAN_PAGE)-new" && mv "$(WEBSITE_MAN_PAGE)-new" "$(WEBSITE_MAN_PAGE)" || exit 0 # Build website. website: website-prepare-latest $(SPHINXW) website-no-latest: website-prepare $(SPHINXW) website-publish-only: @cd "$(WEBSITE_HTML_DIST_DIR)" \ && tar -c -z -f "../$(WEBSITE_ARCHIVE)" . \ && scp "../$(WEBSITE_ARCHIVE)" "$(WEBSITE_REMOTE_HOST):$(WEBSITE_REMOTE_DIR)" \ && rm -f "../$(WEBSITE_ARCHIVE)" @ssh "$(WEBSITE_REMOTE_HOST)" "cd $(WEBSITE_REMOTE_DIR) && tar -x -f $(WEBSITE_ARCHIVE) && rm -f $(WEBSITE_ARCHIVE)" # Publish static website website-publish: website website-publish-only website-publish-no-latest: website-no-latest website-publish-only clean: $(CDIST_CLEAN_HTML) $(SPHINXWC)