
#
# version: mar. mars  1 03:47:11 CET 2016
#
# with Fedora, install with yumextender : gtk-doc glib2-devel
# (for the documentation, not critical but less errors/warnings)
#
#  clean:
# rm -rf Asm-* configure-* CPP-* downloads libSystem-* lib bin include share

MAKE_OPT= #" -j 4 "

export DEFORABASE="/data/Defora"
mkdir -p $DEFORABASE
cd $DEFORABASE

mkdir -p downloads
rm -rf downloads/*.*

PROJECT_LIST="libSystem configure CPP Asm"

# clean:
rm -rf lib bin include share

for PROJECT in $PROJECT_LIST
do
  echo '***************' Working on $PROJECT '***************'
  rm -rf $PROJECT-*

  pushd downloads
    SNAP=snap-$PROJECT.html
    echo $SNAP ':'
    wget -O $SNAP "http://git.defora.org/gitweb/?p=$PROJECT.git;a=shortlog"
          #    grep '"in format: tar.gz"' $SNAP |head -n 1
    TGZLINK=http://git.defora.org$( grep '"in format: tar.gz"' $SNAP |head -n 1|sed -e 's/">snapshot<.*//' -e 's/.*in format: tar[.]gz\" href=\"//' )
    wget -O $PROJECT.tgz $TGZLINK
  popd

  tar xzf downloads/$PROJECT.tgz
  pushd $PROJECT-*
    OPTARG=""
    [ "$PROJECT" = "libSystem" ] &&  OPTARG="LDFLAGS='-ldl'"

    [ "$P" = "libSystem" ] || [ "$P" = "configure" ] || $DEFORABASE/bin/configure

    make $MAKE_OPT PREFIX="$DEFORABASE" $OPTARG install

    [ "$PROJECT" = "libSystem" ] && export PKG_CONFIG_PATH="$DEFORABASE/lib/pkgconfig/"
  popd

done
