Commits

camlspotter committed c6c9089

updated OMyMakefile

Comments (0)

Files changed (1)

     mkdir $(dir) 
   return
 
+# OCaml -where
+# ========================================================================
+
+#|Path to the OCaml library directory
+OCAML_WHERE = $(shell ocamlc -where)
+
 # OCamlFind
 # ========================================================================
 
 USE_OCAMLFIND = true
 OCAMLFIND_DESTDIR= $(shell ocamlfind printconf destdir)
 
-# OCaml -where
-# ========================================================================
-
-#|Path to the OCaml library directory
-OCAML_WHERE = $(shell ocamlc -where)
-
 #|Preinstalled libraries which are always available for normal ocaml.
 #
 # You may want to add the required packages which are built and installed out of OMy framework:
 BYTE_ENABLED = true
 
 ######################### Compiler
+
+OCAMLFLAGS = -w A-4-9 -warn-error A-4-9
+
 OCAMLPACKAGEFLAGS=
 
 # Why we need "public." ?
 #
 # .. note:: Usually you do not need to call this function. Use OCAMLPACKS variable instead. 
 OCamlRequirePackages(packages) =
-    packages += findlib # Yes we use findlib
     required_packs = $(OMyManagedPackages $(packages))
     if $(defined INSTALLED)
       %.cmx %.cmo %.cmi %.cma %.cmxa %.annot %.spot %.spit : $(Installed $(required_packs))
 #
 # .. note:: Usually you do not need to call this function. Use CAML4PACKS variable instead. 
 OCamlRequireCamlP4Packages(packages) =
-    packages += findlib # Yes we use findlib
     required_packs = $(OMyManagedPackages $(packages))
     if $(defined INSTALLED)
       .SCANNER: scan-ocaml-%: $(Installed $(required_packs))
 #     linkopts
 #         C library link option (without OCaml -cclib options)    
 #
+#  You can specify MyOCamlPackageExtras before using this function to install files out of the scope of this rule.   
+#
 #  Example::
 #
 #      MyOCamlPackage(foo, alpha beta, $(EMPTY), $(EMPTY))
   CMA=$(library_name).cma
   CMXA=$(library_name).cmxa
 
+  if $(not $(defined MyOCamlPackageExtras))
+      MyOCamlPackageExtras[]=
+      export
+
   CSTUBLIBRARIES=
   if $(not $(equal $(cmodules), $(EMPTY)))
       CSTUBLIBRARIES= dll$(library_name).so lib$(library_name).a 
   # CR jfuruse: I guess we do not need the following
   # export # export the implicit rule above
 
-  .DEFAULT: $(library_name).cmo $(library_name).cmx $(library_name).cma $(library_name).cmxa
+  .DEFAULT: $(library_name).cmo $(library_name).cmx $(library_name).cma $(library_name).cmxa $(MyOCamlPackageExtras)
 
   $(CMA) $(CMXA) $(library_name).a $(CSTUBLIBRARIES) : $(CSTUBS) $(CMOS) $(CMXS)
-      ocamlmklib -verbose -o $(library_name) $(CSTUBS) $(linkopts) $(CMOS) $(CMXS)
+      if $(not $(equal $(cmodules), $(EMPTY)))
+          ocamlmklib -verbose -o $(library_name) $(CSTUBS) $(linkopts) $(CMOS) $(CMXS)
+      else
+          $(OCamlC) -a -o $(CMA) $(CMOS)
+          $(OCamlOpt) -a -o $(CMXA) $(CMXS)
 
   ## the followings are necessary for packing
 
   ## install
 
   # CR jfuruse: x.cmi is required if x.mli does not exist!
-  targets[]=META $(glob i, *.mli) $(library_name).cmi $(library_name).cmo $(library_name).cmx $(library_name).cma $(library_name).cmxa $(library_name).o $(library_name).a $(CSTUBLIBRARIES)
+  targets[]=META $(glob i, *.mli) $(library_name).cmi $(library_name).cmo $(library_name).cmx $(library_name).cma $(library_name).cmxa $(library_name).o $(library_name).a $(CSTUBLIBRARIES) $(MyOCamlPackageExtras)
 
   if $(OCAML_SPOT)
     targets[]+= $(library_name).spot
 	    $(OCAMLFIND) ocamldoc -I +threads $(OCAMLPACKAGEFLAGS) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLPPFLAGS) $(PREFIXED_OCAMLINCLUDES) -dot -dot-include-all -dot-reduce $+ -o $@
 
 
+#| filter list
+#  example::
+#     is_url(file) =
+#       match $(file)
+#       case $'://'
+#         return true
+#       default
+#         return false
+# 
+#     DOWNLOAD_URLS[]=$(list_filter $(fun x, $(is_url $(x))), $(URLS))
+list_filter(pred, list) =
+  result=
+  foreach(x, $(list))
+    if $(apply $(pred), $(x))
+      result+=$(x)
+      export
+    export
+  return $(result)
+
+#| Obtain files installed as PACK
+GET_OCAMLFIND_OBJS(pack)=
+    return $(Files $(OCAMLFIND_DESTDIR)/$(pack))