#! /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 try to append to port install commands: # +universal macosx_deployment_target=10.4 universal_target=10.4 # 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.2 function init() { MAKEJOBS=3 # 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 WXBUILD="osx-build" WXDEBUGCONF='--disable-debug --enable-optimise' fi WXDIR="$WXNAME/$WXBUILD" # aMule VERSION="${VERSION:-SVN}" PRGNAME="aMule-$VERSION" GeoIPDB="/opt/local/share/GeoIP/GeoIP.dat" GEOIPOPTS='--enable-geoip --with-geoip-headers=/opt/local/include --with-geoip-lib=/opt/local/lib' BUILDER=GToso GEOIP=${GEOIP:-0} PATCH=${PATCH:-""} if [ "$VERSION" == "SVN" ]; then XML="http://amule.sourceforge.net/tarballs/tarballs.xml" revision; 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 } function compile_amule() { CFLAGS="-arch ppc -arch i386 -isysroot $SYSROOT -O2 -mmacosx-version-min=$OSMIN" \ CXXFLAGS="-arch ppc -arch i386 -isysroot $SYSROOT -O2 -mmacosx-version-min=$OSMIN" \ CPPFLAGS="-I/opt/local/include" \ LDFLAGS="-headerpad_max_install_names -L/opt/local/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=/opt/local \ --disable-dependency-tracking \ > ../$PRGNAME-configure.log 2>&1 MACOSX_DEPLOYMENT_TARGET=$OSMIN \ /usr/bin/time make -j$MAKEJOBS > ../$PRGNAME-make.log 2>&1 (cd src/utils/fileview && MACOSX_DEPLOYMENT_TARGET=$OSMIN make) >/dev/null 2>&1 } function compile_wxmac() { CFLAGS="-O2" \ CXXFLAGS="-O2" \ 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=/opt/local \ --enable-universal_binary \ --with-macosx-sdk="$SYSROOT" \ --with-macosx-version-min=$OSMIN \ > ../../$WXNAME-configure.log 2>&1 \ && MACOSX_DEPLOYMENT_TARGET=$OSMIN \ /usr/bin/time make -j$MAKEJOBS > ../../$WXNAME-make.log 2>&1 } 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 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 mkdir -p diskimage/Docs/OSXBuild cp -p ../amule-uni.OSXBuild ../mac_packager ../aMule_bundles.zip diskimage/Docs/OSXBuild/ if [ "$PATCH" ]; then cp -p "../$PATCH" diskimage/Docs/OSXBuild/ fi 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 timestamp() { if (( $(/bin/date +%k) < $RH )); then TSTAMP=$(/bin/date -r $(($(/bin/date +%s) - 3600*$RH)) +%Y%m%d); else TSTAMP=$(/bin/date +%Y%m%d); fi } 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 TIGER=0 LEOPARD=0 DEBUG=0 WXDEBUG=0 PATCHSTRIP=0 REPKG=0 for PAR in $*; do case "$PAR" in -h|--help) help exit ;; -t|--tiger) TIGER=1 ;; -l|--leopard) LEOPARD=1 ;; -d|--debug) DEBUG=1 WXDEBUG=1 ;; --debug-amule) DEBUG=1 ;; -g|--geoip) GEOIP=1 ;; -p?) PATCHSTRIP=$(echo $PAR|cut -c3-) ;; -rp|--repackage) REPKG=1 ;; esac done init sdk if ((GEOIP)); then GEOIPCONF="$GEOIPOPTS" PRGNAME="$PRGNAME-GeoIP" NSUFFIX="GeoIP-$OS-$BUILDER" else GEOIPCONF='' NSUFFIX="$OS-$BUILDER" fi if ((DEBUG)); then DEBUGCONF='--enable-debug --disable-optimize' if ((WXDEBUG)); then PRGNAME="$PRGNAME-Debug" NSUFFIX="Debug-$NSUFFIX" else PRGNAME="$PRGNAME-aDebug" NSUFFIX="aDebug-$NSUFFIX" fi else DEBUGCONF='--disable-debug --enable-optimize' fi 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"; if [ "$PATCH" ]; then patch -p$PATCHSTRIP < "../$PATCH" fi echo -n "Compiling $PRGNAME... " compile_amule echo "OK" echo "Press Return to continue..." read; else cd "$DIRNAME"; fi make_package mv "aMule-$VERSION-$NSUFFIX.dmg" .. cd .. md5 "aMule-$VERSION-$NSUFFIX.dmg" > "aMule-$VERSION-$NSUFFIX.dmg.md5"