forked from tjbarbour/startbootstrap-clean-blog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
120 lines (95 loc) · 3.61 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /usr/bin/make
#
# Gnu Make needed to run te "pull" command
#
# Site update script, mostly needed for custom php email forwarder
# configuration after static site setup
#
# Jordan Hrycaj <[email protected]>
#
# $Id$
#
# ---------------------------------------------------------------------------
# Setup: change SCRIPTS and CONFIG variables maually unless Gnu Make is used
# ---------------------------------------------------------------------------
THEME = $(shell sed -e 's/=/ = /' -e 's/["'\'']//g' $(CONFIG) |\
awk '$$1=="theme"{print$$3;exit}')
# SCRIPTS = ./themes/<theme>/scripts or ./scripts
SCRIPTS = ./$(if $(strip $(THEME)),themes/$(THEME)/)scripts
# CONFIG = config.toml or theme.toml
CONFIG = $(if $(strip $(wildcard config.toml)),config.toml,theme.toml)
# ---------------------------------------------------------------------------
# End setup
# ---------------------------------------------------------------------------
SETUP_PFWD = $(SHELL) $(SCRIPTS)/setup-email-form.sh
TEST_PFWD = $(SHELL) $(SCRIPTS)/send-test-email.sh
.PHONY: help
help:
@echo
@echo "Usage: $(MAKE) <target>"
@echo
@echo "<target>: site -- create production site"
@echo " server -- run hugo server for testing"
@echo " test-mail -- send email test message"
@echo " pull -- update from git repositories"
@echo " clean -- clean up"
@echo " distclean -- full clean up"
@echo
@echo " howto-site -- mail server setup info"
@echo " howto-test-mail -- mail server test info"
@echo
# ---------------------------------------------------------------------------
# Create site
# ---------------------------------------------------------------------------
.site-built:
$(SETUP_PFWD) "$(CONFIG)"
touch "$@"
.PHONY: site howto-site
site:
rm -f .site-built
hugo --config=$(CONFIG)
$(MAKE) .site-built
howto-site:
$(SETUP_PFWD) --help
# ---------------------------------------------------------------------------
# Reinstall site and run test server
# ---------------------------------------------------------------------------
.PHONY: server
server:
rm -f .site-built
hugo server --config=$(CONFIG) --watch=true
# ---------------------------------------------------------------------------
# Send a test mail
# ---------------------------------------------------------------------------
.PHONY: test-mail howto-test-mail
test-mail: .site-built
$(TEST_PFWD) "$(CONFIG)"
howto-test-mail:
$(TEST_PFWD) --help
# ---------------------------------------------------------------------------
# Clean up
# ---------------------------------------------------------------------------
.PHONY: clean distclean
clean distclean::
rm -f .site-built
rm -rf public
distclean::
rm -f *~ */*~ */*/*~
# ---------------------------------------------------------------------------
# The pull command needs GNU make
# ---------------------------------------------------------------------------
git_rxconf = git config -f .gitmodules --get-regexp
get_config = $(shell $(git_rxconf) '^submodule\.$(1)$$'|cut -f2 -d\ )
get_url = $(call get_config,$(notdir $(1))\.url)
pull_submod = cd $(shell pwd)/\$$path && git pull origin master
SUBMODULES = $(call get_config,.*\.path)
BRANCH = $(shell git status -bs|awk '{print$$2;exit}')
$(SUBMODULES):
cd themes && git clone $(call get_url,$(notdir $@))
.PHONY: pull
pull: $(SUBMODULES)
git submodule foreach "$(pull_submod)"
git pull origin $(BRANCH)
# ---------------------------------------------------------------------------
# End
# ---------------------------------------------------------------------------