[augeas-devel] [PATCH] Add naturaldocs support

David Lutterkort lutter at redhat.com
Fri Sep 12 23:38:28 UTC 2008


Hi Raphael,

I played with NaturalDocs some more, and managed to support pretty much
any install scenario by using PERL5LIB and PERL5OPT in the Makefile.

This patch applies on top of your previous patch - give it a spin and
tell me what you think. If you're happy with it, I'll commit the various
ND-related patches.

Now I just need to figure out how that should appear on the website ;)

David

changeset:   665:133aa9bddfd9
tag:         qtip
tag:         tip
tag:         nd-automake-changes.patch
user:        David Lutterkort <dlutter at redhat.com>
date:        Fri Sep 12 16:35:38 2008 -0700
files:       .hgignore configure.ac doc/Makefile.am doc/naturaldocs/Makefile.am
description:
Various changes to the NaturalDocs support

This patch changes a few things around in the NaturalDocs support:

- There is no explicit --with-naturaldocs option anymore; instead,
  configure.ac looks for a program that's either called 'naturaldocs' or
  'NaturalDocs' and enables support for doc generation depending on whether
  that program is found or not.

  This works in any of the following situations:
  (1) NaturalDocs is installed from an RPM, and therefore on the default
      PATH, with its Perl modules installed on the standard Perl library
      path
  (2) NaturalDocs is installed in a random directory, and both PATH and
      PERL5LIB are set accordingly
  (3) A wrapper script that sets the path is on PATH

- Various fixes to make 'make distcheck' work


diff -r 246c6a9d07f4 -r 133aa9bddfd9 .hgignore
--- a/.hgignore	Fri Sep 12 15:46:44 2008 -0700
+++ b/.hgignore	Fri Sep 12 16:35:38 2008 -0700
@@ -22,6 +22,8 @@
 ^src/(parser|lexer)\.[ch]$
 \.(aux|dvi|log|pdf)$
 man/.*\.1$
+doc/naturaldocs/output
+doc/naturaldocs/conf/(c_api|lenses)/Data/.*\.nd$
 
 # Some local stuff
 misc/
diff -r 246c6a9d07f4 -r 133aa9bddfd9 configure.ac
--- a/configure.ac	Fri Sep 12 15:46:44 2008 -0700
+++ b/configure.ac	Fri Sep 12 16:35:38 2008 -0700
@@ -6,39 +6,28 @@
 
 
 dnl Check for NaturalDocs
-AC_ARG_WITH([naturaldocs],
-  [AS_HELP_STRING([--with-naturaldocs=DIR],
-    [path to NaturalDocs install dir to generate documentation])], 
-  [AC_CHECK_FILE($withval/NaturalDocs,
-      [AC_PATH_PROG(PERL, perl, no)
-      if test "x$PERL" = "xno"; then
-           AC_MSG_ERROR(You need a working installation of Perl to use NaturalDocs)
-      fi
-      NATURALDOCSDIR=$withval
-      HAS_NATURALDOCS=naturaldocs
-      ],
-      [ AC_MSG_ERROR(You asked to use NaturalDocs but it could not be found)])
-  ])
-AC_SUBST(HAS_NATURALDOCS)
-AC_SUBST(NATURALDOCSDIR)
-AC_SUBST(PERL)
+AC_PATH_PROGS([ND_PROG], [naturaldocs NaturalDocs], missing)
+AM_CONDITIONAL([ND_ENABLED], [test "x$ND_PROG" != "xmissing"])
 
 dnl NaturalDocs output format, defaults to HTML
-NATURALDOCSFORMAT=HTML
+ND_FORMAT=HTML
 AC_ARG_WITH([naturaldocs-output],
   [AS_HELP_STRING([--with-naturaldocs-output=FORMAT],
     [format of NaturalDocs output (possible values: HTML/FramedHTML, default: HTML)])],
   [
+    if test "x$ND_PROG" = "xmissing"; then
+      AC_MSG_ERROR([NaturalDocs was not found on your path; there's no point in setting the output format])
+    fi
     case $withval in
        HTML|FramedHTML)
-          NATURALDOCSFORMAT=$withval
+          ND_FORMAT=$withval
 	  ;;
        *)
           AC_MSG_ERROR($withval is not a supported output format for NaturalDocs)
 	  ;;
     esac
   ])
-AC_SUBST(NATURALDOCSFORMAT)
+AC_SUBST(ND_FORMAT)
 
 
 dnl Check for pdflatex
diff -r 246c6a9d07f4 -r 133aa9bddfd9 doc/Makefile.am
--- a/doc/Makefile.am	Fri Sep 12 15:46:44 2008 -0700
+++ b/doc/Makefile.am	Fri Sep 12 16:35:38 2008 -0700
@@ -1,10 +1,12 @@
 
