1. camlspotter
  2. spotlib

Commits

camlspotter  committed b4555aa

omymakefile update

  • Participants
  • Parent commits 809f23b
  • Branches default

Comments (0)

Files changed (1)

File OMyMakefile

View file
  • Ignore whitespace
 BIG_ROOT=$(dir .)
 
 #| The prefix. Equal to the PREFIX environment variable
-PREFIX=$(getenv PREFIX)
+try
+  PREFIX=$(getenv PREFIX)
+default
+  eprintln(Specify PREFIX environment variable.)
+  exit 1 
 
 # Installation mark files
 # =======================================================================
   else
       return $(array)
 
+#|Create md5 sum file of $(targets)
+CreateCheckSum(pack, targets)=
+    chan=$(fopen $(pack), w)
+    fprintln($(chan), $(string $(targets)))
+    fprintln($(chan), $(string $(digest $(targets))))
+    close($(chan))
+
 #|Create $(Installed $(pack)) file from the digests of $(targets)
 CreateInstalled(pack, targets)=
     if $(defined INSTALLED)
         println(dump md5 $(INSTALLED)/$(pack))
-        chan=$(fopen $(INSTALLED)/$(pack), w)
-        fprintln($(chan), $(string $(targets)))	
-        fprintln($(chan), $(string $(digest $(targets))))
-        close($(chan))
+        CreateCheckSum($(pack), $(targets))
 
 # Misc tools
 # ======================================================================
 OMyManagedPackages(packages) =
    return $(set-diff $(packages), $(OCAML_PREINSTALLED_PACKS))
 
+#|Add dependencies of any build activity of this directory over $(files).
+#
+# .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
+RequireFiles(files) =
+    .SCANNER: scan-%: $(files)
+    % : $(files)
+    export
+
 #|Add dependencies of any build activity over $(packages).
 #
 # .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
 RequirePackages(packages) =
-    required_packs = $(OMyManagedPackages $(packages))
-    .SCANNER: scan-%: $(Installed $(required_packs))
-    % : $(Installed $(required_packs))
+    RequireFiles($(OMyManagedPackages $(packages)))
+    export
+
+#|Add dependencies of any build activity of this directory over $(targets) and their dependencies
+# Creates an intermidiate md5 memo dependencies.md5
+#
+# .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
+RequireBuild(targets) =
+    dependencies.md5: $(targets)
+        CreateCheckSum($@, $(sequence-sort $(compare), $(dependencies-all $(targets))))
+    RequireFiles(dependencies.md5)
     export
 
 #|Add dependencies of OCaml compiled files (cmx, cmo, etc.) over $(packages).
 
   ## build rule
 
-  # CR jfuruse: forgot to add the deps over the packages!
   OCamlPackage($(library_name), $(files))
 
   ## clean
-
+  AutoClean()
   clean:
 	rm -f $(library_name).spot
-	rm -f $(filter-proper-targets $(ls R, .))
 
   ## 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).spot
 
 
 
   # The following clean the files twice if MyOCamlPackge coexists,
   # but who cases ?
-  clean:
-    rm -f $(filter-proper-targets $(ls R, .))
+  AutoClean()
 
 #|  Add rules to build OCaml library $(name)
 #        name
 
   # The following clean the files twice if MyOCamlPacakge coexists,
   # but who cases ?
-  clean:
-    rm -f $(filter-proper-targets $(ls R, .))
+  AutoClean()
+
+# Auto clean
+# ====================================================================
+
+#| Install clean command which cleans all the target files exists under the directory. Use with care.
+AutoClean()=
+    .PHONY: clean
+    clean:
+        rm -f $(filter-proper-targets $(ls R, .))
 
 # Subdir traversal
 # =====================================================================