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