/[path-sandbox]/trunk/create-localdecls
Gentoo

Contents of /trunk/create-localdecls

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Nov 19 22:03:42 2004 UTC (9 years, 7 months ago) by ferringb
File size: 2915 byte(s)
Initial revision

1 #!/bin/sh
2
3 # This is a quick'n'dirty hack to make the program behave correctly
4 # under different systems.
5 # Example:
6 # when using libc5, (f)trucate's offset argument type is size_t with
7 # libc5, but it's off_t with libc6 (glibc2).
8 #
9 # Uhm... time to learn GNU autoconf :-)
10 #
11 # $Header$
12
13 OUTFILE='localdecls.h'
14
15 # if your arch needs to dlopen() glibc, add it here separated by space :]
16 BROKEN_RTLD_ARCHLIST="mips"
17
18 echo '/* This file is automatically generated *' > $OUTFILE
19 echo ' * Modify create-localdecls instead of this */' >> $OUTFILE
20 echo >> $OUTFILE
21 echo '#ifndef __LOCALDECLS_H_' >> $OUTFILE
22 echo '#define __LOCALDECLS_H_' >> $OUTFILE
23 echo >> $OUTFILE
24
25 ###
26 ###
27 ###
28
29 echo -n 'Checking truncate argument type... '
30 if grep -q 'truncate.*size_t' /usr/include/unistd.h ; then
31 echo 'size_t'
32 echo '#define TRUNCATE_T size_t' >> $OUTFILE
33 else
34 echo 'off_t' # At least, I HOPE it's off_t :-)
35 echo '#define TRUNCATE_T off_t' >> $OUTFILE
36 fi
37
38 ###
39 ###
40 ###
41
42 echo -n 'Checking libc version... '
43 gcc -Wall -o libctest libctest.c
44 VERSION=`ldd libctest | grep libc\\.so | grep -v 'ld-uClibc' | awk '{print $1}'`
45
46 echo $VERSION
47 echo "#define LIBC_VERSION \"$VERSION\"" >> $OUTFILE
48 if test "$VERSION" = 'libc.so.5' ; then
49 echo '#define BROKEN_RTLD_NEXT' >> $OUTFILE
50 echo '#define LIBC 5' >> $OUTFILE
51 else
52 # for the arch's that need to dlopen() libc to fetch real funcs!
53 # 16.12.02 -Torgeir Hansen <torgeir@trenger.ro>
54 MYARCH=`/bin/uname -m`
55 for x in $BROKEN_RTLD_ARCHLIST; do
56 if [ $x = $MYARCH ]; then
57 echo '#define BROKEN_RTLD_NEXT' >> $OUTFILE
58 fi
59 done
60
61 fi
62
63 if test "$VERSION" = 'libc.so.6' ; then
64 echo -n 'Checking glibc subversion...'
65 tmp="$(ldd libctest 2>/dev/null | grep libc.so 2>/dev/null | head -n 1)"
66 LibcPath=`expr "$tmp" : '[^/]*\(/[^ ]*\)'`
67 tmp="`strings $LibcPath | grep -i 'c library'`"
68 OsLibcMajor=`expr "$tmp" : '.* \([0-9][0-9]*\)'`
69 OsLibcMinor=`expr "$tmp" : '.* [0-9][0-9]*\.\([0-9][0-9]*\)'`
70 echo " ${OsLibcMajor}.${OsLibcMinor}"
71 case "$OsLibcMajor" in
72 2)
73 # 2 is the glibc version
74 case "$OsLibcMinor" in
75 0)
76 echo '#define GLIBC_MINOR 0' >> $OUTFILE
77 SUBVERSION='glibc-2.0' ;;
78 1)
79 echo '#define GLIBC_MINOR 1' >> $OUTFILE
80 SUBVERSION='glibc-2.1' ;;
81 2)
82 echo '#define GLIBC_MINOR 2' >> $OUTFILE
83 SUBVERSION='glibc-2.2' ;;
84 3)
85 echo '#define GLIBC_MINOR 3' >> $OUTFILE
86 SUBVERSION='glibc-2.3' ;;
87 *)
88 echo 'Treated as glibc >= 2.1 (finger crossed)'
89 echo '#define GLIBC_MINOR 1' >> $OUTFILE
90 SUBVERSION='glibc-2.1' ;;
91 esac
92 ;;
93 esac
94 fi
95
96 rm libctest
97
98 echo '
99 #ifdef PATH_MAX
100 # define SB_PATH_MAX PATH_MAX * 2
101 # if (SB_PATH_MAX >= INT_MAX) || (SB_PATH_MAX < PATH_MAX)
102 # undef SB_PATH_MAX
103 # define SB_PATH_MAX PATH_MAX + 25
104 # if (SB_PATH_MAX >= INT_MAX) || (SB_PATH_MAX < PATH_MAX)
105 # error SB_PATH_MAX too big!
106 # endif
107 # endif
108 #else
109 # error PATH_MAX not defined!
110 #endif' >> $OUTFILE
111
112 echo >> $OUTFILE
113 echo '#endif' >> $OUTFILE
114 echo

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20