MacOSX build script: Change defaults to SDK 10.6, i386 only. And add building aMuleGUI.
[amule.git] / src / utils / scripts / MacOSX / full_build.sh
blob0e810633b18813ccaeb53118a04c9408ab168cce
1 #!/bin/bash
2 ##################################################
3 # aMule.app bundle creator. #
4 ##################################################
6 ## This file is part of the aMule Project
7 ##
8 ## Copyright (c) 2011 Angel Vidal ( kry@amule.org )
9 ##
10 ## This program is free software; you can redistribute it and/or
11 ## modify it under the terms of the GNU General Public License
12 ## as published by the Free Software Foundation; either
13 ## version 2 of the License, or (at your option) any later version.
15 ## This program is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with this program; if not, write to the Free Software
22 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 SCRIPTDIR=`dirname "$0"`
25 SCRIPTNAME=`basename "$0"`
27 ## Get full path
28 SCRIPTDIR=`cd $SCRIPTDIR; pwd`
30 PATH="$SCRIPTDIR:$PATH"
32 . defs-global.sh $1
33 . defs-wx.sh
34 . defs-functions.sh
36 echo "Start" > $STDOUT_FILE
37 echo "Start" > $ERROR_FILE
39 REPEATSCRIPT=${ROOT_FOLDER}/repeat.sh
40 if [ -f $REPEATSCRIPT ]; then
41 chmod 600 $REPEATSCRIPT
43 echo "Save configuration commandline to ${REPEATSCRIPT} - execute that script to repeat this compilation with the same options."
44 echo "#!/bin/bash" > $REPEATSCRIPT
45 echo "echo \"Starting repeat, moving away current repeat.sh\"" >> $REPEATSCRIPT
46 echo "rm -rf \${0}.old 2>/dev/null; mv \$0 \${0}.old" >> $REPEATSCRIPT
47 if [ x"$SDKNUMBER" == x"" ]; then
48 SDKSTRING="default"
49 else
50 SDKSTRING=$SDKNUMBER
53 echo "BUILDARCHS=\"${BUILDARCHS}\" SDKNUMBER=\"${SDKSTRING}\" UNIVERSAL=\"${UNIVERSAL}\" WXVERSION=\"${WXVERSION}\" WXPORT=\"${WXPORT}\" SLIMWX=\"${SLIMWX}\" BUILD_FOLDER=\"${BUILD_FOLDER}\" $0" >> $REPEATSCRIPT
54 echo "echo \"Repeat finished\"" >> $REPEATSCRIPT
55 chmod 500 $REPEATSCRIPT
57 echo "Starting build..."
59 echo -e "\tGetting aMule sources..."
61 #Get aMule first, because it may contain patches
62 if [ -d $AMULE_FOLDER/ ]; then
63 if [ -d ${AMULE_FOLDER}/.svn/ ]; then
64 echo -e "\t\tSources already exist, updating."
65 pushd $AMULE_FOLDER/ >> $STDOUT_FILE
66 svn up >> $STDOUT_FILE
67 popd >> $STDOUT_FILE
68 else
69 echo -e "\t\taMule sources at \"" $AMULE_FOLDER "\" are not from SVN checkout, so not updating."
71 else
72 echo -e "\tFirst checkout."
73 if [ "$SVN_REPOSITORY" == "public" ]; then
74 SVN_REPOSITORY=http://amule.googlecode.com/svn/trunk/
75 echo -e "\tUsing public SVN repository at ${SVN_REPOSITORY}."
76 else
77 echo -e "\tUsing provided SVN repository at ${SVN_REPOSITORY}."
80 svn co $SVN_REPOSITORY $AMULE_FOLDER >> $STDOUT_FILE
81 if [ ! -d $AMULE_FOLDER/ ]; then
82 echo "ERROR: aMule sources could not be retrieved. Review your settings."
83 exit
87 pushd $ROOT_FOLDER >> $STDOUT_FILE
89 echo -e "\tDone"
91 echo -e "\tGetting wxWidgets sources..."
93 if [ -d ${WXFOLDER} ]; then
94 pushd ${WXFOLDER} >> $STDOUT_FILE
95 svn up >> $STDOUT_FILE 2>> $ERROR_FILE
96 popd >> $STDOUT_FILE
97 else
98 echo -e "\tFirst checkout."
99 svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/${WXSVNROOT} ${WXFOLDER} >> $STDOUT_FILE 2>> $ERROR_FILE
100 pushd ${WXFOLDER} >> $STDOUT_FILE
101 echo -e "\tApplying patches."
102 for i in $AMULE_FOLDER/src/utils/patches/wxWidgets/*.patch; do
103 echo -e "\t\tAppying \"$i\""
104 patch -p0 < $i >> $STDOUT_FILE 2>> $ERROR_FILE
105 done
106 popd >> $STDOUT_FILE
108 echo -e "\tDone"
110 echo -e "\tConfiguring wxWidgets..."
112 pushd ${WXFOLDER} > $STDOUT_FILE
114 if [ "$SDKNUMBER" == "" ]; then
115 WX_SDK_FLAGS=""
116 else
117 WX_SDK_FLAGS="--with-macosx-sdk=/Developer/SDKs/MacOSX${SDKRELEASE}.sdk \
118 --with-macosx-version-min=$SDKNUMBER"
121 if [ -e amulewxcompilation ]; then
122 echo -e "\t\twxWidgets is already configured"
123 else
124 make clean >> $STDOUT_FILE 2>/dev/null
125 ./configure CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION \
126 CFLAGS="$CFLAGS $ARCHCPPFLAGS" CXXFLAGS="$CXXFLAGS $ARCHCPPFLAGS" CPPFLAGS="$CPPFLAGS $ARCHCPPFLAGS" \
127 LDFLAGS="$LDFLAGS $ARCHCPPFLAGS" \
128 OBJCFLAGS="$OBJCFLAGS $ARCHCPPFLAGS" OBJCXXFLAGS="$OBJCXXFLAGS $ARCHCPPFLAGS" \
129 --enable-debug --disable-shared \
130 $EXTRA_WXFLAGS \
131 $ARCHCONFIGFLAGS \
132 $WX_SDK_FLAGS >> $STDOUT_FILE 2>> $ERROR_FILE
133 touch amulewxcompilation >> $STDOUT_FILE
134 echo -e "\t\tConfigured."
137 echo -e "\t\tDone"
139 echo -e "\tCompiling wxWidgets..."
141 make >> $STDOUT_FILE 2>> $ERROR_FILE
143 echo -e "\tDone"
145 popd >> $STDOUT_FILE
147 CRYPTOPP_FOLDER="cryptopp-source"
148 CRYPTOPP_FOLDER_INST="cryptopp"
149 CRYPTOPP_URL=`curl -sS http://www.cryptopp.com/ | grep -oE "http://.*/cryptopp/cryptopp[0-9]+\.zip" | sort -r | head -1`
151 echo -e "\tGetting cryptopp sources..."
153 if [ -d $CRYPTOPP_FOLDER_INST ]; then
154 echo -e "\t\t$CRYPTOPP_FOLDER_INST already exists, skipping (delete and rerun script to get new sources)"
155 else
156 mkdir $CRYPTOPP_FOLDER
157 mkdir $CRYPTOPP_FOLDER_INST
158 curl -L -o cryptopp.zip $CRYPTOPP_URL >> $STDOUT_FILE 2>> $ERROR_FILE
159 unzip cryptopp.zip -d $CRYPTOPP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
160 pushd $CRYPTOPP_FOLDER >> $STDOUT_FILE
161 #./configure
162 for i in $AMULE_FOLDER/src/utils/patches/cryptopp/*.patch; do
163 echo -e "\t\tAppying \"$i\""
164 patch -p0 < $i >> $STDOUT_FILE 2>> $ERROR_FILE
165 done
166 #cp ../GNUMakefile .
167 echo -e "\t\tCompiling cryptopp..."
168 CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION \
169 CXXFLAGS="-pthread $ARCHCPPFLAGS $SDK" CFLAGS="-pthread $ARCHCPPFLAGS $SDK" LDFLAGS="-pthread $SDK" make > $STDOUT_FILE 2> $ERROR_FILE
170 PREFIX=${ROOT_FOLDER}/$CRYPTOPP_FOLDER_INST make install >> $STDOUT_FILE 2>> $ERROR_FILE
171 popd >> $STDOUT_FILE
172 rm cryptopp.zip >> $STDOUT_FILE 2>> $ERROR_FILE
173 rm -rf $CRYPTOPP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
176 echo -e "\tDone"
178 # Gettext
180 echo -e "\tGetting gettext sources..."
182 GETTEXT_FOLDER="gettext-source"
183 GETTEXT_FOLDER_INST="gettext-inst"
184 GETTEXT_URL=`curl -sS http://www.gnu.org/software/gettext/ | grep -m 1 -oE "http://[^\"]+/gettext-([0-9]+\.)+tar.gz" | head -1`
186 if [ -d $GETTEXT_FOLDER_INST ]; then
187 echo -e "\t\t$GETTEXT_FOLDER_INST already exists, skipping"
188 else
189 mkdir $GETTEXT_FOLDER
190 mkdir $GETTEXT_FOLDER_INST
191 curl -L -o gettext.tar.gz $GETTEXT_URL >> $STDOUT_FILE 2>> $ERROR_FILE
192 pushd $GETTEXT_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
193 echo -e "\t\tCompiling gettext..."
194 tar --strip-components 1 -zxf ../gettext.tar.gz >> $STDOUT_FILE 2>> $ERROR_FILE
195 ./configure CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION CXXFLAGS="-pthread $ARCHCPPFLAGS $SDK" \
196 CFLAGS="-pthread $ARCHCPPFLAGS $SDK" LDFLAGS="-pthread $SDK" \
197 --disable-debug --disable-shared --prefix=${ROOT_FOLDER}/$GETTEXT_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
198 make >> $STDOUT_FILE 2>> $ERROR_FILE
199 make install >> $STDOUT_FILE 2>> $ERROR_FILE
200 popd >> $STDOUT_FILE 2>> $ERROR_FILE
201 rm gettext.tar.gz >> $STDOUT_FILE 2>> $ERROR_FILE
202 rm -rf $GETTEXT_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
205 echo -e "\tDone."
207 #libupnp
209 echo -e "\tGetting libupnp sources..."
211 LIBUPNP_FOLDER="libupnp-source"
212 LIBUPNP_FOLDER_INST="libupnp-inst"
213 LIBUPNP_URL=`curl -sS http://sourceforge.net/projects/pupnp/files/ | grep -m 1 -ioE "http://sourceforge.net/[^\"]+/libupnp-([0-9]+\.)+tar.bz2/download" | head -1`
215 if [ -d $LIBUPNP_FOLDER_INST ]; then
216 echo -e "\t\t$LIBUPNP_FOLDER_INST already exists, skipping"
217 else
218 mkdir $LIBUPNP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
219 mkdir $LIBUPNP_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
220 curl -L -o libupnp.tar.bz2 $LIBUPNP_URL >> $STDOUT_FILE 2>> $ERROR_FILE
221 pushd $LIBUPNP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
222 echo -e "\t\tCompiling libupnp..."
223 tar --strip-components 1 -jxf ../libupnp.tar.bz2 >> $STDOUT_FILE 2>> $ERROR_FILE
224 ./configure CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION CXXFLAGS="-pthread $ARCHCPPFLAGS $SDK" \
225 CFLAGS="-pthread $ARCHCPPFLAGS $SDK" LDFLAGS="-pthread $SDK" --disable-dependency-tracking \
226 --disable-debug --disable-shared --prefix=${ROOT_FOLDER}/$LIBUPNP_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
227 make >> $STDOUT_FILE 2>> $ERROR_FILE
228 make install >> $STDOUT_FILE 2>> $ERROR_FILE
229 popd >> $STDOUT_FILE 2>> $ERROR_FILE
230 rm libupnp.tar.bz2 >> $STDOUT_FILE 2>> $ERROR_FILE
231 rm -rf $LIBUPNP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
234 echo -e "\tDone."
236 #geoip
238 echo -e "\tGetting GeoIP sources..."
240 LIBGEOIP_FOLDER="libgeoip-source"
241 LIBGEOIP_FOLDER_INST="libgeoip-inst"
242 LIBGEOIP_URL="http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz"
244 if [ -d $LIBGEOIP_FOLDER_INST ]; then
245 echo -e "\t\t$LIBGEOIP_FOLDER_INST already exists, skipping"
246 else
247 mkdir $LIBGEOIP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
248 mkdir $LIBGEOIP_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
249 curl -L -o libgeoip.tar.gz $LIBGEOIP_URL >> $STDOUT_FILE 2>> $ERROR_FILE
250 pushd $LIBGEOIP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
251 echo -e "\t\tCompiling GeoIP..."
252 tar --strip-components 2 -zxf ../libgeoip.tar.gz >> $STDOUT_FILE 2>> $ERROR_FILE
253 ./configure CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION CXXFLAGS="-pthread $ARCHCPPFLAGS $SDK" \
254 CFLAGS="-pthread $ARCHCPPFLAGS $SDK" LDFLAGS="-pthread $SDK" --disable-dependency-tracking \
255 --disable-debug --disable-shared --prefix=${ROOT_FOLDER}/$LIBGEOIP_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
256 make >> $STDOUT_FILE 2>> $ERROR_FILE
257 make install >> $STDOUT_FILE 2>> $ERROR_FILE
258 popd >> $STDOUT_FILE 2>> $ERROR_FILE
259 rm libgeoip.tar.gz >> $STDOUT_FILE 2>> $ERROR_FILE
260 rm -rf $LIBGEOIP_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
263 echo -e "\tDone."
265 #pkg-config
267 echo -e "\tGetting pkg-config sources..."
269 PKGCFG_FOLDER="pkgcfg-source"
270 PKGCFG_FOLDER_INST="pkgcfg-inst"
271 # pkgconfig introduced a dependency on glib to build on 0.26, and I refuse to build the whole glib for this.
272 # On top of it, glib uses pkgconfig to configure itself...
273 #PKGCFG_FILE=`curl -sS http://pkgconfig.freedesktop.org/releases/ | grep -ioE "pkg-config-([0-9]+\.)+tar.gz" | uniq | sort -r | head -1`
274 #PKGCFG_URL="http://pkgconfig.freedesktop.org/releases/${PKGCFG_FILE}"
275 PKGCFG_URL="http://pkgconfig.freedesktop.org/releases/pkg-config-0.25.tar.gz"
277 if [ -f $PKGCFG_FOLDER_INST/bin/pkg-config ]; then
278 echo -e "\t\t$PKGCFG_FOLDER_INST already exists, skipping"
279 else
280 mkdir $PKGCFG_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
281 mkdir $PKGCFG_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
282 curl -L -o pkgcfg.tar.gz $PKGCFG_URL >> $STDOUT_FILE 2>> $ERROR_FILE
283 pushd $PKGCFG_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
284 echo -e "\t\tCompiling pkg-config..."
285 tar --strip-components 1 -zxf ../pkgcfg.tar.gz >> $STDOUT_FILE 2>> $ERROR_FILE
286 ./configure CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION CXXFLAGS="-pthread $ARCHCPPFLAGS $SDK" \
287 CFLAGS="-pthread $ARCHCPPFLAGS $SDK" LDFLAGS="-pthread $SDK" --disable-dependency-tracking \
288 --disable-debug --disable-shared --prefix=${ROOT_FOLDER}/$PKGCFG_FOLDER_INST >> $STDOUT_FILE 2>> $ERROR_FILE
289 make >> $STDOUT_FILE 2>> $ERROR_FILE
290 make install >> $STDOUT_FILE 2>> $ERROR_FILE
291 popd >> $STDOUT_FILE 2>> $ERROR_FILE
292 if [ -f $PKGCFG_FOLDER_INST/bin/pkg-config ]; then
293 rm -f pkgcfg.tar.gz >> $STDOUT_FILE 2>> $ERROR_FILE
294 rm -rf $PKGCFG_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
295 else
296 echo -e " ERROR: check output $STDOUT_FILE and $ERROR_FILE for details. "
301 echo -e "\tDone."
303 # aMule
305 echo -e "\tFINALLY compiling aMule and aMuleGUI ..."
307 pushd $AMULE_FOLDER >> $STDOUT_FILE 2>> $ERROR_FILE
309 if [ -f configure ]; then
310 echo -e "\t\tConfigure already exists"
311 else
312 PATH="${PATH}:${ROOT_FOLDER}/${GETTEXT_FOLDER_INST}/bin" ./autogen.sh >> $STDOUT_FILE 2>> $ERROR_FILE
315 if [ -d intl/ ]; then
316 echo -e "\t\tGood: intl folder already exists."
317 else
318 mkdir intl >> $STDOUT_FILE 2>> $ERROR_FILE
319 touch intl/Makefile.in >> $STDOUT_FILE 2>> $ERROR_FILE
320 echo "all:" > intl/Makefile >> $STDOUT_FILE 2>> $ERROR_FILE
321 echo "clean:" >> intl/Makefile >> $STDOUT_FILE 2>> $ERROR_FILE
322 echo "" >> intl/Makefile >> $STDOUT_FILE 2>> $ERROR_FILE
325 if [ ! -f src/amule ]; then
326 MULECLEAN=YES
329 rm -rf ${ROOT_FOLDER}/amule-inst/
330 mkdir -p ${ROOT_FOLDER}/amule-inst/
332 if [ "$MULECLEAN" == "YES" ]; then
333 echo -e "\t\tRunning configure"
335 PATH="${PATH}:${ROOT_FOLDER}/${GETTEXT_FOLDER_INST}/bin/:${ROOT_FOLDER}/${PKGCFG_FOLDER_INST}/bin/" \
336 ./configure CC=gcc$CCVERSION CXX=g++$CCVERSION CPP=cpp$CCVERSION LD=g++$CCVERSION \
337 CXXFLAGS="-pthread $ARCHCPPFLAGS $SDK" CFLAGS="-pthread $ARCHCPPFLAGS $SDK" LDFLAGS="-pthread $SDK" \
338 --enable-nls --disable-dependency-tracking --enable-ccache \
339 --with-wxdir=${ROOT_FOLDER}/${WXFOLDER}/ \
340 --with-crypto-prefix=${ROOT_FOLDER}/$CRYPTOPP_FOLDER_INST \
341 --with-libintl-prefix=${ROOT_FOLDER}/${GETTEXT_FOLDER_INST} \
342 --with-libupnp-prefix=${ROOT_FOLDER}/${LIBUPNP_FOLDER_INST} \
343 --with-geoip-static --with-geoip-headers=${ROOT_FOLDER}/${LIBGEOIP_FOLDER_INST}/include --with-geoip-lib=${ROOT_FOLDER}/${LIBGEOIP_FOLDER_INST}/lib/ \
344 --disable-cas --disable-webserver --disable-amulecmd --enable-amule-gui --disable-wxcas --disable-alc --disable-alcc --disable-amule-daemon \
345 --prefix=${ROOT_FOLDER}/amule-inst/ >> $STDOUT_FILE 2>> $ERROR_FILE
347 echo -e "\t\tCleaning compilation"
349 make clean >> $STDOUT_FILE 2>> $ERROR_FILE
352 echo -e "\t\tCompiling aMule"
354 make >> $STDOUT_FILE 2>> $ERROR_FILE
356 echo -e "\tDone."
358 echo -e "\t\tFaking install"
360 make install >> $STDOUT_FILE 2>> $ERROR_FILE
362 echo -e "\tDone."
364 popd >> $STDOUT_FILE 2>> $ERROR_FILE
366 echo -e "Getting application bundle and packaging"
368 rm -rf aMule.app aMule.zip aMuleGUI.app aMuleGUI.zip >> $STDOUT_FILE 2>> $ERROR_FILE
370 cp -R ${AMULE_FOLDER}/aMule.app . >> $STDOUT_FILE 2>> $ERROR_FILE
371 cp -R ${AMULE_FOLDER}/aMuleGUI.app . >> $STDOUT_FILE 2>> $ERROR_FILE
373 find aMule.app \( -name .svn -o -name "Makefile*" -o -name src \) -print0 | xargs -0 rm -rf >> $STDOUT_FILE 2>> $ERROR_FILE
374 find aMuleGUI.app \( -name .svn -o -name "Makefile*" -o -name src \) -print0 | xargs -0 rm -rf >> $STDOUT_FILE 2>> $ERROR_FILE
376 echo -e "Copying i18n files..."
377 cp -r amule-inst/share/locale aMule.app/Contents/SharedSupport/
378 cp -r amule-inst/share/locale aMuleGUI.app/Contents/SharedSupport/
379 echo -e "Done."
381 . application_packager.sh ${AMULE_FOLDER}/ >> $STDOUT_FILE 2>> $ERROR_FILE
383 if [ ! -f aMule.zip ]; then
384 echo "ERROR: aMule.zip was not created. Please review the output files"
385 else
386 echo "All Done"
389 # Pop root folder.
390 popd >> $STDOUT_FILE