[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:30 Nov 2004 12:50:56 -0000 
Subject:New shell script to check for available linux facilities for poplog 
From:Aaron Sloman 
Volume-ID: 

So many people have had problems installing poplog because their linux
installations are "incomplete" that I've finally produced a shell script
to check things out and, if possible, create symbolic links to fix
problems.

At least one Suse9.1 user and possibly others have managed to install
linux with no C compiler, which makes linking impossible.

It seems that linux vendors are now trying to package linux to be as
much like windows as possible and most windows users do not compile
or link anything???

Anyhow the script now tests for gcc, and produces a warning that
poplog cannot be linked without it.

I have prepared a pre-linked version of the core of poplog here
for use by people who don't have gcc and don't know how to get it
or install it:

    http://www.cs.bham.ac.uk/research/poplog/linux-pop-pop.tar.gz

That provides pre-built versions of

    $usepop/pop/pop/
    $usepop/pop/lib/psv/

The second is strictly redundant and I'll probably replace it
with a script for building the saved images.
(I shall later provide instructions for installing the pre-linked
version over an installation that fails to link.)

Next I have found users whose installations do not have

    libXext.so
    libXt.so
    libX11.so

even though they have versions of the same libraries with version
numbers appended, in

    /usr/X11R6/lib

This seems to be a consequence of not selecting 'developer' options
when installing libraries.

So my script checks for that situation and creates an appropriate
link, if possible, for each missing .so file.
(It must be run as root for that bit.)

Finally it does the same for Motif, i.e. libXm.so, though taking the
precaution of not making a link to Lesstif (libXm.so.1) if 'real' Motif
is available (libXm.so.2 or libXm.so.3).

Because csh/tcsh is not available on all linux systems, I've written the
script using bash, which meant learning about bash syntax for the first
time!

The script will be installed here for anyone who wishes to fetch it to
check out a linux system before getting poplog:

    http://www.cs.bham.ac.uk/research/poplog/com/CHECK_LINUX_FACILITIES

I append the file to this message. If any bash expert is willing to
check it out and suggest improvements I'll be grateful.

Thanks.
Aaron
==
http://www.cs.bham.ac.uk/~axs/

=======================================================================
#!/bin/bash
##
## $local/com/CHECK_LINUX_FACILITIES
## http://www.cs.bham.ac.uk/research/poplog/com/CHECK_LINUX_FACILITIES
## To be run before installing Poplog
##  Aaron Sloman 30 Nov 2004
##  http://www.cs.bham.ac.uk/~axs/
##
##
## Check for libraries required for X11 stuff in poplog and
## put links in where necessary.

## First make sure C compiler/linker available

gccloc=`which gcc`

if [ -x "$gccloc" ]
then
    echo "C compiler found: $gccloc"
else
    echo "WARNING: gcc not found."
    echo "So it will not be possible to link poplog on this machine."
    echo "  You should either take steps to get gcc installed,"
    echo "  or try installing a pre-linked version of poplog"
    echo "  as described in PRE_LINKED_LINUX_POPLOG.txt"
fi

echo ""
echo "-----------------------------------"


## Now check out X window libraries and Motif

cd /usr/X11R6/lib

## for testing
#cd /tmp/Xtest


## Test whether file $1 exists. Used several times below
## each time this is run $1 will have a different value
##
check_only()
{
echo ""
echo "Checking for " $1

if [ -f "$1" ]
then

    echo "/usr/X11R6/${1} already exists: Good"

else
    echo "/usr/X11R6/lib${1} does not exist"
    echo "   --- will look for equivalent to link to."
fi

}

check_only "libX11.so"
check_only "libXt.so"
check_only "libXext.so"
check_only "libXm.so"

echo ""
echo "-----------------------------------"


## check_and_fix must be run by super-user
## tests whether file $1 exists and if not whether a suitable
## version exists which can be linked to it.
## E.g. if libXt.so does not exist but libXt.so.6.3 is found then
## the latter can be linked to libXt.so (in /usr/X11R6/lib/).

## variable to record missing files
failed=""

## each time this is run $1 will have a different value
##
check_and_fix()
{
echo ""
echo "Checking whether something needs to be linked to" $1

if [ -f "$1" ]
then

    echo "$1 already exists"

else
    ## The .so file does not exist.
    ## See if there are versions that have version numbers appended
    for file in ${1}* ;
    do
        if [ -f $file ]
        then
            ## found a suitable file, so make a symbolic link
            echo Linking $file to $1 ;
            ln -s $file $1 ;

            ## stop trying any more file names
            break;
        fi
    done

    # check if successful
    if [ -f "$1" ]
    then
        echo "$1 linked"
    else
        echo "   /usr/X11R6/lib/${1}* not found"
        failed="$failed $1"
    fi
fi

}

## The string $failed may be extended by check_and_fix
failed=""

check_and_fix  "libX11.so"
check_and_fix "libXext.so"
check_and_fix "libXt.so"


if [ "$failed" ]
then
    ## Report missing libraries
    echo ""
    echo "X WINDOW LIBRARIES MISSING"
    echo "Could not find $failed"
    echo "  nor files with version numbers to link them to".
    echo "Cannot run poplog with graphical (X window) facilities"
    echo "   Investigate installation of X Window system with libraries"
    echo "   to support development work on your linux system"
    echo "   (see either www.xfree86.org or www.x.org)"
    echo ""
    echo "Alternatively you can install poplog without using X window system"
    nox="true"
else
    echo "The core required X window system libraries are available."
    echo "Poplog should link and run with the X Window system."
    nox=""
fi

echo ""
echo "-----------------------------------"
echo ""
echo "Now checking for Motif"


xx="libXm.so"
xx3="libXm.so.3"
xx2="libXm.so.2"
# last option is for Lesstif
xx1="libXm.so.1"

nomotif=""

if [ -f "$xx" ]
then

    echo "Good: $xx already exists"

else

    for file in ${xx3}* ${xx2}* ${xx1}*;
    do
        if [ -f $file ]
        then
            ## Found a version of Motif, so link it to the .so file
            echo Linking $file to $xx ;
            ln -s $file $xx ;
            break;
        fi
    done

    # check if successful
    if [ -f "$xx" ]
    then
        echo "$xx linked"
    else
        echo "   /usr/X11R6/lib/${xx}* not found."
        echo "   Please check out your motif installation."
        nomotif="true"
    fi
fi


if [ "$nomotif" ]
then
    echo "Could not find Motif (or Lesstif)"
    echo "Cannot run poplog with Motif even if X libraries installed"
else
    echo "Motif OK"
    if [ "$nox" ]
    then
        echo "But other X libraries missing -- so cannot use Motif"
    else
        echo "Poplog should link OK with X and Motif"
        exit 0
    fi
fi

## indicate failure
exit 1
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/  (also talks in /talks )
FREE BOOK: http://www.cs.bham.ac.uk/research/cogaff/crp/
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/packages/simagent.html