-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
173 lines (142 loc) · 5.02 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
########################################################################
# makespec Makefile - licensed under GPL 3.0 by Jakob Voss #
# #
# Current version: https://$(GIT)hub.com/jakobib/makespec #
# Documentation: http://jakobib.$(GIT)hub.com/makespec #
# #
# Requires at least GNU Make >= 3.81, Pandoc, Perl, and sed. #
########################################################################
# path of this file
MAKESPEC = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
# makespec documents itself by default
ifeq ($(words $(MAKEFILE_LIST)),1)
NAME = makespec
SOURCE = makespec.md
GITHUB = https://github.com/jakobib/makespec/
TITLE = Creating specifications with makespec
AUTHOR = Jakob Voß
ABSTRACT_FROM = README.md
endif
# include files
include $(MAKESPEC)/executables.make
include $(MAKESPEC)/configuration.make
include $(MAKESPEC)/version.make
ifneq ($(wildcard $(MAKESPEC)/local.make),)
include $(MAKESPEC)/local.make
endif
########################################################################
VARS=-V GITHUB=$(GITHUB) -V VERSION=$(VERSION)
ifneq ($(LANGUAGE),)
VARS += -V lang=$(LANGUAGE)
endif
ifneq ($(findstring owl,$(FORMATS)),)
VARS += -V RDFXML_URL=$(NAME).owl
endif
########################################################################
COMBINED = $(NAME).tmp
RESULTFILES = $(NAME).html
RESULTFILES += $(foreach f,$(FORMATS),$(NAME).$(f))
RESULTFILES = $(NAME).html
RESULTFILES += $(foreach f,$(FORMATS),$(NAME).$(f))
########################################################################
include $(MAKESPEC)/formats.make
include $(MAKESPEC)/workflow.make
########################################################################
status:
ifeq ($(REVSHRT),)
@echo "Not commited yet$(ABOUT_VERSION)"
else
@echo "Last commit $(REVSHRT) at $(REVDATE)$(ABOUT_VERSION)"
# @if [ -n "$(FILES_CHANGED)" ]; then echo "Your repository contains uncommitted changes!"; fi
endif
info: status
@echo TITLE='$(TITLE)'
@echo AUTHOR='$(AUTHOR)'
@echo DATE='$(DATE)'
@echo LANGUAGE='$(LANGUAGE)'
@echo ABSTRACT_FROM='$(ABSTRACT_FROM)'
@echo ABSTRACT='$(ABSTRACT)'
@echo MAKESPEC='$(MAKESPEC)'
@echo NAME='$(NAME)'
@echo GITHUB='$(GITHUB)'
@echo SOURCE='$(SOURCE)'
@echo VERSION='$(VERSION)'
@echo FORMATS='$(FORMATS)'
@echo RESULTFILES='$(RESULTFILES)'
@if [ "$(FORMATS)" ] ; then \
for f in html $(FORMATS); do \
echo "$$f"; \
done \
fi
@echo VARS='$(VARS)'
sources: Makefile $(MAKESPEC) $(SOURCE) $(REFERENCES)
# rebuild all output formats
new: purge html $(FORMATS)
# TODO: REFERENCES and METADATA not supported yet
# TODO: automatically insert "fork me on GitHub" badge
# TODO: replacement vars, such as $(ABSTRACT) may contain nasty characters
$(COMBINED): sources
@rm -f $@
@if [ '$(TITLE)$(AUTHOR)' ]; then \
echo "% $(TITLE)" > $@ ; \
echo "% $(AUTHOR)" >> $@ ; \
echo "% $(DATE)" >> $@ ; \
echo "" >> $@ ; \
fi
@echo "" > changes.tmp
ifneq ($(REVSHRT),)
# TODO: follow additional source files?
@$(GIT) log -n $(REVISIONS) --pretty=format:'$(LOGFORMAT)' --follow $(SOURCE) >> changes.tmp
endif
@echo "" >> changes.tmp
@$(MAKESPEC)/replace-vars.pl \
GIT_REVISION_DATE '$(REVDATE)' \
GIT_ATOM_FEED '$(GIT_ATOM_FEED)' \
CURRENT_VERSION '$(NAME)-$(REVSHRT)' \
CURRENT_TIMESTAMP '$(REVTIME)' \
GIT_REVISION_HASH '[${REVSHRT}](${REVLINK})' \
ABSTRACT '$(ABSTRACT)' \
VERSION '$(VERSION)' \
GITHUB '$(GITHUB)' \
GIT_CHANGES: changes.tmp \
< $(SOURCE) | $(MAKESPEC)/include.pl >> $@
@rm -f changes.tmp
# TODO: More variables (?)
$(NAME).tmp.ttl: sources
@$(MAKESPEC)/CodeBlocks $(TTLFORMAT) $(SOURCE) > $@
@$(MAKESPEC)/CodeBlocks $(TTLFORMAT) $(SOURCE) | \
$(MAKESPEC)/replace-vars.pl \
GIT_REVISION_DATE '$(REVDATE)' \
VERSION '$(VERSION)' \
> $@
$(NAME).ttl: $(NAME).tmp.ttl
@$(RAPPER) --guess $< -o turtle > $@
$(NAME).owl: $(NAME).tmp.ttl
@$(RAPPER) --guess $< -o rdfxml > $@
revision: $(RESULTFILES)
@for f in html $(FORMATS); do \
cp $(NAME).$$f $(NAME)-$(REVSHRT).$$f ; \
done
website: sources clean purge revision $(RESULTFILES)
@echo "new revision to be shown at $(GITHUB)"
@rm $(RESULTFILES)
@rm -f *.tmp *.tmp.ttl
@$(GIT) checkout gh-pages || ( $(GIT) checkout --orphan gh-pages && git rm -rf . )
@for f in html $(FORMATS); do \
cp $(NAME)-$(REVSHRT).$$f $(NAME).$$f ; \
done
@echo "<!DOCTYPE html><html><head><meta http-equiv='refresh' content='0;url=$(NAME).html'/></head></html>" > index.html
@$(GIT) add index.html $(NAME)-$(REVSHRT).html $(RESULTFILES)
@$(GIT) commit -m "revision $(REVSHRT)"
@$(GIT) checkout master
cleancopy:
@echo "checking that no local modifcations exist..."
@$(GIT) diff-index --quiet HEAD --
all: $(RESULTFILES)
clean: clean-tex
@rm -f $(NAME)-*.* *.tmp *.log *.aux *.out *.toc
clean-tex:
@rm -f *.out *.log *.aux *.bbl *.blg *.dvi *.toc
purge: clean
@rm -f $(RESULTFILES)
.PHONY: info clean purge default status push pull reset-website