-
Notifications
You must be signed in to change notification settings - Fork 368
/
Makefile
83 lines (69 loc) · 2.3 KB
/
Makefile
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
-include ../Makefile.config
ifeq ($(DUNE),)
DUNE_EXE = ../src_ext/dune-local/_build/install/default/bin/dune$(EXE)
ifeq ($(shell command -v cygpath 2>/dev/null),)
DUNE := $(DUNE_EXE)
else
DUNE := $(shell echo "$(DUNE_EXE)" | cygpath -f - -a)
endif
else
DUNE_EXE=
endif
DUNE_PROFILE ?= release
DUNE_ARGS ?=
ifndef OPAM
OPAM = $(DUNE) exec --profile=$(DUNE_PROFILE) -- opam
endif
TOPICS = $(shell $(OPAM) help topics)
TOPICS_ADMIN = cache filter index lint list upgrade
HELPFMT = --help=groff
ifndef OPAM_INSTALLER
OPAM_INSTALLER = $(DUNE) exec --profile=$(DUNE_PROFILE) -- opam-installer
endif
.PHONY: man html pages
all: man html pages
man:
rm -rf man
mkdir -p man
$(OPAM) $(HELPFMT) > man/opam.1 2> man/err
for i in $(TOPICS); do\
$(OPAM) $$i $(HELPFMT) > man/opam-$$i.1 2>> man/err ; \
done
$(OPAM) admin $(HELPFMT) > man/opam-admin.1 2>> man/err
for i in $(TOPICS_ADMIN); do\
$(OPAM) admin $$i $(HELPFMT) > man/opam-admin-$$i.1 2>> man/err ; \
done
$(OPAM_INSTALLER) $(HELPFMT) > man/opam-installer.1 2>> man/err
# Dune doesn't (yet) support --no-print-directory
@if grep -v "^Entering directory '" man/err > man/err2 ; then cat man/err2 ; false ; fi
man-html: man
rm -rf man-html
mkdir -p $@
echo '<!DOCTYPE html>' >$@/index.html
echo '<html><head>' >>$@/index.html
echo ' <title>Opam man-pages index</title>' >>$@/index.html
echo '</head><body>' >>$@/index.html
echo '<h1>Opam $(version) man-pages index</h1>' >>$@/index.html
echo '<ul>' >>$@/index.html
for f in man/*; do\
man2html -r $$f | sed 1,2d > $@/$$(basename $$f .1).html;\
echo " <li><a href=\"$$(basename $$f .1).html\">$$(basename $$f .1)</a></li>" >>$@/index.html;\
done
echo '</ul>' >>$@/index.html
echo '</body></html>' >>$@/index.html
html:
rm -rf html
cd .. && $(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) @doc
cp -r ../_build/default/_doc/_html html
sed 's/%{OPAMVERSION}%/'$(version)'/g' index.html > html/index.html
# Not to break older links, add manpages to the `ocamldoc` dir
mkdir -p html/ocamldoc
cd html/ocamldoc && for f in ../*/*/index.html; do\
ln -sf $$f $$(basename $$(dirname $$f)).html;\
done
pages/%.html: pages/%.md
omd $^ -o $@
PAGES=$(wildcard pages/*.md)
pages: $(PAGES:.md=.html)
clean:
rm -rf dependencies.dot man html/ocamldoc man-html pages/*.html html/index.html