From 560b91ab42809ebcf4bfe365e0eedd18ae862b33 Mon Sep 17 00:00:00 2001
From: g0dil <g0dil@wiback.org>
Date: Wed, 19 Aug 2009 10:18:00 +0000
Subject: [PATCH] Fix HTML @TOPDIR@ links Add doclib/doxygen.sh dependency to
 documentation build Fix doclib/doxygen.sh shell (bash instead of sh)

---
 doclib/SConscript      |  1 -
 doclib/doxygen.sh      | 22 +++++++++++++---------
 senfscons/SENFSCons.py | 22 ++++++++++++----------
 3 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/doclib/SConscript b/doclib/SConscript
index 097ec6b03..696fc2789 100644
--- a/doclib/SConscript
+++ b/doclib/SConscript
@@ -232,7 +232,6 @@ div.tabs li.$projectname a { background-color: #EDE497; }
       <li><a class="ext" href="http://svn.berlios.de/wsvn/senf/?op=log&rev=0&sc=0&isdir=1">ChangeLog</a></li>
       <li><a class="ext" href="http://svn.berlios.de/viewcvs/senf/trunk/">Browse SVN</a></li>
       <li><a class="ext" href="http://developer.berlios.de/bugs/?group_id=7489">Bug Tracker</a></li>
-      <li><a href="@TOPDIR@/doc/html/xref.html">Open Issues</a></li>
     </ul>
   </div>
 </div>
diff --git a/doclib/doxygen.sh b/doclib/doxygen.sh
index 2992bd26e..b2acf845d 100755
--- a/doclib/doxygen.sh
+++ b/doclib/doxygen.sh
@@ -1,11 +1,12 @@
-#!/bin/sh -e
+#!/bin/bash -e
 
 do_html_cleanup()
 {
     sed -e 's/id="current"/class="current"/' \
 	| tidy -ascii -q --wrap 0 --show-warnings no --fix-uri no \
 	| sed -e 's/name="\([^"]*\)"\([^>]*\) id="\1"/name="\1"\2/g' \
-	| xsltproc --novalid --nonet --html --stringparam topdir $TOPDIR "$base/html-munge.xsl" -
+	| xsltproc --novalid --nonet --html --stringparam topdir "$reltopdir" \
+	      "$base/html-munge.xsl" -
 }
 
 ###########################################################################
@@ -62,7 +63,7 @@ EOF
     exit 1
 fi
 
-if [ "$tagfile" == "YES" -a -z "$tagfile_name" ]; then
+if [ "$tagfile" = "YES" -a -z "$tagfile_name" ]; then
     echo "--tagfile-name is required with --tagfile"
     exit 1
 fi
@@ -86,13 +87,14 @@ relpath()
 	srcd="${src%%/*}"
 	dstd="${dst%%/*}"
 	if [ "$srcd" = "$dstd" ]; then
-	    src="${src#*/}"
-	    dst="${dst#*/}"
+	    src="${src#$srcd}"; src="${src#/}"
+	    dst="${dst#$dstd}"; dst="${dst#/}"
 	else
 	    break
 	fi
     done
-    echo "`echo "$src" | sed -e "s/[^\/]*/../g"`/$dst" # `"
+    rel="`echo "$src" | sed -e "s/[^\/]*/../g"`/$dst" # `"
+    echo "${rel%/}"
 }
 
 # Log executed commands
@@ -119,6 +121,8 @@ if [ ! -r "SConstruct" ]; then
     exit 1;
 fi
 TOPDIR="`pwd`";
+reltopdir="`relpath "$doxydir/$output_dir/$html_dir" "$TOPDIR"`" #`"
+echo "relpath $doxydir/$output_dir/$html_dir $TOPDIR -> $reltopdir"
 cd "$doxydir"
 
 
@@ -137,7 +141,7 @@ fi
 ## Call doxygen proper
 
 generate_tagfile=""
-if [ "$tagfile" == "YES" ]; then
+if [ "$tagfile" = "YES" ]; then
     generate_tagfile="$tagfile_name"
 fi
 export TOPDIR html tagfile tagfile_name tagfiles output_dir html_dir generate_tagfile
@@ -147,7 +151,7 @@ cmd ${DOXYGEN:-doxygen}
 
 ## Clean up tagfile, if generated
 
-if [ "$tagfile" == "YES" ]; then
+if [ "$tagfile" = "YES" ]; then
     mv "$tagfile_name" "${tagfile_name}.orig"
     cmd xsltproc --novalid --nonet -o "$tagfile_name" "$tagxsl" "${tagfile_name}.orig"
 fi
@@ -173,7 +177,7 @@ fi
 
 ## Postprocess html files, if generated
 
-if [ "$html" == "YES" ]; then
+if [ "$html" = "YES" ]; then
     for h in "$doxydir/$output_dir/$html_dir"/*.html; do
 	cmd html_cleanup "$h"
     done
diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py
index 90b51c885..1701b996f 100644
--- a/senfscons/SENFSCons.py
+++ b/senfscons/SENFSCons.py
@@ -456,16 +456,17 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
     # Rule to generate tagfile
     # (need to exclude the 'clean' case, otherwise we'll have duplicate nodes)
     if not env.GetOption('clean'):
-        env.Append(ALL_TAGFILES =
-                   env.Doxygen(doxyfile,
-                               DOXYOPTS = [ '--tagfile-name', '"${MODULE}.tag"',
-                                            '--tagfile' ],
-                               DOXYENV  = { 'TOPDIR'          : env.Dir('#').abspath,
-                                            'output_dir'      : 'doc',
-                                            'html_dir'        : 'html',
-                                            'html'            : 'NO',
-                                            'generate_tagfile': 'doc/${MODULE}.tag' },
-                               MODULE   = module )[0].abspath)
+        tagfile = env.Doxygen(doxyfile,
+                              DOXYOPTS = [ '--tagfile-name', '"${MODULE}.tag"',
+                                           '--tagfile' ],
+                              DOXYENV  = { 'TOPDIR'          : env.Dir('#').abspath,
+                                           'output_dir'      : 'doc',
+                                           'html_dir'        : 'html',
+                                           'html'            : 'NO',
+                                           'generate_tagfile': 'doc/${MODULE}.tag' },
+                              MODULE   = module )
+        env.Append(ALL_TAGFILES = tagfile[0].abspath)
+        env.Depends(tagfile, env.File('#/doclib/doxygen.sh'))
 
     # Rule to generate HTML documentation
     doc = env.Doxygen(doxyfile,
@@ -478,6 +479,7 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
                                    'output_dir'      : 'doc',
                                    'html_dir'        : 'html',
                                    'html'            : 'YES' } )
+    env.Depends(doc, env.File('#/doclib/doxygen.sh'))
 
     # Copy the extra_sources (the images) into the documentation directory
     # (need to exclude the 'clean' case otherwise there are multiple ways to clean the copies)
-- 
GitLab