1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-libs/uclibc/uclibc-0.9.26-r8.ebuild,v 1.2 2004/11/11 01:06:15 solar Exp $
inherit eutils flag-o-matic gcc
# To make a new CVS_VER we do.
# wget -O - http://uclibc.org/downloads/snapshots/uClibc-`date +%Y%m%d`.tar.bz2 | tar jxf -
# tar jxf /usr/portage/distfiles/uClibc-0.9.26.tar.bz2
# diff -urN --exclude .cvsignore --exclude CVS uClibc-0.9.26 uClibc | bzip2 - > uClibc-0.9.26-cvs-update-`date +%Y%m%d`.patch.bz2
# rm -rf uClibc-0.9.26-cvs-update-`date +%Y%m%d`.patch.bz2 uClibc uClibc-0.9.26
MY_P="${P/ucl/uCl}"
CVS_VER="20041110"
PATCH_VER="1.2"
DESCRIPTION="C library for developing embedded Linux systems"
HOMEPAGE="http://www.uclibc.org/"
SRC_URI="http://www.kernel.org/pub/linux/libs/uclibc/${MY_P}.tar.bz2
mirror://gentoo/${MY_P}-cvs-update-${CVS_VER}.patch.bz2
mirror://gentoo/${MY_P}-patches-${PATCH_VER}.tar.bz2"
LICENSE="LGPL-2"
SLOT="0"
KEYWORDS="-*"
#KEYWORDS="~x86 ~ppc ~sparc ~mips ~arm"
IUSE="build hardened ipv6 static debug" # nls is not supported yet
RESTRICT="nostrip"
DEPEND="sys-devel/gcc"
RDEPEND=""
PROVIDE="virtual/glibc virtual/libc"
S=${WORKDIR}/${MY_P}
CPU_ARM="GENERIC_ARM ARM{610,710,720T,920T,922T,926T,_{SA110,SA1100,XSCALE}}"
CPU_MIPS="MIPS_ISA_{1,2,3,4,MIPS{32,64}}"
CPU_PPC=""
CPU_SH="SH{2,3,4,5}"
CPU_X86="GENERIC_386 {3,4,5,6}86 PENTIUM{II,III,4} K{6,7} ELAN CRUSOE WINCHIP{C6,2} CYRIXIII NEHEMIAH"
IUSE_UCLIBC_CPU="${CPU_ARM} ${CPU_MIPS} ${CPU_PPC} ${CPU_SH} ${CPU_X86}"
IUSE_UCLIBC_ENDIAN="LITTLE BIG"
check_cpu_opts() {
local cpu_var="CPU_$(echo ${ARCH} | tr [a-z] [A-Z])"
if [ -z "${UCLIBC_CPU}" ] ; then
ewarn "You really should consider setting UCLIBC_CPU"
ewarn "Otherwise, the build will be generic (read: slow)."
ewarn "Available CPU options:"
eval echo ${!cpu_var}
export UCLIBC_CPU="${UCLIBC_CPU_DEFAULT}"
else
local cpu found=0
for cpu in $(eval echo ${!cpu_var}) ; do
[ "${UCLIBC_CPU}" = "${cpu}" ] && found=1 && break
done
if [ ${found} -eq 0 ] ; then
ewarn "UCLIBC_CPU choice '${UCLIBC_CPU}' not supported"
ewarn "Valid choices:"
eval echo ${!cpu_var}
die "pick a supported cpu type"
fi
fi
if [ -z "${UCLIBC_ENDIAN}" ] ; then
ewarn "You really should consider setting UCLIBC_ENDIAN"
ewarn "Otherwise, the build may choose the wrong default."
ewarn "Available CPU endians: little big"
export UCLIBC_ENDIAN="${UCLIBC_ENDIAN_DEFAULT}"
else
export UCLIBC_ENDIAN="$(echo ${UCLIBC_ENDIAN} | tr [a-z] [A-Z])"
if [ "${UCLIBC_ENDIAN}" != "LITTLE" -a "${UCLIBC_ENDIAN}" != "BIG" ] ; then
die "UCLIBC_ENDIAN may only be 'little' or 'big'"
fi
fi
}
check_main_libc() {
if [ "${CHOST/uclibc}" != "${CHOST}" ] ; then
SYS_LIBC=uClibc
else
SYS_LIBC=glibc
fi
export SYS_LIBC
echo
einfo "We are building for ${SYS_LIBC} system library"
echo
}
src_unpack() {
unpack ${A}
cd ${S}
check_cpu_opts
########## PATCHES ##########
[ -n "${CVS_VER}" ] && \
epatch ${DISTDIR}/${MY_P}-cvs-update-${CVS_VER}.patch.bz2
cp ${FILESDIR}/0.9.26/ssp.c ${S}/libc/sysdeps/linux/common/ \
|| die "failed to copy ssp.c to ${S}/libc/sysdeps/linux/common/"
# gcc 3.4 nukes ssp without this patch
[ "`gcc-major-version`" -eq "3" -a "`gcc-minor-version`" -ge "4" ] && \
epatch ${FILESDIR}/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch
if [ -n "${PATCH_VER}" ] ; then
unpack ${MY_P}-patches-${PATCH_VER}.tar.bz2
mv ${WORKDIR}/patch/*frandom* ${WORKDIR}/patch/exclude/
# zdefs/main patches, not yet properly tested
mv ${WORKDIR}/patch/*{zdefs,main}* ${WORKDIR}/patch/exclude/
# needed for gcc-3.4 after frandom
mv ${WORKDIR}/patch/*attribute* ${WORKDIR}/patch/exclude/
epatch ${WORKDIR}/patch
# for math functions (j2sdk/xorg-x11)
#epatch ${WORKDIR}/patch/math
fi
# support archs which dont implement all syscalls
[ -z "${CVS_VER}" ] \
&& epatch ${FILESDIR}/${PV}/arm-fix-missing-syscalls.patch \
|| epatch ${FILESDIR}/${PV}/uclibc-0.9.26-arm-dl-sysdep.patch
# fixup for install perms
sed -i -e "s:-fa:-dRf:g" Makefile
########## CPU SELECTION ##########
local target config_target
case ${ARCH} in
arm) target="arm"; config_target="GENERIC_ARM";;
mips) target="mips"; config_target="MIPS_ISA_1";;
ppc) target="powerpc"; config_target="no cpu-specific options";;
sh) target="sh"; config_target="SH4";;
x86) target="i386"; config_target="GENERIC_386";;
*) die "${ARCH} lists no defaults :/";;
esac
sed -i -e "s:default TARGET_i386:default TARGET_${target}:" \
extra/Configs/Config.in
sed -i -e "s:default CONFIG_${config_target}:default CONFIG_${UCLIBC_CPU:-${config_target}}:" \
extra/Configs/Config.${target}
########## CONFIG SETUP ##########
make defconfig >/dev/null || die "could not config"
for def in UCLIBC_PROFILING DO{DEBUG,ASSERTS} SUPPORT_LD_DEBUG{,_EARLY} ; do
sed -i -e "s:${def}=y:# ${def} is not set:" .config
done
if use debug ; then
echo "SUPPORT_LD_DEBUG=y" >> .config
echo "DODEBUG=y" >> .config
fi
sed -i -e 's:^ARCH_.*_ENDIAN=y::' .config
echo "ARCH_${UCLIBC_ENDIAN}_ENDIAN=y" >> .config
for def in DO_C99_MATH UCLIBC_HAS_{RPC,CTYPE_CHECKED,WCHAR,HEXADECIMAL_FLOATS,GLIBC_CUSTOM_PRINTF,FOPEN_EXCLUSIVE_MODE,GLIBC_CUSTOM_STREAMS,PRINTF_M_SPEC,FTW} ; do
sed -i -e "s:# ${def} is not set:${def}=y:" .config
done
echo "UCLIBC_HAS_FULL_RPC=y" >> .config
echo "PTHREADS_DEBUG_SUPPORT=y" >> .config
#if use nls
#then
# sed -i -e "s:# UCLIBC_HAS_LOCALE is not set:UCLIBC_HAS_LOCALE=y:" .config
# echo "UCLIBC_HAS_XLOCALE=n" >> .config
# echo "UCLIBC_HAS_GLIBC_DIGIT_GROUPING=y" >> .config
# echo "UCLIBC_HAS_SCANF_LENIENT_DIGIT_GROUPING=y" >> .config
# # removed on 20040907 by mjn3
# echo "UCLIBC_HAS_GETTEXT_AWARENESS=y" >> .config
# # on pax enabled kernels the locale files can't be built
# echo "UCLIBC_PREGENERATED_LOCALE_DATA=n" >> .config
#fi
# we disable LOCALE for any case, gettext has to be used
echo "UCLIBC_HAS_LOCALE=n" >> .config
use ipv6 && sed -i -e "s:# UCLIBC_HAS_IPV6 is not set:UCLIBC_HAS_IPV6=y:" .config
if use hardened ; then
sed -i -e "s:# UCLIBC_SECURITY.*:UCLIBC_SECURITY=y:" .config
if has ${ARCH} x86 ppc mips; then
einfo "Enable Position Independent Executable support in ${P}"
echo "UCLIBC_BUILD_PIE=y" >> .config
fi
einfo "Enable Stack Smashing Protections support in ${P}"
echo "UCLIBC_HAS_SSP=y:" >> .config
echo "PROPOLICE_BLOCK_ABRT=n" >> .config
if use debug ; then
echo "PROPOLICE_BLOCK_SEGV=y" >> .config
echo "PROPOLICE_BLOCK_KILL=n" >> .config
else
echo "PROPOLICE_BLOCK_SEGV=n" >> .config
echo "PROPOLICE_BLOCK_KILL=y" >> .config
fi
echo "UCLIBC_BUILD_SSP=y" >> .config
echo "UCLIBC_BUILD_RELRO=y" >> .config
echo "UCLIBC_BUILD_NOW=y" >> .config
echo "UCLIBC_BUILD_NOEXECSTACK=y" >> .config
fi
# we are building against system installed kernel headers
sed -i -e 's:KERNEL_SOURCE.*:KERNEL_SOURCE="/usr":' .config
check_main_libc
if [ "${SYS_LIBC}" = "uClibc" ] ; then
sed -i \
-e 's:SHARED_LIB_LOADER_PREFIX=.*:SHARED_LIB_LOADER_PREFIX="/lib":' \
-e 's:DEVEL_PREFIX=.*:DEVEL_PREFIX="/usr":' \
-e 's:RUNTIME_PREFIX=.*:RUNTIME_PREFIX="/":' \
.config
fi
yes "" | make -s oldconfig > /dev/null || die "could not make oldconfig"
chmod +x extra/scripts/relative_path.sh
cp .config myconfig
emake clean >/dev/null || die "could not clean"
}
src_compile() {
# running tests require this
use build || addwrite /dev/ptmx
cp myconfig .config
#if use nls
#then
# # these can be built only if the build system supports locales (as of 0.9.26)
# emake -j1 headers
# cd extra/locale
# make clean
# find ./charmaps -name "*.pairs" > codesets.txt
# cp LOCALES locales.txt
# emake -j1 || die "could not make locales"
# cd ../..
#fi
emake -j1 || die "could not make"
check_main_libc
if [ "${SYS_LIBC}" = "uClibc" ]
then
emake -j1 utils || die "could not make utils"
fi
if ! use build ; then
if ! hasq maketest $RESTRICT ; then
# assert test fails on pax enabled kernels - normal
# vfork test fails in sandbox (both glibc/uclibc)
cd test; make; cd ..
fi
fi
}
src_install() {
emake PREFIX=${D} install || die "install failed"
# remove files coming from kernel-headers
# scsi is uclibc's own directory since cvs 20040212
check_main_libc
if [ "${SYS_LIBC}" = "uClibc" ]
then
rm -rf ${D}/usr/include/{asm,linux}
rm -f ${D}/usr/lib/lib*_pic.a
! use static && use build && rm -f ${D}/usr/lib/lib*.a
emake PREFIX=${D} install_utils || die "install-utils failed"
dodir /usr/bin
exeinto /usr/bin
doexe docs/getent
fi
if ! use build
then
dodoc Changelog* README TODO docs/*.txt DEDICATION.mjn3
doman debian/*.1
fi
}
#pkg_postinst() {
#check_main_libc
#if [ "${SYS_LIBC}" = "uClibc" ] ; then
# if [ "${ROOT}" = "/" ] ; then
# # should we create ld.so.conf and/or preload?
# # currently the option is not enabled
# /sbin/ldconfig
# [ ! -e /etc/TZ ] && echo UTC > /etc/TZ
# # reload init?
# fi
#else
#should we add the lib dir to ld.so.conf?
#fi
#}
|