#! /bin/bash
export CFLAGS='-I/usr/local/include -fPIC -g -O2'
export CXXFLAGS='-I/usr/local/include -fPIC -g -O2'
export CPPFLAGS='-I/usr/local/include -fPIC -g -O2'
export LDFLAGS=-L/usr/local/lib
#export LDFLAGS='-L/usr/X11/lib'
# export LIBS="$LIBS -framework AGL -framework OpenGL -framework ApplicationServices -framework Cocoa -isysroot /Developer/SDKs/MacOSX10.6.sdk"
#./configure --prefix=/Applications/usr
make
cd src
sh mklocal
make
sh mkxlocal
make install
rm -rf /Applications/usr/bin/xcas.app
cp -f xcas /Applications/usr/bin/
rm -f /Applications/usr/lib/libgiac.a
#cp -f icas /Applications/usr/bin
#cd ~/64/newgiac/src
sh mkdylib10
cp .libs/libgiac.0.dylib /Applications/usr/lib
cp .libs/libgiac.la /Applications/usr/lib
sh mkdyn10
cp icas /Applications/usr/bin
sh mkxdyn10
cp xcas /Applications/usr/bin/xcasdyn
#install_name_tool -change "/usr/local/lib/libpari.dylib" "/Applications/usr/local/lib/libpari.dylib" /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/lib/libgsl.0.dylib" "/Applications/usr/64/local/lib/libgsl.0.dylib" /Applications/usr/64/local/lib/libgsl.0.dylib
install_name_tool -change "/usr/local/lib/libgsl.0.dylib" "/Applications/usr/64/local/lib/libgsl.0.dylib" /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/lib/libgslcblas.0.dylib" "/Applications/usr/64/local/lib/libgslcblas.0.dylib" /Applications/usr/64/local/lib/libgslcblas.0.dylib
install_name_tool -change "/usr/local/lib/libgslcblas.0.dylib" "/Applications/usr/64/local/lib/libgslcblas.0.dylib" /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/opt/gettext/lib/libintl.8.dylib" "/Applications/usr/64/local/lib/libintl.8.dylib" /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/lib/libmpfr.4.dylib" "/Applications/usr/64/local/lib/libmpfr.4.dylib" /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/lib/libgmp.10.dylib" "/Applications/usr/64/local/lib/libgmp.10.dylib" /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/lib/libmpfi.0.dylib" "/Applications/usr/64/local/lib/libmpfi.0.dylib"  /Applications/usr/lib/libgiac.0.dylib
install_name_tool -change "/usr/local/lib/libgmp.10.dylib" "/Applications/usr/64/local/lib/libgmp.10.dylib"  /Applications/usr/64/local/lib/libmpfr.4.dylib
install_name_tool -change "/usr/local/lib/libgmp.10.dylib" "/Applications/usr/64/local/lib/libgmp.10.dylib"  /Applications/usr/64/local/lib/libmpfi.0.dylib
install_name_tool -change "/usr/local/lib/libmpfr.4.dylib" "/Applications/usr/64/local/lib/libmpfr.4.dylib"  /Applications/usr/64/local/lib/libmpfi.0.dylib
#cd ~/64/newgiac/giacpy-nox-0.4.4
#sh mkgiacpy
cd /Applications/usr/bin
fltk-config --post xcas
install_name_tool -change "/usr/local/lib/libao.4.dylib" "/Applications/usr/64/local/lib/libao.4.dylib"  /Applications/usr/bin/xcas.app/Contents/MacOS/xcas
install_name_tool -change "/usr/local/lib/libjpeg.8.dylib" "/Applications/usr/64/local/lib/libjpeg.8.dylib"  /Applications/usr/bin/xcas.app/Contents/MacOS/xcas
install_name_tool -change "/usr/local/lib/libpng16.16.dylib" "/Applications/usr/64/local/lib/libpng16.16.dylib"  /Applications/usr/bin/xcas.app/Contents/MacOS/xcas
install_name_tool -change "/usr/local/opt/libpng/lib/libpng16.16.dylib" "/Applications/usr/64/local/lib/libpng16.16.dylib"  /Applications/usr/bin/xcas.app/Contents/MacOS/xcas
open ~/Desktop/xcas.pmdoc
