#! /bin/sh
# File: bld_bash_GNU
# Why: builds the yacco2 package for a GNU environment like Ubuntu
# Note: set the proper path of package by variable O2
# How to run:
# cd /usr/local/yacco2
# . bld_bash_GNU
#
# U can edit/comment out the Gnu_bash_file make lines not wanted
# Happy ccing
#

# determine base folder 
# and set it as a global bash variable for downstream bash makefiles
O2=/usr/local/yacco2/
export O2

echo "----------->Building yacco2 library<-----------"
cd "$O2"/library
make Rlse -f makefile_GNU
#make Dbg -f makefile_GNU
#make Genw -f makefile_GNU

echo "----------->Building yacco2's grammars library<-----------"
cd "$O2"/compiler/grammars
make Rlse -f makefile_GNU
#make Dbg -f makefile_GNU
#make Genw -f makefile_GNU

echo "----------->Building o2 program --- the compiler / compiler<-----------"
cd "$O2"/compiler/o2
make Rlse -f makefile_GNU
#make Dbg -f makefile_GNU
#make Genw -f makefile_GNU

echo "----------->Building o2linker program --- the companion to o2 compiler / compiler<-----------"
cd "$O2"/o2linker
make Rlse -f makefile_GNU
#make Dbg -f makefile_GNU
#make Genw -f makefile_GNU

###
# testing H2Os by gening all options
# the gened eol*.* c++ code is left in the /tmp account
# See yacco2/compiler/grammars/o2grammars.bat for gening properly all the grammars
###
echo "----------->Simple test on self<-----------"
echo "----will only run successfully----"
echo "----when default /yacco2 is used.----------"
echo "----This is due to the include statements in the grammar being compiled----------"
cd /tmp
"$O2"/bin/o2 -t -err "$O2"/compiler/grammars/eol.lex

echo "----------->Exercise the test suite of grammars<-----------"
cd /yacco2/grammar-testsuite
. test-out-grammars.sh -p

###
### If u have cweave / ctangle then comment out below bash commands
### 
#cweave Err
#pdftex Err
#cweave T
#pdftex T
#cweave Lrk
#pdftex Lrk
#mv Err.pdf "$O2"/docs/
#mv T.pdf "$O2"/docs/
#mv Lrk.pdf "$O2"/docs/