#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
# 
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
sh clean.sh

./autogen.sh
AXIS2C_HOME=`pwd`/deploy
export AXIS2C_HOME 

./configure --prefix=${AXIS2C_HOME} --enable-tests=no --enable-trace=yes  --enable-diclient=no --enable-static=no --enable-openssl=no --with-apache2=/usr/include/apache2 --enable-tcp=yes --with-archive=/usr/include --with-apr=/usr/include/apr-1.0

make
make install

cd tools/tcpmon
./autogen.sh
./configure --prefix=${AXIS2C_HOME} --enable-tests=no
make
make install

cd ../../samples

./autogen.sh

./configure --prefix=${AXIS2C_HOME} --with-axis2=${AXIS2C_HOME}/include/axis2-@VERSION@
make
make install

make dist
tar xf axis2c-sample-src-@VERSION@.tar.gz
mv axis2c-sample-src-@VERSION@ samples
#$rm -rf ${AXIS2C_HOME}/samples
mv samples ${AXIS2C_HOME}/samples/src

cd ..

rm -rf xdocs/api/html
maven site
cd xdocs/api 
doxygen doxygenconf
cd ../..
cp -r xdocs/api/html target/docs/api/
cp xdocs/docs/mod_log/module.xml target/docs/docs/mod_log
cp -r target/docs ${AXIS2C_HOME}

cd ${AXIS2C_HOME}

# rm -rf config.sub missing config.guess depcomp ltmain.sh
for i in `find . -name "*.la"`
do
   rm $i
done

for i in `find . -name "*.a"`
do
   rm $i
done

strip -s ./lib/*
strip -s modules/addressing/*
strip -s modules/logging/*

strip -s ./bin/axis2_http_server
strip -s ./samples/bin/*
strip -s ./samples/bin/amqp/*
strip -s ./bin/tools/tcpmon/*

rm -rf ./lib/pkgconfig
