1. camlspotter
  2. omy

Commits

camlspotter  committed 45de905

added files

  • Participants
  • Branches default

Comments (0)

Files changed (11)

File .hgignore

View file
  • Ignore whitespace
+.*\.omc
+doc/_build
+doc/OMy.*\.rst
+.*~
+

File OMakefile

View file
  • Ignore whitespace
+Subdirs()

File OMyExternal

View file
  • Ignore whitespace
+# ==========================
+# OMyExternal 
+# ==========================
+# Functions to integrate non-OMake projects
+
+#| Run wget and retrieve $(url) to $(dir)
+#  If the file is already downloaded, does nothing.
+WGet(url, dir) =
+    arc=$(basename $(url))
+    dst=$(dir)$(DIRSEP)$(arc)
+    mkdir_if_not_exists($(dir))
+    $(dst):
+        if $(test -e $(dst))
+          touch $(dst)
+        else
+          wget -O $(dst).tmp $(url); mv $(dst).tmp $(dst)
+    return $(dst)
+
+#| List up files in directory $(dir), without the prefix "$(dir)/"
+Files(dir) =
+    return $(removeprefix $(dir)/, $(find $(dir) -f {}))
+    
+#| Get the OCaml module paths from OCaml object and interface file names: x.cmo, y.cmx => x, y
+#  CR : Defined but not useful
+OCamlModulesFromPath(files)=
+    return $(set $(removesuffix $(filter %.cmi %.cmo %.cmx, $(files))))
+
+# CR : It is not used
+FindOCamlSpotFiles(dir, files)=
+    candidates=$(OCamlModulesFromPath $(files))
+    spots=$(find $(dir) -regex .*\.\(annot|spot|spit\)\$)
+
+#| Add a rule to install non-omake project.
+#
+#      Argument
+#          PACK (mandatory)
+#              Name of the package. Once installed, ``Installed($(PACK))`` is created.
+#      Environments
+#          URL (optional)
+#              URL of the source
+#          REQUIRED_PACKS (mandatory)
+#              List of install mark files of required package: ex. REQUIRED_PACKS=$(Installed type-conv)
+#          CONFIGURE (optional)
+#              Configure command: ex. (cd $(EXTRACT_DIR); ./configure --prefix $PREFIX)
+#              Command is executed at the directory where the function is called.
+#          INSTALL (mandatory)
+#              Install command: ex. (cd $(EXTRACT_DIR); make all install).
+#              Command is executed at the directory where the function is called.
+#          OBJS (optional?)
+#              The list of files installed
+#
+#  CR jfuruse: this is pretty buggy
+OCamlExternal(PACK) =
+# build dir
+    BUILD_DIR=_build
+
+#    $(BUILD_DIR):
+#        mkdir_if_not_exists($(BUILD_DIR))
+
+    .PHONY: very-clean
+    very-clean:
+        rm -rf $(BUILD_DIR)
+
+    SRCOMake=
+    if $(not $(defined SRCS)):
+        SRCOMake=$(BUILD_DIR)/sources
+        export SRCOMake
+
+    OBJOMake=
+    if $(not $(defined OBJS)):
+        OBJOMake=$(BUILD_DIR)/objects
+        export OBJOMake
+
+# ARC
+    # adds rule for $(ARC)
+    ARC=$(WGet $(URL), $(BUILD_DIR))
+
+    .PHONY: manual_download
+    manual_download: $(ARC)
+
+# EXTRACT and CONFIGURE
+    EXTRACT_DIR=$(BUILD_DIR)/extract
+
+    .PHONY: clean
+    clean:
+        rm -rf $(EXTRACT_DIR)
+
+    Extract(ARC)=
+        rm -rf $(EXTRACT_DIR)
+        mkdir_if_not_exists($(EXTRACT_DIR))
+        TarExtractAt($(ARC), $(EXTRACT_DIR))
+        return
+
+    .PHONY: manual_extract
+    manual_extract:
+        Extract($(ARC))
+
+    Configure(x)=
+        if $(defined CONFIGURE):
+            (cd $(EXTRACT_DIR); $(CONFIGURE))
+        # Configure can make SRCOMake
+        if $(SRCOMake)
+            section:
+                srcs=$(removeprefix $(EXTRACT_DIR), $(Files $(EXTRACT_DIR)))
+                chan=$(fopen $(SRCOMake), w)
+                fprintln($(chan), SRCS=$(string $(srcs)))
+                close($(chan))
+        return
+
+    .PHONY: manual_configure
+    manual_configure:
+        Configure(0)
+
+    Install(x)=
+        (cd $(EXTRACT_DIR); $(INSTALL))
+        # Install can make OBJOMake
+        if $(OBJOMake)
+            section:
+                println(GET_OBJS)
+                objs=$(GET_OBJS 0)
+                println(Creating $(OBJOMake) = $(string $(objs)))
+                chan=$(fopen $(OBJOMake), w)
+                fprintln($(chan), OBJS=$(string $(objs)))
+                close($(chan))
+                println(Install=> $(string $(objs)))
+                return $(objs)
+        else
+            println(Install: OBJOMake does not exist)
+
+    .PHONY: manual_install
+    manual_install:
+        Install(0)
+    
+    .PHONY: manual_prepare
+    manual_prepare: $(ARC) $(REQUIRED_PACKS)
+        Extract($(ARC))
+        Configure(0)
+        Install(0)
+
+    if $(not $(defined SRCS))
+        SRCS=
+        .INCLUDE: $(SRCOMake)
+            mkdir_if_not_exists($(BUILD_DIR))
+            touch $@
+        SRCS=$(addprefix $(EXTRACT_DIR)/, $(SRCS))
+        export SRCS
+
+    if $(SRCS)
+        $(SRCS) : $(ARC)
+            Extract($(ARC))
+            Configure(0)
+            
+    if $(not $(defined OBJS))
+        OBJS=
+        .INCLUDE: $(OBJOMake)
+            mkdir_if_not_exists($(BUILD_DIR))
+            touch $@
+        export OBJS
+
+    if $(SRCS)
+        if $(OBJS)
+            $(OBJS): $(REQUIRED_PACKS) $(SRCS)
+                Install(0)
+            $(INSTALLED)/$(PACK): $(OBJS)
+                CreateInstalled($(PACK), $(OBJS))
+        else 
+            $(INSTALLED)/$(PACK) $(OBJOMake) : $(SRCS) $(REQUIRED_PACKS)
+                Install(0)    
+                CreateInstalled($(PACK), $(OBJS))
+            .DEFAULT: $(OBJOMake)
+    else
+        if $(OBJS)
+            $(OBJS): $(REQUIRED_PACKS) $(ARC)
+                Extract($(ARC))
+                Configure(0)
+                Install(0) 
+            $(INSTALLED)/$(PACK): $(OBJS)
+                CreateInstalled($(PACK), $(OBJS))
+        else
+            $(INSTALLED)/$(PACK) $(OBJOMake): $(ARC) $(REQUIRED_PACKS)
+                Extract($(ARC))
+                Configure(0)
+                OBJS=Install(0)    
+                CreateInstalled($(PACK), $(OBJS))
+
+    install: $(INSTALLED)/$(PACK)
+    .DEFAULT: install
+
+#| Add a rule to install non-omake OCaml package.
+#
+#      Argument
+#          PACK (mandatory)
+#              Name of the package. Once installed, ``Installed($(PACK))`` is created.
+#      Environments
+#          URL (optional)
+#              URL of the source
+#          REQUIRED_PACKS (mandatory)
+#              List of install mark files of required package: ex. REQUIRED_PACKS=$(Installed type-conv)
+#          CONFIGURE (optional)
+#              Configure command: ex. (cd $(EXTRACT_DIR); ./configure --prefix $PREFIX)
+#              Command is executed at the directory where the function is called.
+#          INSTALL (mandatory)
+#              Install command: ex. (cd $(EXTRACT_DIR); ocamlfind install ...).
+#              Command is executed at the directory where the function is called.
+#              ``ocamlfind remove $(PACK)`` is automatically done before the installation.
+#          OBJS (pretty optional?)
+#              The list of files installed
+#
+#  CR jfuruse: this is pretty buggy
+OCamlExternalPack(PACK) =
+     INSTALL=ocamlfind remove $(PACK); $(INSTALL)
+     REQUIRED_PACKS+=$(Installed findlib)
+     GET_OBJS(dummy)=
+         println(find find $(OCAMLFIND_DESTDIR)/$(PACK))
+         return $(addprefix \$\(OCAMLFIND_DESTDIR\)/\$\(PACK\)/, $(Files $(OCAMLFIND_DESTDIR)/$(PACK)))
+     OCamlExternal($(PACK))

