source: trunk/third/firefox/config/glibcversion.sh @ 21695

Revision 21695, 4.3 KB checked in by rbasch, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21694, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# The contents of this file are subject to the Netscape Public
4# License Version 1.1 (the "License"); you may not use this file
5# except in compliance with the License. You may obtain a copy of
6# the License at http://www.mozilla.org/NPL/
7#
8# Software distributed under the License is distributed on an "AS
9# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10# implied. See the License for the specific language governing
11# rights and limitations under the License.
12#
13# The Original Code is mozilla.org code.
14#
15# The Initial Developer of the Original Code is Netscape
16# Communications Corporation.  Portions created by Netscape are
17# Copyright (C) 1998 Netscape Communications Corporation. All
18# Rights Reserved.
19#
20# Contributor(s):
21#
22
23##############################################################################
24##
25## Name:                glibcversion.sh - Print __GLIBC__ version if gnu libc 2 is
26##              found.
27##
28## Description: This script is needed by the mozilla build system.  It needs
29##              to determine whether the current platform (mostly the
30##              various linux "platforms") are based on the gnu libc2.  This
31##              information is later used in mozilla to determine whether
32##              gnu libc 2 specific "features" need to be handled, such
33##              as broken locales.
34##
35## Author:              Ramiro Estrugo <ramiro@netscape.com>
36##
37##############################################################################
38
39##
40## Command Line Flags Supported:
41##
42##  -g  | --is-glibc2:                          Print True/False if detected __GLIBC__.
43##
44##  -v  | --print-version:                      Print value of __GLIBC__ if found, or none.
45##
46##  -o  | --set-object-name:            Set object name for current system.
47##  -cc | --set-compiler:                       Set compiler for building test program.
48##
49
50
51##
52## Constants
53##
54GLIBC_PROG_PREFIX=./get_glibc_info
55
56##
57## Defaults
58##
59GLIBC_PRINT_IS_GLIBC2=False
60
61GLIBC_PRINT_VERSION=False
62
63GLIBC_OBJECT_NAME=`uname`-`uname -r`
64GLIBC_CC=cc
65
66function glibc_usage()
67{
68echo
69echo "Usage:   `basename $0` [options]"
70echo
71echo "  -g,  --is-glibc2:          Print True/False if detected __GLIBC__."
72echo
73echo "  -v,  --print-version:      Print value of __GLIBC__ if found, or none."
74echo
75echo "  -o,  --set-object-name:    Set object name for current system."
76echo "  -cc, --set-compiler:       Set compiler for building test program."
77echo
78echo "  -h,  --help:               Print this blurb."
79echo
80echo "The default is '-v' if no options are given."
81echo
82}
83
84##
85## Parse the command line
86##
87while [ "$*" ]; do
88    case $1 in
89        -h | --help)
90            shift
91            glibc_usage
92                        exit 0
93            ;;
94
95        -g | --is-glibc2)
96            shift
97            GLIBC_PRINT_IS_GLIBC2=True
98            ;;
99
100        -v | --print-version)
101            shift
102            GLIBC_PRINT_VERSION=True
103            ;;
104
105        -o | --set-object-name)
106            shift
107            GLIBC_OBJECT_NAME="$1"
108            shift
109            ;;
110
111        -cc | --set-compiler)
112            shift
113            GLIBC_CC="$1"
114            shift
115            ;;
116
117        -*)
118            echo "`basename $0`: invalid option '$1'"
119            shift
120            glibc_usage
121                        exit 0
122            ;;
123    esac
124done
125
126##
127## Motif info program name
128##
129GLIBC_PROG="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME"
130GLIBC_SRC="$GLIBC_PROG_PREFIX"_"$GLIBC_OBJECT_NAME.c"
131
132##
133## Cleanup the dummy test source/program
134##
135function glibc_cleanup()
136{
137        true
138
139#       rm -f $GLIBC_PROG
140#       rm -f $GLIBC_SRC
141
142}
143
144glibc_cleanup
145
146if [ ! -f $GLIBC_SRC ]
147then
148cat << EOF > $GLIBC_SRC
149#include <stdio.h>
150
151int main(int argc,char ** argv)
152{
153#ifdef  __GLIBC__
154        fprintf(stdout,"%d\n",__GLIBC__);
155#else
156        fprintf(stdout,"none\n");
157#endif
158
159        return 0;
160}
161EOF
162fi
163
164if [ ! -f $GLIBC_SRC ]
165then
166        echo
167        echo "Could not create test program source $GLIBC_SRC."
168        echo
169
170        glibc_cleanup
171
172        exit
173fi
174
175##
176## Compile the dummy test program if needed
177##
178if [ ! -x $GLIBC_PROG ]
179then
180        $GLIBC_CC -o $GLIBC_PROG $GLIBC_SRC
181fi
182
183if [ ! -x $GLIBC_PROG ]
184then
185        echo
186        echo "Could not create test program $GLIBC_PROG."
187        echo
188
189        glibc_cleanup
190
191        exit
192fi
193
194##
195## Execute the dummy test program
196##
197GLIBC_PROG_OUTPUT=`$GLIBC_PROG`
198
199##
200## -g | --is-glibc2
201##
202if [ "$GLIBC_PRINT_IS_GLIBC2" = "True" ]
203then
204        if [ "$GLIBC_PROG_OUTPUT" = "2" ]
205        then
206                echo True
207        else
208                echo False
209        fi
210
211        glibc_cleanup
212
213        exit 0
214fi
215
216echo $GLIBC_PROG_OUTPUT
217
218glibc_cleanup
Note: See TracBrowser for help on using the repository browser.