1INHIBIT_SYSROOT_STRIP = "1"
2
3PACKAGES = "${PN}-dbg catchsegv sln nscd ldconfig ldd tzcode glibc-thread-db ${PN}-pic libcidn libmemusage 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"
25
26FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${sysconfdir}/ld.so.conf"
27RRECOMMENDS_${PN} = "${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', '${MLPREFIX}ldconfig', '', d)}"
28FILES_ldconfig = "${base_sbindir}/ldconfig"
29FILES_ldd = "${bindir}/ldd"
30FILES_libsegfault = "${base_libdir}/libSegFault*"
31FILES_libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*"
32FILES_libmemusage = "${base_libdir}/libmemusage.so"
33FILES_libnss-db = "${base_libdir}/libnss_db.so.* ${base_libdir}/libnss_db-*.so ${localstatedir}/db/Makefile ${localstatedir}/db/makedbs.sh"
34RDEPENDS_libnss-db = "${PN}-utils"
35FILES_glibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*"
36FILES_sln = "${base_sbindir}/sln"
37FILES_${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o"
38FILES_libsotruss = "${libdir}/audit/sotruss-lib.so"
39FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}"
40FILES_${PN}-dev += "${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal"
41RDEPENDS_${PN}-dev = "linux-libc-headers-dev"
42FILES_${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a"
43FILES_nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_unitdir}/system/nscd* ${sysconfdir}/tmpfiles.d/nscd.conf \
44              ${sysconfdir}/nscd.conf ${sysconfdir}/default/volatiles/98_nscd ${localstatedir}/db/nscd"
45FILES_${PN}-mtrace = "${bindir}/mtrace"
46FILES_tzcode = "${bindir}/tzselect ${sbindir}/zic ${bindir}/zdump"
47FILES_${PN}-utils = "${bindir}/* ${sbindir}/*"
48FILES_catchsegv = "${bindir}/catchsegv"
49RDEPENDS_catchsegv = "libsegfault"
50FILES_${PN}-pcprofile = "${base_libdir}/libpcprofile.so"
51FILES_glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so"
52RPROVIDES_${PN}-dev += "libc-dev"
53RPROVIDES_${PN}-staticdev += "libc-staticdev"
54
55SUMMARY_sln = "The static ln"
56DESCRIPTION_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."
57SUMMARY_nscd = "Name service cache daemon"
58DESCRIPTION_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."
59SUMMARY_glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries"
60DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services."
61SUMMARY_ldd = "print shared library dependencies"
62DESCRIPTION_ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line."
63SUMMARY_${PN}-utils = "Miscellaneous utilities provided by glibc"
64DESCRIPTION_${PN}-utils = "Miscellaneous utilities including getconf, iconv, locale, gencat, ..."
65DESCRIPTION_libsotruss = "Library to support sotruss which traces calls through PLTs"
66DESCRIPTION_tzcode = "tzcode, timezone zoneinfo utils -- zic, zdump, tzselect"
67
68inherit multilib_header
69
70do_install() {
71	oe_runmake install_root=${D} install
72	install -Dm 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/ld.so.conf
73	install -d ${D}${localedir}
74	make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
75	# get rid of some broken files...
76	for i in ${GLIBC_BROKEN_LOCALES}; do
77		sed -i "/$i/d" ${WORKDIR}/SUPPORTED
78	done
79	rm -f ${D}${sysconfdir}/rpc
80	rm -rf ${D}${datadir}/zoneinfo
81	rm -rf ${D}${libexecdir}/getconf
82
83	rm -f ${D}${sysconfdir}/localtime
84
85	# remove empty glibc dir
86	if [ -d ${D}${libexecdir} ]; then
87		rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
88	fi
89
90	oe_multilib_header bits/syscall.h bits/long-double.h bits/floatn.h bits/endianness.h bits/struct_rwlock.h
91
92	if [ -f ${D}${bindir}/mtrace ]; then
93		sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace
94	fi
95	# Info dir listing isn't interesting at this point so remove it if it exists.
96	if [ -e "${D}${infodir}/dir" ]; then
97		rm -f ${D}${infodir}/dir
98	fi
99
100	install -d ${D}${sysconfdir}/init.d
101	install -d ${D}${localstatedir}/db/nscd
102	install -m 0755 ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd
103	install -m 0755 ${S}/nscd/nscd.conf ${D}${sysconfdir}/nscd.conf
104	install -m 0755 ${WORKDIR}/makedbs.sh ${D}${localstatedir}/db
105	sed -i "s%daemon%start-stop-daemon --start --exec%g" ${D}${sysconfdir}/init.d/nscd
106	sed -i "s|\(enable-cache\t\+netgroup\t\+\)yes|\1no|" ${D}${sysconfdir}/nscd.conf
107
108	install -d ${D}${systemd_unitdir}/system
109	install -m 0644 ${S}/nscd/nscd.service ${D}${systemd_unitdir}/system/
110
111	# The dynamic loader will have been installed into
112	# ${base_libdir}. However, if that isn't going to end up being
113	# available in the ABI-mandated location, then a symlink must
114	# be created.
115
116	if [ -n "${ARCH_DYNAMIC_LOADER}" -a ! -e "${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
117		install -d ${D}${root_prefix}/lib
118		ln -s ${@oe.path.relative('${root_prefix}/lib', '${base_libdir}')}/${ARCH_DYNAMIC_LOADER} \
119				${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}
120	fi
121}
122
123def get_libc_fpu_setting(bb, d):
124    if d.getVar('TARGET_FPU') in [ 'soft', 'ppc-efd' ]:
125        return "--without-fp"
126    return ""
127
128do_install_append_class-target() {
129	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
130		install -d ${D}${sysconfdir}/tmpfiles.d
131		echo "d /run/nscd 755 root root -" \
132			> ${D}${sysconfdir}/tmpfiles.d/nscd.conf
133	fi
134
135	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
136		install -d ${D}${sysconfdir}/default/volatiles
137		echo "d root root 0755 /var/run/nscd none" \
138			> ${D}${sysconfdir}/default/volatiles/98_nscd
139	fi
140
141}
142do_install_append_aarch64 () {
143	do_install_armmultilib
144}
145
146do_install_append_arm () {
147	do_install_armmultilib
148}
149
150do_install_append_armeb () {
151	do_install_armmultilib
152}
153
154do_install_armmultilib () {
155	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
156	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
157	oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h
158	oe_multilib_header bits/procfs-id.h bits/procfs.h bits/shmlba.h
159	oe_multilib_header bits/struct_stat.h
160
161	oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h
162
163	oe_multilib_header sys/elf.h sys/procfs.h sys/ptrace.h sys/ucontext.h sys/user.h
164}
165
166
167LOCALESTASH = "${WORKDIR}/stashed-locale"
168bashscripts = "mtrace sotruss xtrace"
169
170do_stash_locale () {
171	dest=${LOCALESTASH}
172	install -d $dest${base_libdir} $dest${bindir} $dest${libdir} $dest${datadir}
173	# Hide away the locale data from the deployment
174	if [ -e ${D}${bindir}/localedef ]; then
175		cp -a ${D}${bindir}/localedef $dest${bindir}
176	fi
177	if [ -e ${D}${libdir}/gconv ]; then
178		cp -a ${D}${libdir}/gconv $dest${libdir}
179	fi
180	if [ -e ${D}${datadir}/i18n ]; then
181		cp -a  ${D}${datadir}/i18n $dest${datadir}
182	fi
183
184	# Make a copy of all the libraries into the locale stash
185	cp -fpPR ${D}${libdir}/* $dest${libdir}
186	if [ "${base_libdir}" != "${libdir}" ]; then
187		cp -fpPR ${D}${base_libdir}/* $dest${base_libdir}
188	fi
189	if [ -e ${D}${exec_prefix}/lib ]; then
190		if [ ${exec_prefix}/lib != ${base_libdir} ] && [ ${exec_prefix}/lib != ${libdir} ]; then
191			cp -fpPR ${D}${exec_prefix}/lib $dest${exec_prefix}
192		fi
193	fi
194
195	cp -fpPR ${D}${datadir}/* $dest${datadir}
196	cp -fpPR ${WORKDIR}/SUPPORTED $dest
197
198	target=$dest/scripts
199	mkdir -p $target
200	for i in ${bashscripts}; do
201		if [ -f ${D}${bindir}/$i ]; then
202			cp ${D}${bindir}/$i $target/
203		fi
204	done
205}
206
207addtask do_stash_locale after do_install before do_populate_sysroot do_package
208do_stash_locale[dirs] = "${B}"
209do_stash_locale[cleandirs] = "${LOCALESTASH}"
210SSTATETASKS += "do_stash_locale"
211do_stash_locale[sstate-inputdirs] = "${LOCALESTASH}"
212do_stash_locale[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
213do_stash_locale[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
214
215python do_stash_locale_setscene () {
216    sstate_setscene(d)
217}
218addtask do_stash_locale_setscene
219
220PACKAGE_PREPROCESS_FUNCS += "stash_locale_package_cleanup"
221SYSROOT_PREPROCESS_FUNCS += "stash_locale_sysroot_cleanup"
222stash_locale_cleanup () {
223	cleanupdir=$1
224	# Remove all files which do_stash_locale() copies
225	for i in ${bashscripts}; do
226		rm -f $cleanupdir${bindir}/$i
227	done
228	rm -f $cleanupdir${bindir}/localedef
229	rm -rf $cleanupdir${datadir}/i18n
230	rm -rf $cleanupdir${libdir}/gconv
231	rm -rf $cleanupdir${localedir}
232	rm -rf $cleanupdir${datadir}/locale
233	rmdir --ignore-fail-on-non-empty $cleanupdir${datadir}
234
235	if [ "${libdir}" != "${exec_prefix}/lib" ] && [ "${root_prefix}/lib" != "${exec_prefix}/lib" ]; then
236		if [ -d "$cleanupdir${exec_prefix}/lib" ]; then
237			if [ -z "${ARCH_DYNAMIC_LOADER}" -o \
238			     ! -e "$cleanupdir${exec_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
239				# error out if directory isn't empty
240				# this dir should only contain locale dir
241				# which has been deleted in the previous step
242				rmdir $cleanupdir${exec_prefix}/lib
243			fi
244		fi
245	fi
246}
247
248stash_locale_sysroot_cleanup() {
249	stash_locale_cleanup ${SYSROOT_DESTDIR}
250}
251stash_locale_package_cleanup() {
252	stash_locale_cleanup ${PKGD}
253}
254
255python populate_packages_prepend () {
256    if d.getVar('DEBIAN_NAMES'):
257        pkgs = d.getVar('PACKAGES').split()
258        bpn = d.getVar('BPN')
259        prefix = d.getVar('MLPREFIX') or ""
260        # Set the base package...
261        d.setVar('PKG_' + prefix + bpn, prefix + 'libc6')
262        libcprefix = prefix + bpn + '-'
263        for p in pkgs:
264            # And all the subpackages.
265            if p.startswith(libcprefix):
266                renamed = p.replace(bpn, 'libc6', 1)
267                d.setVar('PKG_' + p, renamed)
268        # For backward compatibility with old -dbg package
269        d.appendVar('RPROVIDES_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
270        d.appendVar('RCONFLICTS_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
271        d.appendVar('RREPLACES_' + libcprefix + 'dbg', ' ' + prefix + 'libc-dbg')
272}
273
274pkg_postinst_nscd () {
275	if [ -z "$D" ]; then
276		if command -v systemd-tmpfiles >/dev/null; then
277			systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/nscd.conf
278		elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
279			${sysconfdir}/init.d/populate-volatile.sh update
280		fi
281	fi
282}
283CONFFILES_nscd="${sysconfdir}/nscd.conf"
284
285SYSTEMD_PACKAGES = "nscd"
286SYSTEMD_SERVICE_nscd = "nscd.service"
287