forked from OCamlPro/ocp-index
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.simple
58 lines (44 loc) · 1.35 KB
/
Makefile.simple
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
# -*- makefile -*-
LIB = ocp-index-lib
VERSION := $(shell awk -F'[(,)]' '/AC_INIT/ { print $$3 }' configure.ac)
OCAMLBUILD = ocamlbuild -pkg compiler-libs.common -pkg ocp-indent-lib -use-ocamlfind
UNAME := $(shell uname)
ifeq (WIN,$(findstring WIN,$(UNAME)))
EXEEXT := .exe
else
EXEEXT :=
endif
all: $(LIB).cma $(LIB).cmxa
ALWAYS:
%.cma: ALWAYS $(GENERATED)
$(OCAMLBUILD) src/$@
%.cmxa: ALWAYS $(GENERATED)
$(OCAMLBUILD) src/$@
HAS_CMDLINER := \
$(shell ocamlfind query cmdliner >/dev/null 2>&1 \
&& echo yes || echo no)
CMDLINER_DEP = $(if $(HAS_CMDLINER) = no,-I cmdliner,-pkg cmdliner)
.PHONY:cmdliner-dep
cmdliner-dep:
if [ "$(HAS_CMDLINER)" = "no" ]; then \
cp -rf ../cmdliner/src cmdliner; \
fi
ocp-index$(EXEEXT): ALWAYS cmdliner-dep
$(OCAMLBUILD) -pkg unix $(CMDLINER_DEP) -I src src/indexMain.native
cp _build/src/indexMain.native $@
.PHONY: clean
clean:
rm -rf META _build
_build/src/META:
mkdir -p _build/src
echo 'version = "'$(VERSION)'"' > $@
echo 'archive(byte) = "'$(LIB)'.cma"' >> $@
echo 'archive(native) = "'$(LIB)'.cmxa"' >> $@
echo 'requires = "compiler-libs compiler-libs.common"' >> $@
INTERFACES = libIndex indexScope
.PHONY: install
install: _build/src/META $(LIB).cma $(LIB).cmxa
ocamlfind remove ${LIB} || true
cd _build/src && ocamlfind install $(LIB) META \
$(INTERFACES:=.cmi) \
$(LIB).cma $(LIB).cmxa $(LIB).a