|
| 1 | +SRC_DIR = ./src |
| 2 | +OUTPUT_DIR = ./public |
| 3 | +FILES = $(filter-out \ |
| 4 | + $(wildcard $(SRC_DIR)/_*.php) \ |
| 5 | + $(wildcard $(SRC_DIR)/**/_*.php) \ |
| 6 | + $(wildcard $(SRC_DIR)/**/**/_*.php), \ |
| 7 | + $(wildcard $(SRC_DIR)/*.php) \ |
| 8 | + $(wildcard $(SRC_DIR)/**/*.php) \ |
| 9 | + $(wildcard $(SRC_DIR)/**/**/*.php) \ |
| 10 | +) |
| 11 | + |
1 | 12 | target: |
2 | | - @echo my name jeff |
| 13 | + @echo -e "Use 'make \033[0;36mtarget\033[0m' where \033[0;36mtarget\033[0m is one of the following:" |
| 14 | + @awk -F ':|##' '/^[^\t].+?:.*?##/ { printf " \033[0;36m%-15s\033[0m %s\n", $$1, $$NF }' $(MAKEFILE_LIST) |
| 15 | + |
| 16 | +build: ## Build the website |
| 17 | + @echo "Generating static HTML files..." |
| 18 | + @mkdir -p $(OUTPUT_DIR) |
| 19 | + @$(foreach file, $(FILES), \ |
| 20 | + OUTPUT_PATH=$(OUTPUT_DIR)/$(patsubst $(SRC_DIR)/%,%,$(file)); \ |
| 21 | + OUTPUT_HTML=$$(echo $$OUTPUT_PATH | sed 's/\.php$$/\.html/'); \ |
| 22 | + mkdir -p $$(dirname $$OUTPUT_HTML); \ |
| 23 | + ( \ |
| 24 | + php -f $(file) > $$OUTPUT_HTML 2>/dev/null; \ |
| 25 | + ) || { echo "Error processing $(file)"; exit 1; }; \ |
| 26 | + echo "Generated $$OUTPUT_HTML"; \ |
| 27 | + ) |
| 28 | + |
| 29 | + @mkdir -p $(OUTPUT_DIR)/static |
| 30 | + @cp -r ./static/* $(OUTPUT_DIR)/static |
| 31 | + |
| 32 | + @echo "Copying leftover files..." |
| 33 | + @cp -r ./CNAME $(OUTPUT_DIR) |
| 34 | + @cp -r ./robots.txt $(OUTPUT_DIR) |
| 35 | + @cp -r ./sitemap.xml $(OUTPUT_DIR) |
3 | 36 |
|
4 | | -install: |
5 | | - pip install -r requirements.txt |
| 37 | + @echo "Done." |
6 | 38 |
|
7 | | -build: |
8 | | - python index.py build |
| 39 | +clean: ## Clean the output directory |
| 40 | + @echo "Cleaning output directory..." |
| 41 | + @rm -rf $(OUTPUT_DIR) |
| 42 | + @echo "Done." |
9 | 43 |
|
10 | | -dev: |
11 | | - python index.py |
| 44 | +dev: ## Preview the website locally with PHP |
| 45 | + @echo "Previewing locally at http://localhost:8080..." |
| 46 | + @php -S localhost:8080 -t $(OUTPUT_DIR) |
0 commit comments