summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmkmultiarch12
1 files changed, 12 insertions, 0 deletions
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 <multiarch-dispatch.h>
EOF
}
+
+ # done with this file
+ rm -f $tag
}
while [[ $# -gt 0 ]]; do