File OMyMakefile

View file
  • Ignore whitespace
+# ==========================
+# OMyMakefile
+# ==========================
+# Useful functions to build OCaml projects
+
+.PHONY: all install uninstall clean
+
+# Directories
+# =====================================================================
+
+#| The build root directory  
+BIG_ROOT=$(dir .)
+
+#| The prefix. Equal to the PREFIX environment variable
+PREFIX=$(getenv PREFIX)
+
+# Installation mark files
+# =======================================================================
+
+INSTALLED=$(BIG_ROOT)/installed
+mkdir(-p $(INSTALLED))
+
+#|Returns the installation mark files of $(packs)
+Installed(packs) = 
+  return $(addprefix $(INSTALLED)/, $(packs))
+
+#|Create $(Installed $(pack)) file from the digests of $(targets)
+CreateInstalled(pack, targets)=
+    println(dump md5 $(INSTALLED)/$(pack))
+    chan=$(fopen $(INSTALLED)/$(pack), w)
+    fprintln($(chan), $(string $(digest $(targets))))
+    close($(chan))
+
+# Misc tools
+# ======================================================================
+
+#|ditto.
+mkdir_if_not_exists(dir) =
+  if $(not $(test -e $(dir))):
+    mkdir $(dir) 
+  return
+
+# OCamlFind
+# ========================================================================
+
+USE_OCAMLFIND = true
+OCAMLFIND_DESTDIR=$(PREFIX)/lib/ocaml/site-lib
+
+#|Preinstalled libraries which are always available once OCamlFind is installed
+OCAMLFIND_PREINSTALLED_LIBRARIES[]= bigarray camlp4 dbm dynlink findlib graphics num num-top stdlib str threads unix
+
+# byte/nat
+NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
+#|If set false in a project directory, byte compilation is disabled there.
+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)
+
+# Spot files (OCamlSpotter)
+# ==================================================================
+
+#| Define OCAML_ANNOT so that custom ocamlc/ocamlopt automatically create spot/spit/annot files
+setenv(OCAML_ANNOT, 1)
+
+# Additional implicit rules by file extensions
+
+# annot, spot, spit files
+%.annot %.spot: %.ml %.cmi
+	$(OCamlC) -c $<
+
+%.spit: %.mli 
+	$(OCamlC) -c $<
+
+# Dependencies
+# =========================================================================
+
+#|Add dependencies of OCaml compiled files (cmx, cmo, etc.) over $(files)
+OCamlDependsOn(files)=
+    %.cmx %.cmo %.cmi %.cma %.cmxa %.annot %.spot %.spit: $(files)
+
+#|We first build ocamlfind before compiling any ocaml compiled files
+OCamlDependsOn($(Installed findlib))
+
+#|``omake xxx.auto.mli`` generates .mli file from xxx.ml 
+%.auto.mli: %.ml
+	$(OCamlC) -i -c $< > $@
+
+# CamlP4 modules
+# =========================================================
+
+#| Add dependencies of OCaml dependency analysis over $(packages).
+#  Use this for adding dependencies for CamlP4 extensions.
+UseCamlP4Modules(packages) =
+    .SCANNER: scan-ocaml-%: $(Installed $(packages))
+
+# Build rules
+# ==========================================================
+
+# 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))
+   protected.CMOFILES = $(addsuffix .cmo, $(files))
+   protected.CMXFILES = $(addsuffix .cmx, $(files))
+
+   protected.OBJ       = $(file $(name)$(EXT_OBJ))
+   protected.CMO       = $(file $(name).cmo)
+   protected.CMX       = $(file $(name).cmx)
+   protected.CMI       = $(file $(name).cmi)
+   protected.MLI       = $(file $(name).mli)
+
+   protected.BYTE_TARGETS   = $(CMO)
+   protected.NATIVE_TARGETS = $(CMX) $(OBJ)
+
+   if $(BYTE_ENABLED)
+      BYTE_TARGETS += $(file $(name).spot)
+      export
+   else
+      NATIVE_TARGETS += $(file $(name).spot)
+      export
+
+   protected.TARGETS = $(CMI)
+   if $(NATIVE_ENABLED)
+       TARGETS += $(NATIVE_TARGETS)
+       export
+
+   if $(BYTE_ENABLED)
+       TARGETS += $(BYTE_TARGETS)
+       export
+
+   #
+   # Link commands
+   #
+   protected.BYTE_DEPS = $(CMOFILES)
+   $(BYTE_TARGETS): $(CMOFILES)
+      section rule
+         if $(or $(NATIVE_ENABLED), $(target-exists $(MLI)))
+             BYTE_DEPS += $(CMI)
+             export
+         else
+             BYTE_TARGETS += $(CMI)
+             export
+         $(BYTE_TARGETS): $(BYTE_DEPS)
+            $(OCAMLFIND) $(OCAMLC) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
+                $(OCAMLCFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMO) $(OCamlLinkSort $(CMOFILES))
+
+   protected.NATIVE_DEPS = $(CMXFILES) $(OFILES)
+   $(NATIVE_TARGETS): $(NATIVE_DEPS)
+      section rule
+         if $(target-exists $(MLI))
+            NATIVE_DEPS += $(CMI)
+            export
+         else
+            NATIVE_TARGETS += $(CMI)
+            export
+         $(NATIVE_TARGETS): $(NATIVE_DEPS)
+            $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
+                $(OCAMLOPTFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMX) $(OCamlLinkSort $(CMXFILES))
+
+   $(CMI):
+      section rule
+         if $(target-exists $(MLI))
+            $(CMI): $(MLI) :scanner: scan-ocaml-$(name).mli
+                $(OCamlC) -c $<
+         elseif $(NATIVE_ENABLED)
+            $(NATIVE_TARGETS) $(CMI): $(NATIVE_DEPS)
+               $(OCAMLFIND) $(OCAMLOPTLINK) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
+                   $(OCAMLOPTFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMX) $(OCamlLinkSort $(CMXFILES))
+         else
+            $(BYTE_TARGETS) $(CMI): $(BYTE_DEPS)
+               $(OCAMLFIND) $(OCAMLC) $(LAZY_OCAMLFINDFLAGS) $(PREFIXED_OCAMLPACKS) $(OCAMLFLAGS) \
+                   $(OCAMLCFLAGS) $(OCAML_LIB_FLAGS) -pack -o $(CMO) $(OCamlLinkSort $(CMOFILES))
+
+   return $(TARGETS)
+
+#| Add a rule for OCaml package $(library_name).cmo, $(library_name).cmx and etc.
+#     library_name
+#         target package name
+#     files
+#         ML module names (without .ml)
+#     cmodules
+#         C source files (without .c)
+#     linkopts
+#         C library link option (without OCaml -cclib options)    
+#
+#  Todo: external C library
+MyOCamlPackage(library_name, files, cmodules, linkopts) =
+  # We make sure the required libraries are installed
+  installed_packs_ = $(set-diff $(OCAMLPACKS), $(OCAMLFIND_PREINSTALLED_LIBRARIES))
+  installed_packs=$(addprefix $(INSTALLED)/, $(installed_packs_))
+
+  CSTUBS=$(addsuffix .o,$(cmodules))
+  CMOS=$(addsuffix .cmo,$(library_name))
+  CMXS=$(addsuffix .cmx,$(library_name))
+  CMA=$(library_name).cma
+  CMXA=$(library_name).cmxa
+
+  OCamlDependsOn($(installed_packs))
+  # 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
+
+  $(CMA) $(CMXA) dll$(library_name).so lib$(library_name).a $(library_name).a : $(CSTUBS) $(CMOS) $(CMXS)
+      ocamlmklib -verbose -o $(library_name) $(CSTUBS) $(linkopts) $(CMOS) $(CMXS)
+
+  ## 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
+
+  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
+
+
+  $(BIG_ROOT)/installed/$(library_name): $(targets)
+	$(OCAMLFIND) remove $(library_name)
+	section:
+          $(OCAMLFIND) install $(library_name) $(targets)
+          CreateInstalled($(library_name), $(targets))
+
+  install: $(BIG_ROOT)/installed/$(library_name)
+
+  uninstall:
+	rm -f $(BIG_ROOT)/installed/$(library_name)
+	$(OCAMLFIND) remove $(library_name)
+
+############################################################## build ocaml exec
+
+#| Add a rule to build a program $(name)
+#      name
+#          Name of the program
+#      files
+#          OCaml module names (without .ml)
+MyOCamlProgram(name, files) =
+  # We make sure the required libraries are installed
+  installed_packs_ = $(set-diff $(OCAMLPACKS), $(OCAMLFIND_PREINSTALLED_LIBRARIES))
+  installed_packs=$(addprefix $(INSTALLED)/, $(installed_packs_))
+
+  %.cmo %.cmx %.cmi: $(installed_packs)
+  export # export the implicit rule above
+
+  .DEFAULT: $(OCamlProgram $(name), $(files))
+
+  # The following clean the files twice if MyOCamlPackge coexists,
+  # but who cases ?
+  clean:
+    rm -f $(filter-proper-targets $(ls R, .))
+
+#|  Add a rule to build OCaml library $(name)
+#        name
+#            Name of the library
+#        files
+#            OCaml module name (without .ml)
+MyOCamlLibrary(name, files) =
+  # We make sure the required libraries are installed
+  installed_packs_ = $(set-diff $(OCAMLPACKS), $(OCAMLFIND_PREINSTALLED_LIBRARIES))
+  installed_packs=$(addprefix $(INSTALLED)/, $(installed_packs_))
+
+  %.cmo %.cmx %.cmi: $(installed_packs)
+  export # export the implicit rule above
+
+  .DEFAULT: $(OCamlProgram $(name), $(files))
+
+  # The following clean the files twice if MyOCamlPacakge coexists,
+  # but who cases ?
+  clean:
+    rm -f $(filter-proper-targets $(ls R, .))
+
+# Subdir traversal
+# =====================================================================
+
+#| Recursively 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)
+
+#| Recursively traverse all the subdirs
+Subdirs() =
+  Subdirs_except($(array))
+
+#| Recursively traverse the given subdirs $(dirs)
+Subdirs_only(dirs) =
+ .SUBDIRS: $(dirs)
+
+# Dependency dot files for Graphviz
+# ======================================================================
+
+#| Add a rule for ``depend.dot`` for a dependency graph of OCaml files in the current directory
+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 $@
+
+

