forked from ocaml-batteries-team/batteries-included
/
Makefile
130 lines (102 loc) · 3.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# A basic Makefile for building and installing Batteries Included
# It punts to ocamlbuild for all the heavy lifting.
NAME = batteries
# This is also defined in the VERSION file
VERSION := $(shell cat VERSION)
# Define variables and export them for mkconf.ml
DOCROOT ?= /usr/share/doc/ocaml-batteries
export DOCROOT
BROWSER_COMMAND ?= x-www-browser %s
export BROWSER_COMMAND
ifdef DESTDIR
OCAMLFIND_DEST += -destdir $(DESTDIR)
endif
OCAMLBUILD ?= ocamlbuild
BATTERIES_NATIVE ?= yes
BATTERIES_NATIVE_SHLIB ?= yes
INSTALL_FILES = _build/META _build/src/*.cma \
battop.ml _build/src/*.cmi _build/src/*.mli \
_build/src/batteries_help.cmo \
_build/src/syntax/pa_comprehension/pa_comprehension.cmo \
_build/src/syntax/pa_strings/pa_strings.cma
NATIVE_INSTALL_FILES = _build/src/*.cmx _build/src/*.a _build/src/*.cmxa
# What to build
TARGETS = syntax.otarget byte.otarget src/batteries_help.cmo META
TEST_TARGETS = testsuite/main.byte
ifeq ($(BATTERIES_NATIVE_SHLIB), yes)
TARGETS += shared.otarget
TEST_TARGETS += testsuite/main.native
INSTALL_FILES += $(NATIVE_INSTALL_FILES) _build/src/*.cmxs
else ifeq ($(BATTERIES_NATIVE), yes)
TARGETS += native.otarget
TEST_TARGETS += testsuite/main.native
INSTALL_FILES += $(NATIVE_INSTALL_FILES)
endif
.PHONY: all clean doc install uninstall reinstall test fix_camomile camomile82 camomile81 camomile7 camfail
all: fix-camomile
test ! -e src/batteries_config.ml || rm src/batteries_config.ml
$(OCAMLBUILD) $(TARGETS)
clean:
rm -f apidocs
$(OCAMLBUILD) -clean
doc:
$(OCAMLBUILD) batteries.docdir/index.html
test -e apidocs || ln -s _build/batteries.docdir apidocs
install: all
ocamlfind install $(OCAMLFIND_DEST) estring \
libs/estring/META \
_build/libs/estring/*.cmo \
_build/libs/estring/*.cmi \
_build/libs/estring/*.mli
ocamlfind install $(OCAMLFIND_DEST) $(NAME) $(INSTALL_FILES)
uninstall:
ocamlfind remove $(OCAMLFIND_DEST) estring
ocamlfind remove $(OCAMLFIND_DEST) $(NAME)
rm -rf $(DOCROOT)
install-doc: doc
mkdir -p $(DOCROOT)
cp -r doc/batteries/* $(DOCROOT)
# deal with symlink that will break
rm -f $(DOCROOT)/html/batteries_large.png
cp -f doc/batteries_large.png $(DOCROOT)/html
mkdir -p $(DOCROOT)/html/api
cp apidocs/* $(DOCROOT)/html/api
cp LICENSE README FAQ VERSION $(DOCROOT)
reinstall:
$(MAKE) uninstall
$(MAKE) install
test:
$(OCAMLBUILD) $(TARGETS) $(TEST_TARGETS)
$(foreach TEST, $(TEST_TARGETS), _build/$(TEST); )
release: test
git archive --format=tar --prefix=batteries-$(VERSION)/ HEAD \
| gzip > batteries-$(VERSION).tar.gz
##
## Magic to detect which version of camomile is installed
##
CAMVER=$(shell sh -c 'ocamlfind list | grep camomile | grep -o "[0-9\.]*"')
ifeq ($(CAMVER),0.8.2)
CAMFIX=camomile82
endif
ifeq ($(CAMVER),0.8.1)
CAMFIX=camomile81
endif
ifeq ($(CAMVER),0.7.2)
CAMFIX=camomile7
endif
ifeq ($(CAMVER),)
CAMFIX=camfail
endif
fix-camomile: $(CAMFIX)
#replace batcamomile with a version appropriate for camomile 0.8.2
camomile82:
cp -f src/batCamomile-0.8.2.ml src/batCamomile.ml
#replace batcamomile with a version appropriate for camomile 0.8.1
camomile81:
cp -f src/batCamomile-0.8.1.ml src/batCamomile.ml
#replace batcamomile with a version appropriate for camomile 0.7.*
camomile7:
cp -f src/batCamomile-0.7.ml src/batCamomile.ml
camfail:
echo "Camomile not detected, cannot compile batteries"
exit 1