From 4f62a83f1b4264aba6f051cf887cb3799075dedf Mon Sep 17 00:00:00 2001 From: Danny O'Brien Date: Wed, 13 Dec 2023 01:03:47 -0800 Subject: [PATCH] makefile: more sensitive error messages --- Makefile | 30 ++++++++++++------------------ bin/{activate-all => a-activate} | 1 + 2 files changed, 13 insertions(+), 18 deletions(-) rename bin/{activate-all => a-activate} (98%) diff --git a/Makefile b/Makefile index 879c025..82d36a0 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,23 @@ -# Define the source directory, read from the environment variable ALMANACK_ROOT -# Ensure to handle the case where ALMANACK_ROOT is not set -SRC_DIR := $(ALMANACK_ROOT)/web/ -DEST := boat:/var/local/www/www.almnck.com/ - -# Define the rsync options -RSYNC_OPTS := -avz --delete - -# Define the default target, so it does nothing if just 'make' is run .PHONY: default default: @echo "Please specify a target to run, e.g., 'make live' for live deployment." -# Define the 'live' target which will be triggered on 'make live' -.PHONY: live -live: +# Define a common rule to check if ALMANACK_ROOT is set +.PHONY: check-activated +check-activated: ifndef ALMANACK_ROOT - $(error ALMANACK_ROOT is undefined. Please export it before running 'make live'.) + $(error ALMANACK_ROOT is undefined. Please run `source bin/a-activate` before running any targets.) endif - @rsync $(RSYNC_OPTS) $(SRC_DIR) $(DEST) + +# Define the 'live' target which will be triggered on 'make live' +RSYNC_OPTS := -avz --delete +DEST := boat:/var/local/www/www.almnck.com/ +.PHONY: live +live: check-activated + @rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST) .PHONY: test-doc -test-doc: -ifndef ALMANACK_ROOT - $(error ALMANACK_ROOT is undefined. Please export it before running 'make test-doc'.) -endif +test-doc: check-activated @echo Running doc-check-links @sh $(ALMANACK_ROOT)/src/tests/doc-check-links | tapview diff --git a/bin/activate-all b/bin/a-activate similarity index 98% rename from bin/activate-all rename to bin/a-activate index d94c695..ea75f9b 100755 --- a/bin/activate-all +++ b/bin/a-activate @@ -45,4 +45,5 @@ PASSWORD_STORE_DIR=$ALMANACK_ROOT/secrets/ pass $* a-deactivate() { deactivate unset -f cd +unset ALMANACK_ROOT }