summaryrefslogtreecommitdiff
path: root/Makefile
blob: c3f5d7970ea59f7af095ffa6dca9c2da87469246 (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
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
# Makefile for compiling the Ousía Homepage
#
# (c) Andreas Stöckel, 2015
#
# This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
# International License. <http://creativecommons.org/licenses/by-sa/4.0/>

.PHONY: all clean webclean

# Fetch all the source OSML files in the top level directory
SOURCE_OSML=$(wildcard *.osml)

# Derive the target xml and html files from the source files
TARGET_XML=$(SOURCE_OSML:.osml=.xml)
TARGET_HTML=$(SOURCE_OSML:.osml=.html)

# Builds the style and all webpages
all: script/ousia.js style/style.css $(TARGET_XML) $(TARGET_HTML)

# Build the stylesheet using lessc
# On Fedora you can install lessc using the following commands (as root):
#     yum install nodejs npm
#     npm install -g less less-plugin-clean-css
style/style.css: style/*.less style/lib/*.css
	lessc \
		style/style.less \
		style/style.css --clean-css="--s1"

# Build the JavaScript using uglifyjs
# On Fedora you can install uglifyjs using the following commands (as root):
#     yum install nodejs npm
#     npm install -g uglifyjs
script/ousia.js: script/lib/*.js
	uglifyjs \
		script/lib/prism.js \
		script/lib/prism_bash.js \
		script/highlight.js > script/ousia.js

# Compile all osml files to xml
%.xml: %.osml ontology/*.osml
	ousia -F xml -o $@ $<

# Compile the xml files to html
%.html: %.xml xsl/*.xsl
	xsltproc xsl/webpage.xsl $< > $@

# Clean script, remove all target files
clean:
	rm -f style/*.css
	rm -f script/ousia.js
	rm -f $(TARGET_HTML)
	rm -f $(TARGET_XML)
	rm -f *~ style/*~ ontology/*~ xsl/*~

# Webclean script -- deletes all source files, keeping only the compiled HTML,
# CSS and JS code. It is generally a good idea to remove the source files from
# the webserver directory to keep people from downloading potentially large
# source files and to reduce time for deployment (gzip, rsync).
webclean:
	# Avoid accidential execution of this target -- delete the .git folder if
	# you really want to delete all development files and prepare this folder
	# for deployment on a webserver
	test ! -e .git
	find style/ -type f -not -name "style.css" -delete
	find script/ -type f -not -name "ousia.js" -delete
	rmdir script/lib
	rmdir style/lib
	rm -f $(TARGET_XML)
	rm -f $(SOURCE_OSML)
	rm -rf ontology www-src
	rm -f Makefile
	rm -f .gitignore