Commits

camlspotter committed 55a1ed6

build fix

Comments (0)

Files changed (5)

 #| A flag to tell that we can use OMyMakefile functions
 WithOMy=true
 
+# OCaml 
+# ========================================================================
+
+#|Path to the OCaml library directory
+OCAML_WHERE = $(shell ocamlc -where)
+
+#|Version without extensions
+OCAML_VERSION = $(shell ocamlc -version | sed -e 's/^\([0-9.]*\).*/\1/')
+
+#|OMy requires OCamlFind!
+USE_OCAMLFIND = true
+OCAMLFIND_DESTDIR= $(shell ocamlfind printconf destdir)
+
+#|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.
+OCAMLFLAGS = -w A-4-9 -warn-error A-4-9
+
+#|Global variable to be defined as empty
+OCAMLPACKAGEFLAGS=
+
+#|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:
+#
+#::
+#
+#   include OMyMakefile
+#   
+#   OCAML_PREINSTALLED_PACKS += llvm # llvm has been installed already, independently
+#   
+#   Subdirs()
+#
+# It includes "findlib" by default. If you want to build findlib in OMy framework, you have to remove it from the list.
+OCAML_PREINSTALLED_PACKS[]= bigarray camlp4 dbm dynlink graphics num num-top stdlib str threads unix findlib compiler-libs compiler-libs.common
+
+#|Redefinition of compiler commands
+public.OCamlC() =
+    value $(OCAMLFIND) $(OCAMLC) $(OCAMLPACKAGEFLAGS) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS)\
+              $(OCAMLCFLAGS) $(OCAMLPPFLAGS) $(PREFIXED_OCAMLINCLUDES)
+# Why we need "public." ?
+
+public.OCamlOpt() =
+    value $(OCAMLFIND) $(OCAMLOPT) $(OCAMLPACKAGEFLAGS) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS)\
+              $(OCAMLOPTFLAGS) $(OCAMLPPFLAGS) $(PREFIXED_OCAMLINCLUDES)
+
+if $(and $(not $(NATIVE_ENABLED)) $(not $(BYTE_ENABLED)))
+   err. =
+       extends $(UnbuildableException)
+       message = $(string $"You must turn on either NATIVE_ENABLED or BYTE_ENABLED")
+       raise $(err)
+
+#|Additional implicit rules by file extensions
+# annot, cmt, cmti files
+%.annot %.cmt: %.ml %.cmi
+	$(OCamlC) -c -annot -bin-annot $<
+
+%.spit %.cmti: %.mli 
+	$(OCamlC) -c -bin-annot $<
+
+#|Define OCAML_ANNOT so that ocamlc/ocamlopt automatically create spot/spit/annot/cmt/cmti files, even without -annot/-bin-annot option. This requires a special compiler patch 
+setenv(OCAML_ANNOT, 1)
+
+#|Enable the backtrace
+setenv(OCAMLRUNPARAM, b)
+
+# Common phonies
+# ==================================================================
 .PHONY: all install uninstall clean
 
 # Directories
         println(dump md5 $(INSTALLED)/$(pack))
         CreateCheckSum($(INSTALLED)/$(pack), $(targets))
 
-# OCaml -where
-# ========================================================================
-
-#|Path to the OCaml library directory
-OCAML_WHERE = $(shell ocamlc -where)
-
-# OCamlFind
-# ========================================================================
-
-#|OMy requires OCamlFind! Do not ask me how to use OMy without OCamlFind. Please.
-USE_OCAMLFIND = true
-OCAMLFIND_DESTDIR= $(shell ocamlfind printconf destdir)
-
-#|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:
-#
-#::
-#
-#   include OMyMakefile
-#   
-#   OCAML_PREINSTALLED_PACKS += llvm # llvm has been installed already, independently
-#   
-#   Subdirs()
-#
-# It includes "findlib" by default. If you want to build findlib in OMy framework, you have to remove it from the list.
-OCAML_PREINSTALLED_PACKS[]= bigarray camlp4 dbm dynlink graphics num num-top stdlib str threads unix findlib compiler-libs compiler-libs.common
-
-#|If set false in a project directory, native/byte compilation is disabled locally.
-NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
-BYTE_ENABLED = true
-
-######################### Compiler
-
-#|Never use OCAMLFLAGS += ... to override this default. Redefine as OCAMLFLAGS = ...
-OCAMLFLAGS = -w A-4-9 -warn-error A-4-9
-
-OCAMLPACKAGEFLAGS=
-
-# Why we need "public." ?
-public.OCamlC() =
-    value $(OCAMLFIND) $(OCAMLC) $(OCAMLPACKAGEFLAGS) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS)\
-              $(OCAMLCFLAGS) $(OCAMLPPFLAGS) $(PREFIXED_OCAMLINCLUDES)
-
-public.OCamlOpt() =
-    value $(OCAMLFIND) $(OCAMLOPT) $(OCAMLPACKAGEFLAGS) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS)\
-              $(OCAMLOPTFLAGS) $(OCAMLPPFLAGS) $(PREFIXED_OCAMLINCLUDES)
-
-#| Define OCAML_ANNOT so that custom ocamlc/ocamlopt automatically create spot/spit/annot/cmt/cmti files, even without -annot/-bin-annot option. This requires a special compiler patch 
-setenv(OCAML_ANNOT, 1)
-setenv(OCAMLRUNPARAM, b)
-
-# Additional implicit rules by file extensions
-
-# annot, spot, spit files
-%.annot %.spot %.cmt: %.ml %.cmi
-	$(OCamlC) -c $<
-
-%.spit %.cmti: %.mli 
-	$(OCamlC) -c $<
-
 # Packages
 # =========================================================
 
 # ==========================================================
 
 # 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): $(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))
              export
          $(BYTE_TARGETS): $(BYTE_DEPS)
             $(OCAMLFIND) $(OCAMLC) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
