Nicer makefile

This commit is contained in:
Danny O'Brien 2025-07-08 21:39:40 -07:00
parent 4b6b4a9cd3
commit 39035e3d2c

View file

@ -1,6 +1,16 @@
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[0;33m
BLUE := \033[0;34m
MAGENTA := \033[0;35m
CYAN := \033[0;36m
WHITE := \033[0;37m
BOLD := \033[1m
RESET := \033[0m
.PHONY: default .PHONY: default
default: default:
@echo "Please specify a target to run, e.g., 'make live' for live deployment." @echo "$(RED)Please specify a target to run, e.g., 'make live' for live deployment.$(RESET)"
# Define a common rule to check if ALMANACK_ROOT is set # Define a common rule to check if ALMANACK_ROOT is set
.PHONY: check-activated .PHONY: check-activated
@ -11,14 +21,15 @@ endif
# Define the 'live' target which will be triggered on 'make live' # Define the 'live' target which will be triggered on 'make live'
RSYNC_OPTS := -avz --delete --delete-after --filter='dir-merge,-n /.gitignore' -e "a-ssh" RSYNC_OPTS := -avz --delete --delete-after --filter='dir-merge,-n /.gitignore' -e "a-ssh"
DEST1 := boat:/var/local/www/www.almnck.com/ DESTINATIONS := boat:/var/local/www/www.almnck.com/ dallas:/var/local/www/www.almnck.com/ sj:/var/local/www/www.almnck.com/
DEST2 := amsterdam:/var/local/www/www.almnck.com/
DEST3 := phoenix:/home/danny/www/www.almnck.com/
.PHONY: live .PHONY: live
live: check-activated live: check-activated
@rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST1) @test -d "$(ALMANACK_ROOT)/web" || (echo "ERROR: web directory not found" && exit 1)
@rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST2) @echo "Dry run preview:"
@rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST3) @$(foreach dest,$(DESTINATIONS),echo "$(BLUE)To $(dest)$(RESET)"; rsync $(RSYNC_OPTS) --dry-run $(ALMANACK_ROOT)/web/ $(dest);)
@read -p "Continue with deployment? (y/N): " confirm && [ "$$confirm" = "y" ]
@$(foreach dest,$(DESTINATIONS),echo "$(BLUE)To $(dest)$(RESET)"; rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(dest);)
.PHONY: test-doc .PHONY: test-doc
test-doc: check-activated test-doc: check-activated