rewrote buildForMac

added makeUniversal
v0.27.3
Robin Mills 13 years ago
parent cc4ab82ace
commit 201ae6f2ed

@ -2,91 +2,60 @@
##
# buildForMac <configure-options>
# example: contrib/buildForMac --disable-shared
# example: contrib/buildForMac --[dis|en]able-shared
#
# On Lion:
# contrib/buildForMac --with-zlib=/usr/lib
# 11 == `uname -a | cut '-d ' -f 3 | cut '-d.' -f 1`
##
##
# test OS level (L=9 SL==10 Lion = 11, ML=12)
LION=""
(echo $OSTYPE | grep 11) > /dev/null
if [ $? == 0 ]; then
let os=$(uname -a | cut -d' ' -f 3 | cut -d'.' -f 1)
if [ $(( os >= 11 )) ]; then
LION="--with-zlib=/usr/lib"
fi
# b=`basename "${PWD}"`
if [ ! -d contrib ]; then
echo "you are in the wrong directory - please run $0 in the main directory (which includes contrib and src)"
exit 1
fi
TARGET="MACOSX_DEPLOYMENT_TARGET=10.5"
version=`grep EXIV2_LTVERSION config/config.mk | cut "-d " -f 3 | cut -d: -f 1`
lib=libexiv2.$version.dylib
echo
echo -----------------------------
echo version = $version
echo lib = $lib
echo -----------------------------
echo
app=exiv2
LIB=./src/.libs/$lib
APP=./src/.libs/$app
for option in "$@" ; do
if [ "$option" == --disable-shared ]; then
lib=libexiv2.a
LIB=./src/.libs/$lib
APP=./src/$app
fi
done
props() {
ls -alt $*
lipo -info $*
otool -L $*
echo ----------------------
}
if [ -z $TARGET ]; then export TARGET="MACOSX_DEPLOYMENT_TARGET=10.5" ; fi
# version=$(grep EXIV2_LTVERSION config/config.mk | cut "-d " -f 3 | cut -d: -f 1)
# lib=libexiv2.$version.dylib
build() {
make clean
./configure CFLAGS="$arch" CXXFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET $LION "$@"
make CFLAGS="$arch" CXXFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET
make CFLAGS="$arch" CXXFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET all
# make CFLAGS="$arch" CXXFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET samples
if [ "$?" != "0" ]; then
echo build failed
exit
fi
props $APP
props $LIB
}
##
# build one architecture at a time
for arch in '-arch i386' '-arch x86_64' ; do
if [ "$arch" == "-arch i386" ]; then
echo arch = $arch
a=${arch:5:100}
build "$@"
rm -rf app.i386 lib.i386
cp $APP app.i386
cp $LIB lib.i386
elif [ "$arch" == "-arch x86_64" ]; then
build "$@"
rm -rf app.x86_64 lib.x86_64
cp $APP app.x86_64
cp $LIB lib.x86_64
fi
done
LIB=./src/.libs/$lib
APP=./src/.libs/$app
env $TARGET lipo -arch i386 lib.i386 -arch x86_64 lib.x86_64 -create -output $LIB
env $TARGET lipo -arch i386 app.i386 -arch x86_64 app.x86_64 -create -output $APP
##
# copy .libs to .arch
for d in $(find . -name ".libs" -type d); do
D=$(dirname $d)/.$a
# echo --------------
# echo d = $d D = $D
# echo --------------
ditto $d $D
done
done
props $LIB
props $APP
##
# combine the builds into a universal
$(dirname $0)/makeUniversal
# That's all Folks!
##

@ -0,0 +1,28 @@
#!/bin/bash
##
# makeUniversal - combine .i386 and .x86_64 build results into .libs
# this script is called by buildForMac
##
##
# search for directories called .x86_64
# run every file and lipo .x86_64/file .x86_64/file -> .libs/file
for D in $(find . -name ".x86_64"); do
for F in $(find $(dirname $D)/.x86_64 -type f); do
f=$(echo $F | sed -E -e "s/.x86_64/.i386/")
U=$(echo $F | sed -E -e "s/.x86_64/.libs/")
if [[ -e $f && -e $F ]]; then
# echo $F $f -> $U
lipo -arch i386 $f -arch x86_64 $F -create -output $U
if [ $? != '0' ]; then
echo FAILED lipo -arch i386 $f -arch x86_64 $F -create -output $U
else
echo $U $(lipo -info $U|sed -E -e "s/Architectures in the fat file://" -e "s/ are:/ : /") $(stat $U | cut -d' ' -f 2)
fi
fi
done
done
# That's all Folks!
##
Loading…
Cancel
Save