1# Local Make rules.
2#
3# Copyright (C) 2013-2015 Gary V. Vaughan
4# Written by Gary V. Vaughan, 2013
5#
6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
20## ------------ ##
21## Environment. ##
22## ------------ ##
23
24std_path = $(abs_srcdir)/lib/?.lua;$(abs_srcdir)/lib/?/init.lua
25LUA_ENV  = LUA_PATH="$(std_path);$(LUA_PATH)"
26
27
28## ---------- ##
29## Bootstrap. ##
30## ---------- ##
31
32old_NEWS_hash = d41d8cd98f00b204e9800998ecf8427e
33
34update_copyright_env = \
35	UPDATE_COPYRIGHT_HOLDER='(Gary V. Vaughan|Reuben Thomas)' \
36	UPDATE_COPYRIGHT_USE_INTERVALS=1 \
37	UPDATE_COPYRIGHT_FORCE=1
38
39
40## ------------- ##
41## Declarations. ##
42## ------------- ##
43
44classesdir		= $(docdir)/classes
45modulesdir		= $(docdir)/modules
46
47dist_doc_DATA		=
48dist_classes_DATA	=
49dist_modules_DATA	=
50
51include specs/specs.mk
52
53
54## ------ ##
55## Build. ##
56## ------ ##
57
58dist_lua_DATA +=			\
59	lib/std.lua			\
60	$(NOTHING_ELSE)
61
62luastddir = $(luadir)/std
63
64dist_luastd_DATA =			\
65	lib/std/base.lua		\
66	lib/std/container.lua		\
67	lib/std/debug.lua		\
68	lib/std/functional.lua		\
69	lib/std/io.lua			\
70	lib/std/list.lua		\
71	lib/std/math.lua		\
72	lib/std/object.lua		\
73	lib/std/operator.lua		\
74	lib/std/optparse.lua		\
75	lib/std/package.lua		\
76	lib/std/set.lua			\
77	lib/std/strbuf.lua		\
78	lib/std/strict.lua		\
79	lib/std/string.lua		\
80	lib/std/table.lua		\
81	lib/std/tree.lua		\
82	$(NOTHING_ELSE)
83
84# For bugwards compatibility with LuaRocks 2.1, while ensuring that
85# `require "std.debug_init"` continues to work, we have to install
86# the former `$(luadir)/std/debug_init.lua` to `debug_init/init.lua`.
87# When LuaRocks works again, move this file back to dist_luastd_DATA
88# above and rename to debug_init.lua.
89
90luastddebugdir = $(luastddir)/debug_init
91
92dist_luastddebug_DATA =			\
93	lib/std/debug_init/init.lua	\
94	$(NOTHING_ELSE)
95
96# In order to avoid regenerating std.lua at configure time, which
97# causes the documentation to be rebuilt and hence requires users to
98# have ldoc installed, put std/std.lua in as a Makefile dependency.
99# (Strictly speaking, distributing an AC_CONFIG_FILE would be wrong.)
100lib/std.lua: lib/std.lua.in
101	./config.status --file=$@
102
103
104## Use a builtin rockspec build with root at $(srcdir)/lib, and note
105## the github repository doesn't have the same name as the rockspec!
106mkrockspecs_args = --module-dir $(srcdir)/lib --repository lua-stdlib
107
108
109## ------------- ##
110## Distribution. ##
111## ------------- ##
112
113EXTRA_DIST +=				\
114	build-aux/config.ld.in		\
115	lib/std.lua.in			\
116	$(NOTHING_ELSE)
117
118
119## -------------- ##
120## Documentation. ##
121## -------------- ##
122
123
124dist_doc_DATA +=			\
125	$(srcdir)/doc/index.html	\
126	$(srcdir)/doc/ldoc.css
127
128dist_classes_DATA +=					\
129	$(srcdir)/doc/classes/std.container.html	\
130	$(srcdir)/doc/classes/std.list.html		\
131	$(srcdir)/doc/classes/std.object.html		\
132	$(srcdir)/doc/classes/std.optparse.html		\
133	$(srcdir)/doc/classes/std.set.html		\
134	$(srcdir)/doc/classes/std.strbuf.html		\
135	$(srcdir)/doc/classes/std.tree.html		\
136	$(NOTHING_ELSE)
137
138dist_modules_DATA +=					\
139	$(srcdir)/doc/modules/std.html			\
140	$(srcdir)/doc/modules/std.debug.html		\
141	$(srcdir)/doc/modules/std.functional.html	\
142	$(srcdir)/doc/modules/std.io.html		\
143	$(srcdir)/doc/modules/std.math.html		\
144	$(srcdir)/doc/modules/std.operator.html		\
145	$(srcdir)/doc/modules/std.package.html		\
146	$(srcdir)/doc/modules/std.strict.html		\
147	$(srcdir)/doc/modules/std.string.html		\
148	$(srcdir)/doc/modules/std.table.html		\
149	$(NOTHING_ELSE)
150
151## Parallel make gets confused when one command ($(LDOC)) produces
152## multiple targets (all the html files above), so use the presence
153## of the doc directory as a sentinel file.
154$(dist_doc_DATA) $(dist_classes_DATA) $(dist_modules_DATA): $(srcdir)/doc
155
156$(srcdir)/doc: $(dist_lua_DATA) $(dist_luastd_DATA)
157	test -d $@ || mkdir $@
158	$(LDOC) -c build-aux/config.ld -d $(abs_srcdir)/doc .
159