-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (79 loc) · 2.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# TODO: also add the package to the .rockspec file
.PHONY: add
add: ## Add a lua dependency to the local project, usage: make add package=package-name
luarocks install --tree lua_modules $(package)
.PHONY: install
install: ## Install project dependencies
sudo pacman -Sy pandoc
luarocks install --tree lua_modules --deps-only ultima-dev-1.rockspec
SITES := $(shell find sites -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
.PHONY: list-sites
list-sites: ## List all available sites
@echo "Available sites:"
@for site in $(SITES); do \
echo " - $$site"; \
done
.PHONY: build-all
build-all: $(SITES) ## Build all sites
.PHONY: $(SITES)
$(SITES): ## Build a specific site
@echo ""
@echo "Building site: $@"
@source $(CURDIR)/project.env && ./src/ultima.lua $@
# Site-specific targets with force flag
.PHONY: $(addsuffix -f,$(SITES))
$(addsuffix -f,$(SITES)): ## Force build a specific site
@echo "Force building site: $(subst -f,,$@)"
@source $(CURDIR)/project.env && ./src/ultima.lua -f $(subst -f,,$@)
# Site-specific targets for production
.PHONY: $(addsuffix -prod,$(SITES))
$(addsuffix -prod,$(SITES)): ## Build a specific site for production
@echo "Building site for production: $(subst -prod,,$@)"
@source $(CURDIR)/project.env && ./src/ultima.lua -f --env prod $(subst -prod,,$@)
.PHONY: deploy
deploy: ## Build & deploy a specific site to production, usage: make deploy site=site-name
@if [ -z "$(site)" ]; then \
echo "Error: site parameter is required. Usage: make deploy site=site-name"; \
exit 1; \
fi
rm -rf deploy/$(site)
@echo ""
@echo "Building $(site) for production..."
@echo ""
@source $(CURDIR)/project.env && ./src/ultima.lua -f --env prod $(site)
@echo ""
@./scripts/deploy.sh $(site)
.PHONY: run
run: ## Run a specific site, usage: make run site=site-name
@if [ -z "$(site)" ]; then \
echo "Error: site parameter is required. Usage: make run site=site-name"; \
exit 1; \
fi
@source $(CURDIR)/project.env && ./src/ultima.lua $(site)
xdg-open build/$(site)/index.html
.PHONY: clean
clean: ## Clean compiled artifacts
rm -rf build/
rm -rf deploy/
.PHONY: lint
lint: ## Lint lua source files
@luacheck src/
.PHONY: format
format: ## Format lua source files
@stylua -v src/
.PHONY: docs
docs: ## Generate documentation
@./lua_modules/bin/ldoc src/
.PHONY: help
help: ## Show this help
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Site-specific targets are available:"
@echo " make <site> - Build a specific site"
@echo " make <site>-f - Force build a specific site"
@echo " make <site>-prod - Build a specific site for production"
@echo ""
@echo "Available sites:"
@for site in $(SITES); do \
echo " - $$site"; \
done