forked from OCamlPro/ocp-indent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.simple
71 lines (52 loc) · 1.6 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
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- makefile -*-
GENERATED = src/indentVersion.ml src/compat.ml
NAME = 'ocp-indent'
VERSION != awk -F'[(,)]' '/AC_INIT/ { print $$3 }' configure.ac
BEST != if ocamlopt 2>/dev/null; then echo native; else echo byte; fi
OCAML_MAJOR != ocaml -vnum | sed 's/\..*//'
COMPAT_DIR = src/ocaml_$(OCAML_MAJOR)/
OCAMLBUILD = ocamlbuild -I src -use-ocamlfind
LIB = ocp-indent-lib
PKGS = cmdliner,findlib,dynlink
BINS = ocp-indent.byte
LIBS = $(LIB).cma
ifeq ($(BEST),native)
LIBS += $(LIB).cmxa $(LIB).a $(LIB).cmxs
BINS += ocp-indent.native
endif
.PHONY: all
all: $(LIBS) $(BINS) ocp-indent.1
.PHONY: man
man: ocp-indent.1
ocp-indent.1: ocp-indent.$(BEST)
./ocp-indent.$(BEST) --help=groff >$@
ocp-indent.byte:
$(OCAMLBUILD) indentMain.byte -pkgs $(PKGS)
ln -f _build/src/indentMain.byte $@
ocp-indent.native:
$(OCAMLBUILD) indentMain.native -pkgs $(PKGS)
ln -f _build/src/indentMain.native $@
src/compat.ml:
cp $(COMPAT_DIR)/compat.ml src/
src/indentVersion.ml:
echo 'let version = "'$(VERSION)'"' > $@
src/approx_common.ml: src/approx_common.mli
cp $< $@
$(LIB).cma $(LIB).cmxa $(LIB).a $(LIB).cmxs: $(GENERATED)
$(OCAMLBUILD) -use-ocamlfind $@
.PHONY: clean
clean:
rm -rf $(GENERATED) META _build
rm -rf $(BINS) ocp-indent.1
META:
mkdir -p _build/src
echo 'name = "'$(NAME)'"' >$@
echo 'version = "'$(VERSION)'"' >> $@
echo 'archive(byte) = "'$(LIB)'.cma"' >> $@
echo 'archive(native) = "'$(LIB)'.cmxa"' >> $@
.PHONY: install
install: META $(LIBS) $(BINS)
ocamlfind remove $(NAME) || true
ocamlfind install $(NAME) \
$(LIBS:%=_build/src/%) $(BINS) META \
_build/src/*.{mli,cmi,cmt,cmti,annot}