Skip to content
Snippets Groups Projects
runConfigure 7.8 KiB
Newer Older
Ted Leung's avatar
Ted Leung committed
#!/bin/sh
#
# The Apache Software License, Version 1.1
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
# Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
Ted Leung's avatar
Ted Leung committed
# reserved.
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# 1. Redistributions of source code must retain the above copyright
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#    notice, this list of conditions and the following disclaimer.
#
Ted Leung's avatar
Ted Leung committed
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# 3. The end-user documentation included with the redistribution,
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#    if any, must include the following acknowledgment:
Ted Leung's avatar
Ted Leung committed
#       "This product includes software developed by the
#        Apache Software Foundation (http://www.apache.org/)."
#    Alternately, this acknowledgment may appear in the software itself,
#    if and wherever such third-party acknowledgments normally appear.
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# 4. The names "Xerces" and "Apache Software Foundation" must
#    not be used to endorse or promote products derived from this
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#    software without prior written permission. For written
Ted Leung's avatar
Ted Leung committed
#    permission, please contact apache\@apache.org.
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# 5. Products derived from this software may not be called "Apache",
#    nor may "Apache" appear in their name, without prior written
#    permission of the Apache Software Foundation.
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ====================================================================
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation, and was
# originally based on software copyright (c) 1999, International
# Business Machines, Inc., http://www.ibm.com .  For more information
# on the Apache Software Foundation, please see
# <http://www.apache.org/>.
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
#
Ted Leung's avatar
Ted Leung committed
#
Unknown (aruna1)'s avatar
Unknown (aruna1) committed
# $Id$
Ted Leung's avatar
Ted Leung committed
#

#
# runConfigure : This script will run the "configure" script for the appropriate platform
# Only supported platforms are recognized

usage()
{
    echo "runConfigure: Helper script to run \"configure\" for one of the supported platforms"
    echo "Usage: runConfigure \"options\""
    echo "       where options may be any of the following:"
    echo "       -p <platform> (accepts 'aix', 'linux', 'freebsd', 'solaris',
            'hp-10', 'hp-11', 'openserver', 'unixware', 'os400', 'irix',
            'ptx', 'tru64', 'macosx')"
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
    echo "       -c <C compiler name> (e.g. gcc, xlc or icc)"
    echo "       -x <C++ compiler name> (e.g. g++, xlC, or icc)"
Ted Leung's avatar
Ted Leung committed
    echo "       -d (specifies that you want to build debug version)"
    echo "       -l <extra linker options>"
    echo "       -z <extra compiler options>"
    echo "       -h (get help on the above commands)"
Ted Leung's avatar
Ted Leung committed
}

Ted Leung's avatar
Ted Leung committed
if test ${1}o = "o"; then
   usage
Ted Leung's avatar
Ted Leung committed
fi

if test ${XERCESCROOT}o = "o"; then
   echo ERROR : You have not set your XERCESCROOT environment variable
Ted Leung's avatar
Ted Leung committed
   echo Though this environment variable has nothing to do with creating makefiles,
   echo this is just a general warning to prevent you from pitfalls in future. Please
   echo set an environment variable called XERCESCROOT to indicate where you installed
   echo the XERCES-C files, and run this command again to proceed. See the documentation
Ted Leung's avatar
Ted Leung committed
   echo for an example if you are still confused.
Ted Leung's avatar
Ted Leung committed
fi

if test $1 = "-h"; then
   usage
Ted Leung's avatar
Ted Leung committed
fi

# Check the command line parameters
if test -x /usr/bin/getopt; then
getoptErr=`getopt p:c:x:dm:n:t:r:l:z:h $*`
getoptErr=`getopts p:c:x:dm:n:t:r:l:z:h `$*``
Ted Leung's avatar
Ted Leung committed
if [ $? != 0 ]
   then
   usage
Ted Leung's avatar
Ted Leung committed
fi

# Now get the command line parameters
if test -x /usr/bin/getopt; then
set -- `getopt p:c:x:dm:n:t:r:l:z:h $*`
else
set --`getopts p:c:x:dm:n:t:r:l:z:h `$*``
fi

Ted Leung's avatar
Ted Leung committed
# Set up the default values for each parameter
debug=off                # by default debug is off
compileroptions=""
Ted Leung's avatar
Ted Leung committed
   do
Ted Leung's avatar
Ted Leung committed
   -p)
        platform=$2; shift 2;;

   -c)
        ccompiler=$2; shift 2;;

   -x)
        cppcompiler=$2; shift 2;;

   -d)
        debug=on; shift;;

   -z)
        compileroptions="$compileroptions $2"; shift 2;;

