camlspotter avatar camlspotter committed 3eb946b Merge

merge

Comments (0)

Files changed (3)

+open build/C
+open build/OCaml
+open build/LaTeX
+
+DefineCommandVars()
+
+include OMyMakefile
+
+Installed(x)=
+
+.SUBDIRS: .
+
+################################################################### directories
+
+BIG_ROOT=$(dir .)
+INSTALLED=$(BIG_ROOT)/installed
+PREFIX=$(getenv PREFIX)
+
+.PHONY: all install uninstall clean
+
+##################################################################### installed
+
+Installed(packs) = 
+  return $(addprefix $(INSTALLED)/, $(packs))
+
+CreateInstalled(pack, targets)=
+    println(dump md5 $(INSTALLED)/$(pack))
+    chan=$(fopen $(INSTALLED)/$(pack), w)
+    fprintln($(chan), $(string $(digest $(targets))))
+    close($(chan))
+
+######################################################################### shell
+
+mkdir_if_not_exists(dir) =
+  if $(not $(test -e $(dir))):
+    mkdir $(dir) 
+
+##################################################################### ocamlfind
+
+USE_OCAMLFIND = true
+
+# byte/nat
+
+NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
+BYTE_ENABLED = true
+
+# compiler
+
+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)
+
+# Rule to add dependency on $(files) to any ocaml generated files.
+OCamlDependsOn(files)=
+    %.cmx %.cmo %.cmi %.cma %.cmxa %.annot %.spot %.spit: $(files)
+
+# We first build ocamlfind before compiling any ocaml files
+OCamlDependsOn($(Installed findlib))
+
+################################## Additional implicit rules by file extensions
+
+# annot, spot, spit files
+%.annot %.spot: %.ml %.cmi
+	$(OCamlC) -c $<
+
+%.spit: %.mli 
+	$(OCamlC) -c $<
+
+# auto created .mli
+%.auto.mli: %.ml
+	$(OCamlC) -i -c $< > $@
+
+################################################################# build package
+
+# library_name : target package name
+# ocamlpacks : dependent packages
+# files : ML module names
+# Todo: external C library
+MyOCamlPackage(library_name, ocamlpacks, files) =
+  # We make sure the required libraries are installed
+  installed_packs_ = $(set-diff $(ocamlpacks), $(PREINSTALLED_LIBRARIES))
+  installed_packs=$(addprefix $(INSTALLED)/, $(installed_packs_))
+
+  OCamlDependsOn($(installed_packs))
+  # CR jfuruse: I guess we do not need the following
+  # export # export the implicit rule above
+
+  OCAMLPACKS = $(ocamlpacks)
+  export OCAMLPACKS
+
+  .DEFAULT: $(library_name).cmo $(library_name).cmx
+
+  ## the followings are necessary for packing
+
+  OCAMLPACKAGEFLAGS += -for-pack $(capitalize $(library_name))
+  export OCAMLPACKAGEFLAGS
+
+  ## build rule
+
+  OCamlPackage($(library_name), $(files))
+
+  ## clean
+
+  clean:
+	rm -f $(library_name).spot
+	rm -f $(filter-proper-targets $(ls R, .))
+
+  ## install
+
+  $(BIG_ROOT)/installed/$(library_name): $(library_name).cmo $(library_name).cmx $(library_name).cmi
+	$(OCAMLFIND) remove $(library_name)
+	$(OCAMLFIND) install $(library_name) META $(glob i, *.mli) $(library_name).cmi $(library_name).cmo $(library_name).cmx $(library_name).o $(library_name).spot
+        Touch_installed($(library_name))
+
+
+  install: $(BIG_ROOT)/installed/$(library_name)
+
+  uninstall:
+	rm -f $(BIG_ROOT)/installed/$(library_name)
+	$(OCAMLFIND) remove $(library_name)
+
+############################################################## build ocaml exec
+
+MyOCamlProgram(name, ocamlpacks, files) =
+  # We make sure the required libraries are installed
+  installed_packs_ = $(set-diff $(ocamlpacks), $(PREINSTALLED_LIBRARIES))
+  installed_packs=$(addprefix $(INSTALLED)/, $(installed_packs_))
+
+  %.cmo %.cmx %.cmi: $(installed_packs)
+  export # export the implicit rule above
+
+  OCAMLPACKS = $(ocamlpacks)
+  export OCAMLPACKS
+  .DEFAULT: $(OCamlProgram $(name), $(files))
+
+  # The following clean the files twice if MyOCamlPacakge coexists,
+  # but who cases ?
+  clean:
+    rm -f $(filter-proper-targets $(ls R, .))
+
+####################################################################### subdirs
+
+# traverse the subdirs except $(dirs)
+Subdirs_except(dirs) =
+  # println(PWD: $(shell pwd))
+
+  # need to export since .SUBDIRS is evaluated in the global scope
+  export VISIT_SUBDIRS
+
+  sub_omakefiles = $(glob i, */OMakefile)
+  subdirs = $(sub_omakefiles.map $(dirname))
+
+  VISIT_SUBDIRS=$(set-diff $(subdirs), $(dirs))
+
+  # printing requires $(string ...) to convert arrays to strings
+  # println(SUBDIRS: $(string $(VISIT_SUBDIRS)))
+
+  # The rule
+  .SUBDIRS: $(VISIT_SUBDIRS)
+
+# traverse all the subdirs
+Subdirs() =
+  Subdirs_except($(array))
+
+# traverse only $(dirs)
+Subdirs_only(dirs) =
+ .SUBDIRS: $(dirs)
+
+########################################################################### Dot
+
+Dot() =
+	depend.dot: $(ls *.ml *.mli)
+	    $(OCAMLFIND) ocamldoc -I +threads $(OCAMLPACKAGEFLAGS) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLPPFLAGS) $(PREFIXED_OCAMLINCLUDES) -dot -dot-include-all -dot-reduce $+ -o $@
+
+#### C libs
+
+# name : create $(name).cma and $(name).cmxa
+# mlmodules : OCaml module names w/o extensions
+# cmodules : C module names w/o extensions
+# linkopts : C library link options w/o OCaml flags like -cclib 
+
+MyOCamlPackedLibrary(name, mlmodules, cmodules, linkopts) =
+    OCAMLPACKAGEFLAGS += -for-pack $(capitalize $(name))
+    export OCAMLPACKAGEFLAGS
+    OCamlPackage($(name), $(mlmodules))
+    CSTUBS=$(addsuffix .o,$(cmodules))
+    CMOS=$(addsuffix .cmo,$(name))
+    CMXS=$(addsuffix .cmx,$(name))
+    CMA=$(name).cma
+    CMXA=$(name).cmxa
+    $(CMA) $(CMXA) dll$(name).so lib$(name).a $(name).a : $(CSTUBS) $(CMOS) $(CMXS)
+        ocamlmklib -verbose -o $(name) $(CSTUBS) $(linkopts) $(CMOS) $(CMXS)

