Merge pull request #125: fix crash when shared files changed on Shared files tab
[amule.git] / amule_build_install.sh
blob138cbf7abca6b3fe2123b9d9e454119ced605c07
1 #! /bin/bash
5 # Copyright (c) 2004-2011 Marcelo Roberto Jimenez ( phoenix@amule.org )
7 # All rights reserved. This script is provided under the terms of the GPL.
12 # Example usage: copy all tarballs to a directory, cd to it and
13 # $ ./amule_build_install.sh
17 SCRIPT_VERSION="2.0.0"
20 USERHOME=$(echo ~)
21 DEFAULT_PREFIX="${USERHOME}/usr"
22 DEFAULT_TARDIR=$(pwd)
23 DEFAULT_UNTARDIR=${DEFAULT_TARDIR}/untars
24 JOBS=4
28 # This function uses three parameters:
29 # $1 - an input parameter specifying a mask for the distribution,
30 # e.g., 'aMule-CVS-*' for cvs tarballs or 'aMule-*' for distro tarballs.
31 # $2 - an output parameter with the name of the variable that will
32 # receive the full file name of the tar archive
33 # $3 - an output parameter with the name of the variable that will
34 # receive the basename of the distribution
36 function lookup_distro {
37 # assign the filename of distribution
38 # the following is equivalent to execute XXX_FILENAME=$(ls ${TARDIR}/$1)
39 eval $2=$(ls ${TARDIR}/$1)
41 # Now we use indirection to dereference $2
42 #echo $2 # evaluates to XXX_FILENAME
43 #echo ${!2} # evaluates to /home/user/dir/xxx-y.z.t.tar.gz
45 # remove the directory and the extension parts and assing it
46 # to XXX_DISTRO in $3
47 case ${!2} in
48 *.gz)
49 eval $3=$(basename ${!2} .tar.gz)
52 *.bz2)
53 eval $3=$(basename ${!2} .tar.bz2)
56 *.zip)
57 eval $3=$(basename ${!2} .zip)
59 esac
63 function untar_distro {
64 # $1 evaluates to /home/user/dir/xxx-y.z.t.tar.gz or .bz2
65 local TARCMD=
66 case $1 in
67 *.gz)
68 TARCMD="tar zxf"
70 *.bz2)
71 TARCMD="tar jxf"
73 *.zip)
74 TARCMD="unzip -ao"
76 esac
77 $TARCMD $1
81 function init_package_versions {
83 # Put the software distributions in directory $TARDIR and the
84 # script does the rest. There can even be a mixture of .tar.gz and
85 # .tar.bz2 because the untarring routine tests it on the fly
87 # single quotes have to be used here to avoid expansion
89 lookup_distro 'cryptopp*' CRYPTOPP_FILENAME CRYPTOPP_DISTRO
90 lookup_distro 'libupnp-*' LIBUPNP_FILENAME LIBUPNP_DISTRO
91 lookup_distro 'wxWidgets-*.*.*.tar.*' WXWIDGETS_FILENAME WXWIDGETS_DISTRO
92 lookup_distro 'aMule-*' AMULE_FILENAME AMULE_DISTRO
94 echo
95 echo "Software packacge versions:"
96 echo " cryptopp : $CRYPTOPP_DISTRO"
97 echo " libupnp : $LIBUPNP_DISTRO"
98 echo " wxWidgets : $WXWIDGETS_DISTRO"
99 echo " aMule : $AMULE_DISTRO"
100 echo
104 function init_environment {
105 echo
106 echo aMule building script, version $SCRIPT_VERSION
107 echo
109 # only prompt if we're missing information
110 if [ x$PREFIX = x ] || [ x$TARDIR = x ] || [ x$UNTARDIR = x ] ; then
112 PREFIX=${DEFAULT_PREFIX}
113 echo "Where to install?"
114 read -p "[${PREFIX}]: "
115 if [ x$REPLY != x ]; then PREFIX=${REPLY}; fi
117 echo
118 echo "Where are the tarballs?"
119 TARDIR=${DEFAULT_TARDIR}
120 read -p "[${TARDIR}]: "
121 if [ x$REPLY != x ]; then TARDIR=${REPLY}; fi
123 echo
124 echo "Where to untar?"
125 UNTARDIR=${DEFAULT_UNTARDIR}
126 read -p "[${UNTARDIR}]: "
127 if [ x$REPLY != x ]; then UNTARDIR=${REPLY}; fi
131 # test that we have write permissions to the install dir
132 TST_DIR=${PREFIX}/tmp
133 TST_FILE=${TST_DIR}/test-if-has-write-permission
134 mkdir -p ${TST_DIR}
135 touch ${TST_FILE}
136 if [ ! -w ${TST_FILE} ]; then
137 echo "You don't appear to have write permissions to ${PREFIX}."
138 echo "You must fix that before continuing."
139 exit
141 rm -f ${TST_FILE}
143 echo
144 echo "Building for:"
145 echo " --prefix=${PREFIX}"
146 echo " tarballs are at ${TARDIR}"
147 echo " tarballs will be untarred at ${UNTARDIR}"
148 echo
150 # Initialize package version variables
151 init_package_versions
156 # cryptopp
158 function build_cryptopp {
159 CRYPTOPP_INSTALL_DIR="${PREFIX}/cryptopp"
160 CRYPTOPP_SOURCES_DIR="cryptopp_tmpdir"
162 rm -rf ${CRYPTOPP_SOURCES_DIR}
163 mkdir -p ${CRYPTOPP_SOURCES_DIR}
164 cd ${CRYPTOPP_SOURCES_DIR}
166 untar_distro ${CRYPTOPP_FILENAME}
168 make -f GNUmakefile -j${JOBS}
169 PREFIX=${CRYPTOPP_INSTALL_DIR} make install
170 cd ..
175 # libUPnP
177 function build_libupnp {
178 untar_distro ${LIBUPNP_FILENAME}
180 LIBUPNP_INSTALL_DIR="${PREFIX}/libupnp"
181 cd libupnp-?.?.?
182 ./configure \
183 --enable-debug \
184 --prefix=${LIBUPNP_INSTALL_DIR} \
185 && \
186 make -j${JOBS} > /dev/null && \
187 make install > /dev/null
188 cd ..
193 # wxWidgets
195 function build_wxwidgets {
196 untar_distro ${WXWIDGETS_FILENAME}
198 WXWIDGETS_INSTALL_DIR="${PREFIX}/wxWidgets"
199 cd wxWidgets-?.?.?
200 ./configure \
201 --enable-mem_tracing \
202 --enable-debug \
203 --disable-optimise \
204 --enable-debug_flag \
205 --enable-debug_info \
206 --enable-debug_gdb \
207 --with-opengl \
208 --enable-gtk2 \
209 --enable-unicode \
210 --enable-largefile \
211 --prefix=${WXWIDGETS_INSTALL_DIR} \
212 && \
213 make -j${JOBS} > /dev/null &&
214 make install > /dev/null
215 cd ..
220 # aMule
222 function build_amule {
223 untar_distro ${AMULE_FILENAME}
225 AMULE_INSTALL_DIR="${PREFIX}/amule"
226 cd amule-cvs
227 ./configure \
228 --enable-ccache \
229 --with-denoise-level=3 \
230 --enable-debug \
231 --disable-optimize \
232 --enable-verbose \
233 --enable-geoip \
234 --enable-cas \
235 --enable-wxcas \
236 --enable-amule-gui \
237 --enable-webserver \
238 --enable-amulecmd \
239 --enable-amule-daemon \
240 --with-wx-config=${WXWIDGETS_INSTALL_DIR}/bin/wx-config \
241 --prefix=${AMULE_INSTALL_DIR} \
242 --with-crypto-prefix=${CRYPTOPP_INSTALL_DIR} \
243 --with-libupnp-prefix=${LIBUPNP_INSTALL_DIR} \
244 && \
245 LD_LIBRARY_PATH=${WXWIDGETS_INSTALL_DIR}/lib make -j${JOBS} && \
246 LD_LIBRARY_PATH=${WXWIDGETS_INSTALL_DIR}/lib make install > /dev/null
250 # Here is where the fun begins...
252 init_environment
255 # Go to ${UNTARDIR}
257 mkdir -p ${UNTARDIR}
258 cd ${UNTARDIR}
261 # Build stuff
263 build_cryptopp
264 build_libupnp
265 build_wxwidgets
266 build_amule
269 # Leave ${UNTARDIR}
271 cd ..
274 echo
275 echo Finished compilation.
276 echo You should run aMule like this:
277 echo '$LD_LIBRARY_PATH'=${WXWIDGETS_INSTALL_DIR}/lib:${LIBUPNP_INSTALL_DIR}/lib LANG=en_US.UTF-8 ${AMULE_INSTALL_DIR}/bin/amule
278 echo
279 echo Of course you may choose to use a different locale.
280 echo