camlspotter avatar camlspotter committed a9ae2b5

auto update of OMyMakefile

Comments (0)

Files changed (1)

 
 #|Set NATIVE_ENABLED false locally if a project does not requre opt compilation.
 NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
+NATIVE_SHARED_ENABLED = $(OCAMLOPT_EXISTS)
 BYTE_ENABLED = true
 
 #|The default warning and errors. If you want to use different warning and error switches, use redefine the variable.
 # ==========================================================
 
 # Extend the bundled OCamlPackage with .spot creation
+public.OCamlLibrary(name, files) =
+   # XXX: JYH: these variables should be marked private in 0.9.9
+   protected.name = $(file $(name))
+
+   protected.OFILES   = $(addsuffix $(EXT_OBJ), $(files))
+   protected.CMOFILES = $(addsuffix .cmo, $(files))
+   protected.CMXFILES = $(addsuffix .cmx, $(files))
+
+   protected.CLIB      = $(file $(name)$(EXT_LIB))
+   protected.BYTELIB   = $(file $(name).cma)
+   protected.NATIVELIB = $(file $(name).cmxa)
+   protected.NATIVESHAREDLIB = $(file $(name).cmxs)
+
+   #
+   # Link commands
+   #
+   $(BYTELIB): $(CMOFILES)
+        $(OCAMLFIND) $(OCAMLLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) $(OCAMLCFLAGS) \
+                $(OCAML_LIB_FLAGS) -a -o $@ $(OCamlLinkSort $(CMOFILES))
+
+   $(NATIVELIB) $(CLIB): $(CMXFILES) $(OFILES)
+        $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \
+                $(OCAML_LIB_FLAGS) -a -o $(NATIVELIB) $(OCamlLinkSort $(CMXFILES))
+
+   $(NATIVESHAREDLIB) $(CLIB): $(CMXFILES) $(OFILES)
+         $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \
+                 $(OCAML_LIB_FLAGS) -shared -o $(NATIVESHAREDLIB) $(OCamlLinkSort $(CMXFILES))
+
+   return $(array $(if $(NATIVE_ENABLED), $(NATIVELIB)), \
+                  $(if $(NATIVE_ENABLED), $(CLIB)), \
+                  $(if $(NATIVE_SHARED_ENABLED), $(NATIVESHAREDLIB)), \
+                  $(if $(BYTE_ENABLED), $(BYTELIB)))
+
+# Extend the bundled OCamlPackage with .spot creation
 public.OCamlPackage(name, files) =
    # XXX: JYH: these variables should be marked private in 0.9.9
    protected.OFILES   = $(addsuffix $(EXT_OBJ), $(files))
   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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.