summaryrefslogtreecommitdiffstats
path: root/mkmultiarch
diff options
context:
space:
mode:
Diffstat (limited to 'mkmultiarch')
-rwxr-xr-xmkmultiarch58
1 files changed, 58 insertions, 0 deletions
diff --git a/mkmultiarch b/mkmultiarch
new file mode 100755
index 0000000..8f25e48
--- /dev/null
+++ b/mkmultiarch
@@ -0,0 +1,58 @@
+#!/bin/bash
+#---------------------------------------------------------------
+# Project : Mandrakelinux
+# Module : multiarch-utils
+# File : mkmultiarch
+# Version : $Id$
+# Author : Gwenole Beauchesne
+# Created On : Wed Jan 12 10:54:10 CET 2005
+#---------------------------------------------------------------
+
+usage="Usage: $0 <binaries|includes> <file1> [<file2> ...]"
+mplat=`multiarch-platform`
+type=$1
+case $type in
+ binaries|includes) shift;;
+ *) echo $usage; exit 1;;
+esac
+
+function error() {
+ echo ${1+"$@"} > /dev/stderr
+ exit 1
+}
+
+function dispatch_binaries() {
+ local file=$1
+ local bindir=`dirname $file`
+ local archbindir=$bindir/$mplat
+ [[ -d $archbindir ]] || mkdir -p $archbindir
+ mv $file $archbindir/
+ ln -s /usr/bin/multiarch-dispatch $file
+}
+
+function dispatch_includes() {
+ local file=$1
+ local incdir=`dirname $file`
+ local prefix=`echo $incdir | sed -n '/\(.*\/include\)\/.*/s//\1/p'`
+ [[ -z "$prefix" ]] && error "Unsupported includedir $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
+ local archincdir=$prefix/$mplat/$suffix
+ [[ -d $archincdir ]] || mkdir -p $archincdir
+ mv $file $archincdir/
+ cat > $file << EOF
+#define _MULTIARCH_HEADER $suffix${file##*/}
+#include <multiarch-dispatch.h>
+EOF
+}
+
+while [[ $# -gt 0 ]]; do
+ dispatch_$type $1
+ shift
+done