Recursive lipo wrapper
Левашев Иван
octagram at bluebottle.com
Thu Dec 20 18:41:19 PST 2007
Hello, everybody.
I thought you may find it useful.
This script is used to glue up tho whole directory trees.
Recommended way of creating universal binaries is
compiling with "-arch ppc -arch i386". However, it is
only applicable to (Objective-)C(++). This script aims
to aid Universal Binary development in Ada. Programs
in this beautiful language were distributed separatelly
ppc and i386. You are free to use it in the way you like.
Usage:
lipo-r startdir "arch1 arch2 ..." unidir
startdir must contain subdirectories named arch1, arch2,
etc. Resuling directory tree will reside in unidir.
For example:
lipo-r cairo/out "ppc i386" cairo/out/uni
My script handles :
a) space-containing filenames
b) symbolic links
c) text and byte-compiled files are just copied
Notice that lipo can glue up everything without
any warning. Header files will be no longer usable,
for example. I should probably match word "Mach-O",
not "text" or "byte-compiled". I place the original
script here because it worked for me. I've managed to
build many packages this way. (I was glueing only install-exec
files; make install-data was done separatelly). It's a working
piece of code. You are free to improve it if you like.
My script does not handle :
a) when directory trees are not identical
b) files that are neither Mach-O nor text nor byte-compiled
(images, for example) It will glue them up.
LIPO_DEBUG=echo lipo-r args... | less
can give you idea about what is to be done.
#!/bin/bash
# Ivan Levashew, 5 Dec 2007
# Public Domain License
# Free to use in any way, personal or commercial
# Usage:
# lipo-r startdir "arch1 arch2 ..." unidir
for i in $2; do
REF_ARCH="$i"
break
done
ref_root="$1/$REF_ARCH"
#LIPO_DEBUG="echo"
lipo_internal () {
local i j l
$LIPO_DEBUG mkdir -p "$3$4"
for i in "${ref_root}$4"/*; do
j="${i:${#ref_root}}"
if [ -d "$i" ]; then
lipo_internal "$1" "$2" "$3" "$j"
elif [ -L "$i" ]; then
$LIPO_DEBUG ln -s "`readlink "$i"`" "$3$j"
else
((file -b "$i" | grep -q text) || (file -b "$i" | grep -q byte-compiled)) && {
$LIPO_DEBUG cp "$i" "$3$j"
} || {
unset k
local -a k
for l in $2; do
k[${#k[@]}]="-arch"
k[${#k[@]}]="$l"
k[${#k[@]}]="$1/$l$j"
done
$LIPO_DEBUG lipo -create "${k[@]}" -output "$3$j"
}
fi
done
}
lipo_internal "$1" "$2" "$3"
--
If you want to get to the top, you have to start at the bottom
More information about the macports-dev
mailing list