3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998
21 # the Initial Developer. All Rights Reserved.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either of the GNU General Public License Version 2 or later (the "GPL"),
27 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
39 ##############################################################################
41 ## Name: glibcversion.sh - Print __GLIBC__ version if gnu libc 2 is
44 ## Description: This script is needed by the mozilla build system. It needs
45 ## to determine whether the current platform (mostly the
46 ## various linux "platforms") are based on the gnu libc2. This
47 ## information is later used in mozilla to determine whether
48 ## gnu libc 2 specific "features" need to be handled, such
51 ## Author: Ramiro Estrugo <ramiro@netscape.com>
53 ##############################################################################
56 ## Command Line Flags Supported:
58 ## -g | --is-glibc2: Print True/False if detected __GLIBC__.
60 ## -v | --print-version: Print value of __GLIBC__ if found, or none.
62 ## -o | --set-object-name: Set object name for current system.
63 ## -cc | --set-compiler: Set compiler for building test program.
70 GLIBC_PROG_PREFIX
=.
/get_glibc_info
75 GLIBC_PRINT_IS_GLIBC2
=False
77 GLIBC_PRINT_VERSION
=False
79 GLIBC_OBJECT_NAME
=`uname`-`uname -r`
82 function glibc_usage
()
85 echo "Usage: `basename $0` [options]"
87 echo " -g, --is-glibc2: Print True/False if detected __GLIBC__."
89 echo " -v, --print-version: Print value of __GLIBC__ if found, or none."
91 echo " -o, --set-object-name: Set object name for current system."
92 echo " -cc, --set-compiler: Set compiler for building test program."
94 echo " -h, --help: Print this blurb."
96 echo "The default is '-v' if no options are given."
101 ## Parse the command line
113 GLIBC_PRINT_IS_GLIBC2
=True
116 -v |
--print-version)
118 GLIBC_PRINT_VERSION
=True
121 -o |
--set-object-name)
123 GLIBC_OBJECT_NAME
="$1"
127 -cc |
--set-compiler)
134 echo "`basename $0`: invalid option '$1'"
143 ## Motif info program name
145 GLIBC_PROG
="$GLIBC_PROG_PREFIX"_
"$GLIBC_OBJECT_NAME"
146 GLIBC_SRC
="$GLIBC_PROG_PREFIX"_
"$GLIBC_OBJECT_NAME.c"
149 ## Cleanup the dummy test source/program
151 function glibc_cleanup
()
162 if [ ! -f $GLIBC_SRC ]
164 cat << EOF > $GLIBC_SRC
167 int main(int argc,char ** argv)
170 fprintf(stdout,"%d\n",__GLIBC__);
172 fprintf(stdout,"none\n");
180 if [ ! -f $GLIBC_SRC ]
183 echo "Could not create test program source $GLIBC_SRC."
192 ## Compile the dummy test program if needed
194 if [ ! -x $GLIBC_PROG ]
196 $GLIBC_CC -o $GLIBC_PROG $GLIBC_SRC
199 if [ ! -x $GLIBC_PROG ]
202 echo "Could not create test program $GLIBC_PROG."
211 ## Execute the dummy test program
213 GLIBC_PROG_OUTPUT
=`$GLIBC_PROG`
218 if [ "$GLIBC_PRINT_IS_GLIBC2" = "True" ]
220 if [ "$GLIBC_PROG_OUTPUT" = "2" ]
232 echo $GLIBC_PROG_OUTPUT