1
0
Fork 1
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

78 lines
1.7 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.
all: fetch html
# Fetch room listing.
fetch:
/bin/php php/fetch-servers.php $(FLAGS)
# Generate HTML from data.
html:
/bin/php php/generate-html.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)"
# Serve a local copy on all interfaces.
lan-server:
/bin/php -S "0.0.0.0:$(PORT)" -t "$(OUTPUT)"
# Open locally served page in browser.
open:
xdg-open "http://localhost:$(PORT)" >/dev/null 2>/dev/null & disown
# Update HTML on file change. Doesn't check for new files.
watchdog:
find . | grep -v ".git" | entr -n -s "$(MAKE) html"
# Remove artefacts
clean:
-rm -r cache 2>/dev/null || true
-rm -r output/*.html 2>/dev/null || true
# 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
# -- Aliases --
serve: server
lan-serve: lan-server
data: fetch
watch: watchdog