From cf462649e3ac7c5d5f92a791707c231ea8d107b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwenol=C3=A9=20Beauchesne?= Date: Mon, 31 Jan 2005 22:59:19 +0000 Subject: handle ciruclar inclusions (e.g. gd.h) --- mkmultiarch | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mkmultiarch b/mkmultiarch index ec657c6..502884f 100755 --- a/mkmultiarch +++ b/mkmultiarch @@ -53,16 +53,25 @@ function dispatch_binaries() { function dispatch_includes() { local file=$1 local incdir=`dirname $file` + + # handle circular inclusions + local tag=$incdir/.multiarch-processing.${file##*/} + [[ -f "$tag" ]] && return + touch $tag + + # sanity checks, extract path parts echo $file | grep -q '/include/' || error "Unsupported includedir $incdir" local prefix=`echo $incdir | sed -n '/\(.*\/include\)\/.*/s//\1/p'` [[ -z "$prefix" ]] && prefix="$incdir" local suffix=`echo $incdir | sed -n '/.*\/include\/\(.*\)/s//\1/p'` [[ -n "$suffix" ]] && suffix="$suffix/" + # dispatch nested includes expected in local directory sed -n '/^#[ \t]*include[ \t]*"\([^"][^"]*\)".*/s//\1/p' $file | \ while read localfile; do [[ -f "$incdir/$localfile" ]] && dispatch_includes $incdir/$localfile done + # dispatch selected include file, provided it's not already dispatched grep -q _MULTIARCH_HEADER $file || { local archincdir=$prefix/$mplat/$suffix @@ -73,6 +82,9 @@ function dispatch_includes() { #include EOF } + + # done with this file + rm -f $tag } while [[ $# -gt 0 ]]; do -- cgit v1.2.1