newlib/winsup/doc/xidepend
Jon TURNEY 2ef3009068 winsup/doc: Fix xidepend to handle relative pathnames
It seems that xidepend doesn't work correctly if we are ./configure'd using a
relative pathname to the srcdir:

$ make
cd ../../../../src/winsup/doc && ./xidepend ../../../../src/winsup/doc/cygwin-ug-net.xml ../../../../src/winsup/doc/cygwin-api.xml >"/wip/cygwin/build/x86_64-unknown-cygwin/winsup/doc/Makefile.dep"
grep: ../../../../src/winsup/doc/cygwin-ug-net.xml: No such file or directory
grep: ../../../../src/winsup/doc/cygwin-api.xml: No such file or directory

Although it might be better to fix this by making xidepend use pathnames, rather
than ignoring them and assuming everything is in the current directory...

2015-06-12  Jon Turney  <jon.turney@dronecode.org.uk>

	* xidepend: Fix to handle relative pathnames.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-06-16 10:13:29 +01:00

36 lines
909 B
Bash
Executable File

#!/bin/sh
if [ "$1" = "-r" ]
then
# We're being called recursively by another xidepend instance, so
# suppress outputs that only happen at the top level.
shift
subproc=1
else
subproc=0
fi
for f in "$@"
do
f=`basename "$f"`
if fgrep -q 'xi:include' "$f"
then
# This file uses XIncludes. Let's chase its deps recursively.
base=`basename "$f" .xml`
if [ $subproc -eq 0 ] ; then echo -n "$base/$base.html $base/$base.pdf:" ; fi
deps=`grep 'xi:include.*href' "$f" | cut -f2 -d\" | tr '\n' ' '`
echo -n " $deps"
for d in $deps
do
# Call ourselves recursively to continue to collect deps.
# The -r flag tells our subprocess that it is merely
# contributing to a dependency line in progress.
$0 -r $d
done
# If we're at the top recursion level, we have nothing else to
# add to this dependency line other than the newline.
if [ $subproc -eq 0 ] ; then echo ; fi
fi
done