config/glibcversion.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/config/glibcversion.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,202 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +##############################################################################
    1.11 +##
    1.12 +## Name:		glibcversion.sh - Print __GLIBC__ version if gnu libc 2 is 
    1.13 +##              found.
    1.14 +##
    1.15 +## Description:	This script is needed by the mozilla build system.  It needs
    1.16 +##              to determine whether the current platform (mostly the 
    1.17 +##              various linux "platforms") are based on the gnu libc2.  This
    1.18 +##              information is later used in mozilla to determine whether 
    1.19 +##              gnu libc 2 specific "features" need to be handled, such
    1.20 +##              as broken locales.
    1.21 +##
    1.22 +## Author:		Ramiro Estrugo <ramiro@netscape.com>
    1.23 +##
    1.24 +##############################################################################
    1.25 +
    1.26 +##
    1.27 +## Command Line Flags Supported:
    1.28 +##
    1.29 +##  -g  | --is-glibc2:				Print True/False if detected __GLIBC__.
    1.30 +##
    1.31 +##  -v  | --print-version:			Print value of __GLIBC__ if found, or none.
    1.32 +##
    1.33 +##  -o  | --set-object-name:		Set object name for current system.
    1.34 +##  -cc | --set-compiler:			Set compiler for building test program.
    1.35 +##
    1.36 +
    1.37 +
    1.38 +##
    1.39 +## Constants
    1.40 +##
    1.41 +GLIBC_PROG_PREFIX=./get_glibc_info
    1.42 +
    1.43 +##
    1.44 +## Defaults
    1.45 +##
    1.46 +GLIBC_PRINT_IS_GLIBC2=False
    1.47 +
    1.48 +GLIBC_PRINT_VERSION=False
    1.49 +
    1.50 +GLIBC_OBJECT_NAME=`uname`-`uname -r`
    1.51 +GLIBC_CC=cc
    1.52 +
    1.53 +function glibc_usage()
    1.54 +{
    1.55 +echo
    1.56 +echo "Usage:   `basename $0` [options]"
    1.57 +echo
    1.58 +echo "  -g,  --is-glibc2:          Print True/False if detected __GLIBC__."
    1.59 +echo
    1.60 +echo "  -v,  --print-version:      Print value of __GLIBC__ if found, or none."
    1.61 +echo
    1.62 +echo "  -o,  --set-object-name:    Set object name for current system."
    1.63 +echo "  -cc, --set-compiler:       Set compiler for building test program."
    1.64 +echo
    1.65 +echo "  -h,  --help:               Print this blurb."
    1.66 +echo
    1.67 +echo "The default is '-v' if no options are given."
    1.68 +echo
    1.69 +}
    1.70 +
    1.71 +##
    1.72 +## Parse the command line
    1.73 +##
    1.74 +while [ "$*" ]; do
    1.75 +    case $1 in
    1.76 +        -h | --help)
    1.77 +            shift
    1.78 +            glibc_usage
    1.79 +			exit 0
    1.80 +            ;;
    1.81 +
    1.82 +        -g | --is-glibc2)
    1.83 +            shift
    1.84 +            GLIBC_PRINT_IS_GLIBC2=True
    1.85 +            ;;
    1.86 +
    1.87 +        -v | --print-version)
    1.88 +            shift
    1.89 +            GLIBC_PRINT_VERSION=True
    1.90 +            ;;
    1.91 +
    1.92 +        -o | --set-object-name)
    1.93 +            shift
    1.94 +            GLIBC_OBJECT_NAME="$1"
    1.95 +            shift
    1.96 +            ;;
    1.97 +
    1.98 +        -cc | --set-compiler)
    1.99 +            shift
   1.100 +            GLIBC_CC="$1"
   1.101 +            shift
   1.102 +            ;;
   1.103 +
   1.104 +        -*)
   1.105 +            echo "`basename $0`: invalid option '$1'"
   1.106 +            shift
   1.107 +            glibc_usage
   1.108 +			exit 0
   1.109 +            ;;
   1.110 +    esac
   1.111 +done
   1.112 +
   1.113 +##
   1.114 +## Motif info program name
   1.115 +##
   1.116 +GLIBC_PROG="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME"
   1.117 +GLIBC_SRC="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME.c"
   1.118 +
   1.119 +##
   1.120 +## Cleanup the dummy test source/program
   1.121 +##
   1.122 +function glibc_cleanup()
   1.123 +{
   1.124 +	true
   1.125 +
   1.126 +#	rm -f $GLIBC_PROG
   1.127 +#	rm -f $GLIBC_SRC
   1.128 +
   1.129 +}
   1.130 +
   1.131 +glibc_cleanup
   1.132 +
   1.133 +if [ ! -f $GLIBC_SRC ]
   1.134 +then
   1.135 +cat << EOF > $GLIBC_SRC
   1.136 +#include <stdio.h>
   1.137 +
   1.138 +int main(int argc,char ** argv) 
   1.139 +{
   1.140 +#ifdef 	__GLIBC__
   1.141 +	fprintf(stdout,"%d\n",__GLIBC__);
   1.142 +#else
   1.143 +	fprintf(stdout,"none\n");
   1.144 +#endif
   1.145 +
   1.146 +	return 0;
   1.147 +}
   1.148 +EOF
   1.149 +fi
   1.150 +
   1.151 +if [ ! -f $GLIBC_SRC ]
   1.152 +then
   1.153 +	echo
   1.154 +	echo "Could not create test program source $GLIBC_SRC."
   1.155 +	echo
   1.156 +
   1.157 +	glibc_cleanup
   1.158 +
   1.159 +	exit
   1.160 +fi
   1.161 +
   1.162 +##
   1.163 +## Compile the dummy test program if needed
   1.164 +##
   1.165 +if [ ! -x $GLIBC_PROG ]
   1.166 +then
   1.167 +	$GLIBC_CC -o $GLIBC_PROG $GLIBC_SRC
   1.168 +fi
   1.169 +
   1.170 +if [ ! -x $GLIBC_PROG ]
   1.171 +then
   1.172 +	echo
   1.173 +	echo "Could not create test program $GLIBC_PROG."
   1.174 +	echo
   1.175 +
   1.176 +	glibc_cleanup
   1.177 +
   1.178 +	exit
   1.179 +fi
   1.180 +
   1.181 +##
   1.182 +## Execute the dummy test program
   1.183 +##
   1.184 +GLIBC_PROG_OUTPUT=`$GLIBC_PROG`
   1.185 +
   1.186 +##
   1.187 +## -g | --is-glibc2
   1.188 +##
   1.189 +if [ "$GLIBC_PRINT_IS_GLIBC2" = "True" ]
   1.190 +then
   1.191 +	if [ "$GLIBC_PROG_OUTPUT" = "2" ]
   1.192 +	then
   1.193 +		echo True
   1.194 +	else
   1.195 +		echo False
   1.196 +	fi
   1.197 +
   1.198 +	glibc_cleanup
   1.199 +
   1.200 +	exit 0
   1.201 +fi
   1.202 +
   1.203 +echo $GLIBC_PROG_OUTPUT
   1.204 +
   1.205 +glibc_cleanup

mercurial