Source

omy / OMyOPAM

Full commit
OCAMLFIND_DESTDIR=$(HOME)/.opam/system/lib

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 --yes remove $(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 --yes --verbose install $(flname)
            opambuilddir=$(GetOPAMBuildDir $(flname))
            CreateInstalled($(flname), $(find $(OCAMLFIND_DESTDIR)$(DIRSEP)$(flname) -f {}))

OMyOPAM(flname) =
    $(Installed $(flname)):
        section:
            opam --yes --verbose install $(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 --yes --verbose install $(name)
            opambuilddir=$(GetOPAMBuildDir $(name))
            println(Running spotinstall at $(opambuilddir))
            (cd $(opambuilddir); spotinstall $(flname))
            CreateInstalled($(flname), $(find $(OCAMLFIND_DESTDIR)$(DIRSEP)$(flname) -f {}))