#! /bin/bash # # amule-uni.OSXBuild - Mac OS X aMule Universal Binary BuildScript # Copyright (C) 2007,2009 Gianluca Toso # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ----------------------------------------------------------------------------- # # Tiger/Leopard OSXBuild script # =========================== # By: Gianluca Toso # For: aMule 2.2.x and SVN # Descr: multiplatform ed2k client # URL: http://www.amule.org/ # Needs: gd2(no_x11 variant), gettext, libcryptopp, libgeoip(optional), # libupnp >= 1.6.6 (optional), # pkgconfig (needed to aMule configure to find libupnp), # and libpng(already requested by gd2) # from MacPorts (or you have to edit some things). # All these and the dependences must be Universal Binary # and compiled for the right OS! # Notes: On Leopard I initially used 10.5 SDK # and 10.4 as MACOSX_DEPLOYMENT_TARGET/macosx-version-min. # It worked (libiconv and libpng from MacPorts) and # there were no weak linked libraries. # Maybe it works even with 10.5 as deployment version, # but it excludes the G3 processors and I can't test. # But I think that here it makes no sense and doesn't bring # benefits, so now I use 10.4 SDK for Tiger/Leopard buils. # On Leopard try to append to port install commands: # +universal universal_target=10.4 universal_sysroot=/Developer/SDKs/MacOSX10.4u.sdk # (the same for upgrade commands). # It seems work even with only libcryptopp, gettext # and dependencies, but libpng is needed to run on Tiger, # gdlib seems not needed, but configure warns if it's missing: # cas uses it to create the Online Signature Image. MYVER=0.2.7 function init() { MAKEJOBS=3 # Set to the same path to use only one MacPorts # http://guide.macports.org/#installing.macports.source.multiple MACPORTSTiger=/opt/local MACPORTSLeopard=/opt/local2 if [ "$OSMIN" == "10.5" ]; then MACPORTS="$MACPORTSLeopard"; else MACPORTS="$MACPORTSTiger"; fi export PATH=$MACPORTS/bin:$MACPORTS/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin # WxMac WXVER="2.8.10" WXNAME="wxMac-$WXVER" WXFILE="$WXNAME.tar.gz" WXURL="http://heanet.dl.sourceforge.net/sourceforge/wxwindows/$WXFILE" if ((WXDEBUG)); then WXBUILD="osx-build-debug" WXDEBUGCONF='--enable-debug --disable-optimise' else if [ "$FAST" ]; then WXBUILD="osx-build-$FAST" else WXBUILD="osx-build" fi WXDEBUGCONF='--disable-debug --enable-optimise' fi WXBUILD="$WXBUILD-$OSMIN" WXDIR="$WXNAME/$WXBUILD" # See http://trac.wxwidgets.org/ticket/9012 WXPATCH="textctrl_optimization.diff" WXPATCHSTRIP=0 # aMule VERSION="${VERSION:-SVN}" # SVN revision number (default the last) REV=${REV:-""} PRGNAME="aMule-$VERSION" GeoIPDB="$MACPORTSTiger/share/GeoIP/GeoIP.dat" GEOIPOPTS="--enable-geoip --with-geoip-headers=$MACPORTS/include --with-geoip-lib=$MACPORTS/lib" BUILDER=${BUILDER:+-$BUILDER} BUILDER=${BUILDER:--GToso} BUILD=${BUILD:+_$BUILD} BUILD=${BUILD:-""} DMGICON=${DMGICON:-0} GEOIP=${GEOIP:-1} # No spaces allowed in patch file name: more patches separated by spaces PATCH=${PATCH:-""} if ((DEBUG)); then # In SVN enable optimization (-O2) even in debug builds if [ "$VERSION" == "SVN" ] && ! ((WXDEBUG)); then DEBUGCONF='--enable-debug --enable-optimize' else DEBUGCONF='--enable-debug --disable-optimize' fi if ((WXDEBUG)); then NSUFFIX='Debug-' else NSUFFIX='aDebug-' fi else DEBUGCONF='--disable-debug --enable-optimize' if [ "$FAST" ]; then NSUFFIX="$FAST-" else NSUFFIX='' fi fi if ((GEOIP)); then GEOIPCONF="$GEOIPOPTS" else GEOIPCONF='' NSUFFIX="${NSUFFIX}NOGeoIP-" fi if [ "$VERSION" == "SVN" ]; then XML="http://amule.sourceforge.net/tarballs/tarballs.xml" if [ -z "$REV" ]; then revision; fi VERSION="$VERSION-r$REV" FILE="aMule-$VERSION.tar.bz2" URL="http://amule.sourceforge.net/tarballs/$FILE" PRGNAME="$PRGNAME-r$REV" DIRNAME="$PRGNAME" else FILE="$PRGNAME.tar.bz2" URL="http://surfnet.dl.sourceforge.net/sourceforge/amule/$FILE" DIRNAME="$PRGNAME" fi PRGNAME="$PRGNAME-${NSUFFIX}$OS" NSUFFIX="${NSUFFIX}${OS}${BUILDER}${BUILD}" } function compile_amule() { CC="$CC" \ CXX="$CXX" \ CFLAGS="-arch ppc -arch i386 -isysroot $SYSROOT -mmacosx-version-min=$OSMIN $MYFLAGS" \ CXXFLAGS="-arch ppc -arch i386 -isysroot $SYSROOT -mmacosx-version-min=$OSMIN $MYFLAGS" \ CPPFLAGS="-I$MACPORTS/include" \ LDFLAGS="-headerpad_max_install_names -L$MACPORTS/lib" \ MACOSX_DEPLOYMENT_TARGET=$OSMIN \ /usr/bin/time ./configure \ $DEBUGCONF \ --enable-amulecmd \ --enable-webserver \ --enable-cas \ --enable-alcc \ --enable-amule-daemon \ --enable-amule-gui \ --enable-wxcas \ --enable-alc \ $GEOIPCONF \ --with-wxdir=../$WXDIR \ --with-crypto-prefix=$MACPORTS \ --disable-dependency-tracking \ > ../$PRGNAME-configure.log 2>&1 MACOSX_DEPLOYMENT_TARGET=$OSMIN \ /usr/bin/time make -j$MAKEJOBS > ../$PRGNAME-make.log 2>&1 echo -e "\n\nfileview:\n" >> ../$PRGNAME-make.log (cd src/utils/fileview && MACOSX_DEPLOYMENT_TARGET=$OSMIN make) >> ../$PRGNAME-make.log 2>&1 } function compile_wxmac() { CC="$CC" \ CXX="$CXX" \ CFLAGS="$MYFLAGS" \ CXXFLAGS="$MYFLAGS" \ MACOSX_DEPLOYMENT_TARGET=$OSMIN \ /usr/bin/time ../configure \ --disable-shared \ --enable-unicode \ --with-opengl \ $WXDEBUGCONF \ --disable-compat26 \ --with-libjpeg=builtin \ --with-libpng=builtin \ --with-regex=builtin \ --with-libtiff=builtin \ --with-zlib=builtin \ --with-expat=builtin \ --with-libiconv-prefix=$MACPORTS \ --enable-universal_binary \ --with-macosx-sdk="$SYSROOT" \ --with-macosx-version-min=$OSMIN \ > ../../${WXNAME}_$WXBUILD-configure.log 2>&1 \ && MACOSX_DEPLOYMENT_TARGET=$OSMIN \ /usr/bin/time make -j$MAKEJOBS > ../../${WXNAME}_$WXBUILD-make.log 2>&1 # SVN versions require 2.6 compatibility (tested on r9602, r9623), # so to compile SVN versions you may need to remove "--disable-compat26" # or to patch muuli_wdr.cpp } function wxmac() { if [ ! -x $WXDIR/wx-config ]; then if [ ! -d $WXNAME ]; then if ! [ -f $WXFILE ]; then echo "Source $WXFILE not available yet:" download $WXURL fi; tar xfz $WXFILE for PATCHFILE in $WXPATCH; do (cd $WXNAME && patch -p$WXPATCHSTRIP < "../$PATCHFILE") || false done fi rm -rf $WXDIR mkdir $WXDIR echo -n "Compiling $WXNAME... " (cd $WXDIR; compile_wxmac) || false echo "OK" fi } function make_package() { rm -f aMule.app/Icon unzip ../aMule_bundles.zip > /dev/null for i in *.app; do ../mac_update-appver "$i" "$VERSION" >/dev/null 2>/dev/null || true done mkdir -p diskimage/Docs/OSXBuild cp -p ../amule-uni.OSXBuild ../mac_packager ../mac_update-appver ../aMule_bundles.zip diskimage/Docs/OSXBuild/ for PATCHFILE in $PATCH $WXPATCH; do cp -p "../$PATCHFILE" diskimage/Docs/OSXBuild/ done cp -p ../ReadMe.GToso.txt ../LEGGIMI.GToso.txt diskimage/ 2>/dev/null || true if ((GEOIP)); then mkdir -p aMule.app/Contents/Resources/GeoIP mkdir -p aMuleGUI.app/Contents/Resources/GeoIP cp -p $GeoIPDB aMule.app/Contents/Resources/GeoIP/ cp -p $GeoIPDB aMuleGUI.app/Contents/Resources/GeoIP/ fi DOZIP=0 DODMG=1 VERSION="$VERSION" NSUFFIX="$NSUFFIX" ../mac_packager 2>&1 | tee ../$PRGNAME-mac_packager.log } function revision() { REV=$(expr "$(curl -RsS $XML | grep ' /dev/null 2>&1); then wget -nv $1 else /usr/bin/curl -RsS -O $1 fi; } function help() { cat <=1.6.6, optional) from MacPorts. All these and the dependences must be Universal Binary and compiled for the right OS. You may need to edit some things in the init function. EOF } # Exit the script on errors: set -e trap 'echo "$0 FAILED at line ${LINENO}" | tee $PRGNAME-error.log' ERR # Catch unitialized variables: set -u LEOPARD=0 DEBUG=0 WXDEBUG=0 PATCHSTRIP=0 REPKG=0 MYFLAGS="" FAST="" for PAR in $*; do case "$PAR" in -h|--help) help exit ;; -l|--leopard) LEOPARD=1 ;; --fast) MYFLAGS="-fast" FAST="FastG5+" ;; --fast-g4) MYFLAGS="-fast -Xarch_ppc -mcpu=7450" FAST="FastG4+" ;; -d|--debug) DEBUG=1 WXDEBUG=1 ;; -da|--debug-amule) DEBUG=1 ;; -ng|--no-geoip) GEOIP=0 ;; -p?) PATCHSTRIP=$(echo $PAR|cut -c3-) ;; -rp|--repackage) REPKG=1 ;; esac done ((DEBUG)) && MYFLAGS="" && FAST=""; sdk init if ! ((REPKG)); then wxmac if ! [ -f $FILE ]; then echo "Source $FILE not available yet:" download $URL fi; rm -rf "$DIRNAME" tar xfj "$FILE" cd "$DIRNAME"; for PATCHFILE in $PATCH; do patch -p$PATCHSTRIP < "../$PATCHFILE" done echo -n "Compiling $PRGNAME... " compile_amule echo "OK" if [ -e ../diskimage.tar.gz ]; then tar xzf ../diskimage.tar.gz DMGICON=1; fi echo "Press Return to continue..." read; else cd "$DIRNAME"; fi # Very dirty if ((DMGICON)); then ( i=0; while [ $i -lt 90 ]; do if [ -w /Volumes/aMule ]; then SetFile -a C /Volumes/aMule; i=90; else sleep 1; let ++i; fi; done; )& fi make_package mv "aMule-$VERSION-$NSUFFIX.dmg" .. cd .. md5 "aMule-$VERSION-$NSUFFIX.dmg" > "aMule-$VERSION-$NSUFFIX.dmg.md5"