-SUBDIRS = $(HAS_NATURALDOCS)
+SUBDIRS = naturaldocs
+
+EXTRA_DIST = lenses.tex unambig.tex
 
 # PDF targets
 PDFTARGETS=lenses.pdf unambig.pdf
 
-all: $(PDFDOCS)
+all-local: $(PDFDOCS)
 
 pdfdocs: $(PDFTARGETS)
 %.pdf: %.tex
@@ -12,4 +14,3 @@
 
 clean-local:
 	rm -f *.pdf *.aux *.log
-
diff -r 246c6a9d07f4 -r 133aa9bddfd9 doc/naturaldocs/Makefile.am
--- a/doc/naturaldocs/Makefile.am	Fri Sep 12 15:46:44 2008 -0700
+++ b/doc/naturaldocs/Makefile.am	Fri Sep 12 16:35:38 2008 -0700
@@ -1,40 +1,54 @@
 
-NDPROJECT=$(srcdir)/conf
-NDSRC=$(top_srcdir)/src
-NDLENSES=$(top_srcdir)/lenses
-NDFORMAT=HTML
-NDOUTPUT=output
-NDLOADMODULES=NaturalDocs::Languages::Augeas
-NDMODULES=$(NATURALDOCSDIR)/Modules
-NDLOCALMODULES=$(srcdir)/Modules
-NDSTYLE=Augeas
+EXTRA_DIST = $(wildcard conf/Augeas.css conf/c_api/*.txt) \
+             $(wildcard conf/lenses/*.txt) \
+             Modules/NaturalDocs/Languages/Augeas.pm
 
-all: NaturalDocs
+ND_CONF=$(srcdir)/conf
+ND_OUTPUT=output
+ND_STYLE=../Augeas
+
+ND_PERL5LIB=$(abs_srcdir)/Modules
+ND_PERL5OPT='-MNaturalDocs::Languages::Augeas'
+
+if ND_ENABLED
+all-local: NaturalDocs
+endif
 
 NaturalDocs: NDLenses NDCAPI
 
-NDLenses:
-	mkdir -p $(NDOUTPUT)/lenses
-	exec $(PERL) \
-	  -M"$(NDLOADMODULES)" \
-	  -I"$(NDMODULES)" \
-	  -I"$(NDLOCALMODULES)" \
-	  $(NATURALDOCSDIR)/NaturalDocs \
-	    -p $(NDPROJECT)/lenses \
-	    -i $(NDLENSES) \
-	    -o $(NATURALDOCSFORMAT) $(NDOUTPUT)/lenses \
-	    -s $(NDSTYLE)
+env:
+	echo LIB $(ND_PERL5LIB)
+	echo OPT $(ND_PERL5OPT)
+	test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+	test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+        PERL5LIB=$$ND_PERL5LIB PERL5OPT=$$ND_PERL5OPT env | grep PERL
 
-NDCAPI:
-	mkdir -p $(NDOUTPUT)/c_api
-	exec $(PERL) \
-	  $(NATURALDOCSDIR)/NaturalDocs \
-	    -p $(NDPROJECT)/c_api \
-	    -i $(NDSRC) \
-	    -o $(NATURALDOCSFORMAT) $(NDOUTPUT)/c_api \
-	    -s $(NDSTYLE)
+NDLenses: NDConf
+	@mkdir -p $(ND_OUTPUT)/lenses
+	@(echo "Format lens documentation"; \
+	  test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+	  test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+	  PERL5LIB=$$ND_PERL5LIB PERL5OPT=$$ND_PERL5OPT \
+          $(ND_PROG) -p conf/lenses \
+	      -i $(top_srcdir)/lenses \
+	      -o $(ND_FORMAT) $(ND_OUTPUT)/lenses \
+	      -s $(ND_STYLE))
+
+NDCAPI: NDConf
+	@mkdir -p $(ND_OUTPUT)/c_api
+	@(echo "Format C API documentation"; \
+	  test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+	  test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+	  $(ND_PROG) -p conf/c_api \
+	    -i $(top_srcdir)/src \
+	    -o $(ND_FORMAT) $(ND_OUTPUT)/c_api \
+	    -s $(ND_STYLE))
+
+NDConf:
+	@(if test ! -d $(ND_CONF); then \
+	    cp -pr $(ND_CONF) conf; \
+	  fi)
 
 clean-local:
 	rm -rf output conf/Data
-	rm -rf $(NDPROJECT)/c_api/Data $(NDPROJECT)/lenses/Data
-
+	rm -rf $(ND_CONF)/c_api/Data $(ND_CONF)/lenses/Data






More information about the augeas-devel mailing list