#
# **************************************************************
# *                  SIMUSOL PROYECT                           *
# *                                                            *
# *         Table extension for:                               *
# *         C++ Mathematical Expression Toolkit Library        *
# *         which is located in:                               *
# * URL: http://www.partow.net/programming/exprtk/index.html   *
# *                                                            *
# *   The extension was developed by                           *
# *   Diego.Saravia@gmail.com, 2016                            *
# *   and could be used in the same terms of the toolkit       *
# *   or every free license with copyleft needed.              *
# *   http://www.simusol.org                                   *
# **************************************************************
# This file is part of Tabular
#
#    Table is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Table is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Table.  If not, see <http://www.gnu.org/licenses/>.



DOWNLOAD=/tmp/down

all: exprtk_table

define findfirstSB
$(shell $(shellpath) if test -s /usr/$1 ; then \
                   echo /usr;\
                 elif test -s /usr/local/$1 ; then \
                   echo /usr/local;\
                 elif test -s ~/$1 ; then \
                    echo ~;\
                 elif  test -s ../$1 ; then \
                    echo ..;\
                 fi;)
endef
PREFIXMLIB=$(call findfirstSB,share/summapack/data/makefile.lib)
$(info MAKELIB: ${PREFIXMLIB}) 
include $(PREFIXMLIB)/share/summapack/data/makefile.lib


include ../makefile.inc

#http://www.partow.net/downloads/exprtk.zip
#https://svn.apache.org/repos/asf/jakarta/cactus/trunk/descriptors/licenses/cpl-1.0.txt

exprtk_table:  exprtk_table.cpp $(DOWNLOAD)/exprtk.hpp /usr/local/lib/libsimusol_table.so Makefile ../makefile.inc  
	if [ ! -e exprtk.hpp ] ; then echo LINK; ln -fs $(DOWNLOAD)/exprtk.hpp exprtk.hpp ; fi;
	time  $(COMPILER) $(CPPOPTIONS) -std=gnu++14 -g -o exprtk_table    exprtk_table.cpp -lsimusol_table $(LINKER_OPT)

#-f "time: %E"

exprtk_table_static:  exprtk_table.cpp $(DOWNLOAD)/exprtk.hpp simusol_table.o simusol_table.h  simusol_table_internal.h  Makefile  
	if [ ! -e exprtk.hpp ] ; then ln  -fs  $(DOWNLOAD)/exprtk.hpp  exprtk.hpp; fi
	time -f "time: %E" $(COMPILER) $(CPPOPTIONS) std=gnu++14 -g -o exprtk_table simusol_table.o   exprtk_table.cpp $(LINKER_OPT)

#  /usr/local/include/simusol_table.h  
#	time -f "time: %E" $(COMPILER) $(CPPOPTIONS) -g -o exprtk_table simusol_table.o ../tests/finddir.o  exprtk_table.cpp $(LINKER_OPT)


clean::
	rm -f *~ *.o  exprtk_table_static exprtk_table
	rm -f exprtk.hpp

