
BUILDING TCLPRO UNDER FREEBSD

WORK IN PROGRESS -- BETA LEVEL CODE

This is a working document for how to build TclPro under FreeBSD, a
document in progress, documenting a work in progress.

This isn't the easiest thing in the world to build.  In fact, it's rather
tricky.  That's something we're in the process of addressing.  If you're
not familiar with the nuances and idiosyncrasies of building complex software
in a Unix environment, you should probably grab the binary install.

Note -- you should read this document alongside the README.build which
contains generic build instructions for TclPro under Unix-like systems.

Karl Lehenbauer
karl@procplace.com

BUILD AND INSTALL PREREQUISITE SOFTWARE

There are a number of prerequisites for building and installing TclPro
under FreeBSD.

ZIP AND UNZIP

One is that you need zip and unzip.  Fortunately these programs are part
of the The FreeBSD ports system, so fetching them from the Internet, building
and installing them is simple:

    su
    cd /usr/ports/archivers/zip
    make install
    make clean

This will also caused unzip to be fetched and installed.

GNU MAKE

You also need to build and install GNU make.

    cd /usr/ports/devel/gmake
    make install
    make clean

This creates "gmake" in /usr/local/bin

I like to symlink /usr/local/bin/gmake to /usr/local/bin/make and then
fiddle my PATH to put /usr/local/bin first.

Do not, DO NOT replace the Berkeley make in /usr/bin/make with GNU make as
you will lose the ability to build kernels and other FreeBSD-side stuff.

    cd /usr/local/bin
    ln -s gmake make

    PATH=/usr/local/bin:$PATH

"which make" should then say "/usr/local/bin/make"

SYMLINK /BIN/UNAME TO /USR/BIN/UNAME

TclPro currently expects uname to be in /bin, but on FreeBSD it is in
/usr/bin/uname.

As a workaround...

    ln -s /usr/bin/uname /bin/uname

AUTOCONF

GNU autoconf makes configure scripts based on configure.in scripts.
Usually when you pull down a source tree with CVS, people don't have
the configure script checked into their tree, because it is machine
generated by autoconf.

Build and install autoconf:

    cd /usr/ports/devel/autoconf
    make install
    make clean

TCL 8 ALONG YOUR PATH

You need a fairly modern (8.something) Tcl in your PATH.

TCLLIB ALSO REQUIRED

You also need the tcllib package installed.  You can check it out
from SourceForge, I think from the vicinity of 
http://sourceforge.net/projects/tcllib/

If you get an error about cmdline being an unknown package, the version
of Tcl it's using doesn't have tcllib installed.

You should make sure that you can require it:

tclsh8.3
% package require tcllib
%

If you get an error, you haven't gotten it installed correctly.


NEED SOMETHING THAT WORKS AS TCLSH

There are some places in the build that expect "tclsh" to work, rather
than "tclsh8.3" or whatever.  On FreeBSD, /usr/local/bin/tclsh is a script
that says that you have to invoke a numbered version of tclsh8.x or whatever.
You must supersede this with something that works.

I have Tcl built in /usr/pptcl, so I cd to /usr/pptcl/bin and symlink
tclsh8.3 to tclsh and then make sure /usr/pptcl/bin is earlier in my
PATH than /usr/local/bin


PULL DOWN ALL THE TCLPRO COMPONENTS

Checkout all the TclPro and other Tcl-related components using 
TclProCheckout.tcl or something.  Don't do any of this as superuser.

I pulled all mine out underneath /usr/tclpro/src

COMPILING TCLPRO

TclPro doesn't come with the configure script.  You need to create it by
running autoconf.  The build will actually occur in a subdirectory, which
you will create:

    cd /usr/tclpro/src/tclpro
    autoconf
    mkdir freebsd-ix86
    cd freebsd-ix86

    ../configure --with-flavor=Release

Now you're going to run "make".  You can tell
which make will run by doing a "which make".  If you want to know
what version a GNU make is, you can say "make --version"

If you want to build with debugging symbols in your libraries, etc., i.e.
you want to debug within Tcl at the C level, you can substitute "Debug"
for "Release" in the --with-flavor part above.


MAKE IT THE FIRST TIME

Now we want to invoke make to build the software.  Note that this is 
currently very much a batch process.  It takes a little less than
9 minutes to build everything on my 800 MHz Pentium-III.

Since the output is pretty voluminous, it's a good idea to redirect it into
a file so you can study it later.  I use

    make 2>&1 | tee make.out

...so that I can see it while it's compiling and get a copy of it.
The "2>&1" business sends stderr onto the same output pipe as stdout,
if you're using bash or sh.  If you're using csh, I think it's just
make |& tee make.out

FIX WRAPTCLSHDYN

The make will go a long way, but will ultimately fail with some undefined 
references to the math library in wraptclshdyn.

For now, you can fix the Makefile by hand:

Edit 
/usr/tclpro/src/tclpro/freebsd-ix86/build/freebsd-ix86/wraptclshdyn/Makefile

Add "-lm" to the TCL_SHLIB_LD_LIBS line, so it looks like this:

TCL_SHLIB_LD_LIBS = -lm

Go back to your /usr/tclpro/src/tclpro/freebsd-ix86 and do another "make"


MAKE THE DISTRIBUTION

    make dist 2>&1 | tee make-dist.out


MAKE THE IMAGE

    make image 2>&1 | tee make-image.out

SEE IF IT WORKED

    cd /usr/tclpro/src/image/cdrom
    ./SETUP.SH

The installer should fire up.

The web version will be in /usr/tclpro/src/image/web/tclpro15.freebsd.tar

Share and Enjoy...

Please send changes or updates to karl@procplace.com.  Thanks.