File OMyTar

View file
  • Ignore whitespace
+# ==========================
+# OMyTar
+# ==========================
+# Handling tar archives, such as .tar, .tar.gz, .tar.bz2, .tgz, .tbz
+
+TarCompressSwitch(f) =
+  match $(f)
+  case $'tar$'
+      return $"tar"
+  case $'gz$'
+      return $"z"
+  case $'bz2?$'
+      return $"j"
+  default
+      return 
+
+#| Extract tar archive $(f). 
+TarExtract(f) =
+  ext = $(TarCompressSwitch $(f))
+  tar $(ext)xf $(f)
+  return
+
+#| Extract $(f) to directory $(dir)
+TarExtractAt(f, dir) =
+  ext = $(TarCompressSwitch $(f))
+  tar $(ext)xf $(f) -C $(dir) 
+  return
+
+#| Obtain the list of archived files in $(f)
+TarList(f) =
+  ext=$(TarCompressSwitch $(f))
+  cmd=tar $(ext)tf $(f)
+  return $(shella $(cmd))
+
+# CR : not finished
+TopDir(f) =
+  match $(f)
+  case $'^\([^/]+\)/'
+    return $1
+  default
+    return yyy
+
+TarExtractDir(f) =
+  files=$(TarList $(f))
+# return $(set $(foreach TopDir, $(files)))
+  return $(set $(foreach $(fun x, $(TopDir $(x))), $(files)))
+
+#| Extract tar archive $(f) to directory $(dir).
+#  If the archive has more than one files or directories in its top directory structure,
+#  they are expanded into a newly created directory, whose name is from $(f). 
+TarAutoExtract(f, dir) =
+  extdirs = $(TarExtractDir $(f))
+  extdir = $(dir)$(DIRSEP)$(if $(eq 1, $(length $(extdirs))), $(nth 0, $(extdirs)), $(rootname $(basename $(f))))
+  println(EXTDIR $(extdir))
+
+# TarAutoExtract($"external/findlib/findlib-1.2.1.tar.gz", $"hoge")

