API refactoring : ipsec
[vpp.git] / doxygen / Makefile
index 97225f3..92fa363 100644 (file)
@@ -23,11 +23,20 @@ all: doxygen
 # These should be passed in by the root Makefile
 WS_ROOT ?= $(CURDIR)/..
 BR ?= $(WS_ROOT)/build-root
+
+# We support MacOS for docs generation
+ifeq ($(shell uname),Darwin)
+OS_ID = darwin
+endif
+
+# Work out the OS if we haven't already
 OS_ID ?= $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
 
 # Package dependencies
 DOC_DEB_DEPENDS = doxygen graphviz python-pyparsing python-jinja2
 DOC_RPM_DEPENDS = doxygen graphviz pyparsing python-jinja2
+DOC_MAC_BIN_DEPENDS = doxygen dot git
+DOC_MAC_PY_DEPENDS = pyparsing jinja2
 
 # Doxygen configuration and our utility scripts
 DOXY_DIR ?= $(WS_ROOT)/doxygen
@@ -112,6 +121,7 @@ SIPHONS ?= clicmd syscfg
 
 SIPHON_FILES = $(addprefix $(SIPHON_INPUT)/,$(addsuffix .siphon,$(SIPHONS)))
 SIPHON_DOCS = $(addprefix $(SIPHON_OUTPUT)/,$(addsuffix .md,$(SIPHONS)))
+SIPHON_ITEMLIST = $(addprefix $(SIPHON_OUTPUT)/,$(addsuffix .itemlist,$(filter clicmd,$(SIPHONS))))
 
 $(BR)/.doxygen-bootstrap.ok: Makefile
        @echo "Checking whether dependencies for Doxygen are installed..."
@@ -130,8 +140,23 @@ ifeq ($(OS_ID),ubuntu)
        fi
 else ifneq ("$(wildcard /etc/redhat-release)","")
        @sudo yum install $(CONFIRM) $(DOC_RPM_DEPENDS)
+else ifeq ($(OS_ID),darwin)
+       @set -e; \
+       for bin in $(DOC_MAC_BIN_DEPENDS); do \
+               which -s $${bin} || (\
+                       echo "Program '$${bin}' not found, please install it."; \
+                       false; \
+               ); \
+       done
+       @set -e; \
+       for py in $(DOC_MAC_PY_DEPENDS); do \
+               python -c "import $${py}" >/dev/null 2>&1 || (\
+                       echo "Python package '$${py}' not found, please install it."; \
+                       false; \
+               ); \
+       done
 else
-       $(error "This option currently works only on Ubuntu or Centos systems")
+       $(error "Building documentation currently works only on Ubuntu, CentOS or MacOS systems.")
 endif
        @touch $@
 
@@ -176,24 +201,37 @@ $(SIPHON_FILES): $(BR)/.doxygen-bootstrap.ok \
                --output="$(SIPHON_INPUT)" \
                "@$(SIPHON_INPUT)/files"
 
-# Process the .siphon source fragments and render them into doxygen flavored
-# markdown documentation
-.DELETE_ON_ERROR: $(SIPHON_DOCS)
-$(SIPHON_OUTPUT)/%.md: $(SIPHON_INPUT)/%.siphon \
+# Evaluate this to build a siphon doc output target for each desired
+# output type:
+# $(eval $(call siphon-process,file_extension,output_type_name))
+define siphon-process
+$(SIPHON_OUTPUT)/%.$(1): $(SIPHON_INPUT)/%.siphon \
                $(DOXY_DIR)/siphon-process \
                $(wildcard $(DOXY_DIR)/siphon/*.py) \
-               $(wildcard $(DOXY_DIR)/siphon_templates/*/*.md)
-       @echo "Processing siphon from $(notdir $<)..."
+               $(wildcard $(DOXY_DIR)/siphon_templates/$(2)/*/*.$(1))
+       @echo "Processing siphon for $(2) from $$(notdir $$<)..."
        @set -e; \
        cd "$(WS_ROOT)"; \
        $(DOXY_DIR)/siphon-process \
-               --type=$(basename $(notdir $<)) \
-               --output="$@" \
-               "$<"
+               --type=$$(basename $$(notdir $$<)) \
+               --format=$(2) \
+               --output="$$@" \
+               "$$<"
+endef
+
+# Process the .siphon source fragments and render them into doxygen flavored
+# markdown documentation
+.DELETE_ON_ERROR: $(SIPHON_DOCS)
+$(eval $(call siphon-process,md,markdown))
+
+# Process the .siphon source fragments and render them into a list of cli
+# commands.
+.DELETE_ON_ERROR: $(SIPHON_ITEMLIST)
+$(eval $(call siphon-process,itemlist,itemlist))
 
-# This target can be used just to generate the siphoned docs
+# This target can be used just to generate the siphoned things
 .PHONY: doxygen-siphon
-doxygen-siphon: $(SIPHON_DOCS)
+doxygen-siphon: $(SIPHON_DOCS) $(SIPHON_ITEMLIST)
 
 # Generate the doxygen docs
 .PHONY: doxygen