components/stdcxx/Solaris/prep_build_area.sh
changeset 402 94ae4d75524c
equal deleted inserted replaced
401:bf52ef48020c 402:94ae4d75524c
       
     1 #!/bin/bash
       
     2 #
       
     3 # CDDL HEADER START
       
     4 #
       
     5 # The contents of this file are subject to the terms of the
       
     6 # Common Development and Distribution License (the "License").
       
     7 # You may not use this file except in compliance with the License.
       
     8 #
       
     9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
    10 # or http://www.opensolaris.org/os/licensing.
       
    11 # See the License for the specific language governing permissions
       
    12 # and limitations under the License.
       
    13 #
       
    14 # When distributing Covered Code, include this CDDL HEADER in each
       
    15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    16 # If applicable, add the following below this CDDL HEADER, with the
       
    17 # fields enclosed by brackets "[]" replaced with your own identifying
       
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    19 #
       
    20 # CDDL HEADER END
       
    21 #
       
    22 # Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
       
    23 #
       
    24 export SRCDIR=""
       
    25 export BUILDDIR=""
       
    26 export MACH64=""
       
    27 export IS_64_BIT="no"
       
    28 export MACH=`uname -p`
       
    29 export MACH64=""
       
    30 export UNKNOWN_ARG="no"
       
    31 export PRINT_HELP="no"
       
    32 export PATH="/usr/gnu/bin:${PATH}"
       
    33 unset TOPDIR
       
    34 
       
    35 check_args() {
       
    36     while [ "$#" -gt 0 ] ; do
       
    37         UNKNOWN_ARG=no
       
    38         case "$1" in
       
    39             -m32)
       
    40 	    IS_64_BIT="no"
       
    41             ;;
       
    42             -m64)
       
    43 	    IS_64_BIT="yes"
       
    44             ;;
       
    45             -srcdir=*)
       
    46             SRCDIR=`echo $1 | sed "s,^-srcdir=\(.*\),\1,"`
       
    47             ;;
       
    48             -builddir=*)
       
    49             BUILDDIR=`echo $1 | sed "s,^-builddir=\(.*\),\1,"`
       
    50             ;;
       
    51             *)
       
    52             UNKNOWN_ARG="yes"
       
    53             ;;
       
    54         esac
       
    55 
       
    56         if [ "$UNKNOWN_ARG" = "yes" ] ; then
       
    57             echo "$1: Invalid argument"
       
    58             PRINT_HELP="yes"
       
    59             shift
       
    60             continue
       
    61         fi
       
    62         shift
       
    63     done
       
    64 
       
    65     export IS_64_BIT SRCDIR BUILDDIR
       
    66 
       
    67     if [ "x${SRCDIR}" = "x" ] || [ "x${BUILDDIR}" = "x" ] ; then
       
    68 	PRINT_HELP="yes"
       
    69     fi
       
    70 
       
    71     if [ "${PRINT_HELP}" = "yes" ] ; then
       
    72 	echo "Usage: `basename $0` [ -m32 | -m64 ]"
       
    73 	echo "		[ -srcdir=<source directory> ]"
       
    74 	echo "		[ -builddir=<build directory> ]"
       
    75 	echo ""
       
    76 	exit 1
       
    77     fi
       
    78 
       
    79     if [ "${MACH}" = "sparc" ] ; then
       
    80 	MACH64="sparcv9"
       
    81     else
       
    82 	MACH64="amd64"
       
    83     fi
       
    84 
       
    85     export MACH MACH64
       
    86 }
       
    87 
       
    88 clean_symlinks() {
       
    89     if [ ! -d ${BUILDDIR} ] ; then
       
    90 	echo "build directory ${BUILDDIR} not found or unreadable!"
       
    91 	exit 1
       
    92     fi
       
    93 
       
    94     if [ ! -d ${SRCDIR} ] ; then
       
    95 	echo "source directory ${SRCDIR} not found or unreadable!"
       
    96 	exit 1
       
    97     fi
       
    98 
       
    99     cd ${BUILDDIR}/etc/nls
       
   100 
       
   101     for file in \
       
   102 	languages \
       
   103 	encodings \
       
   104 	countries \
       
   105 	gen_list
       
   106 do
       
   107     if [ -L ${file} ] ; then
       
   108 	rm ${file}
       
   109     fi
       
   110 done
       
   111 
       
   112     cd ${BUILDDIR}/build
       
   113 
       
   114     if [ -d nls ] ; then
       
   115 	rm -rf nls
       
   116     fi
       
   117 }
       
   118 
       
   119 create_symlinks() {
       
   120     cd ${BUILDDIR}/etc/nls
       
   121 
       
   122     for file in \
       
   123 	languages \
       
   124 	encodings \
       
   125 	countries \
       
   126 	gen_list
       
   127 do
       
   128     if [ ! -L ${file} ] ; then
       
   129 	if [ -f ${SRCDIR}/etc/nls/${file} ] ; then
       
   130 	    ln -sf ${SRCDIR}/etc/nls/${file}
       
   131 	else
       
   132 	    echo "source file ${SRCDIR}/etc/nls/${file} not found or unreadable!"
       
   133 	fi
       
   134     fi
       
   135 done
       
   136 
       
   137     cd ${BUILDDIR}/build
       
   138 
       
   139     if [ -L nls ] ; then
       
   140 	rm nls
       
   141     fi
       
   142 
       
   143     ln -sf ${SRCDIR}/build/nls
       
   144 }
       
   145 
       
   146 check_args $@
       
   147 clean_symlinks
       
   148 create_symlinks
       
   149 
       
   150 exit 0
       
   151 
       
   152 
       
   153