summaryrefslogtreecommitdiff
path: root/OMakefile
blob: 45f3ad27a17fe7fa00ded8818f75c7be05969157 (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
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
.PHONY: all install clean nuke buildenv ctan ctan-root tds tds-hier usage doc

name		= rst

###############################################################################
# SOURCE
###############################################################################

doc_dir		= ./doc
src_dir		= ./src
misc_dir	= ./misc

## input
lua_src[]	= $(glob $(src_dir)/rst_*.lua)
tex_src		= $(src_dir)/t-rst.mkiv
script_src	= $(src_dir)/mtx-t-rst.lua
ifc_src		= $(misc_dir)/t-rst.xml

meta_files[]	= README.rst COPYING
build_files[]	= OMakeroot OMakefile $(doc_dir)/OMakefile
doc_src[]	= $(filter-out OMakefile, $(glob $(doc_dir)/*))

###############################################################################
# DIRECTORIES
###############################################################################

## The CTAN guys prefer the zipball to extract to a source directory with a
## flat structure containing all the files, and an accompanying TDS zipball
## at the root.
build_root	= ./build
doc_tree	= $(build_root)/doc/context/third/$(name)
tex_tree	= $(build_root)/tex/context/third/$(name)
ifc_tree	= $(build_root)/tex/context/interface/third
src_tree	= $(build_root)/source/context/$(name)/
script_tree	= $(build_root)/scripts/context/lua/third/$(name)
ctan_root	= $(build_root)/$(name)
doc_tmpdir	= $(build_root)/doc-tmp
tds_hier[] 	= $(doc_tree) $(tex_tree) $(script_tree) $(ifc_tree) $(src_tree)
tds_dirnames[]	= doc scripts tex
tds_dirs[]	= $(addprefix $(build_root)/,$(tds_dirnames))

dirs[]		= $(build_root) $(ctan_root) $(tds_hier)

###############################################################################
# GENERATED
###############################################################################

ctan_zipfile	= $(name).zip
tds_zipfile	= $(name).tds.zip

manual_name	= manual
manual_pdf	= $(doc_tmpdir)/$(manual_name).pdf

ctan_zip	= $(build_root)/$(ctan_zipfile)
tds_zip		= $(build_root)/$(tds_zipfile)
pkgs		= $(ctan_zip) $(tds_zip)

###############################################################################
# TARGETS
###############################################################################

section
	OMakeFlags(-s)
	usage:
		echo "****************************** $(name) ******************************"
		echo
		echo " $(name) is distributed under the 2-clause BSD license. See the file"
		echo " COPYING in the root tree of this repository for details."
		echo
		echo "defined targets:"
		echo "    ctan      package for CTAN"
		echo "    tds       package as TDS directory hierarchy"
		echo
		echo "    doc       create module manual"
		echo
		echo "    clean     remove temporary files"
		echo "    nuke      remove all created files"
		echo

ctan-root:
	mkdir(-p $(ctan_root))

tds-hier:
	#printvln(:: $(tds_hier))
	mkdir(-p $(tds_hier))

buildenv: ctan-root tds-hier

## nuke -- remove the entire build directory and packaged files
nuke:
	$(rm -rf -- $(build_root) $(pkgs))

## clean -- leave the build directory, documentation and tarballs intact
clean: .PHONY/$(doc_tmpdir)/clean
	$(rm -rf -- $(tds_dirs) $(ctan_root))

## tds -- package according to TeX directory structure
tds: $(tds_zip)

## ctan -- package for CTAN upload
ctan: $(ctan_zip)

## PDF documentation
doc: .PHONY/$(doc_tmpdir)/manual

$(tds_zip): doc tds-hier
	$(echo $(name)> packaging as $@ with TDS directories)
	cp($(lua_src)     $(tex_tree))
	cp($(tex_src)     $(tex_tree))
	cp($(script_src)  $(script_tree))
	cp($(doc_src)     $(doc_tree))
	cp($(manual_pdf)  $(doc_tree))
	cp($(ifc_src)     $(ifc_tree))
	cp($(meta_files)  $(src_tree))
	cp($(build_files) $(src_tree))
	cd $(build_root) && zip -9 -r ./$(tds_zipfile) $(tds_dirnames)

$(ctan_zip): ctan-root $(tds_zip)
	$(echo $(name)> packaging as $@ for CTAN upload)
	cp($(lua_src)    $(ctan_root))
	cp($(script_src) $(ctan_root))
	cp($(tex_src)    $(ctan_root))
	cp($(doc_src)    $(ctan_root))
	cp($(manual_pdf) $(ctan_root))
	cp($(ifc_src)    $(ctan_root))
	cp($(meta_files) $(ctan_root))
	cd $(build_root) && zip -9 -r ./$(ctan_zipfile) $(name) $(tds_zipfile)

.DEFAULT: usage