1# Copyright 2017 Artem Savkov <artem.savkov@gmail.com>
2# Copyright 2017-2018 Alex Schroeder <alex@gnu.org>
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17EXTRA_DIST = mastodon-help.txt
18
19all-local: HELP.md
20
21install-data-local:
22	if [ -f $(datadir)/help.txt ]; then \
23		for file in $(EXTRA_DIST); do \
24		  mkdir -p $(DESTDIR)$(datadir); \
25			$(INSTALL) -m 644 $(srcdir)/$$file $(DESTDIR)$(datadir)/; \
26		done \
27	else \
28		echo "Detected dir $(datadir) is not bitlbee's data dir"; \
29		echo "Skipping help install"; \
30	fi
31
32HELP.md: mastodon-help.txt Makefile
33	@ac_cv_path_SED@ \
34	-e '1i# Bitlbee Mastodon\nThis document was generated from the help text for the plugin.\n' \
35	-e '1d' \
36	-e 's/^%$$//g' \
37	-e 's/^\?mastodon /## /g' \
38	-e 's/^\?/## /g' \
39	-e 's/\*/\\*/g' \
40	-e 's//**/g' \
41	-e 's/^ \*/* */g' \
42	-e 's/\*help mastodon \([a-z]*2*\)\*/[\1](#\1)/g' \
43	-e 's/</\&lt;/g' \
44	-e 's/>/\&gt;/g' \
45	-e 's/^\(\*[^ ].*\)/> \1  /g' \
46	< $< > $@
47