This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / d_gnulibc.U
1 ?RCS: $Id: d_gnulibc.U 1 2006-08-24 12:32:52Z rmanfredi $
2 ?RCS:
3 ?RCS: Copyright (c) 1996,1998 Andy Dougherty
4 ?RCS: Copyright (c) 1996, Sven Verdoolaege
5 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
6 ?RCS: 
7 ?RCS: You may redistribute only under the terms of the Artistic Licence,
8 ?RCS: as specified in the README file that comes with the distribution.
9 ?RCS: You may reuse parts of this distribution only within the terms of
10 ?RCS: that same Artistic Licence; a copy of which may be found at the root
11 ?RCS: of the source tree for dist 4.0.
12 ?RCS:
13 ?MAKE:d_gnulibc gnulibc_version: Myread Oldconfig Setvar rm \
14         cat Compile run
15 ?MAKE:  -pick add $@ %<
16 ?S:d_gnulibc:
17 ?S:     Defined if we're dealing with the GNU C Library.
18 ?S:.
19 ?S:gnulibc_version:
20 ?S:     This variable contains the version number of the GNU C library.
21 ?S:     It is usually something like '2.2.5'.  It is a plain '' if this
22 ?S:     is not the GNU C library, or if the version is unknown.
23 ?S:.
24 ?C:HAS_GNULIBC ~ %<:
25 ?C:     This symbol, if defined, indicates to the C program that 
26 ?C:     the GNU C library is being used.  A better check is to use
27 ?C:     the __GLIBC__ and __GLIBC_MINOR__ symbols supplied with glibc.
28 ?C:.
29 ?H:?%<:#$d_gnulibc HAS_GNULIBC          /**/
30 ?H:?%<:#if defined(HAS_GNULIBC) && !defined(_GNU_SOURCE)
31 ?H:?%<:#define _GNU_SOURCE
32 ?H:?%<:#endif
33 ?H:.
34 ?F:!glibc.ver !try.c !try
35 ?LINT: set d_gnulibc
36 ?LINT: usefile try.c
37 ?LINT: known _GNU_SOURCE
38 ?X:     gnulibc can be executed by calling __libc_main().
39 ?X:     Ulrich Drepper doesn't think any other libc does that,
40 ?X:     but we check if it says 'GNU C Library' to be sure.
41 ?X:
42 ?X: Alas, as of 3/1998 glibc 2.0.7 reportedly isn't going to
43 ?X: have __libc_main() anymore. :-(.  Fortunately, all released
44 ?X: versions of glibc 2.x.x _do_ have CPP variables.  For 2.0.6,
45 ?X: they are:
46 ?X: #define     __GLIBC__  2
47 ?X: #define__GLIBC_MINOR__ 0.
48 ?X: (The '6' isn't available :-(.
49 ?X: glibc2.1 will also have 
50 ?X:             extern const char * __gnu_get_libc_release(void);
51 ?X:             extern const char * __gnu_get_libc_version(void);
52 ?X: functions.   --thanks to Andreas Jaeger.   --AD  6/1998.
53 ?X: Although the exact format isn't documented, __gnu_get_libc_version()
54 ?X: returns a simple string '2.1.3' in glibc 2.1.3.
55 ?X:
56 : determine whether we are using a GNU C library
57 echo " "
58 echo "Checking for GNU C Library..." >&4
59 cat >try.c <<'EOCP'
60 /* Find out version of GNU C library.  __GLIBC__ and __GLIBC_MINOR__
61    alone are insufficient to distinguish different versions, such as
62    2.0.6 and 2.0.7.  The function gnu_get_libc_version() appeared in
63    libc version 2.1.0.      A. Dougherty,  June 3, 2002.
64 */
65 #include <stdio.h>
66 int main(void)
67 {
68 #ifdef __GLIBC__
69 #   ifdef __GLIBC_MINOR__
70 #       if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
71 #           include <gnu/libc-version.h>
72             printf("%s\n",  gnu_get_libc_version());
73 #       else
74             printf("%d.%d\n",  __GLIBC__, __GLIBC_MINOR__);
75 #       endif
76 #   else
77         printf("%d\n",  __GLIBC__);
78 #   endif
79     return 0;
80 #else
81     return 1;
82 #endif
83 }
84 EOCP
85 set try
86 if eval $compile_ok && $run ./try > glibc.ver; then
87         val="$define"
88         gnulibc_version=`$cat glibc.ver`
89         echo "You are using the GNU C Library version $gnulibc_version"
90 else
91         val="$undef"
92         gnulibc_version=''
93         echo "You are not using the GNU C Library"
94 fi
95 $rm -f try try.* glibc.ver
96 set d_gnulibc
97 eval $setvar
98