blob: 23e5ed0383cfdc31c2dfd82b789d78b0e0463fdd (
plain)
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
|
CONFIG=config.json
TARGET=ngxconf
NGXCONF=nginx.conf
GENERATED=templates.go
SOURCES=$(wildcard *.go) $(GENERATED)
all: build config
@echo "Run 'make preview' to view the rendered template or 'make save' to save it in $(NGXCONF)"
build: $(TARGET)
$(TARGET): $(SOURCES)
@echo "Generating Go sources..."
@go generate || echo "Failed. We need at least Go version 1.4 to generate code. $(TARGET) still works but you ned to specify the full path to your template directory."
go build
config: $(CONFIG)
$(CONFIG): $(TARGET)
./$(TARGET) -genconfig $(CONFIG)
@echo ""
save: build
@if [ ! -f $(CONFIG) ]; then make config; fi
./$(TARGET) -config $(CONFIG) > $(NGXCONF)
preview: build
@if [ ! -f $(CONFIG) ]; then make config; fi
@./$(TARGET) -config $(CONFIG)
edit: $(CONFIG)
$(EDITOR) $(CONFIG)
clean:
$(RM) $(RMFLAGS) $(CONFIG) $(TARGET) $(NGXCONF) $(GENERATED)
@echo "package main" > $(GENERATED); \
echo "// To be replaced by go generate" >> $(GENERATED); \
echo "func isGenerated() bool { return false }" >> $(GENERATED); \
echo "func getTemplate() string { return \"\" }" >> $(GENERATED)
help:
@echo "Generates a standard nginx config file"
@echo "make build -- compile"
@echo "make config -- generate config"
@echo "make save -- render template and save in $(NGXCONF)"
@echo "make preview -- preview rendered template"
@echo "make edit -- edit $(CONFIG)"
@echo "make clean -- removes generated files"
|