summaryrefslogtreecommitdiff
path: root/Makefile
blob: a3921d7ac09a40a87057e4a103b71d2e8e39d310 (plain)
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
# To be used by system package managers to bootstrap opam. topkg
# cannot be used as it needs opam-installer which is provided by opam
# itself.

# Typical usage:
#
# make all
# make install PREFIX=/usr/local
# make install-doc PREFIX=/usr/local

# Adjust the following on the cli invocation for configuring

-include $(shell ocamlc -where)/Makefile.config

PREFIX=/usr
LIBDIR=$(DESTDIR)$(PREFIX)/lib/ocaml/cmdliner
DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/cmdliner
NATIVE=$(shell ocamlopt -version > /dev/null 2>&1 && echo true)
# EXT_LIB     by default value of OCaml's Makefile.config
# NATDYNLINK  by default value of OCaml's Makefile.config

INSTALL=install
B=_build
BASE=$(B)/cmdliner

ifeq ($(NATIVE),true)
	BUILD-TARGETS=build-byte build-native
	INSTALL-TARGETS=install-common install-byte install-native
	ifeq ($(NATDYNLINK),true)
	  BUILD-TARGETS += build-native-dynlink
	  INSTALL-TARGETS += install-native-dynlink
	endif
else
	BUILD-TARGETS=build-byte
	INSTALL-TARGETS=install-common install-byte
endif

all: $(BUILD-TARGETS)

install: $(INSTALL-TARGETS)

install-doc:
	$(INSTALL) -d "$(DOCDIR)/odoc-pages"
	$(INSTALL) CHANGES.md LICENSE.md README.md "$(DOCDIR)"
	$(INSTALL) doc/index.mld doc/cli.mld doc/examples.mld doc/tutorial.mld \
	           doc/tool_man.mld "$(DOCDIR)/odoc-pages"

clean:
	ocaml build.ml clean

build-byte:
	ocaml build.ml cma

build-native:
	ocaml build.ml cmxa

build-native-dynlink:
	ocaml build.ml cmxs

create-libdir:
	$(INSTALL) -d "$(LIBDIR)"

install-common: create-libdir
	$(INSTALL) pkg/META $(BASE).mli $(BASE).cmi $(BASE).cmti "$(LIBDIR)"
	$(INSTALL) cmdliner.opam "$(LIBDIR)/opam"

install-byte: create-libdir
	$(INSTALL) $(BASE).cma "$(LIBDIR)"

install-native: create-libdir
	$(INSTALL) $(BASE).cmxa $(BASE)$(EXT_LIB) $(wildcard $(B)/cmdliner*.cmx) \
  "$(LIBDIR)"

install-native-dynlink: create-libdir
	$(INSTALL) $(BASE).cmxs "$(LIBDIR)"

.PHONY: all install install-doc clean build-byte build-native \
	build-native-dynlink create-libdir install-common install-byte \
  install-native install-dynlink