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

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

doc_src[]	= $(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)
script_tree	= $(build_root)/scripts/context/lua/third/$(name)
ctan_root	= $(build_root)/$(name)
tds_hier[] 	= $(doc_tree) $(tex_tree) $(script_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

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 "defined targets:"
		echo "    ctan      package for CTAN"
		echo "    tds       package as TDS directory hierarchy"
		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:
	$(rm -rf -- $(tds_dirs) $(ctan_root))

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

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

$(tds_zip): 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))
	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))
	cd $(build_root) && zip -9 -r ./$(ctan_zipfile) $(name) $(tds_zipfile)

.DEFAULT: usage