# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: package/.../glibc32/glibc32.conf
# Copyright (C) 2004 - 2006 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---

# we need -m32 ... - still needed?
var_insert GCC_WRAPPER_INSERT " " "-m32"

arch_target="`echo $arch_target | arch2arch32`"
echo_status "Set arch_target to $arch_target ..."
set_confopt

# do what glibc does
. $base/package/*/glibc/glibc.conf

# a bit hacky - might need/get a cleanup ...
var_append patchfiles " " "`ls $confdir/../glibc/*.patch`"
if ! atstage native; then
	var_append patchfiles " " "`ls $confdir/../glibc/*.patch.cross`"
fi

# do not build the programs
hook_add premake 5 "cat > configparms <<-EOT
build-programs=no
EOT
"

var_remove makeinstopt ' ' 'install'
var_append makeinstopt ' ' 'install-lib-all'

libdir=${libdir%64}
slibdir=lib

# glibc installs some headers it should not
var_append INSTALL_WRAPPER_FILTER "|" "sed -e 's,.*usr/include/.*\.h,/tmp/weg.h,'"

# and last overwrite the postmake function to do less stuff

glibc_postmake()
{
	# No wrong absolute path in libc.so
	# Obsolete? -ReneR
	#
	if ! atstage native; then
		libcso=$root/usr/$slibdir/libc.so
		sed 's,/[^ ]*/,,g' < $libcso > $libcso.new
		mv $libcso.new $libcso
	fi

	# Create /lib/ld-lsb.so.1 symlink
	#
	if [ -f $root/$slibdir/ld-linux-$arch_machine.so.2 ] ; then
		ln -vfs ld-linux-$arch_machine.so.2 $root/$slibdir/ld-lsb.so.1
	elif [ -f $root/$slibdir/ld-linux.so.2 ] ; then
		ln -vfs ld-linux.so.2 $root/$slibdir/ld-lsb.so.1
	fi
}