Name: logtalk
Summary: Logtalk - Open source object-oriented logic programming language
Version: LOGTALK_VERSION
Release: 1
License: ASL 2.0
Group: Development/Languages
Packager: Paulo Moura <pmoura@logtalk.org>
Source: https://logtalk.org/files/LOGTALK_INSTALL_DIRECTORY.tar.bz2
BuildArchitectures: noarch
URL: https://logtalk.org/
AutoReqProv: no
%description
Logtalk is a declarative object-oriented logic programming language that extends and leverages the Prolog language with modern code encapsulation and code reuse mechanisms while also providing improved predicate semantics. As a multi-paradigm language, it includes support for modules, prototypes, classes, protocols (interfaces), categories (components and hot patching), event-driven programming, and high-level multi-threading programming.

%prep
%setup -q -c LOGTALK_INSTALL_DIRECTORY -n LOGTALK_INSTALL_DIRECTORY

%build

%install
rm -rf $RPM_BUILD_ROOT
cd scripts
mkdir -p $RPM_BUILD_ROOT/usr/local
./install.sh -p $RPM_BUILD_ROOT/usr/local

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/ACKNOWLEDGMENTS.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/BIBLIOGRAPHY.bib
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/CITATION.cff
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/CODE_OF_CONDUCT.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/CONTRIBUTING.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/CUSTOMIZE.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/INSTALL.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/LICENSE.txt
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/NOTICE.txt
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/QUICK_START.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/README.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/RELEASE_NOTES.md
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/UPGRADING.md
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/VERSION.txt
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/loader-sample.lgt
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/settings-sample.lgt
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/tester-sample.lgt
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/tests-sample.lgt
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/adapters
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/coding
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/contributions
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/core
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/docs
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/examples
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/integration
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/library
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/paths
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/ports
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/man
%doc /usr/local/share/LOGTALK_INSTALL_DIRECTORY/manuals
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/scratch
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/scripts
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/tests
/usr/local/share/LOGTALK_INSTALL_DIRECTORY/tools
/usr/local/share/logtalk
/usr/local/bin/logtalk_user_setup
/usr/local/bin/lgt2svg
/usr/local/bin/lgt2pdf
/usr/local/bin/lgt2html
/usr/local/bin/lgt2xml
/usr/local/bin/lgt2md
/usr/local/bin/lgt2rst
/usr/local/bin/lgt2txt
/usr/local/bin/lgtenv
/usr/local/bin/logtalk_allure_report
/usr/local/bin/logtalk_tester
/usr/local/bin/logtalk_doclet
/usr/local/bin/logtalk_version_select
/usr/local/bin/logtalk_backend_select
/usr/local/bin/logtalk_setup_env.sh
/usr/local/bin/bplgt
/usr/local/bin/ciaolgt
/usr/local/bin/cxlgt
/usr/local/bin/eclipselgt
/usr/local/bin/gplgt
/usr/local/bin/jiplgt
/usr/local/bin/xvmlgt
/usr/local/bin/quintuslgt
/usr/local/bin/sicstuslgt
/usr/local/bin/swilgt
/usr/local/bin/taulgt
/usr/local/bin/tplgt
/usr/local/bin/xsblgt
/usr/local/bin/yaplgt
/usr/local/share/info/dir
/usr/local/share/info/LogtalkAPIs-LOGTALK_VERSION.info
/usr/local/share/info/TheLogtalkHandbook-LOGTALK_VERSION.info
/usr/local/share/man/man1/bplgt.1.gz
/usr/local/share/man/man1/ciaolgt.1.gz
/usr/local/share/man/man1/cxlgt.1.gz
/usr/local/share/man/man1/eclipselgt.1.gz
/usr/local/share/man/man1/gplgt.1.gz
/usr/local/share/man/man1/jiplgt.1.gz
/usr/local/share/man/man1/lgt2svg.1.gz
/usr/local/share/man/man1/lgt2html.1.gz
/usr/local/share/man/man1/lgt2pdf.1.gz
/usr/local/share/man/man1/lgt2xml.1.gz
/usr/local/share/man/man1/lgt2md.1.gz
/usr/local/share/man/man1/lgt2rst.1.gz
/usr/local/share/man/man1/lgt2txt.1.gz
/usr/local/share/man/man1/lgtenv.1.gz
/usr/local/share/man/man1/logtalk_allure_report.1.gz
/usr/local/share/man/man1/logtalk_backend_select.1.gz
/usr/local/share/man/man1/logtalk_tester.1.gz
/usr/local/share/man/man1/logtalk_doclet.1.gz
/usr/local/share/man/man1/logtalk_user_setup.1.gz
/usr/local/share/man/man1/logtalk_version_select.1.gz
/usr/local/share/man/man1/xvmlgt.1.gz
/usr/local/share/man/man1/quintuslgt.1.gz
/usr/local/share/man/man1/sicstuslgt.1.gz
/usr/local/share/man/man1/swilgt.1.gz
/usr/local/share/man/man1/taulgt.1.gz
/usr/local/share/man/man1/tplgt.1.gz
/usr/local/share/man/man1/xsblgt.1.gz
/usr/local/share/man/man1/yaplgt.1.gz
%exclude /usr/local/share/mime

