0N/A#!/bin/bash
0N/A#
0N/A# CDDL HEADER START
0N/A#
0N/A# The contents of this file are subject to the terms of the
0N/A# Common Development and Distribution License (the "License").
0N/A# You may not use this file except in compliance with the License.
0N/A#
0N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A# or http://www.opensolaris.org/os/licensing.
0N/A# See the License for the specific language governing permissions
0N/A# and limitations under the License.
0N/A#
0N/A# When distributing Covered Code, include this CDDL HEADER in each
0N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A# If applicable, add the following below this CDDL HEADER, with the
0N/A# fields enclosed by brackets "[]" replaced with your own identifying
0N/A# information: Portions Copyright [yyyy] [name of copyright owner]
0N/A#
0N/A# CDDL HEADER END
0N/A#
0N/A#
0N/A# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A#
0N/Aunset MAKEFLAGS
0N/Aunset MAKELEVEL
0N/A
0N/Aexport BUILDTYPE=""
0N/Aexport BUILDMODE=""
0N/Aexport CONFIG="sunpro.config"
0N/Aexport TOPLEVELDIR=""
0N/Aexport BUILDDIR=""
0N/Aexport LDSOFLAGS="${LDFLAGS}"
0N/Aexport CXXOPTS="${CXXFLAGS}"
0N/Aexport LDOPTS="${LDFLAGS}"
0N/Aexport LD="${CXX} ${CXXFLAGS} ${LDFLAGS}"
0N/A
0N/AUNKNOWN_ARG=yes
0N/APRINT_HELP=no
0N/A
0N/Acheck_args() {
0N/A while [ "$#" -gt 0 ] ; do
0N/A UNKNOWN_ARG=no
0N/A case "$1" in
0N/A -m32)
0N/A BUILDTYPE="8d"
0N/A BUILDMODE="shared,pthreads"
0N/A ;;
0N/A -m64)
0N/A BUILDTYPE="8D"
0N/A BUILDMODE="shared,pthreads"
0N/A ;;
0N/A -topdir=*)
0N/A TOPLEVELDIR=`echo $1 | sed "s,^-topdir=\(.*\),\1,"`
0N/A ;;
0N/A -builddir=*)
0N/A BUILDDIR=`echo $1 | sed "s,^-builddir=\(.*\),\1,"`
0N/A ;;
0N/A *)
0N/A UNKNOWN_ARG=yes
0N/A ;;
0N/A esac
0N/A
0N/A if [ "$UNKNOWN_ARG" = "yes" ] ; then
0N/A echo "$1: Invalid argument"
0N/A PRINT_HELP=yes
0N/A shift
0N/A continue
0N/A fi
0N/A shift
0N/A done
0N/A
0N/A export BUILDTYPE BUILDMODE TOPLEVELDIR
0N/A export BUILDDIR="${TOPLEVELDIR}/build"
0N/A export LD_LIBRARY_PATH="${BUILDDIR}/lib:${LD_LIBRARY_PATH}"
0N/A
0N/A echo "BUILDTYPE: ${BUILDTYPE}"
0N/A echo "TOPLEVELDIR: ${TOPLEVELDIR}"
0N/A echo "BUILDDIR: ${BUILDDIR}"
0N/A
0N/A cd ${TOPLEVELDIR}
0N/A if [ -f config.done ] ; then
0N/A rm -f config.done
0N/A fi
0N/A
0N/A if [ "x${BUILDTYPE}" = "x" ] || [ "x${TOPLEVELDIR}" = "x" ] ; then
0N/A PRINT_HELP=yes
0N/A fi
0N/A
0N/A if [ "$PRINT_HELP" = "yes" ] || [ "$UNKNOWN_ARG" = "yes" ] ; then
0N/A echo "Usage: `basename $0` [ -m32 | -m64 ] --topdir=[ \$(top_srcdir) ]"
0N/A exit 1
0N/A fi
0N/A}
0N/A
0N/Acheck_directories() {
0N/A if [ ! -d Solaris ] ; then
0N/A echo "Expected directory Solaris not found."
0N/A echo "Make sure this directory exists in the stdcxx toplevel."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A}
0N/A
0N/Acheck_buildtype() {
0N/A if [ "x${BUILDTYPE}" = "x" ] ; then
0N/A echo "\$BUILDTYPE [ 8d | 8D ] is not set."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "BUILDTYPE: ${BUILDTYPE}."
0N/A echo "BUILDMODE: ${BUILDMODE}."
0N/A}
0N/A
0N/Acheck_compiler_flags() {
0N/A if [ "x${CC}" = "x" ] ; then
0N/A echo "\$CC is not set."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "CC: ${CC}."
0N/A export CC=`echo ${CC}`
0N/A
0N/A if [ "x${CXX}" = "x" ] ; then
0N/A echo "\$CXX is not set."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "CXX: ${CXX}."
0N/A export CXX=`echo ${CXX}`
0N/A
0N/A if [ "x${CFLAGS}" = "x" ] ; then
0N/A echo "\$CFLAGS is not set."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "CFLAGS: ${CFLAGS}."
0N/A
0N/A if [ "x${CPPFLAGS}" = "x" ] ; then
0N/A echo "\$CPPFLAGS is not set."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "CPPFLAGS: ${CPPFLAGS}."
0N/A
0N/A if [ "x${CXXFLAGS}" = "x" ] ; then
0N/A echo "\$CXXFLAGS is not set. Make sure you have set -library=no%Cstd."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "CXXFLAGS: ${CXXFLAGS}."
0N/A
0N/A if [ "x${LDFLAGS}" = "x" ] ; then
0N/A echo "\$LDFLAGS is not set."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A echo "LDFLAGS: ${LDFLAGS}."
0N/A}
0N/A
0N/Acheck_gnu_make() {
0N/A if [ "x${MAKE}" = "x" ] ; then
0N/A echo "\$MAKE is not set. Please use GNU make to build stdcxx."
0N/A echo ""
0N/A exit 1
0N/A fi
0N/A gnumake=`${MAKE} --version | grep -- "GNU"`
0N/A if [ "x${gnumake}" = "x" ] ; then
0N/A echo "\$MAKE is not GNU make. stdcxx requires GNU make."
0N/A exit 1
0N/A fi
0N/A echo "MAKE: ${MAKE}."
0N/A}
0N/A
0N/Afix_ansi_dir() {
0N/A cd ${TOPLEVELDIR}
0N/A
0N/A for file in \
0N/A wctype.h \
0N/A wchar.h \
0N/A time.h \
0N/A string.h \
0N/A stdlib.h \
0N/A stdio.h \
0N/A stddef.h \
0N/A stdarg.h \
0N/A signal.h \
0N/A setjmp.h \
0N/A math.h \
0N/A locale.h \
0N/A limits.h \
0N/A float.h \
0N/A errno.h \
0N/A ctype.h \
0N/A 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