# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Aspicere2.
#
# The Initial Developer of the Original Code is
# the Ghislain Hoffman Software Engineering Lab, INTEC, University Ghent.
# Portions created by the Initial Developer are Copyright (C) 2006
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#   Bram Adams <bram_DOT_adams_AT_ugent_DOT_be>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

Aspicere2 has a number of requirements:
 * recent Linux or OSX with Perl
 * LLVM 2.1
 * DejaGNU, Expect and TCL
 * SWI Prolog
 * Boost.regex 1.33.1
 * source code of Aspicere2 itself
 * [OPTIONALLY] Doxygen

Here's how to install everything chronologically (presuming that you already have a working Linux or OSX with Perl):
 1) Aspicere2 (http://users.ugent.be/~badams/aspicere2)
   - download the latest version and unpack in /path/to
   - add "export ASPICERE2=/path/to/aspicere2" to $HOME/.bashrc
   - add "export ASPICERE2_SRC=$ASPICERE2/aspicere2" to $HOME/.bashrc
   - add "export ASPICERE2_BUILD=$ASPICERE2/aspicere2-build" to $HOME/.bashrc
   - add "export ASPICERE2_INSTALL=$ASPICERE2/aspicere2-install" to $HOME/.bashrc
   - add "export LLVM_BUILD=$ASPICERE2/llvm-build" to $HOME/.bashrc
   - add "export LLVM_INSTALL=$ASPICERE2/llvm-install" to $HOME/.bashrc
   - before building anything a number of other tools need to be installed, starting with LLVM 2.0
 2) [OPTIONALLY] Doxygen (http://www.stack.nl/~dimitri/doxygen)
   - download it from http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc either in binary form or install from source (instructions on the web page)
   - be sure to add "export PATH=/path/to/doxygen/bin:$PATH" to $HOME/.bashrc
   - to enable graphical representations of relationships between classes, you also need dot (http://www.graphviz.org) from http://www.graphviz.org/Download.php
   - add "export PATH=/path/to/dot_directory:$PATH" to $HOME/.bashrc
 3) LLVM 2.0 (http://llvm.org)
   - frontend (a):
      * go to http://llvm.org/releases/download.html#2.0 and download the "LLVM-GCC 4 Front End Binaries" for your platform. If there is no compiled version for your platform, jump to frontend (b).
      * unpack the archive into /path/to (doesn't matter where)
      * add "export LLVM_FRONT=/path/to/llvm-gcc4-2.0-blabla" and "export PATH=$LLVM_FRONT/bin:$PATH" to your $HOME/.bashrc
      * cd into your $LLVM_FRONT/bin and prepend "llvm-" to c++, cpp, g++, gcc, gccbug and gcov resulting in llvm-c++, llvm-cpp, llvm-g++, llvm-gcc, llvm-gccbug and llvm-gcov
      * try out "llvm-gcc --version"; if you don't get info about the version number or copyright but see an error instead, then we need to manually compile the frontend, otherwise you can jump to the backend instructions
   - frontend (b):
      * to compile the frontend, download the LLVM-GCC 4 Front End Source Code from http://llvm.org/releases/download.html#2.0
      * unpack the archive into /path/to/llvm-gcc (this means you'll end up with the source code under /path/to/llvm-gcc/llvm-gcc)
      * temporarily put "export LLVM_FRONT=/path/to/llvm-gcc/llvm-gcc" into $HOME/.bashrc
      * we will proceed with a first attempt at building the backend; after getting errors there, you can proceed with frontend (c) again (the intent here is that some files are copied from $LLVM_SRC to $LLVM_BUILD that are needed to compile the frontend)
      * OK, go to /path/to/llvm-gcc and do "mkdir llvm-build" and "mkdir llvm-install"
      * cd into /path/to/llvm-gcc/llvm-build and do "../llvm-gcc/configure --prefix=/path/to/llvm-gcc/llvm-install/ --enable-llvm=$LLVM_BUILD --enable-languages=c,c++ --disable-threads --enable-checking --program-prefix=llvm-" (the --disable-threads should only be added on Linux; omit --enable-checking when you want to generate a non-debug version of the frontend)
   - frontend (c):
      * now do "make ; make install"
      * change the definition of $LLVM_FRONT back to "export LLVM_FRONT=/path/to/llvm-gcc/llvm-install" in $HOME/.bashrc
      * add "export PATH=$LLVM_FRONT/bin:$PATH" to $HOME/.bashrc and prepend "llvm-" to the relevant binaries of $LLVM_FRONT/bin as explained before
      * now return to the backend part right after cd-ing into $LLVM_BUILD
   - backend (a):
      * download the LLVM source code from http://llvm.org/releases/download.html#2.0 and unpack it into $ASPICERE2, so you'll get $ASPICERE2/llvm
      * add "export LLVM_SRC=$ASPICERE2/llvm" to $HOME/.bashrc
      * cd into $LLVM_BUILD
   - backend (b):
      * do "source $HOME/.bashrc ; ../configure-llvm.sh" (for a release-build without debug-support remove the --disable-optimized option in this script; likewise doxygen-support can be disabled by removing the --enable-doxygen)
      * ignore any warnings about the frontend
      * now issue "make ; make install"
      * add "export PATH=$LLVM_INSTALL/bin:$PATH" to $HOME/.bashrc
      * in case of errors related to the frontend, return to the frontend again and after completing build return to the backend instructions starting from backend (b)
 4) DejaGNU, Expect and TCL (used for unit testing)
    - you can find DejaGNU and its install instructions on http://www.gnu.org/software/dejagnu 
    - Expect can be found on http://expect.nist.gov
    - if Tcl/Tk is not installed on your system yet, get it from http://www.tcl.tk/software
 5) SWI Prolog (http://www.swi-prolog.org/)
    - install a binary release from the Download section
    - add "export SWI=/path/to/swiblabla" to $HOME/.bashrc
    - add "export SWI_LIB=$SWI/lib/name_of_only_subdirectory" to $HOME/.bashrc
    - cd to $SWI/include and look whether it contains SWI-cpp.h
    - if not, you should download the source distribution, unpack it and copy packages/cpp/SWI-cpp.h to $SWI/include
 6) Boost.regex (http://www.boost.org)
    - follow the steps outlined in http://www.boost.org/more/getting_started.html
    - make sure that libboost_regex is now in /usr/lib or another place ldconfig looks at, while boost/regexp.hpp should be in /usr/include or /usr/local/include
 7) Aspicere2 (http://users.ugent.be/~badams/aspicere2)
    - now that everything is in place, cd into $ASPICERE2_BUILD
    - do "source $HOME/.bashrc ; ../configure-aspicere2.sh" (if you'd like doxygen docs, add "doxy" as argument to the script)
    - now do "make install" and add "export PATH=$ASPICERE2_INSTALL/bin:$PATH" to $HOME/.bashrc
    - move into $ASPICERE2/myclips/src and do "make" to generate the modified CLIPS engine
    - finish with "source $HOME/.bashrc ; make check"
    - you should find that all tests succeeded except for two (which is normal)

After all these actions, your $HOME/.bashrc should now contain the following things (in one form or another):

#LLVM
export LLVM_FRONT=/path/to/llvm-gcc/llvm-gcc
export PATH=$LLVM_FRONT/bin:$PATH

#Aspicere2
export ASPICERE2=/path/to/aspicere2
export LLVM_SRC=$ASPICERE2/llvm
export LLVM_BUILD=$ASPICERE2/llvm-build
export LLVM_INSTALL=$ASPICERE2/llvm-install
export ASPICERE2_SRC=$ASPICERE2/aspicere2
export ASPICERE2_BUILD=$ASPICERE2/aspicere2-build
export ASPICERE2_INSTALL=$ASPICERE2/aspicere2-install
export PATH=$LLVM_INSTALL/bin:$ASPICERE2_INSTALL/bin:$PATH

#SWI Prolog
export SWI=/opt/local/lib/swipl-5.6.4
export SWI_LIB=$SWI/lib/powerpc-darwin8.4.0

#Doxygen
export PATH=/path/to/doxygen_directory:/path/to/dot_directory:$PATH

Congratulations, you can now experiment with Aspicere2. If you have any questions about the installation instructions, feel free to email bram_DOT_adams_AT_ugent_DOT_be (replace _DOT_ by . and _AT_ by @).