-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
98 lines (85 loc) · 5.86 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
# genscertifies.tocards.net/Makefile
# This makefile compiles some shit into some other shit.
#
# Copyright 2013 Remi "calops" Labeyrie <calops@tocards.net>
#
# This work is free. You can redistribute it and/or modify it under the terms
# of the Do What The Fuck You Want To Public License, Version 2, as published
# by Sam Hocevar.
# See the LICENSE file (http://genscertifies.tocards.net/LICENSE) for more
# details.
# This variable contains the path separator used to separate directories in a
# path.
VARIABLECONTAININGTHEPATHSEPARATOR = /
# This variable contains the radical of the target file.
VARIABLECONTAININGTHERADICALOFTHETARGETFILE = index
VARIABLECONTAININGTHEFILEEXTENSIONSEPARATORFORFILE = .
# This variable contains the extension of the target file.
VARIABLECONTAININGTHEFILEEXTENSIONFORHTMLFILE = html
VARIABLECONTAININGTHEFILEEXTENSIONFORTARGETFILE = $(VARIABLECONTAININGTHEFILEEXTENSIONSEPARATORFORFILE)$(VARIABLECONTAININGTHEFILEEXTENSIONFORHTMLFILE)
# This variable contains the file extension of the source file.
VARIABLECONTAININGTHEFILEEXTENSIONFORMDFILE = md
VARIABLECONTAININGTHEFILEEXTENSIONFORSOURCEFILE = $(VARIABLECONTAININGTHEFILEEXTENSIONSEPARATORFORFILE)$(VARIABLECONTAININGTHEFILEEXTENSIONFORMDFILE)
# This variable contains the full name of the target file.
VARIABLECONTAININGTHETARGETNAME = $(VARIABLECONTAININGTHERADICALOFTHETARGETFILE)$(VARIABLECONTAININGTHEFILEEXTENSIONFORTARGETFILE)
# This variable contains the full name of the source file. Tricky part: it is
# actually computed from the variable containing the full name of the target
# file.
VARIABLECONTAININGTHESOURCEFILECOMPUTEDFROMTHETARGETNAME = $(subst $(VARIABLECONTAININGTHEFILEEXTENSIONFORTARGETFILE),$(VARIABLECONTAININGTHEFILEEXTENSIONFORSOURCEFILE),$(VARIABLECONTAININGTHETARGETNAME))
# These variables contain backend-related stuff in order to abstract OS
# interactions from the actual compiling code.
# TODO: according to the certifiedmakefile coding style, every variable
# declaration should have its own verbose and excplicit comment describing its
# behavior.
# TODO: write the certifiedmakefile coding style
ifeq '${/usr/bin/env python2 && echo "python2 is here" || echo "python2 is not here"}' 'python2 is here'
VARIABLECONTAININGTHEVERSIONOFPYTHON = python2
else
VARIABLECONTAININGTHEVERSIONOFPYTHON = python
endif
VARIABLEREFERENCINGTHEPYTHONINTERPRETER = $(VARIABLECONTAININGTHEPATHSEPARATOR)usr$(VARIABLECONTAININGTHEPATHSEPARATOR)bin$(VARIABLECONTAININGTHEPATHSEPARATOR)env $(VARIABLECONTAININGTHEVERSIONOFPYTHON)
VARIABLECONTAININGTHEPATHTOTHESEDBINARY = $(VARIABLECONTAININGTHEPATHSEPARATOR)bin$(VARIABLECONTAININGTHEPATHSEPARATOR)sed
VARIABLECONTAININGTHENAMEOFTHEMARKUPMODULE = markdown
VARIABLECONTAININGTHEPATHTOTHERMBINARY = $(VARIABLECONTAININGTHEPATHSEPARATOR)bin$(VARIABLECONTAININGTHEPATHSEPARATOR)rm
VARIABLECONTAININGTHEPATHTOTHETESTDIRECTORY = t
VARIABLECONTAININGTHEPATHTOTHEDIFFBINARY = $(VARIABLECONTAININGTHEPATHSEPARATOR)usr$(VARIABLECONTAININGTHEPATHSEPARATOR)bin$(VARIABLECONTAININGTHEPATHSEPARATOR)diff
VARIABLECONTAININGTHEPATHTOTHECDBINARY = cd
VARIABLECONTAININGTHECOMMANDTOCREATEANEWINSTANCEOFMAKE = $(MAKE)
# TODO i18n these strings
# TODO adjust to the naming convention if these stay here
VARIABLETESTWHITESPACE = " "
VARIABLETESTNAME = "Test"
VARIABLETESTNAMESCHEME = $(VARIABLETESTNAME)$(VARIABLETESTWHITESPACE)
VARIABLETESTSUCCESSSTRING = "Success"
VARIABLETESTFAILURESTRING = "Failure"
VARIABLETESTSUCCESS = $($VARIABLETESTNAMESCHEME)$(VARIABLETESTSUCCESSSTRING)
VARIABLETESTFAILURE = $($VARIABLETESTNAMESCHEME)$(VARIABLETESTFAILURESTRING)
# This is the default rule that tepens only on the target file.
all: $(VARIABLECONTAININGTHETARGETNAME)
# This is the rule that does all the work. It compiles the source file into the
# target file, and then modifies the target file to be exactly like we wanted
# it to be in the first place and are too lazy to configure the markdown module
# before calling it.
$(VARIABLECONTAININGTHETARGETNAME): $(VARIABLECONTAININGTHESOURCEFILECOMPUTEDFROMTHETARGETNAME)
# This command compiles the source file as a markdown file into an html
# file, which happens to be our target file
$(VARIABLEREFERENCINGTHEPYTHONINTERPRETER) -m $(VARIABLECONTAININGTHENAMEOFTHEMARKUPMODULE) $< > $@
# This command adds a header to the target file to put a decent charset and
# shit.
$(VARIABLECONTAININGTHEPATHTOTHESEDBINARY) -i '1i<meta http-equiv="content-type" content="text/html; charset=utf-8" />' $@
# This command helps formatting the entries that are interpreted as code
# due to markdown syntax but actually we just wanted a <pre> mark. But
# yeah, that doesn't do exactly what we want so we sed the shit out of it.
$(VARIABLECONTAININGTHEPATHTOTHESEDBINARY) -i 's/<pre>/<pre style="white-space: pre-wrap;">/' $@
# This rule implements a basic unit test
# TODO: every line should have its own comment
test:
$(VARIABLECONTAININGTHEPATHTOTHECDBINARY) $(VARIABLECONTAININGTHEPATHTOTHETESTDIRECTORY); $(VARIABLECONTAININGTHECOMMANDTOCREATEANEWINSTANCEOFMAKE)
# FIXME: there are hardcoded strings in this command. This is unacceptable.
$(VARIABLECONTAININGTHEPATHTOTHEDIFFBINARY) $(VARIABLECONTAININGTHEPATHTOTHETESTDIRECTORY)$(VARIABLECONTAININGTHEPATHSEPARATOR)index.html $(VARIABLECONTAININGTHEPATHTOTHETESTDIRECTORY)$(VARIABLECONTAININGTHEPATHSEPARATOR)index.html.ref && echo $(VARIABLETESTSUCCESS) || echo $(VARIABLETESTFAILURE)
# This rule helps clean the project by removing every generated file.
clean:
# This command deletes a file. Ideally, the target file.
$(VARIABLECONTAININGTHEPATHTOTHERMBINARY) -f $(VARIABLECONTAININGTHETARGETNAME)
# Yes, the number of occurrences of the word "shit" in this file is way too
# high.