# Tanım: GNU compiler collection, which includes the C, C++, fortran and objc compilers.
# URL: http://gcc.gnu.org
# Paketçi: milisarge@gmail.com
# Gerekler:

isim=gcc
surum=5.3.0
devir=1

kaynak=(http://ftp.gnu.org/gnu/gcc/gcc-$surum/gcc-$surum.tar.bz2)

derle()
{
cd gcc-$surum

mkdir -v ../gcc-build
cd ../gcc-build

SED=sed \
../gcc-$surum/configure --prefix=/usr \
    --enable-languages=c,c++,objc,fortran \
    --disable-multilib --disable-bootstrap --with-system-zlib

make

make DESTDIR=$PKG install

mkdir $PKG/lib

ln -sv ../usr/bin/cpp $PKG/lib/cpp

ln -sv gcc $PKG/usr/bin/cc


install -dm755 $PKG/usr/share/gdb/auto-load/usr/lib
install -dm755 $PKG/usr/lib/bfd-plugins
cd $PKG/usr/lib/bfd-plugins

case `uname -m` in
	i?86) sed -i "s|-L$SRC[^ ]* ||g" \
		$PKG/usr/lib/{libstdc++.la,libsupc++.la} 
		mv -v $PKG/usr/lib/*gdb.py \
		$PKG/usr/share/gdb/auto-load/usr/lib
		ln -sfv ../../libexec/gcc/i686-pc-linux-gnu/$surum/liblto_plugin.so;;
	x86_64)
		sed -i "s|-L$SRC[^ ]* ||g" \
		$PKG/usr/lib64/{libstdc++.la,libsupc++.la} 
		mv -v $PKG/usr/lib64/*gdb.py \
		$PKG/usr/share/gdb/auto-load/usr/lib
		ln -sfv ../../libexec/gcc/x86_64-unknown-linux-gnu/$surum/liblto_plugin.so;;
esac

rm -rf $PKG/usr/share/info/dir


# Move the needed runtime libraries
case `uname -m` in
	i?86) mkdir -pv $PKG/usr/lib
	mv -v $PKG/usr/lib/libgfortran.{a,la} \
	$PKG/lib/
	ln -sv ../../lib/libgfortran.{la,a} $PKG/usr/lib
	mv -v $PKG/usr/lib/libgfortran.so{,.3,.3.0.0} \
	$PKG/lib/
	ln -svf ../../lib/libgfortran.so{,.3,.3.0.0} $PKG/usr/lib
	mv -v $PKG/usr/lib/libgcc_s.so{,.1} \
	$PKG/lib
	ln -sv ../../lib/libgcc_s.so{,.1} $PKG/usr/lib
	mv -v $PKG/usr/lib/libstdc++.* \
	$PKG/lib/
	mv -v $PKG/usr/lib/libsupc++.{la,a} \
	$PKG/lib
	ln -sv ../../lib/libstdc++.so{,.6,.6.0.30} \
	$PKG/usr/lib
	ln -sv ../../lib/libstdc++.{a,la} \
	$PKG/usr/lib
	ln -sv ../../lib/libsupc++.{la,a} \
	$PKG/usr/lib;;
	
	x86_64) mkdir -pv $PKG/usr/lib64
	mv -v $PKG/usr/lib64/libgfortran.{a,la} \
	$PKG/lib
	ln -sv ../../lib/libgfortran.{la,a} $PKG/usr/lib64
	mv -v $PKG/usr/lib64/libgfortran.so{,.3,.3.0.0} \
	$PKG/lib
	ln -sv ../../lib/libgfortran.so{,.3,.3.0.0} $PKG/usr/lib64
	mv -v $PKG/usr/lib64/libgcc_s.so{,.1} \
	$PKG/lib
	ln -sv ../../lib/libgcc_s.so{,.1} $PKG/usr/lib64
	mv -v $PKG/usr/lib64/libstdc++.* \
	$PKG/lib
	mv -v $PKG/usr/lib64/libsupc++.{la,a} \
	$PKG/lib
	ln -sv ../../lib/libstdc++.so{,.6,.6.0.30} \
	$PKG/usr/lib64
	ln -sv ../../lib/libstdc++.{a,la} \
	$PKG/usr/lib64
	ln -sv ../../lib/libsupc++.{la,a} \
	$PKG/usr/lib64;;
esac

}
