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 ##############################################################################
9 ## Name: glibcversion.sh - Print __GLIBC__ version if gnu libc 2 is
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
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.
38 GLIBC_PROG_PREFIX
=.
/get_glibc_info
43 GLIBC_PRINT_IS_GLIBC2
=False
45 GLIBC_PRINT_VERSION
=False
47 GLIBC_OBJECT_NAME
=`uname`-`uname -r`
50 function glibc_usage
()
53 echo "Usage: `basename $0` [options]"
55 echo " -g, --is-glibc2: Print True/False if detected __GLIBC__."
57 echo " -v, --print-version: Print value of __GLIBC__ if found, or none."
59 echo " -o, --set-object-name: Set object name for current system."
60 echo " -cc, --set-compiler: Set compiler for building test program."
62 echo " -h, --help: Print this blurb."
64 echo "The default is '-v' if no options are given."
69 ## Parse the command line
81 GLIBC_PRINT_IS_GLIBC2
=True
86 GLIBC_PRINT_VERSION
=True
89 -o |
--set-object-name)
91 GLIBC_OBJECT_NAME
="$1"
102 echo "`basename $0`: invalid option '$1'"
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
()
130 if [ ! -f $GLIBC_SRC ]
132 cat << EOF > $GLIBC_SRC
135 int main(int argc,char ** argv)
138 fprintf(stdout,"%d\n",__GLIBC__);
140 fprintf(stdout,"none\n");
148 if [ ! -f $GLIBC_SRC ]
151 echo "Could not create test program source $GLIBC_SRC."
160 ## Compile the dummy test program if needed
162 if [ ! -x $GLIBC_PROG ]
164 $GLIBC_CC -o $GLIBC_PROG $GLIBC_SRC
167 if [ ! -x $GLIBC_PROG ]
170 echo "Could not create test program $GLIBC_PROG."
179 ## Execute the dummy test program
181 GLIBC_PROG_OUTPUT
=`$GLIBC_PROG`
186 if [ "$GLIBC_PRINT_IS_GLIBC2" = "True" ]
188 if [ "$GLIBC_PROG_OUTPUT" = "2" ]
200 echo $GLIBC_PROG_OUTPUT