-                $(OCAMLCFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMO) $(OCamlLinkSort $(CMOFILES))
+                $(OCAMLCFLAGS) $(OCAML_LIB_FLAGS) -pack -bin-annot -o $(CMO) $(OCamlLinkSort $(CMOFILES))
 
    protected.NATIVE_DEPS = $(CMXFILES) $(OFILES)
    $(NATIVE_TARGETS): $(NATIVE_DEPS)
             export
          $(NATIVE_TARGETS): $(NATIVE_DEPS)
             $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
-                $(OCAMLOPTFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMX) $(OCamlLinkSort $(CMXFILES))
+                $(OCAMLOPTFLAGS) $(OCAML_LIB_FLAGS) -pack -bin-annot -o $(CMX) $(OCamlLinkSort $(CMXFILES))
 
    $(CMI):
       section rule
 #         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.   
+#  
+#  If $(NO_INSTALL) is defined, omake install does not install the package
 #
 #  Example::
 #
   ## the followings are necessary for packing
 
   OCAMLPACKAGEFLAGS += -for-pack $(capitalize $(library_name))
-  export OCAMLPACKAGEFLAGS
+  # export OCAMLPACKAGEFLAGS
 
   ## build rule
 
 
   targets[]+= $(library_name).cmt
 
-  if $(defined INSTALLED)
-    $(Installed $(library_name)): $(targets)
-	$(OCAMLFIND) remove $(library_name)
-	section:
-            $(OCAMLFIND) install $(library_name) $(targets)
-            CreateInstalled($(library_name), $(targets))
+  if $(not $(defined NO_INSTALL))
+    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))
+      install: $(Installed $(library_name))
 
