#!/bin/bash

source ./scripts/pkgver

cd $SRCDIR

# bash
wget http://ftp.gnu.org/gnu/bash/bash-$BASH_VER.tar.gz

if [ $BASH_PATCHLEVEL -gt 000 ]; then
  for p in $(seq -w 001 $BASH_PATCHLEVEL); do
      wget http://ftp.gnu.org/gnu/bash/bash-$BASH_VER-patches/bash${BASH_VER/.}-$p
  done
fi

# binutils
wget http://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VER.tar.bz2

# bison
# bison-$BISON_VER.tar.bz2

# bzip2
wget http://www.bzip.org/$BZIP2_VER/bzip2-$BZIP2_VER.tar.gz

# cloog-ppl

# coreutils
wget http://ftp.gnu.org/gnu/coreutils/coreutils-$COREUTILS_VER.tar.gz

# diffutils
# findutils
# file
# flex
# gawk
if [ ! -f gawk-$GAWK_VER.tar.gz ]; then
  wget ftp://ftp.gnu.org/gnu/gawk/gawk-$GAWK_VER.tar.gz
fi

# gcc
wget http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/gcc-core-$GCC_VER.tar.bz2
wget http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/gcc-g++-$GCC_VER.tar.bz2

# gettext

# glibc
wget http://ftp.gnu.org/gnu/glibc/glibc-$GLIBC_VER.tar.bz2

# gmp
wget ftp://ftp.gnu.org/gnu/gmp/gmp-$GMP_VER.tar.bz2
  
# grep
if [ ! -f grep-$GREP_VER.tar.bz2 ]; then
  wget ftp://ftp.gnu.org/gnu/grep/grep-$GREP_VER.tar.bz2
fi

# grub
if [ ! -f grub-$GRUB_VER.tar.gz ]; then
  wget ftp://alpha.gnu.org/gnu/grub/grub-$GRUB_VER.tar.gz
fi

# gzip
if [ ! -f gzip-$GZIP_VER.tar.gz ]; then
  wget ftp://ftp.gnu.org/pub/gnu/gzip/gzip-$GZIP_VER.tar.gz
fi

# m4
# make

# mpfr
wget http://mpfr.loria.fr/mpfr-current/mpfr-$MPFR_VER.tar.bz2

# nano
cd $SRCDIR
if [ ! -f nano-$NANO_VER.tar.gz ]; then
  wget http://www.nano-editor.org/dist/v2.2/nano-$NANO_VER.tar.gz
fi

# ncurses
wget ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-$NCURSES_VER.tar.gz

# patch
# ppl
# sed
if [ ! -f sed-$SED_VER.tar.bz2 ]; then
  wget ftp://ftp.gnu.org/gnu/sed/sed-$SED_VER.tar.bz2
fi

# tar
# texinfo

# xz-utils
if [ ! -f xz-$XZUTILS_VER.tar.gz ]; then                                                                                                                                              
  wget http://tukaani.org/xz/xz-$XZUTILS_VER.tar.gz
fi

# zlib
wget http://www.zlib.net/zlib-$ZLIB_VER.tar.gz

# gnumach-git
if [ -d $SRCDIR/gnumach ] ; then
  cd $SRCDIR/gnumach && git pull origin
else
  cd $SRCDIR
  git clone git://git.sv.gnu.org/hurd/gnumach.git
fi

# hurd-git
if [ -d $SRCDIR/hurd ] ; then
  cd $SRCDIR/hurd && git pull origin
else
  cd $SRCDIR
  git clone git://git.sv.gnu.org/hurd/hurd.git
fi

# libpthread-git
if [ -d $SRCDIR/libpthread ] ; then
  cd $SRCDIR/libpthread && git pull origin
else
  cd $SRCDIR
  git clone git://git.sv.gnu.org/hurd/libpthread.git
fi

# mig-git
if [ -d $SRCDIR/mig ] ; then
  cd $SRCDIR/mig && git pull origin
else
  cd $SRCDIR
  git clone git://git.sv.gnu.org/hurd/mig.git
fi
