5 # Copyright (c) 2004-2008 by 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"
21 DEFAULT_PREFIX
="${USERHOME}/usr"
23 DEFAULT_UNTARDIR
=${DEFAULT_TARDIR}/untars
28 # This function uses three parameters:
29 # $1 - an input parameter specifying a mask for the distribution,
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
49 eval $3=$
(basename ${!2} .
tar.gz
)
53 eval $3=$
(basename ${!2} .
tar.bz2
)
57 eval $3=$
(basename ${!2} .
zip)
63 function untar_distro
{
64 # $1 evaluates to /home/user/dir/xxx-y.z.t.tar.gz or .bz2
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-CVS-*' AMULE_FILENAME AMULE_DISTRO
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"
104 function init_environment
{
106 echo aMule building
script, version
$SCRIPT_VERSION
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
118 echo "Where are the tarballs?"
119 TARDIR
=${DEFAULT_TARDIR}
120 read -p "[${TARDIR}]: "
121 if [ x
$REPLY != x
]; then TARDIR
=${REPLY}; fi
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
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."
145 echo " --prefix=${PREFIX}"
146 echo " tarballs are at ${TARDIR}"
147 echo " tarballs will be untarred at ${UNTARDIR}"
150 # Initialize package version variables
151 init_package_versions
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
177 function build_libupnp
{
178 untar_distro
${LIBUPNP_FILENAME}
180 LIBUPNP_INSTALL_DIR
="${PREFIX}/libupnp"
184 --prefix=${LIBUPNP_INSTALL_DIR} \
186 make -j${JOBS} > /dev
/null
&& \
187 make install > /dev
/null
195 function build_wxwidgets
{
196 untar_distro
${WXWIDGETS_FILENAME}
198 WXWIDGETS_INSTALL_DIR
="${PREFIX}/wxWidgets"
201 --enable-mem_tracing \
204 --enable-debug_flag \
205 --enable-debug_info \
211 --prefix=${WXWIDGETS_INSTALL_DIR} \
213 make -j${JOBS} > /dev
/null
&&
214 make install > /dev
/null
222 function build_amule
{
223 untar_distro
${AMULE_FILENAME}
225 AMULE_INSTALL_DIR
="${PREFIX}/amule"
229 --with-denoise-level=3 \
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} \
244 LD_LIBRARY_PATH
=${WXWIDGETS_INSTALL_DIR}/lib
make -j${JOBS} && \
245 LD_LIBRARY_PATH
=${WXWIDGETS_INSTALL_DIR}/lib
make install > /dev
/null
249 # Here is where the fun begins...
274 echo Finished compilation.
275 echo You should run aMule like this
:
276 echo '$LD_LIBRARY_PATH'=${WXWIDGETS_INSTALL_DIR}/lib:${LIBUPNP_INSTALL_DIR}/lib LANG=en_US.UTF-8 ${AMULE_INSTALL_DIR}/bin
/amule
278 echo Of course you may choose to use a different locale.