POPLOG ON FREEBSD
http://www.cs.bham.ac.uk/research/poplog/freebsd/poplog-on-freebsd.txt
Modified  26 Nov 2004 (Port of poplog provided by Andrew Rydz)
Modified  23 Nov 2004 (Note from John Duncan)
Installed 17 May 2004 by Aaron Sloman
=====================

Andrew Rydz has provided a port of poplog to Freebsd described in
    http://www.cs.bham.ac.uk/research/poplog/freebsd/new/README-freebsd-poplog.txt

    Which starts:
        I have a port of POPLOG for FreeBSD 4.9, which I have tested quite
        extensively. The port requires the FreeBSD LINUX emulator which is supplied
        by default. From within POPLOG, using the "imcsh" facility, it is also
        possible to compile 'C' code for external linking. I have also tested the
        callback mechanism.


All the files referred to in the README file are in the same directory

    http://www.cs.bham.ac.uk/research/poplog/freebsd/new/freebsd-poplog.tgz
    http://www.cs.bham.ac.uk/research/poplog/freebsd/new/local.tgz
    http://www.cs.bham.ac.uk/research/poplog/freebsd/new/Makefile
    http://www.cs.bham.ac.uk/research/poplog/freebsd/new/rgb.txt

=====================

17 May 2004
John Duncan has kindly contributed the following instructions on how to
install poplog on a PC running FreeBSD, starting from the Linux PC
Poplog package available here

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

The notes are written from the point of view of someone completely new
to Poplog, who is familiar with FreeBSD

For more information on Poplog please see
    http://www.cs.bham.ac.uk/research/poplog/freepoplog.html
    http://www.cs.bham.ac.uk/research/poplog/poplog.info.html
    http://www.cs.bham.ac.uk/research/poplog/comp.lang.pop.faq.html

Note that you can install poplog either with or without motif. The
former option provides some minor advantages especially if you use
the  poplog editor Ved in its multi-window version XVed.
=======================================================================

Message from John Duncan
Subject: Linux Poplog Works On DragonFly BSD
Date: 20 Nov 2004 20:53:35 +1000

   DragonFly BSD is a fork from FreeBSD by Matt Dillon and
   others. Following some recent changes they made to their Linux
   Emulation setup Poplog for Linux will run on DragonFly BSD.

   The instructions for installing are the same as for FreeBSD,
   below.

=======================================================================
Instructions by John Duncan:

               How To Build and Run Linux Poplog on FreeBSD


Linux Poplog can be used on FreeBSD with the Linux ABI support
provided in the GENERIC kernel. See the FreeBSD Handbook and manual
pages for the gory details. To get this support every time you run
put,

    linux_enable="YES"

in your /etc/rc.conf and to ensure that FreeBSD recognises the Poplog
binaries as Linux use this sysctl variable like so,

    # sysctl kern.fallback_elf_brand=3

This will have to be repeated upon a reboot. You could just try to
brand the binaries like this,

    # brandelf -t Linux poplog_binaries

but maybe some parts of the Poplog system are seen as binaries that I
don't know about.

First we have to set up a Linux type system under /compat/linux in
FreeBSD, we do this by building the ports which give us a RedHat 8 set
of libraries. This is because of the version of the Linux libc that
Poplog needs now. At the moment these are,

    /usr/ports/emulators/linux_base-8
    /usr/ports/devel/linux_devtools
    /usr/ports/x11/linux-XFree86-libs

This will install the following packages,

    linux_base-8-8.0_4   linux_devtools-8.0_1  linux-XFree86-libs-4.3.0_2

After this we will need to install some things that the Poplog
installation scripts need, we do this by installing the RedHat RPMS
for RedHat 8.0 en which can be found at websites like rpmfind. We need,

    tcsh-6.12-2.i386.rpm
    tar-1.13.25-8.i386.rpm
    gzip-1.3.3-5.i386.rpm
    textutils-2.0.21-5.i386.rpm
    util-linux-2.11r-10.i386.rpm

    openmotif-2.2.2-12.i386.rpm
        ---  only if you want to install Poplog WITH_MOTIF
        ---  Recommended, but not essential.

You install them like in this example

    # rpm -i --ignoreos --nodeps --root /compat/linux \
        --dbpath /var/lib/rpm tcsh-6.12-2.i386.rpm

When you install the util-linux RPM you will get the message

    group tty does not exist using root

This does not seem to worry the installation. Another point is
that although there is a /compat/linux/usr/tmp directory symlinked
to /var/tmp the Poplog installation can't use this so we need to
make another one

    # cd /compat/linux
    # mkdir tmp

Assuming you have downloaded the large Linux Poplog tarball(21MB)

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

to your home directory and had a look at the documentation available
at the Birmingham University website to see what should happen

     http://www.cs.bham.ac.uk/research/poplog/linux-cd/SHORT-CUT-INSTALLATION.txt

lets start the installation.

I am going to install everything in the default position and so
that all users can use Poplog, there is now provision in the build
scripts to install in other places if you want, see the documentation
for details. First make a directory under /compat/linux for the
source and copy the tarball into it.

   # cd /compat/linux/usr
   # mkdir -p /compat/linux/usr/local/poplog/src
   # cd /home/whoever
   # cp -p bham-linux-poplog.tar.gz /compat/linux/usr/local/poplog/src

