-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (90 loc) · 2.6 KB
/
Copy pathMakefile
File metadata and controls
101 lines (90 loc) · 2.6 KB
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
94
95
96
97
98
99
100
101
# Makefile for developing website (cross-platform)
HUGO_VERSION := 0.124.1
# Detect OS and architecture
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
# Set OS-specific variables
ifeq ($(UNAME_S),Linux)
OS := Linux
ARCH := 64bit
ARCHIVE_EXT := tar.gz
BINARY_EXT :=
endif
ifeq ($(UNAME_S),Darwin)
OS := macOS
ARCH := 64bit
ARCHIVE_EXT := tar.gz
BINARY_EXT :=
endif
ifeq ($(OS),Windows_NT)
OS := Windows
ARCH := 64bit
ARCHIVE_EXT := zip
BINARY_EXT := .exe
endif
# Handle different architectures
ifeq ($(UNAME_M),arm64)
ARCH := ARM64
endif
ifeq ($(UNAME_M),aarch64)
ARCH := ARM64
endif
HUGO_BINARY := .tmp/hugo$(BINARY_EXT)
HUGO_URL := https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_extended_$(HUGO_VERSION)_$(OS)-$(ARCH).$(ARCHIVE_EXT)
# Default target
.PHONY: build
build: hugo-check
$(HUGO_BINARY) --minify
# Development server
.PHONY: serve
serve: hugo-check
$(HUGO_BINARY) server --disableFastRender
# Clean generated files
.PHONY: clean
clean:
rm -rf public/ resources/
# Check if Hugo is available, download if missing
.PHONY: hugo-check
hugo-check:
@if ! test -f $(HUGO_BINARY); then \
echo "Hugo not found at $(HUGO_BINARY), downloading Hugo $(HUGO_VERSION) extended..."; \
$(MAKE) download-hugo; \
else \
HUGO_VER=$$($(HUGO_BINARY) version | grep -o 'v[0-9.]*' | head -1 | sed 's/v//'); \
if test "$$HUGO_VER" != "$(HUGO_VERSION)"; then \
echo "Hugo version $$HUGO_VER found, but $(HUGO_VERSION) required. Downloading..."; \
$(MAKE) download-hugo; \
else \
echo "Hugo $(HUGO_VERSION) found at $(HUGO_BINARY)"; \
fi \
fi
# Download and install Hugo extended
.PHONY: download-hugo
download-hugo:
@echo "Downloading Hugo $(HUGO_VERSION) extended for $(OS)-$(ARCH)..."
@mkdir -p .tmp
ifeq ($(ARCHIVE_EXT),zip)
@curl -sL $(HUGO_URL) -o .tmp/hugo.zip
@cd .tmp && unzip -q hugo.zip
@rm -f .tmp/hugo.zip .tmp/LICENSE .tmp/README.md
else
@curl -sL $(HUGO_URL) -o .tmp/hugo.tar.gz
@tar -xzf .tmp/hugo.tar.gz -C .tmp
@rm -f .tmp/hugo.tar.gz .tmp/LICENSE .tmp/README.md
endif
@chmod +x $(HUGO_BINARY)
@echo "Hugo $(HUGO_VERSION) extended installed to $(HUGO_BINARY)"
# Help target
.PHONY: help
help:
@echo "Cross-platform Hugo website build system"
@echo "Detected platform: $(OS)-$(ARCH)"
@echo ""
@echo "Available targets:"
@echo " build - Build the website (default)"
@echo " serve - Start development server"
@echo " clean - Clean generated files"
@echo " hugo-check - Check/install Hugo $(HUGO_VERSION) extended"
@echo " help - Show this help"
@echo ""
@echo "Supported platforms: Linux, macOS, Windows (x86_64/ARM64)"