# OpenSolaris 10.1

# This assumes you already have a development environment installed
#  (gcc, git, etc.)
#
# You can use pkg to install the various tools.
#  pkg install pkg:/developer/gcc/gcc-432

# You'll need to do most 'make install' steps with sudo if you don't
# have permissions to write into the /usr/local tree.

# install libffi
wget ftp://sourceware.org:/pub/libffi/libffi-3.0.8.tar.gz
gunzip libffi-3.0.8.tar.gz
tar -xvf libffi-3.0.8.tar
cd libffi-3.0.8

./configure
make
make install
cd ..

# libffi puts its include files under its lib directory.
# Add some links for sanity of build paths.
ln -s /usr/local/lib/libffi-3.0.8/include/ffi.h /usr/local/include/ffi.h
ln -s /usr/local/lib/libffi-3.0.8/include/ffitarget.h /usr/local/include/ffitarget.h

# gnustep-make

wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.2.0.tar.gz
gunzip gnustep-make-2.2.0.tar.gz
tar -xvf gnustep-make-2.2.0.tar
cd gnustep-make-2.2.0

./configure --enable-native-objc-exceptions
gmake
gmake install
cd ..

# gnustep-base
wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-base-1.19.2.tar.gz
gunzip gnustep-base-1.19.2.tar.gz
tar -xvf gnustep-base-1.19.2.tar
cd gnustep-base-1.19.2

# these are the default GNUstep install paths. You can change them in 
# the configure steps above.
export GNUSTEP_MAKEFILES=/usr/GNUstep/System/Makefiles
export GNUSTEP_SYSTEM_ROOT=/usr/GNUstep/System

. $GNUSTEP_SYSTEM_ROOT/Library/Makefiles/GNUstep.sh

# The openssl libraries on OpenSolaris are in /lib, which isn't in 
# any search paths.  This will probably be corrected in a future OS release.
# See 
#   http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6842009
# for details.

export CFLAGS='-I/usr/local/lib/libffi-3.0.8/include -I/usr/include/libxml2'
export LDFLAGS='-L/lib -L/usr/local/lib'
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/export/home/jsb/GNUstep/Library/Libraries:/usr/GNUstep/Local/Library/Libraries:/usr/GNUstep/System/Library/Libraries

# ./configure --enable-libffi --enable-fake-main
./configure --enable-libffi --with-ffi-include=/usr/local/lib/libffi-3.0.8/include --with-ffi-library=/u/local/lib --with-openssl-library=/lib
gmake
gmake install
cd ..

# readline - not part of OpenSolaris

wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
gunzip readline-6.0.tar.gz
tar -xvf readline-6.0.tar
cd readline-6.0

./configure
make
make install
cd ..


# pcre with UTF-8 support is already available as a Sun package
#wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz
#gunzip pcre-7.9.tar.gz
#tar -xvf pcre-7.9.tar
#cd pcre-7.9
#
#./configure --disable-dependency-tracking --enable-utf8
#make
#make install
#cd ..


# 'gnustep-config --objc-flags' should look something like this on FreeBSD:
#
# -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 
# -D_REENTRANT -pthread -fPIC -g -Wall -DDEBUG -fno-omit-frame-pointer -DGSWARN 
# -DGSDIAGNOSE -Wno-import -g -fno-strict-aliasing -fexceptions -fobjc-exceptions 
# -D_NATIVE_OBJC_EXCEPTIONS -fgnu-runtime -fconstant-string-class=NSConstantString 
# -I. -I/usr/local/include -I/usr/GNUstep/Local/Library/Headers 
# -I/usr/GNUstep/System/Library/Headers


# 'gnustep-config --base-libs' should look something like this on FreeBSD:
# -rdynamic -pthread -shared-libgcc -fexceptions -fgnu-runtime 
# -L/usr/GNUstep/Local/Library/Libraries -L/usr/GNUstep/System/Library/Libraries 
# -L/usr/local/lib -lgnustep-base -pthread -lobjc -lm


# Now build Nu
git clone git://github.com/timburks/nu.git
cd nu

rm -rf /usr/local/share/libNu
mkdir -p /usr/local/share/libNu
cp -rp nu /usr/local/share/libNu

gmake
./mininush tools/nuke
./mininush tools/nuke install

nuke clean
nuke
nuke install

# On Unix environments, you'll get a "text file busy" error when nuke is running
cp libNu.so /usr/local/lib
cp nush /usr/local/bin

# You can run 'nuke test' now to test your installation.


