rewrote buildForMac

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

@ -1,92 +1,61 @@
#!/bin/bash #!/bin/bash
## ##
# buildForMac <configure-options> # 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="" LION=""
(echo $OSTYPE | grep 11) > /dev/null let os=$(uname -a | cut -d' ' -f 3 | cut -d'.' -f 1)
if [ $? == 0 ]; then if [ $(( os >= 11 )) ]; then
LION="--with-zlib=/usr/lib" LION="--with-zlib=/usr/lib"
fi fi
# b=`basename "${PWD}"`
if [ ! -d contrib ]; then if [ ! -d contrib ]; then
echo "you are in the wrong directory - please run $0 in the main directory (which includes contrib and src)" echo "you are in the wrong directory - please run $0 in the main directory (which includes contrib and src)"
exit 1 exit 1
fi fi
TARGET="MACOSX_DEPLOYMENT_TARGET=10.5" 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
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 ----------------------
}
# version=$(grep EXIV2_LTVERSION config/config.mk | cut "-d " -f 3 | cut -d: -f 1)
# lib=libexiv2.$version.dylib
build() { build() {
make clean make clean
./configure CFLAGS="$arch" CXXFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET $LION "$@" ./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 if [ "$?" != "0" ]; then
echo build failed echo build failed
exit exit
fi fi
props $APP
props $LIB
} }
##
# build one architecture at a time
for arch in '-arch i386' '-arch x86_64' ; do for arch in '-arch i386' '-arch x86_64' ; do
if [ "$arch" == "-arch i386" ]; then echo arch = $arch
build "$@" a=${arch:5:100}
rm -rf app.i386 lib.i386 build "$@"
cp $APP app.i386
cp $LIB lib.i386 ##
elif [ "$arch" == "-arch x86_64" ]; then # copy .libs to .arch
build "$@" for d in $(find . -name ".libs" -type d); do
rm -rf app.x86_64 lib.x86_64 D=$(dirname $d)/.$a
cp $APP app.x86_64 # echo --------------
cp $LIB lib.x86_64 # echo d = $d D = $D
fi # echo --------------
ditto $d $D
done
done done
LIB=./src/.libs/$lib ##
APP=./src/.libs/$app # combine the builds into a universal
$(dirname $0)/makeUniversal
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
props $LIB
props $APP
# That's all Folks! # 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