configure revision 1011
791N/A#!/bin/bash
791N/A#
1302N/A# CDDL HEADER START
791N/A#
1607N/A# The contents of this file are subject to the terms of the
791N/A# Common Development and Distribution License (the "License").
791N/A# You may not use this file except in compliance with the License.
919N/A#
919N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
919N/A# or http://www.opensolaris.org/os/licensing.
919N/A# See the License for the specific language governing permissions
919N/A# and limitations under the License.
919N/A#
919N/A# When distributing Covered Code, include this CDDL HEADER in each
919N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
919N/A# If applicable, add the following below this CDDL HEADER, with the
919N/A# fields enclosed by brackets "[]" replaced with your own identifying
919N/A# information: Portions Copyright [yyyy] [name of copyright owner]
919N/A#
919N/A# CDDL HEADER END
919N/A#
919N/A#
919N/A# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
919N/A#
791N/Aunset MAKEFLAGS
791N/Aunset MAKELEVEL
791N/A
791N/Aexport BUILDTYPE=""
1035N/Aexport BUILDMODE=""
791N/Aexport CONFIG="sunpro.config"
970N/Aexport TOPLEVELDIR=""
970N/Aexport BUILDDIR=""
970N/Aexport LDSOFLAGS="${LDFLAGS}"
970N/Aexport CXXOPTS="${CXXFLAGS}"
970N/Aexport LDOPTS="${LDFLAGS}"
970N/Aexport LD="${CXX} ${CXXFLAGS} ${LDFLAGS}"
970N/A
970N/AUNKNOWN_ARG=yes
970N/APRINT_HELP=no
970N/A
1033N/Acheck_args() {
970N/A while [ "$#" -gt 0 ] ; do
1551N/A UNKNOWN_ARG=no
1551N/A case "$1" in
970N/A -m32)
970N/A BUILDTYPE="8d"
970N/A BUILDMODE="shared,pthreads"
1003N/A ;;
970N/A -m64)
1356N/A BUILDTYPE="8D"
1302N/A BUILDMODE="shared,pthreads"
1302N/A ;;
791N/A -topdir=*)
1033N/A TOPLEVELDIR=`echo $1 | sed "s,^-topdir=\(.*\),\1,"`
791N/A ;;
911N/A -builddir=*)
1033N/A BUILDDIR=`echo $1 | sed "s,^-builddir=\(.*\),\1,"`
1033N/A ;;
911N/A *)
791N/A UNKNOWN_ARG=yes
791N/A ;;
791N/A esac
791N/A
791N/A if [ "$UNKNOWN_ARG" = "yes" ] ; then
1033N/A echo "$1: Invalid argument"
791N/A PRINT_HELP=yes
1035N/A shift
1035N/A continue
791N/A fi
1033N/A shift
791N/A done
791N/A
791N/A export BUILDTYPE BUILDMODE TOPLEVELDIR
1491N/A export BUILDDIR="${TOPLEVELDIR}/build"
791N/A export LD_LIBRARY_PATH="${BUILDDIR}/lib:${LD_LIBRARY_PATH}"
791N/A
791N/A echo "BUILDTYPE: ${BUILDTYPE}"
791N/A echo "TOPLEVELDIR: ${TOPLEVELDIR}"
791N/A echo "BUILDDIR: ${BUILDDIR}"
1607N/A
1607N/A cd ${TOPLEVELDIR}
1196N/A if [ -f config.done ] ; then
1033N/A rm -f config.done
1491N/A fi
791N/A
791N/A if [ "x${BUILDTYPE}" = "x" ] || [ "x${TOPLEVELDIR}" = "x" ] ; then
1607N/A PRINT_HELP=yes
1033N/A fi
791N/A
791N/A if [ "$PRINT_HELP" = "yes" ] || [ "$UNKNOWN_ARG" = "yes" ] ; then
1607N/A echo "Usage: `basename $0` [ -m32 | -m64 ] --topdir=[ \$(top_srcdir) ]"
791N/A exit 1
791N/A fi
791N/A}
1033N/A
1033N/Acheck_directories() {
1033N/A if [ ! -d Solaris ] ; then
791N/A echo "Expected directory Solaris not found."
791N/A echo "Make sure this directory exists in the stdcxx toplevel."
791N/A echo ""
791N/A exit 1
791N/A fi
791N/A}
1425N/A
1607N/Acheck_buildtype() {
1425N/A if [ "x${BUILDTYPE}" = "x" ] ; then
791N/A echo "\$BUILDTYPE [ 8d | 8D ] is not set."
791N/A echo ""
791N/A exit 1
791N/A fi
791N/A echo "BUILDTYPE: ${BUILDTYPE}."
1033N/A echo "BUILDMODE: ${BUILDMODE}."
791N/A}
791N/A
801N/Acheck_compiler_flags() {
791N/A if [ "x${CC}" = "x" ] ; then
791N/A echo "\$CC is not set."
1196N/A echo ""
1196N/A exit 1
791N/A fi
1033N/A echo "CC: ${CC}."
791N/A export CC=`echo ${CC}`
791N/A
791N/A if [ "x${CXX}" = "x" ] ; then
791N/A echo "\$CXX is not set."
791N/A echo ""
1033N/A exit 1
1033N/A fi
791N/A echo "CXX: ${CXX}."
791N/A export CXX=`echo ${CXX}`
791N/A
791N/A if [ "x${CFLAGS}" = "x" ] ; then
echo "\$CFLAGS is not set."
echo ""
exit 1
fi
echo "CFLAGS: ${CFLAGS}."
if [ "x${CPPFLAGS}" = "x" ] ; then
echo "\$CPPFLAGS is not set."
echo ""
exit 1
fi
echo "CPPFLAGS: ${CPPFLAGS}."
if [ "x${CXXFLAGS}" = "x" ] ; then
echo "\$CXXFLAGS is not set. Make sure you have set -library=no%Cstd."
echo ""
exit 1
fi
echo "CXXFLAGS: ${CXXFLAGS}."
if [ "x${LDFLAGS}" = "x" ] ; then
echo "\$LDFLAGS is not set."
echo ""
exit 1
fi
echo "LDFLAGS: ${LDFLAGS}."
}
check_gnu_make() {
if [ "x${MAKE}" = "x" ] ; then
echo "\$MAKE is not set. Please use GNU make to build stdcxx."
echo ""
exit 1
fi
gnumake=`${MAKE} --version | grep -- "GNU"`
if [ "x${gnumake}" = "x" ] ; then
echo "\$MAKE is not GNU make. stdcxx requires GNU make."
exit 1
fi
echo "MAKE: ${MAKE}."
}
fix_ansi_dir() {
cd ${TOPLEVELDIR}
for file in \
wctype.h \
wchar.h \
time.h \
string.h \
stdlib.h \
stdio.h \
stddef.h \
stdarg.h \
signal.h \
setjmp.h \
math.h \
locale.h \
limits.h \
float.h \
errno.h \
ctype.h \
assert.h \
_cwctype.h \
_cwchar.h \
_ctime.h \
_cstring.h \
_cstdlib.h \
_cstdio.h \
_cstddef.h \
_cstdarg.h \
_csignal.h \
_csetjmp.h \
_cmath.h \
_clocale.h \
_cfloat.h \
_cerrno.h \
_cctype.h \
_cassert.h
do
if [ -f ./include/ansi/$file ] ; then
rm -f ./include/ansi/$file
fi
done
for file in \
stdint.h
do
if [ -f ./include/tr1/$file ] ; then
rm -f ./include/tr1/$file
fi
done
for file in \
cstdint
do
if [ -f ./include/tr1/${file} ] ; then
cp -fp ./include/tr1/${file} ./include/ansi/
fi
done
}
make_config() {
echo "Configuring ..." `pwd`
rm -rf ${BUILDDIR}
echo
echo "MAKEFLAGS: ${MAKEFLAGS}"
echo "MAKELEVEL: ${MAKELEVEL}"
unset MAKEFLAGS
unset MAKELEVEL
export LIBDIR="${TOPLEVELDIR}/lib"
rm -rf ${LIBDIR}
mkdir -p ${LIBDIR}
for file in \
"collapse_static_locals.lib" \
"collapse_template_statics.lib" \
"collapse_template_locals.lib" \
"extern_inline.lib" \
"lib_exceptions.lib"
do
echo "${CXX} ${CPPFLAGS} ${CXXFLAGS} -c ${TOPLEVELDIR}/etc/config/src/${file}.cpp -o ${LIBDIR}/${file}.o"
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c ${TOPLEVELDIR}/etc/config/src/${file}.cpp -o ${LIBDIR}/${file}.o
echo "${CXX} ${CXXFLAGS} ${LDFLAGS} -G -hlib${file}.so ${LIBDIR}/${file}.o -o ${LIBDIR}/lib${file}.so"
${CXX} ${CXXFLAGS} ${LDFLAGS} -G -h${file}.so ${LIBDIR}/${file}.o -o ${LIBDIR}/lib${file}.so
done
unset LIBDIR
export LD_OPTIONS="-L${TOPLEVELDIR}/lib -R${TOPLEVELDIR}/lib"
export LD_OPTIONS="${LD_OPTIONS} -L${BUILDDIR}/include -R${BUILDDIR}/include"
echo $MAKE SHELL=/bin/bash CC=${CC} CXX=${CXX} LD_OPTIONS="${LD_OPTIONS}" LDFLAGS="${LDFLAGS} ${LD_OPTIONS}" TOPDIR=${TOPLEVELDIR} BUILDTYPE=${BUILDTYPE} BUILDMODE=${BUILDMODE} CONFIG=${CONFIG} config
${MAKE} SHELL=/bin/bash CC="${CC}" CXX="${CXX}" LD_OPTIONS="${LD_OPTIONS}" LDFLAGS="${LDFLAGS} ${LD_OPTIONS}" TOPDIR="${TOPLEVELDIR}" BUILDTYPE="${BUILDTYPE}" BUILDMODE="${BUILDMODE}" CONFIG="${CONFIG}" config
unset LD_OPTIONS
echo "Configuration finished."
}
post_config() {
echo "Performing post-configuration updates ... "
if [ ! -f ../Solaris/atomic-cxx.d ] ; then
echo "atomic-cxx.d not found!"
echo "Post-configuration FAILED!!!"
exit 1
fi
mkdir -p build/lib/.depend
cp -fp ../Solaris/atomic-cxx.d build/lib/.depend/
touch -acm build/lib/.depend/atomic-cxx.d
cd ${BUILDDIR}/include
if [ -f config.h ] ; then
mv config.h config.h.orig
unamep=`uname -p`
is64bit=`echo ${CXXFLAGS} | grep -- "-m64"`
export HEADER_FILE="stdcxx"
if [ "x${unamep}" = "xsparc" ] ; then
if [ "x${is64bit}" = "x" ] ; then
export HEADER_FILE="${HEADER_FILE}_sparc.h"
else
export HEADER_FILE="${HEADER_FILE}_sparcv9.h"
fi
else
if [ "x${is64bit}" = "x" ] ; then
export HEADER_FILE="${HEADER_FILE}_i386.h"
else
export HEADER_FILE="${HEADER_FILE}_amd64.h"
fi
fi
if [ ! -f ../../Solaris/${HEADER_FILE} ] ; then
echo "Required configuration header file ${HEADER_FILE} not found!"
exit 1
fi
echo "Using configuration header file ${HEADER_FILE}"
cp -fp ../../Solaris/${HEADER_FILE} .
chmod 0644 ${HEADER_FILE}
touch -r config.h.orig -acm ${HEADER_FILE}
if [ -f "${TOPLEVELDIR}/../Solaris/rwconfig_std.h" ] ; then
cp -fp "${TOPLEVELDIR}/../Solaris/rwconfig_std.h" .
chmod 0644 rwconfig_std.h
touch -acm rwconfig_std.h
ln -sf rwconfig_std.h config.h
cd ${TOPLEVELDIR}
echo "Removing configuration phase core files [expected]."
find . -type f -name "core" -exec rm -f {} \; -print
echo "Post-configuration succeeded."
else
echo "Standard configuration file ${TOPLEVELDIR}/../Solaris/rwconfig_std.h not found!"
echo "Post-configuration FAILED!!!"
exit 1
fi
else
echo "Initial configuration file 'config.h' has not been created."
echo "Post-configuration FAILED!!!"
exit 1
fi
}
finish() {
echo "stdcxx has been configured. You can now type '$MAKE' to build."
echo ""
cd ${TOPLEVELDIR}
touch config.done
exit 0
}
check_args $@
check_directories
check_buildtype
check_compiler_flags
check_gnu_make
fix_ansi_dir
make_config
post_config
finish