memo/nicolas.txt

-let mpython () = 
-let mx = pymodule_new "Mymms" in 
-
-let sd = pyimport_getmoduledict () in 
-let _ = pydict_setitemstring (sd, "Mymms", mx) in 
-
-let _ = pydict_setitemstring (pymodule_getdict mx, "pytypecheck", pytypecheck) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "mymms2python", mymms2python) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "simpl", simpl) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "interp", interp) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "simpl2", simpl2) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "interp2", interp2) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "mymmsrequire", mymmsrequire) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "mymmsload", mymmsload) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "addinload", addinload) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "getnormaloutput", getnormaloutput) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "getdebugoutput", getdebugoutput) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "geterroroutput", geterroroutput) in 
-let _ = pydict_setitemstring (pymodule_getdict mx, "mymmscommand", mymmscommand) in 
-
-try 
-
-let filename = Sys.argv.(2) in 
-let argv = Array.init ((Array.length Sys.argv) - 2) (fun i -> Sys.argv.(i+2)) in 
-set_python_argv argv; 
-let filechannel = open_in filename in 
-let fl = read_file filechannel in 
-let _ =pyrun_simplestring fl in 
-() 
-
-with 
-| Sys_error _ -> print_error "file does not exists\n"; exit 0; 
-| Invalid_argument _ -> ( 
-let _ = pyrun_interactiveloop (0,"-") in 
-exit 0; 
-) 
-| e -> raise e 
-
-;; 
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.