%post
echo
echo "Installed Logtalk on \"/usr/local/share\"."
echo

echo "Links to the following scripts have been created in /usr/local/bin:"
echo
echo "- logtalk_user_setup, logtalk_backend_select, logtalk_version_select"
echo "- logtalk_tester, logtalk_allure_report, logtalk_doclet"
echo "- lgt2svg, lgt2pdf, lgt2html, lgt2xml, lgt2md, lgt2rst, lgt2txt"
echo "- lgtenv"
echo
echo "The following integration scripts are installed for running Logtalk"
echo "with selected backend Prolog compilers:"
echo
echo "* B-Prolog (8.1 or later):           bplgt       (experimental)"
echo "* Ciao Prolog (1.22.0 or later):     ciaolgt     (experimental; first run may require sudo)"
echo "* CxProlog (0.98.1 or later):        cxlgt"
echo "* ECLiPSe (6.1#143 or later):        eclipselgt"
echo "* GNU Prolog (1.4.5 or later):       gplgt"
echo "* JIProlog (4.1.7.1 or later):       jiplgt      (first run may require sudo)"
echo "* Quintus Prolog (3.3 or later):     quintuslgt  (experimental)"
echo "* SICStus Prolog (4.1.0 or later):   sicstuslgt"
echo "* SWI-Prolog (6.6.0 or later):       swilgt"
echo "* Tau Prolog (0.3.2 or later):       taulgt"
echo "* Trealla Prolog (2.59.21 or later): tplgt"
echo "* XSB (3.8.0 or later):              xsblgt      (first run may require sudo)"
echo "* XVM (10.0.0 or later):             xvmlgt"
echo "* YAP (6.3.4 or later):              yaplgt"
echo
echo "Links to the Prolog integration scripts can be found on \"/usr/local/bin\"."
echo "Make sure that the Prolog compilers are properly installed and available"
echo "on your execution path."
echo
echo "If you get an unexpected failure when using one of the Prolog integration"
echo "scripts, consult the \"/usr/local/share/logtalk/adapters/NOTES.md\" file"
echo "for compatibility notes or consult the integration script man page."
echo
mkdir -p /etc/profile.d
echo "# Logtalk environment setup" > /etc/profile.d/logtalk.sh
echo "" >> /etc/profile.d/logtalk.sh
echo "# Logtalk installation directory:" >> /etc/profile.d/logtalk.sh
echo "export LOGTALKHOME=/usr/local/share/logtalk" >> /etc/profile.d/logtalk.sh
echo "" >> /etc/profile.d/logtalk.sh
echo "# Default location for Logtalk end-user files:" >> /etc/profile.d/logtalk.sh
echo "export LOGTALKUSER=\$HOME/logtalk" >> /etc/profile.d/logtalk.sh
chmod a+x /etc/profile.d/logtalk.sh
echo "# Logtalk environment setup" > /etc/profile.d/logtalk.csh
echo "" >> /etc/profile.d/logtalk.csh
echo "# Logtalk installation directory:" >> /etc/profile.d/logtalk.csh
echo "setenv LOGTALKHOME /usr/local/share/logtalk" >> /etc/profile.d/logtalk.csh
echo "" >> /etc/profile.d/logtalk.csh
echo "# Default location for Logtalk end-user files:" >> /etc/profile.d/logtalk.csh
echo "setenv LOGTALKUSER \$HOME/logtalk" >> /etc/profile.d/logtalk.csh
chmod a+x /etc/profile.d/logtalk.csh
echo "Defined the following environment variables for all users:"
echo
echo "  Logtalk installation directory: LOGTALKHOME = /usr/local/share/logtalk"
echo "  Default Logtalk user files directory: LOGTALKUSER = \$HOME/logtalk"
echo
echo "You may need to logout and login again or start a new shell in order to"
echo "use the new environment variables."
echo
echo "Users may change the default value of the LOGTALKUSER environment variable"
echo "in their shell configuration files if they already use, or want to use, a "
echo "different location for the Logtalk user files directory. This directory "
echo "is created by running the \"logtalk_user_setup\" shell script, which must"
echo " be run once by each user before using the integration scripts."
echo
if [ -x /usr/bin/update-mime-database ]; then
	mkdir -p /usr/share/mime/packages
	rm -f /usr/share/mime/packages/logtalk.xml
	cp /usr/local/share/LOGTALK_INSTALL_DIRECTORY/scripts/freedesktop/logtalk.xml /usr/share/mime/packages/logtalk.xml
	update-mime-database /usr/share/mime
	echo "Added the Logtalk mime-type to the Shared MIME-info Database."
	echo
fi
echo "Logtalk basic installation completed."
echo

%postun
rm -f /etc/profile.d/logtalk.sh 2> /dev/null
rm -f /etc/profile.d/logtalk.csh 2> /dev/null
