1#!/bin/sh
2cd `dirname $0`
3
4echo "Generating Makefile"
5exec 4<&1
6exec 1>Makefile
7
8# Will need to be smarter if/when we add a 'combined'.
9FILES="*.adoc"
10
11
12# Heading
13cat << EOF
14## GENERATED FILE
15
16BDIR=build
17ADOC=asciidoctor -atoc -anumbered
18
19# Default target
20all: \${BDIR}
21
22\${BDIR}:
23	mkdir -p \${BDIR}
24	(cd \${BDIR} && ln -s ../static .)
25
26clean:
27	rm -rf \${BDIR}
28
29allclean: clean
30	rm -f Makefile
31
32
33# Individual files
34
35EOF
36
37
38# Now list the files
39for i in ${FILES}; do
40	in="${i}"
41	out="\${BDIR}/`echo ${i} | sed -E -e 's/(.*)\.adoc/\1.html/'`"
42	echo "all: ${out}"
43	echo "${out}: \${BDIR} ${in}"
44	printf "\t\${ADOC} -o ${out} ${in}\n"
45	echo
46done
47
48
49
50exec 1<&4
51
52echo "Done."
53