#!/bin/sh
#
# Copyright (C) 2003, 2004, 2007, 2008, 2011 Thien-Thi Nguyen
#
# This file is part of Guile-PG.
#
# Guile-PG 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, or
# (at your option) any later version.
#
# Guile-PG 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 Guile-PG; see the file COPYING.  If not,
# write to the Free Software Foundation, Inc., 51 Franklin Street,
# Fifth Floor, Boston, MA  02110-1301  USA

##
# usage:
#  sh show-platform      # display "uname -a" and "tool: version" info
#  sh show-platform -m   # also mail info to <ttn@gnuvola.org>
##

recip='ttn@gnuvola.org'

go ()
{
    echo 'Guile-PG 0.45'
    for opt in m s r ; do echo uname-${opt}: `uname -$opt` ; done
    echo autoconf: `autoconf --version | sed -e 's/[^0-9.]*//g;1q'`
    echo automake: `automake --version | sed -e 's/[^0-9.]*//g;1q'`
    echo libtool: `libtool --version | sed 's/([^)]*)//g;s/^[^0-9]*//;1q'`
    echo gcc: `gcc --version`
    echo cc: `cc --version`
    echo psql: `psql --version | sed -e 's/[^0-9.]*//g;1q'`
    echo guile: `guile-config info guileversion`
}

gosexp ()
{
    echo '('
    go | sed 's/^\([-a-z]*\): *\(.*\)/(\1 . "\2")/g'
    echo ')'
}

if [ x"$1" = x-m ] ; then
    tmp="show-platform.$$"
    gosexp > $tmp
    mail -s "show-platform output" $recip < $tmp
    rv=$?
    cat $tmp
    rm $tmp
    [ $rv = 0 ] && echo "(mail successfully sent to $recip)"
else
    go
fi

# show-platform ends here