File doc/Makefile

View file
  • Ignore whitespace
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  qthelp    to make HTML files and a qthelp project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/OMyMakefile.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/OMyMakefile.qhc"
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."

File doc/OMakefile

View file
  • Ignore whitespace
+.PHONY: clean
+
+MODULES[]=
+    OMyMakefile
+    OMyExternal
+    OMyTar
+
+RSTS=$(addsuffix .rst, $(MODULES)) index.rst
+
+HTMLS=$(addprefix _build/html/, $(addsuffix .html, $(MODULES))) _build/html/index.html
+
+.DEFAULT: $(HTMLS)
+
+$(HTMLS): $(RSTS)
+	make html
+
+%.rst : ../% reSTOMake.py
+	./reSTOMake.py $< > $@
+
+clean:
+	make clean 
+	rm -f $(filter-proper-targets $(ls R, .))

File doc/conf.py

View file
  • Ignore whitespace
+# -*- coding: utf-8 -*-
+#
+# OMyMakefile documentation build configuration file, created by
+# sphinx-quickstart on Wed Jan 26 14:51:27 2011.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'OMyMakefile'
+copyright = u'2011, Jun FURUSE'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1.0.0'
+# The full version, including alpha/beta/rc tags.
+release = '1.0.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'OMyMakefiledoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'OMyMakefile.tex', u'OMyMakefile Documentation',
+   u'Jun FURUSE', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True