Tinny Ng's avatar
Tinny Ng committed
   -l)
        linkeroptions="$linkeroptions $2"; shift 2;;
Ted Leung's avatar
Ted Leung committed
   -h)
        usage
Ted Leung's avatar
Ted Leung committed

   --)
        shift; break;;

   *)
       echo "unknown option $1"
       usage
       exit ${ERROR_EXIT_CODE};;
Ted Leung's avatar
Ted Leung committed
   esac
done

Tinny Ng's avatar
Tinny Ng committed
if test $platform = "aix"; then
      if test ! -n "$ccompiler" -o ! -n "$cppcompiler"; then
              ccompiler=xlc
              cppcompiler=xlC
      fi
fi

Ted Leung's avatar
Ted Leung committed
echo "Generating makefiles with the following options ..."
echo "Platform: $platform"
echo "C Compiler: $ccompiler"
echo "C++ Compiler: $cppcompiler"
echo "Extra compile options: $compileroptions"
echo "Extra link options: $linkeroptions"

#
# Now check if the options are correct or not, bail out if incorrect
#
case $platform in
   aix | openserver | unixware | linux | freebsd | solaris | hp-10 | hp-11 | os400 | irix | ptx | tru64 | macosx)
       # platform has been recognized
       ;;
   *)
      echo "I do not recognize the platform '$platform'. Please type '${0} -h' for help."
      exit ${ERROR_EXIT_CODE};;
esac

#
# Enable debugging or not...
#
Ted Leung's avatar
Ted Leung committed
if test $debug = "off"; then
    echo "Debug is OFF"
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
    if test $platform = "os400"; then
    debugflag="-O";
Tinny Ng's avatar
Tinny Ng committed
    elif test $platform = "irix"; then
       debugflag="-w -O2";
    elif test $platform = "aix"; then
       debugflag="-w -O2";
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
    else
Ted Leung's avatar
Ted Leung committed
    debugflag="-w -O";
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
    fi
Ted Leung's avatar
Ted Leung committed
else
    echo "Debug is ON"
    debugflag="-g";
fi

Ted Leung's avatar
Ted Leung committed
# Set the C compiler and C++ compiler environment variables
Ted Leung's avatar
Ted Leung committed
case $cppcompiler in
   xlC* | xlc* | g++ | c++ | cc | CC | aCC | icc | ICC | cxx)
      ;;
Ted Leung's avatar
Ted Leung committed

   *)
      echo "I do not recognize the C++ compiler '$cppcompiler'. Continuing anyway ..."
      ;;
esac

CC="$ccompiler"
export CC

CXX="$cppcompiler"
export CXX

#
Ted Leung's avatar
Ted Leung committed
# Set the extra C and C++ compiler flags
# include the user defined CXXFLAGS/CFLAGS first in case they have
# set an platform spefic flags
#
CXXFLAGS="$CXXFLAGS $compileroptions $debugflag"; export CXXFLAGS
CFLAGS="$CFLAGS $compileroptions $debugflag"; export CFLAGS

# gcc crashes if optimisation is turned on in a Tru64 environment
if [ $platform = "tru64" -a $CXX = "g++" ]; then
    CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-O[0-9]*//g'`
    CFLAGS=`echo $CFLAGS | sed -e 's/-O[0-9]*//g'`
LDFLAGS="$LDFLAGS $linkeroptions"; export LDFLAGS
Ted Leung's avatar
Ted Leung committed

echo
rm -f config.cache
rm -f config.log
rm -f config.status
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
if test $platform = "os400"; then
./configure --host AS400-OS400
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
elif test $platform = "ptx"; then
./configure --prefix=$XMLINSTALL
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
else
Ted Leung's avatar
Ted Leung committed
./configure
Unknown (abagchi)'s avatar
Unknown (abagchi) committed
fi
# exit if configure failed
if test $? != 0; then
  exit 1
fi
Ted Leung's avatar
Ted Leung committed

echo
echo In future, you may also directly type the following commands to create the Makefiles.
echo
echo export CC=$CC
echo export CXX=$CXX
echo export CXXFLAGS=$CXXFLAGS
echo export CFLAGS=$CFLAGS
echo export LIBS=$LIBS
echo export LDFLAGS=$LDFLAGS
echo configure

Ted Leung's avatar
Ted Leung committed
echo
echo If the result of the above commands look OK to you, go to the directory
Unknown (aruna1)'s avatar
Unknown (aruna1) committed
echo ${XERCESCROOT}/samples and type \"gmake\" to make the samples.
Ted Leung's avatar
Ted Leung committed

exit 0;