Source

omy / OMyOPAM

GetOPAMVersion(opamname) =
    return $(shell opam list --installed | awk '$$1 ~ /^$(opamname)$$/ { print $$2 }')

OPAMPrefix = $(shell opam config var prefix)

# We cannot remove ocamlfind
CleanOPAMPackages() =
    installed=$(shell opam list --installed | awk '$$2 !~ /(base|system|package)/ && $$1 !~ /ocamlfind|omake/ { print $$1 }')
    if $(gt $(length $(installed)), 0):
        println(Uninstalling OPAM packages: $(string $(installed)))
        opam remove --yes $(installed)

GetOPAMBuildDir(opamname) =
    ver = $(GetOPAMVersion $(opamname))
    return "$(OPAMPrefix)$(DIRSEP)build$(DIRSEP)$(opamname).$(ver)"

# CR jfuruse: need to be unified
OMyOPAMNoSpotInstall(flname) =
    $(Installed $(flname)):
        section:
            opam install --yes --verbose $(flname)
            opambuilddir=$(GetOPAMBuildDir $(flname))
            CreateInstalled($(flname), $(find $(OCAMLFIND_DESTDIR)$(DIRSEP)$(flname) -f {}))

OMyOPAM(flname) =
    $(Installed $(flname)):
        section:
            opam install --yes --verbose $(flname)
            opambuilddir=$(GetOPAMBuildDir $(flname))
            println(Running spotinstall at $(opambuilddir))
            (cd $(opambuilddir); spotinstall $(flname))
            CreateInstalled($(flname), $(find $(OCAMLFIND_DESTDIR)$(DIRSEP)$(flname) -f {}))

OMyOPAM2(name, flname) =
    $(Installed $(flname)):
        section:
            opam install --yes --verbose $(name)
            opambuilddir=$(GetOPAMBuildDir $(name))
            println(Running spotinstall at $(opambuilddir))
            (cd $(opambuilddir); spotinstall $(flname))
            CreateInstalled($(flname), $(find $(OCAMLFIND_DESTDIR)$(DIRSEP)$(flname) -f {}))