openmoko-session2: add RDEPENDS openmoko-panel-memory and oe-stylize
[vuplus_openembedded] / packages / uclibc / uclibc.inc
1 DESCRIPTION = "C library for embedded systems"
2 LICENSE = "LGPL"
3 SECTION = "libs"
4 PRIORITY = "required"
5
6 #
7 # For now, we will skip building of a gcc package if it is a uclibc one
8 # and our build is not a uclibc one, and we skip a glibc one if our build
9 # is a uclibc build.
10 #
11 # See the note in gcc/gcc_3.4.0.oe
12 #
13
14 python __anonymous () {
15     import bb, re
16     uc_os = (re.match('.*uclibc*', bb.data.getVar('TARGET_OS', d, 1)) != None)
17     if not uc_os:
18         raise bb.parse.SkipPackage("incompatible with target %s" %
19                                    bb.data.getVar('TARGET_OS', d, 1))
20 }
21
22 PROVIDES += "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc"
23 PROVIDES += "${@['virtual/libiconv', ''][bb.data.getVar('USE_NLS', d, 1) != 'yes']}"
24 DEPENDS = "virtual/${TARGET_PREFIX}binutils \
25            virtual/${TARGET_PREFIX}gcc-initial linux-libc-headers"
26
27 # Blackfin needs a wrapper around ld
28 DEPENDS_append_bfin = " elf2flt "
29
30 INHIBIT_DEFAULT_DEPS = "1"
31 PARALLEL_MAKE = ""
32
33 PACKAGES =+ "ldd uclibc-utils-dbg uclibc-utils uclibc-gconv uclibc-thread-db"
34
35 # The last line (gdb and lib1) is for uclinux-uclibc builds 
36 uclibc_baselibs = "/lib/libcrypt*.so* /lib/libdl*.so \
37                    /lib/libintl*.so* /lib/libm*.so \
38                    /lib/libnsl*.so* /lib/libpthread*.so \
39                    /lib/libresolv*.so* /lib/libutil*.so \
40                    /lib/libuClibc*.so* /lib/ld*.so* \
41                    /lib/libc*.so* /lib/libdl*.so* \
42                    /lib/libm*.so* /lib/libutil*.so* \
43                    /lib/libpthread*.so* /lib/librt*.so* \
44                    /usr/lib/libc.gdb /usr/lib/libc /lib/lib1.so \
45                    "
46 FILES_${PN} = "${sysconfdir} ${uclibc_baselibs} /sbin/ldconfig \
47                ${libexecdir} ${datadir}/zoneinfo ${libdir}/locale"
48 FILES_ldd = "${bindir}/ldd"
49 FILES_uclibc-dev += "${libdir}/*.o"
50 FILES_uclibc-utils = "${bindir} ${sbindir}"
51 FILES_uclibc-utils-dbg += "${bindir}/.debug ${sbindir}/.debug"
52 FILES_uclibc-gconv = "${libdir}/gconv"
53 FILES_uclibc-thread-db = "/lib/libthread_db*"
54 RPROVIDES_uclibc-dev += "libc-dev"
55
56 #
57 # This locale file gets copied into uClibc-${PV}/extra/locale/ prior to
58 # build, it does not need to be unpacked, but we can't inhibit the unpacking
59 # in the current build system.
60 #
61 UCLIBC_LOCALE_FILE = "uClibc-locale-030818.tgz"
62 UCLIBC_LOCALE_FILE_arm = "uClibc-locale-030818.arm.tgz"
63 UCLIBC_LOCALE_URI = "http://www.uclibc.org/downloads/${UCLIBC_LOCALE_FILE}"
64 UCLIBC_LOCALE_URI_arm = "http://openembedded.org/dl/uclibc-locale/${UCLIBC_LOCALE_FILE}"
65
66 SRC_URI = "${@['${UCLIBC_LOCALE_URI}', ''][bb.data.getVar('USE_NLS', d, 1) != 'yes']} \
67            file://uClibc.config"
68
69 UCLIBC_STAGE_PREFIX = "${STAGING_DIR_HOST}${layout_prefix}"
70
71 # do_stage barfs on a CC with whitepspace, therefore put the 'HOST_CC_ARCH' in
72 # the CFLAGS (for when building the utils).
73 OEMAKE_NO_CC = "'OPTIMIZATION=' 'CPU_CFLAGS=${CFLAGS}' 'STRIPTOOL=true' 'LD=${LD}' \
74                 'LOCALE_DATA_FILENAME=${UCLIBC_LOCALE_FILE}'"
75 EXTRA_OEMAKE = "${OEMAKE_NO_CC} 'CC=${CC}'"
76 EXTRA_OEMAKE_task_do_populate_staging = "${OEMAKE_NO_CC}"
77 EXTRA_OEMAKE_task_do_package = "${OEMAKE_NO_CC}"
78
79 KERNEL_SOURCE = "${STAGING_INCDIR}"
80 KERNEL_HEADERS = "${STAGING_INCDIR}"
81
82 # Lets munge this via siteinfo.bbclass as well:
83 # ARCH_BIG_ENDIAN=y
84 # ARCH_WANTS_BIG_ENDIAN=y
85 # ARCH_WANTS_LITTLE_ENDIAN is not set
86
87 configmangle = 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE="${KERNEL_SOURCE}",g; \
88                 s,^KERNEL_HEADERS=.*,KERNEL_HEADERS="${KERNEL_HEADERS}",g; \
89                 s,^RUNTIME_PREFIX=.*,RUNTIME_PREFIX="/",g; \
90                 s,^DEVEL_PREFIX=.*,DEVEL_PREFIX="/${prefix}",g; \
91                 s,^SHARED_LIB_LOADER_PATH=.*,SHARED_LIB_LOADER_PATH="/lib",; \
92                 s,^SHARED_LIB_LOADER_PREFIX=.*,SHARED_LIB_LOADER_PREFIX="/lib",; \
93                 s,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g; \
94                 ${@["s,.*UCLIBC_HAS_LOCALE.*,# UCLIBC_HAS_LOCALE is not set,;", ""][bb.data.getVar("USE_NLS", d, 1) == "yes"]}'
95 CFLAGS := "${@oe_filter_out('-I\S+', '${CFLAGS}', d)}"
96
97 python () {
98         if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
99                 bb.data.setVar('configmangle_append', ' s,^HAS_FPU=y,# HAS_FPU is not set,;', d)
100 }
101
102 uclibcbuild_do_patch() {
103         ln -sf ${STAGING_INCDIR}/linux ${S}/include/linux
104         ln -sf ${STAGING_INCDIR}/asm ${S}/include/asm
105         
106         ${@['cp %s/%s extra/locale' % (bb.data.getVar('DL_DIR', d, 1) or '', bb.data.getVar('UCLIBC_LOCALE_FILE', d, 1) or ''), ''][bb.data.getVar('USE_NLS', d, 1) != 'yes']}
107 }
108
109 python do_patch () {
110         bb.build.exec_func('base_do_patch', d)
111         bb.build.exec_func('uclibcbuild_do_patch', d)
112 }
113
114 do_configure() {
115         rm -f ${S}/.config
116
117         # For uClibc 0.9.29, OpenEmbedded splits the uClibc.config in two parts:
118         # uClibc.machine and uClibc.distro. So, if they exist use them, otherwise
119         # use a uClibc.config
120         if [ -f ${WORKDIR}/uClibc.machine -a -f ${WORKDIR}/uClibc.distro ]; then
121                 echo "### uClibc.machine ###" >${S}/merged.config
122                 cat ${WORKDIR}/uClibc.machine >>${S}/merged.config
123                 echo "### uClibc.distro ###" >>${S}/merged.config
124                 cat ${WORKDIR}/uClibc.distro >>${S}/merged.config
125         else
126                 echo "### uClibc.config ###" >${S}/merged.config
127                 cat ${WORKDIR}/uClibc.config >>${S}/merged.config
128         fi
129         cp ${S}/merged.config ${S}/.config      
130
131         # Mangle the resulting .config depending on OE variables
132         perl -i -p -e 's,^CROSS=.*,TARGET_ARCH=${TARGET_ARCH}\nCROSS=${TARGET_PREFIX},g' ${S}/Rules.mak
133         perl -i -p -e '${configmangle}' ${S}/.config
134
135         sed -i -e '/CONFIG_ARM_EABI/d' ${S}/.config
136
137         if [ "${TARGET_OS}" = "linux-gnueabi" -o  "${TARGET_OS}" = "linux-uclibcgnueabi" ]; then
138                 echo "CONFIG_ARM_EABI=y"                >> ${S}/.config
139         else
140                 echo "# CONFIG_ARM_EABI is not set"     >> ${S}/.config
141         fi
142
143         yes '' | oe_runmake oldconfig
144 }
145
146 do_stage() {
147         # This MUST be done first because we
148         # will install crt1.o in the install_dev stage and gcc needs it
149
150         # Install into the staging dir
151         oe_runmake PREFIX= DEVEL_PREFIX=${UCLIBC_STAGE_PREFIX}/ \
152                 RUNTIME_PREFIX=${UCLIBC_STAGE_PREFIX}/ \
153                 install_dev install_runtime
154
155         # Install into the staging dir
156         oe_runmake PREFIX= DEVEL_PREFIX=${UCLIBC_STAGE_PREFIX}/ \
157                 RUNTIME_PREFIX=${UCLIBC_STAGE_PREFIX}/ \
158                 install_utils
159
160         # We don't really need this
161         rm -f ${UCLIBC_STAGE_PREFIX}/include/.cvsignore
162
163         # Fixup shared lib symlinks
164         ( cd ${UCLIBC_STAGE_PREFIX}/lib
165                 for f in c crypt dl m nsl pthread resolv thread_db util; do
166                         ln -sf lib${f}.so.? lib${f}.so
167                 done
168         )
169
170         # This conflicts with the c++ version of this header
171         rm -f ${UCLIBC_STAGE_PREFIX}/include/bits/atomicity.h
172 }
173
174 do_install() {
175         # This MUST be done first because we
176         # will install crt1.o in the install_dev stage and gcc needs it)
177         oe_runmake PREFIX= DEVEL_PREFIX=${UCLIBC_STAGE_PREFIX}/ \
178                 RUNTIME_PREFIX=${UCLIBC_STAGE_PREFIX}/ \
179                 install_dev install_runtime
180
181         oe_runmake PREFIX=${D} DEVEL_PREFIX=${prefix}/ RUNTIME_PREFIX=/ \
182                 install_dev install_runtime 
183
184         # We don't really need this in ${includedir}
185         rm -f ${D}${prefix}/include/.cvsignore
186
187         # This conflicts with the c++ version of this header
188         rm -f ${D}${prefix}/include/bits/atomicity.h
189
190         # ugh.. uclibc doesn't like obeying our path variables.
191         if [ "${includedir}" != "${prefix}/include" ]; then
192                 install -d ${D}${includedir}
193                 mv ${D}${prefix}/include/* ${D}${includedir}/
194                 rmdir ${D}${prefix}/include
195         fi
196
197         if [ "${libdir}" != "${prefix}/lib" ]; then
198                 install -d ${D}${libdir}
199                 mv ${D}${prefix}/lib/* ${D}${libdir}/
200                 rmdir ${D}${prefix}/lib
201         fi
202
203         if [ "${bindir}" != "/usr/bin" ]; then
204                 install -d ${D}${bindir}
205                 mv ${D}/usr/bin/* ${D}${bindir}/
206                 rmdir ${D}/usr/bin
207         fi
208
209         oe_runmake utils
210         oe_runmake PREFIX=${D} DEVEL_PREFIX=${prefix}/ RUNTIME_PREFIX=/ \
211                 install_utils
212 }
213