#
# ***************************************************************
# *                  Tabular - SIMUSOL PROYECT                  *
# *                                                             *
# *   Table extension for SIMUSOL PROYECT, for use with:        *                
# *       +  C++ Mathematical Expression Toolkit Library        *
# *          which is located in URL:                           *
# *          http://www.partow.net/programming/exprtk/index.html*
# *          used in Siru/Simusol                               *
# *       +  SCEPTRE (System for Circuit Evaluation             *
# *          and Prediction of Transient Radiation Effects)     *
# *          http://alpha.fh-friedberg.de/iem/84.html           *
# *          used in Simusol                                    *
# *   The extension was developed by                            *
# *   Diego.Saravia@ututo.org, 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
#
#    Tabular is free software: you can redistribute it and/or modify
#    it under the terms of
#
#     1)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.
#
#    2) Any other free licence with copyleft recognized by the FSF
#
#    Tabular 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 Tabular.  If not, see <http://www.gnu.org/licenses/>.




#VERSION=0.1
#NAME=simusol_table

SUBDIRS= src check examples exprtk   #src esta incluido en los otros # no parece que no # src primero, di no encuentra simusol_table.h

.PHONY:  subdirs  $(SUBDIRS)

# SOLO PARA DEBIAN UBUNTU!!!! si no se usa summapack completo
# /usr/local/share/summapack/data/makefile.lib


all:  unzip $(SUBDIRS)  gnuplot-x11 gnuplot5 subversion

define findfirstSB
$(shell $(shellpath) if test -s ./$1 ; then \
                   echo .;\
                 elif test -s ~/$1 ; then \
                    echo ~;\
                 elif test -s /usr/local/$1 ; then \
                   echo /usr/local;\
                 elif  test -s /usr/$1 ; then \
                    echo /usr;\
                 fi;)
endef

cpmakefilelib:
	cp ../summapack/share/summapack/data/makefile.lib ../tabular/share/summapack/data/makefile.lib 

PREFIXMLIB=$(call findfirstSB,share/summapack/data/makefile.lib)
$(info MAKELIB: ${PREFIXMLIB})
ifneq ("$(wildcard $(PREFIXMLIB)/share/summapack/data/makefile.lib)","")
  include $(PREFIXMLIB)/share/summapack/data/makefile.lib
endif
$(info MAKELIB: ${PREFIXMLIB})


SERVERBAJARWD=http://simusol.org/downloads


$(info SERVERSUBIR: ${SERVERSUBIR})
$(info SERVERBAJAR: ${SERVERBAJAR})
$(info SERVERBAJARWD: ${SERVERBAJARWD})
$(info SERVERDIR: ${SERVERDIR})
$(info SERVERUSER: ${SERVERUSER})






summapackNAME=summapack-last.tar.gz
summapackDIR=$(SERVERBAJARWD)/${summapackNAME}


include makefile.inc

# OJO  NO ES UPD
/usr/local/share/summapack/data/makefile.lib: 
	sudo make updsummapack


subdirs: $(SUBDIRS)

$(SUBDIRS):
	$(MAKE) -C $@

clean::
	rm -f *~  \#*
	rm -f gnudata.txt
	for dir in $(SUBDIRS); do \
	  $(MAKE) -C $$dir  clean; \
	  done

install:
	for dir in src; do \
	  $(MAKE) -C $$dir  install; \
	done

updsummapack:  ${DOWNLOAD}
	$(call download,,$(DOWNLOAD),${summapackNAME},${summapackDIR},summapack,SummaPack,$(call compilation))
