#!/bin/bash
|
|
#+--------------------------------------------------------------------------------------------
|
#|Description: This shell script used download and compile appweb for ARM
|
#| Author: GuoWenxue <guowenxue@gmail.com>
|
#| ChangeLog:
|
#| 1, Initialize 1.0.0 on 2011.04.12
|
#+--------------------------------------------------------------------------------------------
|
|
PRJ_PATH=`pwd`
|
PREFIX_PATH=`pwd`/appweb
|
|
TFTP_PATH=/tftp
|
|
mkdir -p $PREFIX_PATH/{bin,modules}
|
|
LYFTP_SRC=http://master.weike-iot.com:2211/src/
|
|
CROSS_COMPILE=/opt/gcc-aarch32-10.3-2021.07/bin/arm-none-linux-gnueabihf-
|
|
TARBALL=appweb_cortexa5.tar.bz2
|
|
function msg_banner()
|
{
|
echo ""
|
echo "+-----------------------------------------------------------------------"
|
echo "| $1 "
|
echo "+-----------------------------------------------------------------------"
|
echo ""
|
}
|
|
function check_result()
|
{
|
if [ $? != 0 ] ; then
|
echo ""
|
echo "+-----------------------------------------------------------------------"
|
echo "| $1 "
|
echo "+-----------------------------------------------------------------------"
|
echo ""
|
exit ;
|
fi
|
}
|
|
function export_cross()
|
{
|
# export cross toolchain
|
export CC=${CROSS_COMPILE}gcc
|
export AS=${CROSS_COMPILE}as
|
export AR=${CROSS_COMPILE}ar
|
export LD=${CROSS_COMPILE}ld
|
export NM=${CROSS_COMPILE}nm
|
export RANLIB=${CROSS_COMPILE}ranlib
|
export OBJDUMP=${CROSS_COMPILE}objdump
|
export STRIP=${CROSS_COMPILE}strip
|
|
# export cross configure
|
export CONFIG_CROSS=" --build=i686-pc-linux --host=arm-linux "
|
|
# Clear LDFLAGS and CFLAGS
|
export LDFLAGS=
|
export CFLAGS=
|
}
|
|
PHP_SRC_NAME=php-5.4.10
|
function compile_php()
|
{
|
SRC_NAME=${PHP_SRC_NAME}
|
PACK_SUFIX=tar.bz2
|
|
if [ -f ${PREFIX_PATH}/modules/libphp5.so ] ; then
|
msg_banner "$SRC_NAME already compile and installed"
|
return 0;
|
fi
|
|
msg_banner "Start cross compile $SRC_NAME "
|
|
if [ ! -f ${SRC_NAME}.${PACK_SUFIX} ] ; then
|
#wget http://museum.php.net/php5/${SRC_NAME}.${PACK_SUFIX}
|
wget $LYFTP_SRC/$SRC_NAME.$PACK_SUFIX
|
check_result "ERROR: download ${SRC_NAME} failure"
|
fi
|
|
tar -xjf ${SRC_NAME}.${PACK_SUFIX}
|
cd ${SRC_NAME}
|
|
sed -i -e "s/uint _res/uint/g" main/php_output.h
|
line=`sed -n '/Your system seems to lack POSIX threads/=' configure`
|
sed -i -e ${line}s'|.*|{ echo "configure: error: Your system seems to lack POSIX threads." 1>\&2;}|' configure
|
|
./configure --prefix=${PREFIX_PATH} ${CONFIG_CROSS} --disable-rpath --disable-cli --enable-bcmath \
|
--enable-calendar --enable-maintainer-zts -enable-embed=shared --enable-force-cgi-redirect --disable-ftp \
|
--enable-inline-optimization --disable-magic-quotes --enable-memory-limit --disable-safe-mode \
|
--enable-sockets --enable-track-vars --enable-trans-sid -enable-wddx --sysconfdir=/apps/appWeb/etc --with-pic \
|
--with-db --with-regex=system --with-pear --without-zlib --without-iconv --disable-dom --disable-libxml \
|
--disable-simplexml --disable-xml --disable-wddx --disable-xmlreader --without-xmlrpc --disable-xmlwriter \
|
--with-config-file-path=/apps/appweb
|
check_result "ERROR: configure ${SRC_NAME} failure"
|
|
export LDFLAGS+="-lpthread -ldl"
|
make && make install
|
check_result "ERROR: compile ${SRC_NAME} failure"
|
|
# install and clear PHP
|
${STRIP} ${PREFIX_PATH}/lib/libphp5.so
|
cp -rf $PREFIX_PATH/lib/libphp5.so $PREFIX_PATH/modules
|
rm -rf ${PREFIX_PATH}/bin/*
|
rm -rf $PREFIX_PATH/include
|
rm -rf $PREFIX_PATH/lib
|
rm -rf $PREFIX_PATH/php
|
|
cd -
|
}
|
|
|
|
function compile_appweb()
|
{
|
SRC_NAME=appweb-3.4.2
|
PACK_SUFIX=-0-src.tgz
|
|
if [ -f ${PREFIX_PATH}/bin/appweb ] ; then
|
msg_banner "$SRC_NAME already compiled"
|
return 0;
|
fi
|
|
msg_banner "Start cross compile $SRC_NAME "
|
|
if [ ! -f ${SRC_NAME}${PACK_SUFIX} ] ; then
|
#wget https://embedthis.com/software/${SRC_NAME}${PACK_SUFIX}
|
wget $LYFTP_SRC/${SRC_NAME}${PACK_SUFIX}
|
check_result "ERROR: download ${SRC_NAME} failure"
|
fi
|
|
tar -xzf ${SRC_NAME}${PACK_SUFIX}
|
cd ${SRC_NAME}
|
|
./configure --prefix=${PREFIX_PATH} ${CONFIG_CROSS} --type=RELEASE --static --port=80 --enable-assert \
|
--enable-complete-cross --enable-legacy-api --enable-log --enable-multi-thread --enable-samples \
|
--enable-test --enable-send --enable-upload --enable-file --enable-regex --with-php=${PRJ_PATH}/${PHP_SRC_NAME}
|
check_result "ERROR: configure ${SRC_NAME} failure"
|
|
make TRACE=1
|
check_result "ERROR: compile ${SRC_NAME} failure"
|
|
|
cp bin/arm-unknown-linux/appweb $PREFIX_PATH/bin
|
cp modules/arm-unknown-linux/* $PREFIX_PATH/modules
|
$STRIP $PREFIX_PATH/bin/*
|
cp -rf test/{appweb.conf,groups.db,mime.types,users.db} $PREFIX_PATH
|
|
cd -
|
}
|
|
function install_appweb()
|
{
|
cd ${PRJ_PATH}
|
|
if [ -f ${TARBALL} ] ; then
|
msg_banner "$SRC_NAME already installed"
|
return 0;
|
fi
|
|
msg_banner "Start install webserver appweb "
|
|
# install web page
|
rm -rf $PREFIX_PATH/web
|
cp -rf web $PREFIX_PATH
|
|
sed -i -e "s|^Listen 4100|Listen 80|g" $PREFIX_PATH/appweb.conf
|
sed -i -e 's|^LoadModulePath "../modules"|LoadModulePath "./modules"|g' $PREFIX_PATH/appweb.conf
|
sed -i -e "s|^DirectoryIndex.*|DirectoryIndex index.php|g" $PREFIX_PATH/appweb.conf
|
|
set -x
|
|
cat << EOF > run.sh
|
#!/bin/sh
|
APPWEB_PATH=/apps/appweb
|
export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:\${APPWEB_PATH}/modules
|
cd \${APPWEB_PATH}
|
./bin/appweb --config appweb.conf &
|
EOF
|
|
chmod 755 run.sh
|
mv run.sh $PREFIX_PATH/
|
|
tar -cjf ${TARBALL} `basename $PREFIX_PATH`
|
|
if [ -d $TFTP_PATH -a -w $TFTP_PATH ] ; then
|
cp ${TARBALL} $TFTP_PATH
|
fi
|
}
|
|
|
export_cross
|
|
compile_php
|
|
compile_appweb
|
|
install_appweb
|