/[gentoo-x86]/sys-libs/uclibc/uclibc-0.9.33.1.ebuild
Gentoo

Contents of /sys-libs/uclibc/uclibc-0.9.33.1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Sat Jun 9 06:47:12 2012 UTC (11 months, 2 weeks ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -5 lines
Drop tc-is-softfloat usage as the FPU knob merely controls enabling of libm.

(Portage version: 2.2.0_alpha110/cvs/Linux x86_64)

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-libs/uclibc/uclibc-0.9.33.1.ebuild,v 1.2 2012/06/01 04:22:53 zmedico Exp $
4
5 inherit eutils flag-o-matic multilib toolchain-funcs savedconfig
6 if [[ ${PV} == "9999" ]] ; then
7 EGIT_REPO_URI="git://git.busybox.net/uClibc"
8 inherit git-2
9 fi
10
11 export CBUILD=${CBUILD:-${CHOST}}
12 export CTARGET=${CTARGET:-${CHOST}}
13 if [[ ${CTARGET} == ${CHOST} ]] ; then
14 if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
15 export CTARGET=${CATEGORY/cross-}
16 fi
17 fi
18
19 MY_P=uClibc-${PV}
20 DESCRIPTION="C library for developing embedded Linux systems"
21 HOMEPAGE="http://www.uclibc.org/"
22 if [[ ${PV} != "9999" ]] ; then
23 PATCH_VER="1"
24 SRC_URI="http://uclibc.org/downloads/${MY_P}.tar.bz2
25 ${PATCH_VER:+mirror://gentoo/${MY_P}-patches-${PATCH_VER}.tar.bz2}"
26 KEYWORDS="-* ~amd64 ~arm ~m68k ~mips ~ppc ~sh ~sparc ~x86"
27 fi
28
29 LICENSE="LGPL-2"
30 SLOT="0"
31 IUSE="debug hardened iconv ipv6 nptl rpc ssp uclibc-compat wordexp crosscompile_opts_headers-only"
32 RESTRICT="strip"
33
34 S=${WORKDIR}/${MY_P}
35
36 is_crosscompile() {
37 [[ ${CHOST} != ${CTARGET} ]]
38 }
39 alt_build_kprefix() {
40 if [[ ${CBUILD} == ${CHOST} && ${CTARGET} == ${CHOST} ]] ; then
41 echo /usr/include
42 else
43 echo /usr/${CTARGET}/usr/include
44 fi
45 }
46
47 just_headers() {
48 use crosscompile_opts_headers-only && is_crosscompile
49 }
50
51 uclibc_endian() {
52 # XXX: this wont work for a toolchain which is bi-endian, but we
53 # dont have any such thing at the moment, so not a big deal
54 touch "${T}"/endian.s
55 $(tc-getAS ${CTARGET}) "${T}"/endian.s -o "${T}"/endian.o
56 case $(file "${T}"/endian.o) in
57 *" MSB "*) echo "BIG";;
58 *" LSB "*) echo "LITTLE";;
59 *) echo "NFC";;
60 esac
61 rm -f "${T}"/endian.{s,o}
62 }
63
64 pkg_setup() {
65 if [ ${CTARGET} == ${CHOST} ] ; then
66 case ${CHOST} in
67 *-uclinux*|*-uclibc*) ;;
68 *) die "Use sys-devel/crossdev to build a uclibc toolchain" ;;
69 esac
70 fi
71 }
72
73 # XXX: We should kill these off.
74 CPU_ALPHA=""
75 CPU_AMD64=""
76 CPU_ARM="GENERIC_ARM ARM{610,710,7TDMI,720T,920T,922T,926T,10T,1136JF_S,1176JZ{_,F_}S,_{SA110,SA1100,XSCALE,IWMMXT},_CORTEX_{M3,M1}}"
77 CPU_IA64=""
78 CPU_M68K=""
79 CPU_MIPS="MIPS_ISA_{1,2,3,4,MIPS{32{,R2},64}} MIPS_{N64,O32,N32}_ABI"
80 CPU_PPC=""
81 CPU_SH="SH{2,2A,3,4,5}"
82 CPU_SPARC="SPARC_V{7,8,9,9B}"
83 CPU_X86="GENERIC_386 {3,4,5,6}86 586MMX PENTIUM{II,III,4} K{6,7} ELAN CRUSOE WINCHIP{C6,2} CYRIXIII NEHEMIAH"
84 IUSE_UCLIBC_CPU="${CPU_ARM} ${CPU_MIPS} ${CPU_PPC} ${CPU_SH} ${CPU_SPARC} ${CPU_X86}"
85
86 check_cpu_opts() {
87 local cpu_var="CPU_$(echo $(tc-arch) | tr [a-z] [A-Z])"
88 [[ -z ${!cpu_var} ]] && return 0
89
90 if [[ -z ${UCLIBC_CPU} ]] ; then
91 ewarn "You really should consider setting UCLIBC_CPU"
92 ewarn "Otherwise, the build will be generic (read: slow)."
93 ewarn "Available CPU options:"
94 UCLIBC_CPU=$(eval echo ${!cpu_var})
95 echo ${UCLIBC_CPU}
96 case ${CTARGET} in
97 mips[1234]*) export UCLIBC_CPU="MIPS_ISA_${CTARGET:4:1}";;
98 sh[2345]*) export UCLIBC_CPU="SH${CTARGET:2:1}";;
99 i[456]86*) export UCLIBC_CPU="${CTARGET:1:1}86";;
100 *) export UCLIBC_CPU=${UCLIBC_CPU%% *};;
101 esac
102 else
103 local cpu found=0
104 for cpu in $(eval echo ${!cpu_var}) ; do
105 [[ ${UCLIBC_CPU} == "${cpu}" ]] && found=1 && break
106 done
107 if [[ ${found} -eq 0 ]] ; then
108 ewarn "UCLIBC_CPU choice '${UCLIBC_CPU}' not supported"
109 ewarn "Valid choices:"
110 eval echo ${!cpu_var}
111 die "pick a supported cpu type"
112 fi
113 fi
114 }
115
116 kconfig_q_opt() {
117 local flag=$1; shift
118 case ${flag} in
119 y|n) ;;
120 *) flag=$(usex ${flag} y n) ;;
121 esac
122
123 local var="defs_${flag}"
124 eval "${var}+=( $* )"
125 }
126
127 get_opt() {
128 (
129 unset ${1}
130 . ${2:-"${S}"/.config}
131 echo ${!1}
132 )
133 }
134
135 src_oldconfig() {
136 yes "" 2>/dev/null | emake -s oldconfig >/dev/null
137 }
138 src_config() {
139 restore_config .config
140 if [ -f .config ]; then
141 src_oldconfig
142 return 0
143 else
144 ewarn "Could not locate user configfile, so we will save a default one"
145 fi
146
147 emake ARCH=${target} defconfig >/dev/null || die
148
149 local defs_{y,n} defs
150
151 defs=(
152 DO{DEBUG_PT,ASSERTS}
153 SUPPORT_LD_DEBUG_EARLY
154 UCLIBC_HAS_PROFILING
155 )
156 kconfig_q_opt n "${defs[@]}"
157 kconfig_q_opt debug DODEBUG SUPPORT_LD_DEBUG
158
159 sed -i -e '/ARCH_.*_ENDIAN/d' .config
160 kconfig_q_opt y "ARCH_WANTS_$(uclibc_endian)_ENDIAN"
161
162 if [[ ${CTARGET} == arm* ]] ; then
163 kconfig_q_opt n CONFIG_ARM_OABI
164 kconfig_q_opt y CONFIG_ARM_EABI
165 fi
166
167 defs=(
168 MALLOC_GLIBC_COMPAT
169 DO_C99_MATH
170 UCLIBC_HAS_{CTYPE_CHECKED,WCHAR,HEXADECIMAL_FLOATS,GLIBC_CUSTOM_PRINTF,FOPEN_EXCLUSIVE_MODE,GLIBC_CUSTOM_STREAMS,PRINTF_M_SPEC}
171 UCLIBC_HAS_FENV
172 UCLIBC_HAS_FTW
173 UCLIBC_HAS_GNU_GLOB
174 UCLIBC_HAS_LIBUTIL
175 UCLIBC_HAS_PROGRAM_INVOCATION_NAME
176 UCLIBC_HAS_RESOLVER_SUPPORT
177 UCLIBC_HAS_TZ_FILE_READ_MANY
178 UCLIBC_SUSV3_LEGACY
179 UCLIBC_SUSV3_LEGACY_MACROS
180 UCLIBC_SUSV4_LEGACY
181 PTHREADS_DEBUG_SUPPORT
182 )
183 kconfig_q_opt y "${defs[@]}"
184 kconfig_q_opt n UCLIBC_HAS_CTYPE_UNSAFE
185 kconfig_q_opt n UCLIBC_HAS_LOCALE
186 kconfig_q_opt n HAS_NO_THREADS
187 kconfig_q_opt ipv6 UCLIBC_HAS_IPV6
188 kconfig_q_opt nptl UCLIBC_HAS_THREADS_NATIVE
189 kconfig_q_opt !nptl LINUXTHREADS_OLD
190 kconfig_q_opt rpc UCLIBC_HAS_{,{FULL,REENTRANT}_}RPC
191 kconfig_q_opt wordexp UCLIBC_HAS_WORDEXP
192 kconfig_q_opt uclibc-compat UCLIBC_HAS_LIB{NSL,RESOLV}_STUB COMPAT_ATEXIT
193
194 # we need to do it independently of hardened to get ssp.c built into libc
195 kconfig_q_opt y UCLIBC_HAS_SSP
196 kconfig_q_opt n UCLIBC_HAS_SSP_COMPAT
197 kconfig_q_opt y UCLIBC_HAS_ARC4RANDOM
198 kconfig_q_opt n PROPOLICE_BLOCK_ABRT
199 kconfig_q_opt y PROPOLICE_BLOCK_SEGV
200
201 # arm/mips do not emit PT_GNU_STACK, but if we enable this here
202 # it will be emitted as RWE, ppc has to be checked, x86 needs it
203 # this option should be used independently of hardened
204 if has $(tc-arch) x86 || has $(tc-arch) ppc ; then
205 kconfig_q_opt y UCLIBC_BUILD_NOEXECSTACK
206 else
207 kconfig_q_opt n UCLIBC_BUILD_NOEXECSTACK
208 fi
209 kconfig_q_opt y UCLIBC_BUILD_RELRO
210 kconfig_q_opt hardened UCLIBC_BUILD_PIE
211 kconfig_q_opt hardened UCLIBC_BUILD_NOW
212 kconfig_q_opt !ssp SSP_QUICK_CANARY
213 kconfig_q_opt ssp UCLIBC_BUILD_SSP
214
215 local def
216 for def in 1 2 ; do
217 # Run twice as some config opts depend on others being enabled first.
218 for def in ${defs_y[@]} ; do
219 sed -i -e "s:.*\<${def}\>.*set:${def}=y:g" .config
220 done
221 for def in ${defs_n[@]} ; do
222 sed -i -e "s:${def}=y:# ${def} is not set:g" .config
223 done
224 src_oldconfig
225 done
226
227 einfo "Enabled options:"
228 for def in ${defs_y[@]} ; do
229 einfo " " $(grep "^${def}=y" .config || echo "could not find ${def}")
230 done
231 einfo "Disabled options:"
232 for def in ${defs_n[@]} ; do
233 einfo " " $(grep "^# ${def} is not set" .config || echo "could not find ${def}")
234 done
235
236 # setup build and run paths
237 sed -i \
238 -e "/^CROSS_COMPILER_PREFIX/s:=.*:=\"${CTARGET}-\":" \
239 -e "/^KERNEL_HEADERS/s:=.*:=\"$(alt_build_kprefix)\":" \
240 -e "/^SHARED_LIB_LOADER_PREFIX/s:=.*:=\"/$(get_libdir)\":" \
241 -e "/^DEVEL_PREFIX/s:=.*:=\"/usr\":" \
242 -e "/^RUNTIME_PREFIX/s:=.*:=\"/\":" \
243 -e "/^UCLIBC_EXTRA_CFLAGS/s:=.*:=\"${UCLIBC_EXTRA_CFLAGS}\":" \
244 .config || die
245
246 src_oldconfig
247 }
248
249 src_unpack() {
250 if [[ ${PV} == "9999" ]] ; then
251 git-2_src_unpack
252 else
253 unpack ${A}
254 fi
255 cd "${S}"
256 if [[ -n ${PATCH_VER} ]] ; then
257 EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
258 fi
259
260 check_cpu_opts
261
262 echo
263 einfo "Runtime Prefix: /"
264 einfo "Devel Prefix: /usr"
265 einfo "Kernel Prefix: $(alt_build_kprefix)"
266 einfo "CBUILD: ${CBUILD}"
267 einfo "CHOST: ${CHOST}"
268 einfo "CTARGET: ${CTARGET}"
269 einfo "CPU: ${UCLIBC_CPU:-default}"
270 einfo "ENDIAN: $(uclibc_endian)"
271 echo
272
273 ########## CPU SELECTION ##########
274
275 local target config_target
276 case $(tc-arch) in
277 alpha) target="alpha"; config_target="no cpu-specific options";;
278 amd64) target="x86_64"; config_target="no cpu-specific options";;
279 arm) target="arm"; config_target="GENERIC_ARM";;
280 avr) target="avr32"; config_target="no cpu-specific options";;
281 ia64) target="ia64"; config_target="no cpu-specific options";;
282 m68k) target="m68k"; config_target="no cpu-specific options";;
283 mips) target="mips"; config_target="MIPS_ISA_1";;
284 ppc) target="powerpc"; config_target="no cpu-specific options";;
285 sh) target="sh"; config_target="SH4";;
286 sparc) target="sparc"; config_target="no cpu-specific options";;
287 x86) target="i386"; config_target="GENERIC_386";;
288 *) die "$(tc-arch) lists no defaults :/";;
289 esac
290 sed -i -e "s:default CONFIG_${config_target}:default CONFIG_${UCLIBC_CPU:-${config_target}}:" \
291 extra/Configs/Config.${target}
292 sed -i -e "s:^HOSTCC.*=.*:HOSTCC=$(tc-getBUILD_CC):" Rules.mak
293
294 src_config
295
296 if use iconv ; then
297 # Run after make clean, otherwise files removed
298 find ./extra/locale/charmaps -name "*.pairs" > extra/locale/codesets.txt
299 if [[ ! -f /etc/locale.gen ]] ; then
300 # See ./extra/locale/LOCALES for examples
301 die "Please create an appropriate /etc/locale.gen for locale support"
302 fi
303 echo -e "@euro e\n@cyrillic c\n#---\nUTF-8 yes\n8-BIT yes\n#---\n\n" > ./extra/locale/locales.txt
304 cat /etc/locale.gen >> ./extra/locale/locales.txt
305 fi
306 }
307
308 src_compile() {
309 emake headers || die
310 just_headers && return 0
311
312 emake || die
313 if is_crosscompile ; then
314 emake -C utils hostutils || die
315 else
316 emake utils || die
317 fi
318 }
319
320 src_test() {
321 is_crosscompile && return 0
322
323 # assert test fails on pax/grsec enabled kernels - normal
324 # vfork test fails in sandbox (both glibc/uclibc)
325 emake UCLIBC_ONLY=1 check || die
326 }
327
328 src_install() {
329 local sysroot=${D}
330 is_crosscompile && sysroot+="/usr/${CTARGET}"
331
332 local target="install"
333 just_headers && target="install_headers"
334 emake DESTDIR="${sysroot}" ${target} || die
335
336 save_config .config
337
338 # remove files coming from kernel-headers
339 rm -rf "${sysroot}"/usr/include/{linux,asm*}
340
341 # Make sure we install the sys-include symlink so that when
342 # we build a 2nd stage cross-compiler, gcc finds the target
343 # system headers correctly. See gcc/doc/gccinstall.info
344 if is_crosscompile ; then
345 dosym usr/include /usr/${CTARGET}/sys-include
346 if ! just_headers && [[ -n $(get_opt HAVE_SHARED) ]] ; then
347 newbin utils/ldconfig.host ${CTARGET}-ldconfig || die
348 newbin utils/ldd.host ${CTARGET}-ldd || die
349 fi
350 return 0
351 fi
352
353 emake DESTDIR="${D}" install_utils || die
354 dobin extra/scripts/getent
355 dodoc Changelog* README TODO docs/*.txt DEDICATION.mjn3
356 }
357
358 pkg_postinst() {
359 is_crosscompile && return 0
360
361 if [ ! -e "${ROOT}"/etc/TZ ] ; then
362 ewarn "Please remember to set your timezone in /etc/TZ"
363 mkdir -p "${ROOT}"/etc
364 echo "UTC" > "${ROOT}"/etc/TZ
365 fi
366 [ "${ROOT}" != "/" ] && return 0
367 # update cache before reloading init
368 ldconfig
369 # reload init ...
370 /sbin/telinit U 2>/dev/null
371 }

  ViewVC Help
Powered by ViewVC 1.1.13