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.
		
		
		
		
		
			
		
			
				
	
	
		
			86 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Makefile
		
	
			
		
		
	
	
			86 lines
		
	
	
		
			1.9 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.
 | 
						|
watchdog:
 | 
						|
	set -o pipefail; \
 | 
						|
	while :; do find . | grep -v ".git" | entr -nds "$(MAKE) html" && exit; done
 | 
						|
 | 
						|
# Remove artefacts
 | 
						|
clean:
 | 
						|
	-git clean -dfX
 | 
						|
 | 
						|
# 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 --fast --no-color
 | 
						|
test-ci: clean all
 | 
						|
 | 
						|
# -- Aliases --
 | 
						|
serve: server
 | 
						|
 | 
						|
lan-serve: lan-server
 | 
						|
 | 
						|
data: fetch
 | 
						|
 | 
						|
watch: watchdog
 | 
						|
 |