#! /bin/bash
# Install brew then install compiler and libraries with 
# brew install fltk mpfi readline libxft jpeg gsl ntl glpk libsamplerate autoconf automake pari libao libusb
# run mkosx, then click Applications, then usr, then bin, then xcas
# archive with cd / ; tar cvfz ~/xcas_osx14.tgz Applications/usr
# scp ~/xcas_osx14.tgz malherbe:public_html/giac
# OR
# cd 
# dylibbundler -od -b -x ./xcas.app/Contents/MacOS/xcas -d ./xcas.app/Contents/libs/
# pkgbuild --install-location /Applications --identifier xcas.pkg.app --root xcas.app Downloads/Xcas.pkg 
# productbuild --sign Xcas --component /Applications/xcas.app/ xcas.pkg
# should reconfigure for x86_64 arch, compile, then call dylibbundler then call lipo
#export CC=gcc-13
#export CXX=g++-13
export CFLAGS='-I/opt/homebrew/include -fPIC -g -O2'
export CXXFLAGS='-std=c++11 -I/opt/homebrew/include -I/opt/homebrew/Cellar/fltk/1.3.9/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/jpeg/include -I/Applications/usr/include/ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -fPIC -g -O2'
export CPPFLAGS='-I/opt/homebrew/include -I/opt/homebrew/Cellar/fltk/1.3.9/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/jpeg/include -I/Applications/usr/include/ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -fPIC -g -O2'
export LDFLAGS='-L/opt/homebrew/lib -L/opt/homebrew/Cellar/fltk/1.3.9/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/jpeg/lib -L/Applications/usr/lib'
#./configure --disable-gettext --prefix=/Applications/usr
./configure --prefix=/Applications/usr
#/bin/cp config.h.osx config.h
#/bin/cp config.h.osx src/config.h
make -j
make install
