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 130 131 132 133 134 135 136
|
# 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
BINDIR=$(DESTDIR)$(PREFIX)/bin
LIBDIR=$(DESTDIR)$(PREFIX)/lib/ocaml/cmdliner
SHAREDIR=$(DESTDIR)$(PREFIX)/share
DOCDIR=$(SHAREDIR)/doc/cmdliner
MANDIR=$(SHAREDIR)/man
BASHCOMPDIR=$(SHAREDIR)/bash-completion/completions
ZSHCOMPDIR=$(SHAREDIR)/zsh/site-functions
PWSHCOMPDIR=$(SHAREDIR)/powershell
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)/src/cmdliner
TOOLBDIR=$(B)/src/tool
TOOL=$(TOOLBDIR)/cmdliner
ifeq ($(NATIVE),true)
BUILD-EXE=build-native-exe
BUILD-TARGETS=build-byte build-native build-native-exe build-completions \
build-man
INSTALL-TARGETS=install-common install-srcs install-byte install-native \
install-exe install-completions
ifeq ($(NATDYNLINK),true)
BUILD-TARGETS += build-native-dynlink
INSTALL-TARGETS += install-native-dynlink
endif
else
BUILD-EXE=build-byte-exe
BUILD-TARGETS=build-byte build-byte-exe build-completions \
build-man
INSTALL-TARGETS=install-common install-srcs install-byte install-exe \
install-completions
endif
all: $(BUILD-TARGETS)
install: $(INSTALL-TARGETS)
clean:
ocaml build.ml clean
build-byte:
ocaml build.ml cma
build-native:
ocaml build.ml cmxa
build-native-dynlink:
ocaml build.ml cmxs
build-byte-exe: build-byte
ocaml build.ml bytexe
build-native-exe: build-native
ocaml build.ml natexe
build-completions: $(BUILD-EXE)
$(TOOL) generic-completion bash > $(TOOLBDIR)/bash-completion.sh
$(TOOL) tool-completion bash cmdliner > $(TOOLBDIR)/bash-cmdliner.sh
$(TOOL) generic-completion zsh > $(TOOLBDIR)/zsh-completion.sh
$(TOOL) tool-completion zsh cmdliner > $(TOOLBDIR)/zsh-cmdliner.sh
$(TOOL) generic-completion pwsh > $(TOOLBDIR)/pwsh-completion.ps1
$(TOOL) tool-completion pwsh cmdliner > $(TOOLBDIR)/pwsh-cmdliner.ps1
build-man: $(BUILD-EXE)
$(TOOL) install tool-manpages $(TOOLBDIR)/cmdliner $(TOOLBDIR)/man
prepare-prefix:
$(INSTALL) -d "$(BINDIR)" "$(LIBDIR)"
install-common: prepare-prefix
$(INSTALL) -m 644 pkg/META $(BASE).cmi "$(LIBDIR)"
$(INSTALL) -m 644 cmdliner.opam "$(LIBDIR)/opam"
install-srcs: prepare-prefix
$(INSTALL) -m 644 $(wildcard $(BASE)*.mli) $(wildcard $(BASE)*.ml) \
$(wildcard $(BASE)*.cmti) $(wildcard $(BASE)*.cmt) "$(LIBDIR)"
install-byte: prepare-prefix
$(INSTALL) -m 644 $(BASE).cma "$(LIBDIR)"
install-native: prepare-prefix
$(INSTALL) -m 644 $(BASE).cmxa $(BASE)$(EXT_LIB) $(wildcard $(BASE)*.cmx) \
"$(LIBDIR)"
install-native-dynlink: prepare-prefix
$(INSTALL) -m 644 $(BASE).cmxs "$(LIBDIR)"
install-exe:
$(INSTALL) -m 755 "$(TOOLBDIR)/cmdliner" "$(BINDIR)/cmdliner"
install-doc:
$(INSTALL) -d "$(MANDIR)/man1"
$(INSTALL) -m 644 $(wildcard $(TOOLBDIR)/man/man1/*.1) "$(MANDIR)/man1"
$(INSTALL) -d "$(DOCDIR)/odoc-pages"
$(INSTALL) -m 644 CHANGES.md LICENSE.md README.md "$(DOCDIR)"
$(INSTALL) -m 644 doc/index.mld doc/cli.mld doc/examples.mld \
doc/tutorial.mld doc/cookbook.mld doc/tool_man.mld "$(DOCDIR)/odoc-pages"
install-completions:
$(INSTALL) -d "$(BASHCOMPDIR)"
$(INSTALL) -m 644 $(TOOLBDIR)/bash-completion.sh \
"$(BASHCOMPDIR)/_cmdliner_generic"
$(INSTALL) -m 644 $(TOOLBDIR)/bash-cmdliner.sh "$(BASHCOMPDIR)/cmdliner"
$(INSTALL) -d "$(ZSHCOMPDIR)"
$(INSTALL) -m 644 $(TOOLBDIR)/zsh-completion.sh \
"$(ZSHCOMPDIR)/_cmdliner_generic"
$(INSTALL) -m 644 $(TOOLBDIR)/zsh-cmdliner.sh "$(ZSHCOMPDIR)/_cmdliner"
$(INSTALL) -d "$(PWSHCOMPDIR)"
$(INSTALL) -m 644 $(TOOLBDIR)/pwsh-completion.ps1 \
"$(PWSHCOMPDIR)/cmdliner_generic_completion.ps1"
$(INSTALL) -m 644 $(TOOLBDIR)/pwsh-cmdliner.ps1 \
"$(PWSHCOMPDIR)/cmdliner_completion.ps1"
.PHONY: all install install-doc clean build-byte build-native \
build-native-dynlink build-byte-exe build-native-exe build-completions \
prepare-prefix install-common install-byte install-native install-dynlink \
install-exe install-completions build-man
|