Backed out changeset 8c25245410c5 (bug 909888) for being far from NPOTB and breaking...
[gecko.git] / config / glibcversion.sh
blobadccc4f6c895b2e6b96b224cdcef225617fcc9d3
1 #!/bin/sh
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 ##############################################################################
8 ##
9 ## Name: glibcversion.sh - Print __GLIBC__ version if gnu libc 2 is
10 ## found.
12 ## Description: This script is needed by the mozilla build system. It needs
13 ## to determine whether the current platform (mostly the
14 ## various linux "platforms") are based on the gnu libc2. This
15 ## information is later used in mozilla to determine whether
16 ## gnu libc 2 specific "features" need to be handled, such
17 ## as broken locales.
19 ## Author: Ramiro Estrugo <ramiro@netscape.com>
21 ##############################################################################
24 ## Command Line Flags Supported:
26 ## -g | --is-glibc2: Print True/False if detected __GLIBC__.
28 ## -v | --print-version: Print value of __GLIBC__ if found, or none.
30 ## -o | --set-object-name: Set object name for current system.
31 ## -cc | --set-compiler: Set compiler for building test program.
36 ## Constants
38 GLIBC_PROG_PREFIX=./get_glibc_info
41 ## Defaults
43 GLIBC_PRINT_IS_GLIBC2=False
45 GLIBC_PRINT_VERSION=False
47 GLIBC_OBJECT_NAME=`uname`-`uname -r`
48 GLIBC_CC=cc
50 function glibc_usage()
52 echo
53 echo "Usage: `basename $0` [options]"
54 echo
55 echo " -g, --is-glibc2: Print True/False if detected __GLIBC__."
56 echo
57 echo " -v, --print-version: Print value of __GLIBC__ if found, or none."
58 echo
59 echo " -o, --set-object-name: Set object name for current system."
60 echo " -cc, --set-compiler: Set compiler for building test program."
61 echo
62 echo " -h, --help: Print this blurb."
63 echo
64 echo "The default is '-v' if no options are given."
65 echo
69 ## Parse the command line
71 while [ "$*" ]; do
72 case $1 in
73 -h | --help)
74 shift
75 glibc_usage
76 exit 0
79 -g | --is-glibc2)
80 shift
81 GLIBC_PRINT_IS_GLIBC2=True
84 -v | --print-version)
85 shift
86 GLIBC_PRINT_VERSION=True
89 -o | --set-object-name)
90 shift
91 GLIBC_OBJECT_NAME="$1"
92 shift
95 -cc | --set-compiler)
96 shift
97 GLIBC_CC="$1"
98 shift
102 echo "`basename $0`: invalid option '$1'"
103 shift
104 glibc_usage
105 exit 0
107 esac
108 done
111 ## Motif info program name
113 GLIBC_PROG="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME"
114 GLIBC_SRC="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME.c"
117 ## Cleanup the dummy test source/program
119 function glibc_cleanup()
121 true
123 # rm -f $GLIBC_PROG
124 # rm -f $GLIBC_SRC
128 glibc_cleanup
130 if [ ! -f $GLIBC_SRC ]
131 then
132 cat << EOF > $GLIBC_SRC
133 #include <stdio.h>
135 int main(int argc,char ** argv)
137 #ifdef __GLIBC__
138 fprintf(stdout,"%d\n",__GLIBC__);
139 #else
140 fprintf(stdout,"none\n");
141 #endif
143 return 0;
148 if [ ! -f $GLIBC_SRC ]
149 then
150 echo
151 echo "Could not create test program source $GLIBC_SRC."
152 echo
154 glibc_cleanup
156 exit
160 ## Compile the dummy test program if needed
162 if [ ! -x $GLIBC_PROG ]
163 then
164 $GLIBC_CC -o $GLIBC_PROG $GLIBC_SRC
167 if [ ! -x $GLIBC_PROG ]
168 then
169 echo
170 echo "Could not create test program $GLIBC_PROG."
171 echo
173 glibc_cleanup
175 exit
179 ## Execute the dummy test program
181 GLIBC_PROG_OUTPUT=`$GLIBC_PROG`
184 ## -g | --is-glibc2
186 if [ "$GLIBC_PRINT_IS_GLIBC2" = "True" ]
187 then
188 if [ "$GLIBC_PROG_OUTPUT" = "2" ]
189 then
190 echo True
191 else
192 echo False
195 glibc_cleanup
197 exit 0
200 echo $GLIBC_PROG_OUTPUT
202 glibc_cleanup