1INHIBIT_SYSROOT_STRIP = "1"
2
3PACKAGES = "${PN}-dbg catchsegv sln nscd ldconfig ldd tzcode glibc-thread-db ${PN}-pic libcidn libmemusage malloc-debug libnss-db libsegfault ${PN}-pcprofile libsotruss ${PN} ${PN}-utils glibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}-src"
4
5# The ld.so in this glibc supports the GNU_HASH
6RPROVIDES:${PN} = "eglibc rtld(GNU_HASH)"
7RPROVIDES:${PN}-utils = "eglibc-utils"
8RPROVIDES:${PN}-mtrace = "eglibc-mtrace libc-mtrace"
9RPROVIDES:${PN}-pic = "eglibc-pic"
10RPROVIDES:${PN}-dev = "eglibc-dev libc6-dev virtual-libc-dev"
11RPROVIDES:${PN}-staticdev = "eglibc-staticdev"
12RPROVIDES:${PN}-doc = "eglibc-doc"
13RPROVIDES:glibc-extra-nss = "eglibc-extra-nss"
14RPROVIDES:glibc-thread-db = "eglibc-thread-db"
15RPROVIDES:${PN}-pcprofile = "eglibc-pcprofile"
16RPROVIDES:${PN}-dbg = "eglibc-dbg"
17libc_baselibs = "${base_libdir}/libc.so.* ${base_libdir}/libc-*.so ${base_libdir}/libm*.so.* ${base_libdir}/libm-*.so ${base_libdir}/libmvec-*.so ${base_libdir}/ld*.so.* ${base_libdir}/ld-*.so ${base_libdir}/libpthread*.so.* ${base_libdir}/libpthread-*.so ${base_libdir}/libresolv*.so.* ${base_libdir}/libresolv-*.so ${base_libdir}/librt*.so.* ${base_libdir}/librt-*.so ${base_libdir}/libutil*.so.* ${base_libdir}/libutil-*.so ${base_libdir}/libnsl*.so.* ${base_libdir}/libnsl-*.so ${base_libdir}/libnss_files*.so.* ${base_libdir}/libnss_files-*.so ${base_libdir}/libnss_compat*.so.* ${base_libdir}/libnss_compat-*.so ${base_libdir}/libnss_dns*.so.* ${base_libdir}/libnss_dns-*.so ${base_libdir}/libdl*.so.* ${base_libdir}/libdl-*.so ${base_libdir}/libanl*.so.* ${base_libdir}/libanl-*.so ${base_libdir}/libBrokenLocale*.so.* ${base_libdir}/libBrokenLocale-*.so"
18ARCH_DYNAMIC_LOADER = ""
19# The aarch64 ABI says the dynamic linker -must- be
20# /lib/ld-linux-aarch64{,_be}.so.1. With usrmerge, that may mean that
21# we need to install it in /usr/lib.
22ARCH_DYNAMIC_LOADER:aarch64 = "ld-linux-${TARGET_ARCH}.so.1"
23libc_baselibs:append = " ${@oe.utils.conditional('ARCH_DYNAMIC_LOADER', '', '', '${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}', d)}"
24INSANE_SKIP:${PN}:append:aarch64 = " libdir"
25INSANE_SKIP:${PN}-dev += "staticdev"
26
27FILES:${PN} = "${libc_baselibs} ${libexecdir}/* ${sysconfdir}/ld.so.conf"
28RRECOMMENDS:${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', '${MLPREFIX}ldconfig', '', d)}"
29FILES:ldconfig = "${base_sbindir}/ldconfig"
30FILES:ldd = "${bindir}/ldd"
31FILES:libsegfault = "${base_libdir}/libSegFault*"
32FILES:libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*"
33FILES:libmemusage = "${base_libdir}/libmemusage.so"
34FILES:malloc-debug = "${base_libdir}/libc_malloc_debug.so.0"
35FILES:libnss-db = "${base_libdir}/libnss_db.so.* ${base_libdir}/libnss_db-*.so ${localstatedir}/db/Makefile ${localstatedir}/db/makedbs.sh"
36RDEPENDS:libnss-db = "${PN}-utils"
37FILES:glibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*"
38FILES:sln = "${base_sbindir}/sln"
39FILES:${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o"
40FILES:libsotruss = "${libdir}/audit/sotruss-lib.so"
41FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}"
42FILES:${PN}-dev += "${libdir}/libpthread.a ${libdir}/libdl.a ${libdir}/libutil.a ${libdir}/libanl.a ${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal"
43RDEPENDS:${PN}-dev = "linux-libc-headers-dev"
44FILES:${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a"
45FILES:nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_system_unitdir}/nscd* ${sysconfdir}/tmpfiles.d/nscd.conf \
46              ${sysconfdir}/nscd.conf ${sysconfdir}/default/volatiles/98_nscd ${localstatedir}/db/nscd"
47FILES:${PN}-mtrace = "${bindir}/mtrace"
48FILES:tzcode = "${bindir}/tzselect ${sbindir}/zic ${bindir}/zdump"
49FILES:${PN}-utils = "${bindir}/* ${sbindir}/*"
50FILES:catchsegv = "${bindir}/catchsegv"
51RDEPENDS:catchsegv = "libsegfault"
52FILES:${PN}-pcprofile = "${base_libdir}/libpcprofile.so"
53FILES:glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so"
54RPROVIDES:${PN}-dev += "libc-dev"
55RPROVIDES:${PN}-staticdev += "libc-staticdev"
56
57SUMMARY:sln = "The static ln"
58DESCRIPTION:sln = "Similar to the 'ln' utility, but statically linked.  sln is useful to make symbolic links to dynamic libraries if the dynamic linking system, for some reason, is not functional."
59SUMMARY:nscd = "Name service cache daemon"
60DESCRIPTION:nscd = "nscd, name service cache daemon, caches name service lookups for the passwd, group and hosts information.  It can damatically improvide performance with remote, such as NIS or NIS+, name services."
61SUMMARY:glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries"
62DESCRIPTION:glibc-extra-nss = "glibc: nis, nisplus and hesiod search services."
63SUMMARY:ldd = "print shared library dependencies"
64DESCRIPTION:ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line."
65SUMMARY:${PN}-utils = "Miscellaneous utilities provided by glibc"
66DESCRIPTION:${PN}-utils = "Miscellaneous utilities including getconf, iconv, locale, gencat, ..."
67DESCRIPTION:libsotruss = "Library to support sotruss which traces calls through PLTs"
68DESCRIPTION:tzcode = "tzcode, timezone zoneinfo utils -- zic, zdump, tzselect"
69
70inherit multilib_header
71
72do_install() {
73	oe_runmake install_root=${D} install
74	install -Dm 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/ld.so.conf
75	install -d ${D}${localedir}
76	make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
77	# get rid of some broken files...
78	for i in ${GLIBC_BROKEN_LOCALES}; do
79		sed -i "/$i/d" ${WORKDIR}/SUPPORTED
80	done
81	rm -f ${D}${sysconfdir}/rpc
82	rm -rf ${D}${datadir}/zoneinfo
83	rm -rf ${D}${libexecdir}/getconf
84
85	rm -f ${D}${sysconfdir}/localtime
86
87	# remove empty glibc dir
88	if [ -d ${D}${libexecdir} ]; then
89		rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
90	fi
91
92	oe_multilib_header bits/syscall.h bits/long-double.h bits/floatn.h bits/endianness.h bits/struct_rwlock.h
93
94	if [ -f ${D}${bindir}/mtrace ]; then
95		sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace
96	fi
97	# Info dir listing isn't interesting at this point so remove it if it exists.
98	if [ -e "${D}${infodir}/dir" ]; then
99		rm -f ${D}${infodir}/dir
100	fi
101
102	install -d ${D}${sysconfdir}/init.d
103	install -d ${D}${localstatedir}/db/nscd
104	install -m 0755 ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd
105	install -m 0755 ${S}/nscd/nscd.conf ${D}${sysconfdir}/nscd.conf
106	install -m 0755 ${WORKDIR}/makedbs.sh ${D}${localstatedir}/db
107	sed -i "s%daemon%start-stop-daemon --start --exec%g" ${D}${sysconfdir}/init.d/nscd
108	sed -i "s|\(enable-cache\t\+netgroup\t\+\)yes|\1no|" ${D}${sysconfdir}/nscd.conf
109
110	install -d ${D}${systemd_system_unitdir}
111	install -m 0644 ${S}/nscd/nscd.service ${D}${systemd_system_unitdir}/
112
113	# The dynamic loader will have been installed into
114	# ${base_libdir}. However, if that isn't going to end up being
115	# available in the ABI-mandated location, then a symlink must
116	# be created.
117
118	if [ -n "${ARCH_DYNAMIC_LOADER}" -a ! -e "${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
119		install -d ${D}${root_prefix}/lib
120		ln -s ${@oe.path.relative('${root_prefix}/lib', '${base_libdir}')}/${ARCH_DYNAMIC_LOADER} \
121				${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}
122	fi
123        lnr ${D}${base_libdir}/libpthread.so.0 ${D}${libdir}/libpthread.so
124        lnr ${D}${base_libdir}/librt.so.1 ${D}${libdir}/librt.so
125}
126
127def get_libc_fpu_setting(bb, d):
128    if d.getVar('TARGET_FPU') in [ 'soft', 'ppc-efd' ]:
129        return "--without-fp"
130    return ""
131
132do_install:append:class-target() {
133	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
134		install -d ${D}${sysconfdir}/tmpfiles.d
135		echo "d /run/nscd 755 root root -" \
136			> ${D}${sysconfdir}/tmpfiles.d/nscd.conf
137	fi
138
139	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
140		install -d ${D}${sysconfdir}/default/volatiles
141		echo "d root root 0755 /var/run/nscd none" \
142			> ${D}${sysconfdir}/default/volatiles/98_nscd
143	fi
144
145}
146do_install:append:aarch64 () {
147	do_install_armmultilib
148}
149
150do_install:append:arm () {
151	do_install_armmultilib
152}
153
154do_install:append:armeb () {
155	do_install_armmultilib
156}
157
158do_install_armmultilib () {
159	oe_multilib_header bits/endian.h bits/fcntl.h bits/fenv.h bits/fp-fast.h bits/hwcap.h bits/ipc.h bits/link.h
160	oe_multilib_header bits/local_lim.h bits/mman.h bits/msq.h bits/pthreadtypes.h bits/pthreadtypes-arch.h  bits/sem.h  bits/semaphore.h bits/setjmp.h
161	oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h
162	oe_multilib_header bits/procfs-id.h bits/procfs.h bits/shmlba.h
163	oe_multilib_header bits/struct_stat.h bits/pthread_stack_min.h
164
165	oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h
166
167	oe_multilib_header sys/elf.h sys/procfs.h sys/ptrace.h sys/ucontext.h sys/user.h
168}
169
170
171LOCALESTASH = "${WORKDIR}/stashed-locale"
172bashscripts = "mtrace sotruss xtrace"
173
174do_stash_locale () {
175	dest=${LOCALESTASH}
176	install -d $dest${base_libdir} $dest${bindir} $dest${libdir} $dest${datadir}
177	# Hide away the locale data from the deployment
178	if [ -e ${D}${bindir}/localedef ]; then
179		cp -a ${D}${bindir}/localedef $dest${bindir}
180	fi
181	if [ -e ${D}${libdir}/gconv ]; then
182		cp -a ${D}${libdir}/gconv $dest${libdir}
183	fi
184	if [ -e ${D}${datadir}/i18n ]; then
185		cp -a  ${D}${datadir}/i18n $dest${datadir}
186	fi
187
188	# Make a copy of all the libraries into the locale stash
189	cp -fpPR ${D}${libdir}/* $dest${libdir}
190	if [ "${base_libdir}" != "${libdir}" ]; then
191		cp -fpPR ${D}${base_libdir}/* $dest${base_libdir}
192	fi
193	if [ -e ${D}${exec_prefix}/lib ]; then
194		if [ ${exec_prefix}/lib != ${base_libdir} ] && [ ${exec_prefix}/lib != ${libdir} ]; then
195			cp -fpPR ${D}${exec_prefix}/lib $dest${exec_prefix}
196		fi
197	fi
198
199	cp -fpPR ${D}${datadir}/* $dest${datadir}
200	cp -fpPR ${WORKDIR}/SUPPORTED $dest
201
202	target=$dest/scripts
203	mkdir -p $target
204	for i in ${bashscripts}; do
205		if [ -f ${D}${bindir}/$i ]; then
206			cp ${D}${bindir}/$i $target/
207		fi
208	done
209}
210
211addtask do_stash_locale after do_install before do_populate_sysroot do_package
212do_stash_locale[dirs] = "${B}"
213do_stash_locale[cleandirs] = "${LOCALESTASH}"
214SSTATETASKS += "do_stash_locale"
215do_stash_locale[sstate-inputdirs] = "${LOCALESTASH}"
216do_stash_locale[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
217do_stash_locale[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
218
219python do_stash_locale_setscene () {
220    sstate_setscene(d)
221}
222addtask do_stash_locale_setscene
223
224PACKAGE_PREPROCESS_FUNCS += "stash_locale_package_cleanup"
225SYSROOT_PREPROCESS_FUNCS += "stash_locale_sysroot_cleanup"
226stash_locale_cleanup () {
227	cleanupdir=$1
228	# Remove all files which do_stash_locale() copies
229	for i in ${bashscripts}; do
230		rm -f $cleanupdir${bindir}/$i
231	done
232	rm -f $cleanupdir${bindir}/localedef
233	rm -rf $cleanupdir${datadir}/i18n
234	rm -rf $cleanupdir${libdir}/gconv
235	rm -rf $cleanupdir${localedir}
236	rm -rf $cleanupdir${datadir}/locale
237	rmdir --ignore-fail-on-non-empty $cleanupdir${datadir}
238
239	if [ "${libdir}" != "${exec_prefix}/lib" ] && [ "${root_prefix}/lib" != "${exec_prefix}/lib" ]; then
240		if [ -d "$cleanupdir${exec_prefix}/lib" ]; then
241			if [ -z "${ARCH_DYNAMIC_LOADER}" -o \
242			     ! -e "$cleanupdir${exec_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
243				# error out if directory isn't empty
244				# this dir should only contain locale dir
245				# which has been deleted in the previous step
246				rmdir $cleanupdir${exec_prefix}/lib
247			fi
248		fi
249	fi
250}
251
252stash_locale_sysroot_cleanup() {
253	stash_locale_cleanup ${SYSROOT_DESTDIR}
254}
255stash_locale_package_cleanup() {
256	stash_locale_cleanup ${PKGD}
257}
258
259python populate_packages:prepend () {
260    if d.getVar('DEBIAN_NAMES'):
261        pkgs = d.getVar('PACKAGES').split()
262        bpn = d.getVar('BPN')
263        prefix = d.getVar('MLPREFIX') or ""
264        # Set the base package...
265        d.setVar('PKG:' + prefix + bpn, prefix + 'libc6')
266        libcprefix = prefix + bpn + '-'
267        for p in pkgs:
268            # And all the subpackages.
269            if p.startswith(libcprefix):
270                renamed = p.replace(bpn, 'libc6', 1)
271                d.setVar('PKG:' + p, renamed)
272        # For backward compatibility with old -dbg package
273        d.appendVar('RPROVIDES:' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
274        d.appendVar('RCONFLICTS:' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
275        d.appendVar('RREPLACES:' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
276}
277
278pkg_postinst:nscd () {
279	if [ -z "$D" ]; then
280		if command -v systemd-tmpfiles >/dev/null; then
281			systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/nscd.conf
282		elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
283			${sysconfdir}/init.d/populate-volatile.sh update
284		fi
285	fi
286}
287CONFFILES:nscd="${sysconfdir}/nscd.conf"
288
289SYSTEMD_PACKAGES = "nscd"
290SYSTEMD_SERVICE:nscd = "nscd.service"
291