#!/bin/bash
## <a name="installation-summary"></a><b>INSTALLATION/SETUP SUMMARY</b>
## Installed 24 Dec 2019 (Updated 31 Dec 2019)
## Written by Aaron Sloman http://www.cs.bham.ac.uk/~axs
## based on work by Waldek Hebisch http://www.math.uni.wroc.pl/~hebisch
## who produced the 64 bit port: https://github.com/hebisch/poplog
## This script starts from the files downloaded from github, and adds
## extra documentation and a collection of packages, including teaching
## materials, from the University of Birmingham.
##
## FETCH POPLOG INSTALLATION FILES.
## Choose an appropriate location to run this script to install poplog.
## Fetch this script using the following shell command, and make it executable.
##
##  wget https://www.cs.bham.ac.uk/research/projects/poplog/V16/getpoplog.sh
##  chmod 744 getpoplog.sh
##
##  You may have to edit some uncommented parts of the script to fit your
##  environment. Also make sure you have previously installed the required
##  linux libraries for your version of linux. See this file for guidance:
##
##   http://www.cs.bham.ac.uk/research/projects/poplog/V16/required-packages.html
##   (Please send corrections and additions to a.sloman AT cs.bham.ac.uk)
##
## This is a much simplified version, partly because the final steps are now run by
## the script build_all.csh, invoked after the tar files have been unpacked.
## See changes for 'position independent' code, below.

## This is now reduced mainly to what used to be the first part of getpoplog.sh
##
## For the broader context please see:
##  https://www.cs.bham.ac.uk/research/projects/poplog/V16/AREADME.html

## Results of running this script:
## A directory poplog_base will be created in the directory in which it is run.
## Initially it contains scripts used to unpack and set up the poplog directory tree
## with root in poplog_base, whose path name has to be assigned to be environment
## variable $usepop for users of Poplog.
## Everything else is accessed via $usepop.
##
## After unpacking and installing the main poplog tar package (from the github site
## set up by Waldek Hebisch:  https://github.com/hebisch/poplog)
## the directory  will contain the files required at run time. Some of the downloaded
## files are used to build the final usable poplog system.

## Expert users may wish to modify some of the instructions before running
## the scripts.

## End of preamble.

## Get the required poplog-specific tar files used for installation

echo "Running getpoplog.sh"

echo 'Download the latest "core" version of poplog with sources and documentation'
echo 'produced by Waldek Hebisch'
echo ''
echo 'wget http://www.cs.bham.ac.uk/research/projects/poplog/V16/latest_poplog_base.tar.bz2'

wget http://www.cs.bham.ac.uk/research/projects/poplog/V16/latest_poplog_base.tar.bz2

echo ''
echo 'Download the poplog documentation and tutorial files from Birmingham'
echo 'To be added to the poplog system in the $usepop/pop/{doc,help,teach,ref} directories'
echo ''
echo 'wget http://www.cs.bham.ac.uk/research/projects/poplog/V16/docs.tar.bz2'
wget http://www.cs.bham.ac.uk/research/projects/poplog/V16/docs.tar.bz2
echo ''

echo 'Download the poplog "packages" system from Birmingham'
echo '  to be added to the core poplog system,
echo '  located in the $usepop/pop/packages sub-directory

echo ''
echo 'wget http://www.cs.bham.ac.uk/research/projects/poplog/packages-v16.tgz'
wget http://www.cs.bham.ac.uk/research/projects/poplog/packages-v16.tgz
echo ''

echo 'Tar files containing the documentation files and the poplog "packages"'
echo 'system have now been in the installation directory, ready to be unpacked'
echo ''

echo 'ls -ltr'
ls -ltr

echo ''

echo 'Unpack the poplog_base package, including contents downloaded from the'
echo 'github site'.
echo ''
echo tar 'xfj latest_poplog_base.tar.bz2'
tar xfj latest_poplog_base.tar.bz2

## echo ''
## echo 'Untarred - latest latest_poplog_base.tar.bz2'
## echo 'That creates the directory poplog_base with all the core files of poplog,'
## echo 'including files needed to create a minimal running pop11 system.'
## echo ''
## echo 'After that has been set up, additional documentation libraries will be added'
## echo 'And the packages file downloaded from
## echo '    http://www.cs.bham.ac.uk/research/projects/poplog/packages-V16.tar.bz2'
## echo 'and upacked, located at poplog_base/pop/packages.'
##
## echo ''
## echo 'These files are  now in poplog_base'
## echo 'ls -ltr poplog_base'

ls -ltr poplog_base

echo ''

## echo 'cd poplog_base and run build_all.csh'
## echo "  (I could not make a '.sh' version directly executable.)"
## echo ''
## echo 'cd poplog_base'

cd poplog_base

pwd

## Note: for Arch linux and Debian Debian 9 and "testing"
## an extra instruction is needed at this point. For now, that is
## included in build_all_nopie.csh which should be invoked here instead of
## the next command. At present this is done by using getpoplog-nopie.sh
##

## echo 'Build Poplog'
## echo 'Running: build_all.csh based on script from Waldek Hebisch, to build'
## echo 'a new core poplog, including pop11, prolog, common lisp and poplog ml'
## echo 'with additional commands to unpack the documentation and packages'
## echo 'tar files from Birmingham'
## echo ''
## echo 'Running build_all.csh'

./build_all.csh

exit
