1. camlspotter
  2. omy

Commits

camlspotter  committed ca11a20

OMyLibrary also has installation by ocamlfind

  • Participants
  • Parent commits 8552c8d
  • Branches default

Comments (0)

Files changed (1)

File OMyMakefile

View file
   OCamlRequireCamlP4Packages($(OCAMLPACKS) $(CAMLP4PACKS))
   export
 
-#|If NO_INSTALL is true, it surpresses the installation of package/library/executables defined MyOCamlXXX by omake install
-NO_INSTALL=false
-
 #| Add a rule for OCaml package $(library_name).cmo, $(library_name).cmx and etc.
 #     library_name
 #         target package name
 
   targets[]+= $(library_name).cmt
 
-  if $(not $(NO_INSTALL))
+  if $(not $(defined NO_INSTALL))
     if $(defined INSTALLED)
       $(Installed $(library_name)): $(targets)
         $(OCAMLFIND) remove $(library_name)
   MyOCamlTestProgram($(name), $(files))
   export # The above thing is local: need to be exported
 
-  if $(not $(NO_INSTALL))
+  if $(not $(defined NO_INSTALL))
     install: $(name) $(name).run $(name).opt
       install $(name) $(name).run $(name).opt $(PREFIX)/bin
     uninstall:
   AutoClean()
   export # The above thing is local: need to be exported
 
-  if $(not $(NO_INSTALL))
+  if $(not $(defined NO_INSTALL))
     install: $(name) $(name).run
       install $(name) $(name).run $(PREFIX)/bin
     uninstall:
 #            OCaml module name (without .ml)
 #
 #   .. note :: Probably you should use MyOCamlPackage
-MyOCamlLibrary(name, files) =
+MyOCamlLibrary(library_name, files) =
   AddLocalOCamlPackageDependencies()
-  OCamlLibrary($(name), $(files))
+  targets = $(OCamlLibrary $(library_name), $(files))
+
+  .DEFAULT: $(targets)
+
   export # The above thing is local: need to be exported
 
+  if $(not $(defined NO_INSTALL))
+    targets[] += META 
+    if $(defined INSTALLED)
+      $(Installed $(library_name)): $(targets)
+        $(OCAMLFIND) remove $(library_name)
+        section:
+              $(OCAMLFIND) install $(library_name) $(targets)
+              CreateInstalled($(library_name), $(targets))
+
+      install: $(Installed $(library_name))
+
+      uninstall:
+        rm -f $(Installed $(library_name))
+        $(OCAMLFIND) remove $(library_name)
+      export
+    else
+      install: $(targets)
+        $(OCAMLFIND) remove $(library_name)
+        $(OCAMLFIND) install $(library_name) $(targets)
+
+      uninstall:
+	$(OCAMLFIND) remove $(library_name)
+      export
+    export
+
   # The following clean the files twice if MyOCamlPacakge coexists,
   # but who cases ?
   AutoClean()