Now enter into a chrooted environment under /compat/linux to untar
the sources and run the build scripts. First run the ldconfig program
for the /compat/linux libraries just in case, this step also seems to
be able to be done from outside the chroot if needed.

    # cd /compat/linux/usr
    # chroot /compat/linux /bin/bash
    bash2.05b# pwd                      ( just to check )
    /
    bash2.05b# cd /lib
    bash2.05b# /sbin/ldconfig
    bash2.05b# cd /usr/X11R6/lib
    bash2.05b# /sbin/ldconfig
    bash2.05b# cd /usr/local/poplog/src
    bash2.05b# zcat bham-linux-poplog.tar.gz | tar xf -

You now have the build scripts and some documentation in this
directory. The docs explain a lot, I will just say that there are two
ways to build, linked with and without Motif. I recommend with Motif
if this is your first look at Poplog. So run either,

    bash2.05b# ./INSTALL_EVERYTHING_WITH_MOTIF > install.log
( or )
    bash2.05b# ./INSTALL_EVERYTHING_WITHOUT_MOTIF > install.log

[Recommendation to redirect output to 'install.log' added by
A.Sloman. A lot of printout will go into the log file, and it
may be useful to keep it in case you need to ask for help.
System warning messages and error messages will go to the terminal,
not to the install.log file.]

There are a lot of warning messages at the start of the build saying,

   cc1: warning: changing search order for system directory "usr/include"
   as it already has been specified as a non-system directory

I am told these occur when building Poplog on RedHat 8 or 9 so are
nothing unusual, other errors that appear are normal for any build.

Exit out of the chroot and copy the whole Birmingham Poplog set up
into /usr/local for FreeBSD.

    bash2.05b# exit
    # cd /compat/linux/usr/local/poplog
    # cp -pR /compat/linux/usr/local/poplog /usr/local

Now Poplog depends heavily on environmental variables and there are
some example configuration scripts bundled with the documentation but
I will keep things as simple as possible to get you started. I use a
C type shell so,

    # cd /usr/local/bin
    # ln -s /usr/local/poplog/local/setup/bin/poplog /usr/local/bin/poplog
    # exit
    > cd
    > rehash
    > setenv usepop /usr/local/poplog/v15.53e
    > setenv poplocal /usr/local/poplog
    > setenv local $poplocal/local
    > source $usepop/pop/com/poplog

For the other shells
    $ cd
    $ usepop=/usr/local/poplog/v15.53e
    $ export usepop
    $ poplocal=/usr/local/poplog
    $ local=$poplocal/local
    $ export poplocal local
    $ . $usepop/pop/com/poplog.sh

Now open up an xterm and try to start Poplog,

    > poplog pop11 %x

If you used Motif you might see this error printed with the start up
banner,

    Can't open shared object
        /usr/local/poplog/current.poplog/pop/extern/lib/libXm.so
        ( Inappropiate ioctl for device )

I think what happens here is that I have FreeBSD openmotif installed
and initially it looks at this but in a few seconds comes good and
starts up with a Motif control panel and a window for the Xved editor
with the file temp.p in it.

If you didn't use Motif you might think that the graphical interface
failed but that is not so, read in a file at the Setpop prompt in your
xterm, i.e. the full colon by entering the line below and press <RETURN>

    Setpop
    : teach teach

and the graphical editor Xved should start with this teach file and
and a separate window with the file temp.p in it. In this teach file
it is explained how to get a control menu up.


If anything goes wrong or you change your mind about Motif to try
again it is a simple matter to just remove the untarred Poplog files
and installation and try again.

    # cd /usr/local/bin
    # rm poplog
    # cd /usr/local/poplog
    # rm -rf /usr/local/poplog
    # cd /compat/linux/usr/local/poplog
    # rm -rf /compat/linux/usr/local/poplog

With or without Motif once you have a window open with the Xved
editor enter the lines below at the Setpop prompt in your xterm and
press <RETURN> for each line. This will give you some intuitive
keyboard keys until you find your feet with Xved configuration.

    Setpop
    : uses oldvedxvedkeys
    : oldvedxvedkeys();

Once you have done this you can read the documentation in the Xved
editor window. With a PC keyboard any reference now to the <ENTER> key
means the enter key on the number pad. Start with these below, when the
<ENTER> key is pressed the editor will jump to a mini command line at
top and show your commands there. You will find that there is a sort
of hyperlink system in the documentation in Xved, some links use Esc-h
and others show red color and use the mouse.

               <ENTER> teach teach <RETURN>
               <ENTER> teach xved <RETURN>
               <ENTER> teach pop11 <RETURN>

[[Notes added by A.S

1. You can also start XVed, the poplog editor, directly, giving
this command to your shell prompt:

    poplog xved

or start XVed with a file called myprogram.p

    poplog xved myprogram.p

2. In the installation directory /usr/local/poplog/src you should
find a sub-directory startup/ containing some demonstration programs
which can be used to test the Poplog installation.
]]

There you go, you now have a wealth of documentation and examples at
your disposal to help you learn how to program in the Linux Poplog
Virtual Machine.

                             THE END
                            All the best,
                              John Duncan