#	%%global _default_patch_fuzz 2
%define	GCC_INCDIR	GCC_INCDIR=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include
#TARBALL:	http://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz
#MD5SUM:	e6c279d5b2f0736f740216f152acf974;SOURCES/glibc-2.29.tar.xz
#TARBALL:	http://www.linuxfromscratch.org/patches/lfs/8.4/glibc-2.29-fhs-1.patch
#MD5SUM:	9a5997c3452909b1769918c759eff8a2;SOURCES/glibc-2.29-fhs-1.patch
#-----------------------------------------------------------------------------
Summary:	Main C library
Name:		glibc
Version:	2.29
Release:	1
License:	GPLv2
URL:		http://www.gnu.org/software/libc
Group:		LFS/Base
Vendor:	Elizabeth
Source0:	http://ftp.gnu.org/gnu/glibc/%{name}-%{version}.tar.xz
Source1:	locale-gen
Patch0:	glibc-%{version}-fhs-1.patch
Requires:	filesystem
%description
This library provides the basic routines for allocating memory,
searching directories, opening and closing files, reading and
writing files, string handling, pattern matching, arithmetic,
and so on.
#-----------------------------------------------------------------------------
%prep
%setup -q _T -b 0 -n %{NAME}-%{VERSION}
%patch0 -p1
	mkdir -v build
%build
	cd build
	CC='gcc -isystem %{GCC_INCDIR} -isystem /usr/include' \
	../configure --prefix=%{_prefix} \
		--disable-werror \
		--enable-kernel=3.2 \
		--enable-stack-protector=strong \
		libc_cv_slibdir=/lib
	make PARALLELMFLAGS=" %{_smp_mflags} "
#	make %{_smp_mflags}
%install
	cd build
#	touch /etc/ld.so.conf - already installed by filesystem
#	sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile - not needed
	make install_root=%{buildroot} install
#	add symlinks
	install -vdm 755 %{buildroot}/lib64
	ln -sfv ../lib/ld-linux-x86-64.so.2 %{buildroot}/lib64
	ln -sfv ../lib/ld-linux-x86-64.so.2 %{buildroot}/lib64/ld-lsb-x86-64.so.3
#	Create directories
	install -vdm 755 %{buildroot}/etc
	install -vdm 755 %{buildroot}/sbin
#	Install the configuration file and runtime directory for nscd:
	install -vDm 644 ../nscd/nscd.conf %{buildroot}/etc/nscd.conf
	install -vdm 755 %{buildroot}/var/cache/nscd
	cd -
#-----------------------------------------------------------------------------
#	6.9.2.1. Adding nsswitch.conf 
#-----------------------------------------------------------------------------	
cat > %{buildroot}/etc/nsswitch.conf <<- EOF
# Begin /etc/nsswitch.conf
	passwd: files
	group: files
	shadow: files

	hosts: files dns
	networks: files

	protocols: files
	services: files
	ethers: files
	rpc: files

# End /etc/nsswitch.conf
EOF
#-----------------------------------------------------------------------------
#	6.9.2.3. Configuring the Dynamic Loader
#-----------------------------------------------------------------------------
cat > %{buildroot}/etc/ld.so.conf <<- EOF
# Begin /etc/ld.so.conf
	/usr/local/lib
	/opt/lib
# Add an include directory
	include /etc/ld.so.conf.d/*.conf
EOF
#-----------------------------------------------------------------------------
#	Install locale generation script and config file
#-----------------------------------------------------------------------------
install -vdm 755 %{buildroot}/sbin
install -vdm 755 %{buildroot}/usr/lib/locale
cp %{_sourcedir}/locale-gen %{buildroot}/sbin/locale-gen
chmod 755 %{buildroot}/sbin/locale-gen
cat > %{buildroot}/etc/locale-gen.conf << EOF
# Configuration file for locale-gen
#
# lists of locales that are to be generated by the locale-gen command.
#
# Each line is of the form:
#
#     #<inputfile>	<charmap>	<outputpath>
#
#	where <inputfile> is one of the locales given in /usr/share/i18n/locales
# 	and <charmap> is one of the character sets listed in /usr/share/i18n/charmaps
#	and <outputpath> is tyhe name of the resulting locale
#
#  The locale-gen command will generate all the locales,
#  placing them in /usr/lib/locale.
#
#  A list of supported locales is included in this file.
#
#	localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
#	localedef [-f charmapfile] [-i inputfile] [--force] [--verbose] [--posix] [--quiet] outputpath
#
# Each line is of the form:
#<inputfile>	<charmap>	<outputpath>
POSIX		UTF-8		C.UTF-8
cs_CZ		UTF-8		cs_CZ.UTF-8
de_DE		ISO-8859-1	de_DE
de_DE@euro	ISO-8859-15	de_DE@euro
de_DE		UTF-8		de_DE.UTF-8
el_GR		ISO-8859-7	el_GR
en_GB		UTF-8		en_GB.UTF-8
en_HK		ISO-8859-1	en_HK
en_PH		ISO-8859-1	en_PH
en_US		ISO-8859-1	en_US
en_US		UTF-8		en_US.UTF-8
es_MX		ISO-8859-1	es_MX
fa_IR		UTF-8		fa_IR
fr_FR		ISO-8859-1	fr_FR
fr_FR@euro	ISO-8859-15	fr_FR@euro
fr_FR		UTF-8		fr_FR.UTF-8
it_IT		ISO-8859-1	it_IT
it_IT		UTF-8		it_IT.UTF-8
ja_JP		EUC-JP		ja_JP
ja_JP		SHIFT_JIS	ja_JP.SIJS
ja_JP		UTF-8		ja_JP.UTF-8
ru_RU		KOI8-R		ru_RU.KOI8-R
ru_RU		UTF-8		ru_RU.UTF-8
tr_TR		UTF-8		tr_TR.UTF-8
zh_CN		GB18030		zh_CN.GB18030
zh_HK		BIG5-HKSCS	zh_HK.BIG5-HKSCS
EOF
#-----------------------------------------------------------------------------
#	Copy license/copying file
	install -D -m644 LICENSES %{buildroot}/usr/share/licenses/%{name}/LICENSE
#-----------------------------------------------------------------------------
#	Create file list
	rm  %{buildroot}%{_infodir}/dir
	find %{buildroot} -name '*.la' -delete
	find "${RPM_BUILD_ROOT}" -not -type d -print > filelist.rpm
	sed -i "s|^${RPM_BUILD_ROOT}||" filelist.rpm
	sed -i '/man\/man/d' filelist.rpm
	sed -i '/\/usr\/share\/info/d' filelist.rpm
#-----------------------------------------------------------------------------
%files -f filelist.rpm
	%defattr(-,root,root)
	%{_infodir}/libc.*
#-----------------------------------------------------------------------------
%changelog
*	Fri Mar 15 2019 baho-utot <baho-utot@columbus.rr.com> 2.29-1
*	Mon Mar 19 2018 baho-utot <baho-utot@columbus.rr.com> 2.27-1
*	Wed Dec 20 2017 baho-utot <baho-utot@columbus.rr.com> 2.26-1
*	Sat Mar 22 2014 baho-utot <baho-utot@columbus.rr.com> 2.19-1
*	Sun Sep 01 2013 baho-utot <baho-utot@columbus.rr.com> 2.18-2
*	Sat Aug 24 2013 baho-utot <baho-utot@columbus.rr.com> 2.18-1
*	Sun Mar 24 2013 baho-utot <baho-utot@columbus.rr.com> 2.17-1
*	Wed Jan 30 2013 baho-utot <baho-utot@columbus.rr.com> 2.16-1
-	Initial version
