
# **************************************************************
# *                  SIMUSOL EXAMPLES DE SIMUSOL               *
# *                        SIMUSOL  PROYECT                    *
# *                                                            *
# *                    Makefile                                *
# *                                                            *
# *                                                            *
# *   Developed by                                             *
# *   Dolores.Alia@gmail.com,                                  *
# *   Luis.R.Saravia@gmail.com                                 *
# *   Diego.Saravia@gmail.com                                  * 
# *   2017                                                     *
# *   and could be used with GPL                               *
# *   or every free license with copyleft needed.              *
# *   http://www.simusol.org                                   *
# **************************************************************
#  primero instalar summapack
#    This file is part of Simusol
#
#    Simusol 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/>.


# antes de lib
# no ejecuta nada con make, hacer sudo make install
all: install

define findfirstSB
$(shell $(shellpath) test -x /usr/$1  && echo /usr;\
                 test -x /usr/local/$1  && echo /usr/local;\
                 test -x ~/$1  && echo ~;)
endef
PREFIXMLIB=$(call findfirstSB,/share/summapack/data/makefile.lib)
$(info makelib: ${PREFIXMLIB}) 
include $(PREFIXMLIB)/share/summapack/data/makefile.lib



STABLE=last
STABLE=UNSTABLE


USERACTUAL=$(shell id -un)
USERBASE=$(shell ls -l Makefile| awk -F' ' '{print $$3}' )
$(info User Id is $(USERID) - $(USERACTUAL) - ${USER} - Su ${SUDO_USER} - BASE ${USERBASE})



# PREFIX  puede ser modificada (override) com argumento en la linea de comando
# make PREFIX=/pepito
# instala   sheets y shapes dia, documentos
USERID=$(shell id -u)

#DISTRO O UBUNTU
#~UBUNTU=$(shell cat /etc/issue| grep Ubuntu)
#$(info UBUNTU: ${UBUNTU}) 

 #$(info User Id is $(USERID))


PREFIX=/usr/local
SPREFIX=\/usr\/local

#PREFIX=/tmp/local
#SPREFIX=\/tmp\/local


USERS=`ls /home`


### eliminar en el .dia de cada usuario todo pero ver si el usuario no tiene algo propio
# es complejo

#### debe ser sudo

install:                                    #$(SUDO)       en este make base hay que decir sudo, en meta makes no
	#sudo mkdir -p /usr/local/lib/simusol
	#sudo mkdir -p /usr/local/lib/simusol/elementos
	$(call copytree,$(PREFIX),$(ETCDIR),,$(PREFIX))
	$(call listado,)
	$(call mexec,)
	$(PREFIX)/bin/simusol-examples_install ${USERBASE} $(PREFIX)

installtot:
	sudo make ../summapack 
	sudo make install
#make inslaunchers


# este no se sube es solo para hacer paquetes deb o rpm u otros
installdist: clean
	echo "PACKAGE DISTRIBUTION FILE ${PACKV}-${VERSION}-AI.tgz (architecture independent)"
	rm -rf /tmp/$(BASETMP) ; 
	mkdir -p /tmp/$(BASETMP)/$(PREFIX) ;
	$(call copytree, /tmp/${BASETMP}${PREFIX}, /tmp/${BASETMP}$(ETCRES),,${PREFIX})
	$(call listado,/tmp/${BASETMP})
	$(call mexec,/tmp/${BASETMP})
	cd  /tmp/${BASETMP}; tar -c . | gzip -n> $(CURDIR)/../${PACKV}-${VERSION}-AI.tgz
	md5sum  ../${PACKV}-${VERSION}-AI.tgz>../${PACKV}-${VERSION}-AI.tgz.md5.


# aqui listado no debe mover, pero bueno, no molesta
#################################