-    uninstall:
-	rm -f $(Installed $(library_name))
-	$(OCAMLFIND) remove $(library_name)
-
-    export
-  else
-    install: $(targets)
-	$(OCAMLFIND) remove $(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:
+      uninstall:
 	$(OCAMLFIND) remove $(library_name)
-
+      export
     export
 
 ############################################################## build ocaml exec
 #          Name of the program
 #      files
 #          OCaml module names (without .ml)
-MyOCamlProgram(name, files) =
+MyOCamlTestProgram(name, files) =
   AddLocalOCamlPackageDependencies()
   export # The above thing is local: need to be exported
 
   $(name).run $(name).opt: $(Installed $(OMyManagedPackages $(OCAMLPACKS)))
 
-  .PHONY: install
-  install: $(name) $(name).run $(name).opt
-    /bin/cp -a $(name) $(name).run $(name).opt $(PREFIX)/bin
-
   # CR jfuruse: forgot to add the deps over the packages!
   .DEFAULT: $(OCamlProgram $(name), $(files))
 
 #          Name of the program
 #      files
 #          OCaml module names (without .ml)
-#  In addition to MyOCamlProgram, the binary is installed by omake install
-MyOCamlInstalledProgram(name, files) =
-  MyOCamlProgram($(name), $(files))
+#  In addition to MyOCamlTestProgram, the binary is installed by omake install
+MyOCamlProgram(name, files) =
+  MyOCamlTestProgram($(name), $(files))
   export # The above thing is local: need to be exported
 
-  .PHONY: install
-  install: $(name) $(name).run $(name).opt
-    /bin/cp -a $(name) $(name).run $(name).opt $(PREFIX)/bin
-  uninstall:
-    rm -f $(PREFIX)/bin/$(name) $(PREFIX)/bin/$(name).run $(PREFIX)/bin/$(name).opt
+  if $(not $(defined NO_INSTALL))
+    install: $(name) $(name).run $(name).opt
+      install $(name) $(name).run $(name).opt $(PREFIX)/bin
+    uninstall:
+      rm -f $(PREFIX)/bin/$(name) $(PREFIX)/bin/$(name).run $(PREFIX)/bin/$(name).opt
+    export
+
+#| Add a rule to build a toplevel $(name)
+#      name
+#          Name of the program
+#      files
+#          OCaml module names (without .ml)
+OCamlTop(name, files) =
+   # XXX: JYH: these variables should be marked private in 0.9.9
+   protected.CMOFILES  = $(addsuffix .cmo, $(files))
+   # protected.CMXFILES  = $(addsuffix .cmx, $(files))
+   # protected.OFILES    = $(addsuffix $(EXT_OBJ), $(files))
+
+   protected.CMAFILES  = $(addsuffix .cma,  $(OCAML_LIBS))
+   # protected.CMXAFILES = $(addsuffix .cmxa, $(OCAML_LIBS))
+   protected.ARFILES   = $(addsuffix $(EXT_LIB), $(OCAML_LIBS))
+   protected.CMA_OTHER_FILES = $(addsuffix .cma, $(OCAML_OTHER_LIBS))
+   # protected.CMXA_OTHER_FILES = $(addsuffix .cmxa, $(OCAML_OTHER_LIBS))
+
+   protected.CLIBS = $(addsuffix $(EXT_LIB), $(OCAML_CLIBS))
+
+   protected.name = $(file $(name))
+
+   protected.PROG     = $(file $(name)$(EXE))
+   protected.BYTEPROG = $(file $(name).run)
+   # protected.OPTPROG  = $(file $(name).opt)
+
+   #
+   # Rules to build byte-code and native targets
+   #
+   $(BYTEPROG): $(CMAFILES) $(CMOFILES) $(CLIBS)
+        $(OCAMLFIND) $(OCAMLMKTOP) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) $(OCAMLCFLAGS)\
+                $(PREFIXED_OCAMLINCLUDES) $(OCAML_BYTE_LINK_FLAGS)\
+                -o $@ $(CMA_OTHER_FILES) $(CMAFILES) $(OCamlLinkSort $(CMOFILES))\
+                $(CLIBS) $(OCAML_LINK_FLAGS)
+
+   $(PROG): $(BYTEPROG)
+        ln-or-cp $< $@
+
+   return $(array $(PROG), $(BYTEPROG))
+
+MyOCamlTop(name, files) =
+  AddLocalOCamlPackageDependencies()
+  export # The above thing is local: need to be exported
+
+  $(name): $(Installed $(OMyManagedPackages $(OCAMLPACKS)))
+
+  # CR jfuruse: forgot to add the deps over the packages!
+  .DEFAULT: $(OCamlTop $(name), $(files))
+
+  # The following clean the files twice if MyOCamlPackge coexists,
+  # but who cases ?
+  AutoClean()
+  export # The above thing is local: need to be exported
+
+  if $(not $(defined NO_INSTALL))
+    install: $(name) $(name).run
+      install $(name) $(name).run $(PREFIX)/bin
+    uninstall:
+      rm -f $(PREFIX)/bin/$(name) $(PREFIX)/bin/$(name).run
+    export
 
 #|  Add rules to build OCaml library $(name)
 #        name
 #            OCaml module name (without .ml)
 #
 #   .. note :: Probably you should use MyOCamlPackage
-MyOCamlLibrary(name, files) =
+MyOCamlLibrary(library_name, files) =
   AddLocalOCamlPackageDependencies()
+  targets = $(OCamlLibrary $(library_name), $(files))
+
+  .DEFAULT: $(targets)
+
   export # The above thing is local: need to be exported
 
-  # CR jfuruse: forgot to add the deps over the packages!
-  install-lib: $(OCamlLibrary $(name), $(files))
+  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 ?
 name="treeprint"
-version="1.0.0"
+version="1.0.1"
 description="Small tree structure printer with operator associations and precedences"
 requires="spotlib"
 archive(byte)="treeprint.cmo"

opam/treeprint.1.0.0/descr

-Small tree structure printer with operator associations and precedences.
-Treeprint is a small printer combinator library for ASTs with infix,
-prefix and postfix operators with associativity and precedence. 
-It provides abstract printing with minimum parentheses insertion.

opam/treeprint.1.0.0/opam

-opam-version: "1"
-maintainer: "jun.furuse@gmail.com"
-build: [
-  ["ocaml" "setup.ml" "-configure" "--prefix" "%{prefix}%"]
-  ["ocaml" "setup.ml" "-build"]
-  ["ocaml" "setup.ml" "-install"]
-]
-remove: [
-  ["ocamlfind" "remove" "treeprint"]
-]
-depends: [ "ocamlfind" "spotlib" {>="2.0.0"} "omake"]

opam/treeprint.1.0.0/url

-archive: "https://bitbucket.org/camlspotter/treeprint/get/1.0.0.tar.gz"
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.