Skip to content

Commit 16ab6b5

Browse files
committed
Add a Makefile to generate an ocamlfind toolchain configuration
1 parent 8d4aa9b commit 16ab6b5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Makefile.ocamlfindconf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generate an ocamlfind toolchain configuration
2+
3+
# This will drop the ocaml-, ocaml-cross- and cross- prefixes of the generated
4+
# file name, so that the opam install instructions can simply use the package
5+
# name (probably using such a prefix) to generate the toolchain configuration
6+
7+
%.conf:
8+
mkdir -p $(@D)
9+
$(MAKE) --no-print-directory --quiet -f Makefile.ocamlfindconf \
10+
print-$(patsubst cross-%,%,$(patsubst ocaml-%,%,$(*F))) \
11+
> $(@D)/$(patsubst cross-%,%,$(patsubst ocaml-%,%,$(@F)))
12+
13+
# To get $(prefix) and $(EXE)
14+
include Makefile.config
15+
16+
# Phony but generic rule, so without a `.PHONY` declaration
17+
# Fail if `prefix` is empty (but still display the content)
18+
print-%:
19+
@test -n "$(prefix:%=x)"
20+
$(info path($*) = "$(prefix)/lib/ocaml:$(prefix)/lib")
21+
$(info destdir($*) = "$(prefix)/lib")
22+
$(info stdlib($*) = "$(prefix)/lib/ocaml")
23+
$(info ocamlopt($*) = "$(prefix)/bin/ocamlopt.opt$(EXE)")
24+
$(info ocamlc($*) = "$(prefix)/bin/ocamlc.opt$(EXE)")
25+
$(info ocamlmklib($*) = "$(prefix)/bin/ocamlmklib$(EXE)")
26+
$(info ocamldep($*) = "$(prefix)/bin/ocamldep.opt$(EXE)")
27+
$(info ocamlcp($*) = "$(prefix)/bin/ocamlcp$(EXE)")
28+
$(info ldconf($*) = "$(prefix)/lib/ocaml/ld.conf")

0 commit comments

Comments
 (0)