You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sessioncommunities.online/Makefile

102 lines
2.4 KiB
Makefile

PORT ?= 8081
OUTPUT ?= output
FLAGS ?=
MAKE = make FLAGS=$(FLAGS)
# First goal is the default with `make`.
# List make scripts.
list:
grep "^[^[:space:]]*:" Makefile --before-context=1 --group-separator=""
## Using make dependencies is duplicating behaviour but reads better.
# /bin/php php/update-listing.php
# Refresh listing and generate HTML.
sco: fetch html
# Refresh listing, generate HTML and update listing provider.
all:
/bin/php php/update-listing.php $(FLAGS)
# Fetch room listing.
fetch:
/bin/php php/fetch-servers.php $(FLAGS)
# Fetch room listing without writing to disk.
fetch-dry:
/bin/php php/fetch-servers.php $(FLAGS) --dry-run
# Generate HTML from data.
html:
/bin/php php/generate-html.php $(FLAGS)
# Generate listing provider endpoints from data.
listing:
/bin/php php/generate-listings.php $(FLAGS)
# Serve a local copy which responds to file changes.
dev: FLAGS = --verbose
dev: open
$(MAKE) server &
$(MAKE) watchdog
# (Last item run in foreground to receive interrupts.)
# Serve a local copy on LAN which responds to file changes.
lan-dev: FLAGS = --verbose
lan-dev: open
-which ip 1>/dev/null 2>/dev/null && ip addr | fgrep -e ' 192.' -e ' 10.' || true
$(MAKE) lan-server &
$(MAKE) watchdog
# Serve a local copy.
server:
/bin/php -S "localhost:$(PORT)" -t "$(OUTPUT)" -q
# Serve a local copy on all interfaces.
lan-server:
/bin/php -S "0.0.0.0:$(PORT)" -t "$(OUTPUT)" -q
# Open locally served page in browser.
open:
nohup xdg-open "http://localhost:$(PORT)" >/dev/null 2>/dev/null
# Update HTML on file change.
watchdog:
set -o pipefail; \
while :; do find . | grep -v ".git" | entr -nds "$(MAKE) html" && exit; done
# Remove artefacts
clean:
-awk '/^[^#]/ { printf " -e \"!%s\"", $$0 }' <etc/.gitpreserve | xargs git clean -Xdf $(CLEANFLAGS)
# Display files affected by artefact removal.
would-clean: CLEANFLAGS="-n"
would-clean: clean
# Build everything from scratch and test functionality.
test: FLAGS = --verbose
test: clean all open server
# Build everything from scratch and test functionality on LAN.
test-lan: FLAGS = --verbose
test-lan: clean all open lan-server
# Run basic tests without launching site in browser.
test-noninteractive: FLAGS = --verbose
test-noninteractive: clean all
# Run Continuous Integration tests.
test-ci: FLAGS = --verbose --no-color
test-ci: clean all
# -- Aliases --
serve: server
lan-serve: lan-server
data: fetch
watch: watchdog