diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2005-01-12 17:22:02 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2005-01-12 17:22:02 +0000 |
commit | ce5c270d5bce8ef9b9ff280338d577483bff03da (patch) | |
tree | e0239736b0ea4d11193de48bc1a94cebcf6f95c7 /mkmultiarch | |
parent | 3db240e64d3c941d2dcf6c1bce879922b28777d8 (diff) | |
download | multiarch-utils-topic/first-version.tar multiarch-utils-topic/first-version.tar.gz multiarch-utils-topic/first-version.tar.bz2 multiarch-utils-topic/first-version.tar.xz multiarch-utils-topic/first-version.zip |
Initial revisionfirst-releasetopic/first-version
Diffstat (limited to 'mkmultiarch')
-rwxr-xr-x | mkmultiarch | 58 |
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 |