-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.ocaml
84 lines (59 loc) · 2 KB
/
Makefile.ocaml
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
# -*- makefile -*-
SHELL:=bash
# This is a generic Makefile.ocaml file, intended to be included in a
# top-level Makefile. NOTE that this file in turn attempts to include
# Makefile.local, which you can use to override defaults if needed.
# There are two envvars:
# scratch - the Makefile.ocaml will check here for updates to
# Makefile.ocaml itself; if this path doesn't exist on your system
# there is nothing to worry about
#
#
scratch?=/tmp/l/github/scratch
# TMP_DOC_DIR_ROOT - where docs are placed temporarily (before
# updating docs/); this could be /tmp for example (docs are placed in
# subdirs of this root, according to the name of the root dir of this
# repo)
TMP_DOC_DIR_ROOT?=/tmp
TMP_DOC_DIR?=$(TMP_DOC_DIR_ROOT)/$(notdir $(abspath .))
# generic makefile follows ---------------------------------------------
# allow overriding locally
-include Makefile.local
# NOTE minimal dune/opam files might be at /tmp/l/github/notes/minimal_ocaml_proj/
# allow overriding from main makefile
DUNE?=dune
# default: all
build::
$(DUNE) build @install
# note: add build:: to have more things built
install::
$(DUNE) install
uninstall::
$(DUNE) uninstall
clean::
$(DUNE) clean
all::
$(MAKE) Makefile.ocaml
$(MAKE) build
$(MAKE) install
$(MAKE) docs
clean_all::
$(MAKE) clean
$(MAKE) all
SRC:=_build/default/_doc/_html
DST:=docs
DST2:=$(TMP_DOC_DIR)
docs:: FORCE
$(DUNE) build @doc
@if [ ! -z "$$PROMOTE_DOCS" ]; then rm -rf $(DST)/* ; cp -R $(SRC)/* $(DST); echo "docs built and promoted to docs/"; else \
rsync -vaz $(SRC)/* $(DST2); echo "docs built in $(DST2) but not promoted to docs/"; fi
promote_docs:: FORCE
PROMOTE_DOCS=true $(MAKE) docs
view_doc:
google-chrome $(SRC)/index.html
Makefile.ocaml: FORCE
@if test -f $(scratch)/Makefile.ocaml; then diff ./Makefile.ocaml $(scratch)/Makefile.ocaml; fi
# FIXME update Makefile.ocaml itself, from scratch; error if
# different, forcing user to update manually
# https://www.gnu.org/software/make/manual/html_node/Overriding-Makefiles.html
FORCE: ;