File doc/index.rst

View file
  • Ignore whitespace
+.. OMyMakefile documentation master file, created by
+   sphinx-quickstart on Wed Jan 26 14:51:27 2011.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to OMyMakefile's documentation!
+=======================================
+
+Contents:
+
+.. toctree::
+   :glob:
+   :maxdepth: 2
+
+   *
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`search`
+
+.. * :ref:`modindex`
+

File doc/make.bat

View file
  • Ignore whitespace
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=sphinx-build
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html      to make standalone HTML files
+	echo.  dirhtml   to make HTML files named index.html in directories
+	echo.  pickle    to make pickle files
+	echo.  json      to make JSON files
+	echo.  htmlhelp  to make HTML files and a HTML help project
+	echo.  qthelp    to make HTML files and a qthelp project
+	echo.  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  changes   to make an overview over all changed/added/deprecated items
+	echo.  linkcheck to check all external links for integrity
+	echo.  doctest   to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\OMyMakefile.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\OMyMakefile.ghc
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+:end

File doc/reSTOMake.py

View file
  • Ignore whitespace
+#!/usr/bin/python
+
+import re
+import sys
+
+def doComments(lines):
+    formatted = []
+    indent = None
+    heading = None
+    for line in lines:
+        if re.match("^#", line):
+            line = re.sub(r"^#[|^]", " ", line)
+            line = re.sub(r"^#", "", line)
+            if indent == None:
+                m = re.match("^( +)", line)
+                if m:
+                    indent = m.group(1)
+                else:
+                    indent = ""
+            line = re.sub(r"^" + indent, "", line)
+            if re.match("(===|---)", line):
+                heading = ""
+            formatted.append(line)
+        else:
+            m = re.match("^\s*([A-Za-z_0-9]+\(.*\))\s*=", line) # a function
+            if m:
+                heading = ".. function:: " + m.group(1) + "\n\n"
+            else:
+                m = re.match("^\s*([A-Za-z_0-9\[\]]+)\s*=(.*)", line) # a variable
+                if m:
+                    heading = ".. function:: " + m.group(1) + "\n\n"
+                    if not re.match("^\s*$", m.group(2)):
+                        formatted = ["\n", "::", "\n", "\n", "    = " + m.group(2) + "\n\n"] + formatted
+                elif re.match(":", line): # a rule
+                    heading = ".. function:: " + line  + "\n"
+                else: # an expr
+                    heading = ".. function:: " + line + "\n"
+    if heading == None:
+        ()
+    elif heading == "":
+        for line in formatted:
+            print line,
+    else:
+        print heading,
+        for line in formatted:
+            # line = re.sub(r"^((::)?)", r"\1    ", line)
+            print "    " + line,
+    print ""
+
+for arg in sys.argv:
+    seeNext = False
+    lines = []
+    for line in open(arg):
+        if re.match("^#", line):
+            lines.append(line)
+            if re.match(r"#\|", line):
+                seeNext = True
+        elif seeNext:
+            lines.append(line)
+            seeNext = False
+            doComments(lines)
+            lines = []
+        else:
+            if lines != []:
+                doComments(lines)
+            lines = []
+