Monday, July 31, 2017

Building Harbour

Almost unbelievable!
Let's build the "(xBASE) Clipper" compiler for Solaris 11.3!
But let me do a correction ;-), let's build the Harbour or simply HB for short.
Yes, Harbour seems to be one of the finest next-step Clipper substitutes.
If you know nothing about xBASE language, get to know it.

NOTE
The xBASE language is originally and essentially procedural, not object-oriented. But the case for object-orientation is not a real impediment if modularity is well exploited. Originally, there's no SQL and the database is made of a bunch of data-files (.DBF) and index-files, which can be shared over the network with adequate file and record locking support. Essentially, databases are file-record based. The language is reasonably flexible and there's a nice support for (kind of forms-based and menu-driven) console applications (sometimes even with mouse support). Roughly, one could say it's more powerful (more modern and much easier) than COBOL, sufficiently low-level as COBOL can't ever be and much more resourceful on the UI aspect (although it could be purely BATCH). Well, and much, much more.
Why Harbour, one could reasonably ask?
Isn't that a dead or outdated development option from the 80s?
We're living on the 21st century! Why care about something 35 years old?

Nowadays I would say that the main favorable argument is SIMPLICITY.
But not only that. It's PRACTICAL, EFFICIENT and RESOURCEFUL.
As anything else, it's not a perfect and universal solution.
But it excels in its niche and it's easy to learn and use.
The possibilities it still offers outweighs its age.
And it now runs natively under Solaris 11.3!
Check the About Harbour web page.

NOTE
I would risk to say that one interesting deployment of xBASE with Harbour would be for on-line or batch networked console applications modules running on "text-only" (minimal non-GUI systems such as Solaris 11 text-installs) boxes for supporting industrial plants IT infrastructure on tough environments.
The Harbour Project has been trying to bring in many enhancements, as well as many new features, such as GUI support with Qt integration, some object orientation support and more:











 
NOTE
It may be important to mention that most libraries have both options of being static or dynamic. So, the there's no concern about code bloats or exaggerated consumption of resources. Furthermore, it's not constrained by the inherent DOS limitations and idiosyncrasies (it's a new world, it's UNIX and it can be Solaris).
But it's not necessarily a wonderful world right from the start. Although a remarkable work and effort, as being free and open-source, the Harbour Project naturally lacks some "minor' finishing works, specially in website and documentation update and maintenance, as well as to source-code level deployment and build support and documentation. Particularly related to Solaris, currently, there are a few issues that haave to be manually adjusted (hacked) at first. The source-code deployment doesn't use a standard GNU - Build Automation and this brings difficulties in getting to know something different. I confess I don't have enough time to get to know all the details of Harbour's particular build process, but I'd summarize it as a mix of GNU and some inter-wined xBASE coding. I may have missed some points on how to properly deal with it, but I suspect that these points are actually bugs or shortcomings that would have to be addressed in the future. These difficulties did not prevent me from successfully build and use the current version.

NOTE
By the way, currently, there may be some confusion about versions. The main page says that the latest stable is 3.0.0 but the link points to version 3.2.0dev (just look at ./include/hbver.h macros). But there's also a fork to version 3.4.0. Anyway, for now, I'll stick to the main page version, 3.2.0dev.
As I said, the build process is "unusual" and the documentation and general detection support seems scarce or needing more work and improvement. Due to all that I'll start with just the 32-bits scenario. I'll develop this post so that in the end for targeting 64-bits it will be just a matter of substituting 32 with 64 or, if you prefer, substituting 64 for 32 where applicable :-D

For learning how to build, one would certainly try to start from the web-page README or from the (roughly equivalent) ./READ.md file (by the way, .MD are MarkDown files frequently used with GitHub, but I don't care). In fact, there's not much there for a Solaris build, except for a few confirmations that minimum requirements are fulfilled, there's a bunch of environment variables to drive the build and installation and that you should use gmake or gmake install. But be aware that there are a few pitfalls; it's not that straightforward with respect to a Solaris build environment. I would say that the main value of this post is precisely the attempt to guide the whole build process in a more hassle-free approach.

Beyond GCC, other pre-requisites are (at least):


To get started, going manually or by customizing a script such as the one demonstrated at GNU - Build preparation post, create the underlying ZFS support using the same approach previously described in other "Building-series" posts of mine, for instance: Building Qt 4.8.7. In the end, it will become something similar to:

$ DS=.../software/hb
$ zfs list -o name -t all -r $DS |sed 's,$DS,...,'
NAME
...

.../hb-3.2.0
.../hb-3.2.0@source
.../hb-3.2.0-gnu32
.../hb-3.2.0-gnu32@start
.../hb-3.2.0-gnu32@build
.../hb-3.2.0-gnu64
.../hb-3.2.0-gnu64@start
.../hb-3.2.0-gnu64@build


The -gnuXX datasets are clones from @source. The @start snapshot is particularly important as an eventual reset point. Before creating it some manual fixes (hacks) to the extracted source-code tarball must be applied. There's no @config snapshots due to the building process differences from the standard GNU - Build Automation. Here, the @build snapshot is more than ever of just good-practice style.

The final resting place (and state) of the built modules will be similar to:
(pre-created as well, but as root, due to the /opt mountpoint)

$ DS=.../hb-3.2.0
$ zfs list -o name,mountpoint -t all -r $DS
NAME                         MOUNTPOINT
.../hb-3.2.0
                 /opt/hb-3.2.0
.../hb-3.2.0/gnu32           /opt/hb-3.2.0/gnu32
...
/hb-3.2.0/gnu32@release
.../hb-3.2.0/gnu64           /opt/hb-3.2.0/gnu64 
.../hb-3.2.0/gnu64@release

Now, I'll refer to a source-script (setenv) such as the one demonstrated at GNU - Build preparation post, with the following additions / customizations (located at ~/software/hb):

...

#
# Other PATH and PKG_CONFIG_PATH settings.
# Put entries in reverse order of dependency.

# (following my PATH building suggestion) 
#

extend-env /opt/qt-4.8.7
extend-env /opt/sqlite-3.19.3

extend-env /opt/tcl-8.5.19
extend-env /opt/automake-1.15
extend-env /opt/autoconf-2.69

extend-env /opt/m4-1.4.18
extend-env /opt/libtool-2.4.6


...

#
# To be appended to the end of the setenv source-script
#

export HB_INSTALL_PREFIX=/opt/hb-3.2.0/gnu$BITS
  
export HB_COMPILER=gcc
export HB_USER_CFLAGS="$CFLAGS -R$HB_INSTALL_PREFIX/lib"
export HB_USER_DFLAGS="$HB_USER_CFLAGS"

export HB_USER_LDFLAGS="$HB_USER_CFLAGS"

export HB_BUILD_DYN=yes
export HB_INSTALL_DYN=yes

export HB_BUILD_CONTRIB=yes
export HB_BUILD_CONTRIB_DYN=yes

export HB_INSTALL_MAN=""

export HB_WITH_ODBC=/usr/include/odbc
export HB_WITH_SQLITE3=/opt/sqlite-3.19.3/gnu$BITS/include
export HB_WITH_GD=/usr/include/gd2
export HB_WITH_BZIP2=/usr/include

export HB_WITH_QT=/opt/qt-4.8.7/gnu$BITS/include
export HB_QTPATH=/opt/qt-4.8.7/gnu$BITS/bin


Now proceed to the fixes (hacks) to cope with GCC 4.8.2 and Solaris 11.3:

1) The layout of the HB_INSTALL_PREFIX tree is suboptimal. There are hard-coded subdirectories named harbour which can be inconvenient. I won't fix it, but I'll circumvent them as to my preference as follows:

$ cd ~/software/hb/hb-3.2.0-gnu32
$ diff /tmp/original-global.mk ./config/global.mk

492a493,505 
> ifeq ($(HB_HOST_PLAT),sunos)
> ifneq ($(findstring amd64,$(shell isainfo -k)),)
> HB_HOST_CPU := x86_64
> ifneq ($(filter $(HB_USER_CFLAGS),-m64),)
> HB_CPU := x86_64
> else
> ifneq ($(filter $(HB_USER_CFLAGS),-m32),)
> HB_CPU := x86
> endif
> endif
> endif
> endif


1820c1833
< ifeq ($(HB_SYSLOC),yes)
---
> # ifeq ($(HB_SYSLOC),yes)
 

1822c1835
< endif
---
> # endif


1852,1853c1865,1866
<             LIBPOSTFIX := $(LIBPOSTFIX)$(DIRSEP)harbour
<             INCPOSTFIX := $(DIRSEP)harbour

---
>             LIBPOSTFIX :=
>             INCPOSTFIX :=


1889c1902
<          export HB_INSTALL_DOC :=

        $(HB_INSTALL_PREFIX)$(DIRSEP)share$(DIRSEP)doc$(DIRSEP)harbour
---
>          export HB_INSTALL_DOC :=

         $(HB_INSTALL_PREFIX)$(DIRSEP)share$(DIRSEP)doc

1896c1909
<          ifeq ($(HB_SYSLOC),yes)
---
> #         ifeq ($(HB_SYSLOC),yes)
1898c1911
<          endif
---
> #         endif


1908c1921
<             export HB_INSTALL_ETC :=

          $(HB_INSTALL_PREFIX)$(DIRSEP)etc$(DIRSEP)harbour
---
>             export HB_INSTALL_ETC :=

          $(HB_INSTALL_PREFIX)$(DIRSEP)etc

1916c1929
<          ifneq ($(findstring |/opt/harbour,|$(HB_INSTALL_PREFIX)),)
---
> #         ifneq ($(findstring |/opt/harbour,|$(HB_INSTALL_PREFIX)),)


1918,1920c1931,1933
<          else
<             export HB_INSTALL_CONTRIB :=

          $(HB_INSTALL_PREFIX)$(DIRSEP)share$(DIRSEP)harbour$(DIRSEP)contrib
<          endif

---
> #         else
> #            export HB_INSTALL_CONTRIB :=

            $(HB_INSTALL_PREFIX)$(DIRSEP)share$(DIRSEP)harbour$(DIRSEP)contrib
> #         endif

In case the above diff output gets difficult or somehow inconsistent, here's an attempt to present the above changes (hacks) in a different way:

 493 ifeq ($(HB_HOST_PLAT),sunos)
 494    ifneq ($(findstring amd64,$(shell isainfo -k)),)
 495       HB_HOST_CPU := x86_64
 496       ifneq ($(filter $(HB_USER_CFLAGS),-m64),)
 497          HB_CPU := x86_64
 498       else
 499          ifneq ($(filter $(HB_USER_CFLAGS),-m32),)
 500             HB_CPU := x86
 501          endif
 502       endif
 503    endif
 504 endif
 505
 506 ifeq ($(HB_INIT_DONE),)
 507    $(info ! HB_HOST_PLAT: ...
 508 endif


1827 export HB_SYSLOC
1828
1829 ifneq ($(HB_INSTALL_PREFIX),)
1830
1831    ifeq ($(HB_BUILD_SHARED),)
1832       ifneq ($(HB_PLATFORM_UNIX),)
1833 #         ifeq ($(HB_SYSLOC),yes)
1834             export HB_BUILD_SHARED := yes
1835 #         endif
1836       endif
1837    endif


1863       else
1864          ifneq ($(findstring |/opt,|$(HB_INSTALL_PREFIX)),)
1865             LIBPOSTFIX :=
1866             INCPOSTFIX :=
1867          else
1868             LIBPOSTFIX :=
1869          endif
1870       endif
1871    endif
1872    endif


1897    # Standard name: DOCDIR
1898    ifeq ($(HB_INSTALL_DOC),)
1899       ifeq ($(HB_PLATFORM_UNIX),)
1900          export HB_INSTALL_DOC := ...
1901       else
1902          export HB_INSTALL_DOC :=

                 $(HB_INSTALL_PREFIX)$(DIRSEP)share$(DIRSEP)doc
1903       endif
1904    endif


1905    # Standard name: MANDIR
1906    ifeq ($(HB_INSTALL_MAN),)
1907       # Do not set man dir for non-*nix targets
1908       ifneq ($(HB_PLATFORM_UNIX),)
1909 #         ifeq ($(HB_SYSLOC),yes)
1910             export HB_INSTALL_MAN :=

                    $(HB_INSTALL_PREFIX)$(DIRSEP)share$(DIRSEP)man
1911 #         endif
1912       endif
1913    endif


1914    # Standard name: ETCDIR
1915    ifeq ($(HB_INSTALL_ETC),)
1916       # Do not set doc dir for non-*nix targets
1917       ifneq ($(HB_PLATFORM_UNIX),)
1918          ifeq ($(HB_PLATFORM),darwin)
1919             export HB_INSTALL_ETC := ...
1920          else
1921             export HB_INSTALL_ETC :=

                    $(HB_INSTALL_PREFIX)$(DIRSEP)etc
1922          endif
1923       endif
1924    endif


1925    ifeq ($(HB_INSTALL_CONTRIB),)
1926       ifeq ($(HB_PLATFORM_UNIX),)
1927          export HB_INSTALL_CONTRIB := $(HB_INSTALL_PREFIX)$(DIRSEP)contrib
1928       else
1929 #         ifneq ($(findstring |/opt/harbour,|$(HB_INSTALL_PREFIX)),)
1930             export HB_INSTALL_CONTRIB :=

                    $(HB_INSTALL_PREFIX)$(DIRSEP)contrib
1931 #         else
1932 #            export HB_INSTALL_CONTRIB := ...
1933 #         endif
1934       endif
1935    endif

2) In ./include/hbdefs.h,
after line 637, insert the following fix for the correct endianess detection:

...
637 #define HB_DBLFL_PREC_FACTOR 1.0000000000000002;
638
639 #if defined(__BYTE_ORDER__)
640
641   #if defined(__ORDER_LITTLE_ENDIAN__)

642
643     #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
644       #define HB_LITTLE_ENDIAN
645     #endif
646
647   #elif defined(__ORDER_BIG_ENDIAN__)

648
649     #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
650       #define HB_BIG_ENDIAN
651     #endif
652
653   #elif defined(__ORDER_PDP_ENDIAN__ )

654
655     #if __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
656       #define HB_PDP_ENDIAN
657     #endif
658
659   #endif
660
661 #endif
662

...

NOTE
How did I get to the above fix?
By noting the following GCC 4.8.2 preprocessor defines:
$ gcc -dM -E - < /dev/null |egrep '(ORDER|ENDIAN)'
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __ORDER_PDP_ENDIAN__ 3412
#define __ORDER_BIG_ENDIAN__ 4321
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__

For fixing the hbmk2's default cpu setting (see the bottom of this post) I'll have to (approximately) adjust ./utils/hbmk2/hbmk2.prg as follows:

12955    CASE HBMK_ISCOMP( "gcc|icc|clang|sunpro|diab|pcc|tcc" )
12956       /* TOFIX: This is not necessarily correct, since these inherit the
12957                 default CPU architecture from OS default, by and large,
12958                 and targets can be overridden using user options. */
12959       #ifdef __ARCH64BIT__
12960       RETURN "x86_64"
12961       #else
12962       RETURN "x86"
12963       #endif

Take the @start snapshot:
$ zfs snapshot $DS/hb-3.2.0-gnu32@start


Now proceed to the "main build":

$ source ../setenv 32
...

$ gmake
...

And proceed to the "flawed" installation:

NOTE
The following command is just "su", not "su -".
This is important and a limitation of the Harbour "make system".
$ su
# gmake install
...

# ^D

On both previous steps there will be a few unexpected errors:
hbmk2[hbgd]: Exit code: 7: failed in final assembly (linker or library manager)
hbmk2[hbziparc]: Exit code: 7: failed in final assembly (linker or library manager)
hbmk2[sddodbc]: Exit code: 7: failed in final assembly (linker or library manager)
hbmk2[sddsqlt3]: Exit code: 7: failed in final assembly (linker or library manager)
And there will be other expected harmless "warnings":
hbmk2[gtalleg]: Exit code: 10: dependency missing or disabled
hbmk2[hbfbird]: Exit code: 10: dependency missing or disabled
hbmk2[hbfimage]: Exit code: 10: dependency missing or disabled
hbmk2[hbmagic]: Exit code: 10: dependency missing or disabled
hbmk2[hbmysql]: Exit code: 10: dependency missing or disabled
hbmk2[hbpgsql]: Exit code: 10: dependency missing or disabled
hbmk2[sddfb]: Exit code: 10: dependency missing or disabled
hbmk2[sddmy]: Exit code: 10: dependency missing or disabled
hbmk2[sddoci]: Exit code: 10: dependency missing or disabled
hbmk2[sddpg]: Exit code: 10: dependency missing or disabled

hbmk2[gtwvg]: Exit code: 50: stop requested
hbmk2[hbblat]: Exit code: 50: stop requested
hbmk2[hbwin]: Exit code: 50: stop requested
hbmk2[libhpdf]: Exit code: 50: stop requested
hbmk2[lzf]: Exit code: 50: stop requested
hbmk2[minilzo]: Exit code: 50: stop requested
hbmk2[minizip]: Exit code: 50: stop requested
hbmk2[mxml]: Exit code: 50: stop requested
hbmk2[rddads]: Exit code: 50: stop requested
hbmk2[tinymt]: Exit code: 50: stop requested
hbmk2[xdiff]: Exit code: 50: stop requested
Naturally, the priority is to address the unexpected errors.
For now, I gave up trying to understand the Harbour "make system".
I'll consider it some sort of bug, because AFAIK I could manually fix it.

As root make sure you place the all dynamic libraries in the right location (the lib subdir of the HB_INSTALL_PREFIX). AFAIK I couldn't get it working just via the environment variables!

$ env |grep HB
HB_BUILD_CONTRIB_DYN=yes
HB_WITH_SQLITE3=/opt/sqlite-3.19.3/gnu32/include
HB_WITH_GD=/usr/include/gd2
HB_BUILD_CONTRIB=yes
HB_USER_CFLAGS=-m32 -march=core2 -std=gnu89
HB_WITH_ODBC=/usr/include/odbc
HB_INSTALL_DYN=yes
HB_BUILD_DYN=yes
HB_WITH_QT=/opt/qt-4.8.7/gnu32/include
HB_INSTALL_PREFIX=/opt/hb-3.2.0/gnu32
HB_COMPILER=gcc
HB_INSTALL_MAN=
HB_QTPATH=/opt/qt-4.8.7/gnu32/bin


$ export HB=$(pwd)
$ su
# cd $HB_INSTALL_PREFIX/lib 

# (cd $HB/lib/sunos/gcc; gtar cf /tmp/libs1.tar *.so*)
# gtar xf /tmp/libs1.tar

# (cd $HB/bin/sunos/gcc; gtar cf /tmp/libs2.tar *.so*)
# gtar xf /tmp/libs2.tar


# ^D

NOTE
You could gather the previous privileged (#) commands on a script because they will have to be repeated later. For instance:
#!/bin/bash

if [[ -z $HB_INSTALL_PREFIX ]]
then
  echo HB_INSTALL_PREFIX not set!
  exit 1
fi

if [[ -z $HB ]]
then
  echo HB not set!
  exit 1
fi

echo From $HB/bin and $HB/lib to $HB_INSTALL_PREFIX/lib

cd $HB_INSTALL_PREFIX/lib

(cd $HB/lib/sunos/gcc; gtar cf /tmp/libs1.tar *.so*)
gtar xf /tmp/libs1.tar

(cd $HB/bin/sunos/gcc; gtar cf /tmp/libs2.tar *.so*)
gtar xf /tmp/libs2.tar

rm /tmp/libs1.tar /tmp/libs2.tar
 Then, manually build the libraries that have failed in the automatic build:
 
$ export PATH=$HB_INSTALL_PREFIX/bin:$PATH
$ echo $PATH
/opt/hb-3.2.0/gnu32/bin:/opt/libtool-2.4.6/gnu32/bin:/opt/m4-1.4.18/gnu32/bin:/opt/autoconf-2.69/gnu32/bin:/opt/automake-1.15/gnu32/bin:/opt/tcl-8.5.19/gnu32/bin:/opt/sqlite-3.19.3/gnu32/bin:/opt/qt-4.8.7/gnu32/bin:/usr/gnu/bin:/usr/bin:/usr/sbin


$ cd $HB/contrib
$ INCLUDE_FIX="$(pwd)/rddsql"

$ ../bin/sunos/gcc/hbmk2 -cflag=-I"$INCLUDE_FIX" \
  -width=0 -autohbm- @hbpre -inc -hbdyn \
  sddsqlt3/sddsqlt3.hbp @hbpost sddsqlt3/sddsqlt3.hbc
hbmk2: Processing environment options: -comp=gcc
hbmk2: Dependency 'sqlite3' found: /opt/sqlite-3.19.3/gnu32/include (3.19.3)
hbmk2: Compiling...
hbmk2: Creating dynamic library... ../bin/sunos/gcc/libsddsqlt3.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libsddsqlt3.so to libsddsqlt3.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libsddsqlt3.so.3.2 to libsddsqlt3.so.3.2.0


$ ../bin/sunos/gcc/hbmk2 -cflag=-I"$INCLUDE_FIX" \
  -width=0 -autohbm- @hbpre -inc -hbdyn \
  sddodbc/sddodbc.hbp @hbpost sddodbc/sddodbc.hbc
hbmk2: Processing environment options: -comp=gcc
hbmk2: Dependency 'odbc' found: /usr/include/odbc
hbmk2: Compiling...
hbmk2: Creating dynamic library... ../bin/sunos/gcc/libsddodbc.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libsddodbc.so to libsddodbc.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libsddodbc.so.3.2 to libsddodbc.so.3.2.0


$ ../bin/sunos/gcc/hbmk2 \
  -width=0 -autohbm- @hbpre -inc -hbdyn \
  hbziparc/hbziparc.hbp @hbpost hbziparc/hbziparc.hbc
hbmk2: Processing environment options: -comp=gcc
hbmk2: Compiling Harbour sources...
hbmk2: Compiling...
hbmk2: Creating dynamic library... ../bin/sunos/gcc/libhbziparc.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libhbziparc.so to libhbziparc.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libhbziparc.so.3.2 to libhbziparc.so.3.2.0


$ ../bin/sunos/gcc/hbmk2 \
  -width=0 -autohbm- @hbpre -inc -hbdyn \
  hbgd/hbgd.hbp @hbpost hbgd/hbgd.hbc
hbmk2: Processing environment options: -comp=gcc
hbmk2: Dependency 'gd' found: /usr/include/gd2
hbmk2: Compiling Harbour sources...
hbmk2: Compiling...
hbmk2: Creating dynamic library... ../bin/sunos/gcc/libhbgd.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libhbgd.so to libhbgd.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libhbgd.so.3.2 to libhbgd.so.3.2.0


Maybe (double-check the build logs) it can be necessary to:

$ export HB_WITH_BZIP2=/usr/include

$ ../bin/sunos/gcc/hbmk2 \
  -width=0 -autohbm- @hbpre -inc hbbz2/hbbz2.hbp @hbpost
hbmk2: Processing environment options: -comp=gcc
hbmk2: Dependency 'bzip2' found: /usr/include
hbmk2: Compiling...
hbmk2: Creating static library... ../lib/sunos/gcc/libhbbz2.a


$ ../bin/sunos/gcc/hbmk2 \
  -width=0 -autohbm- @hbpre -inc -hbdyn hbbz2/hbbz2.hbp @hbpost hbbz2/hbbz2.hbc
hbmk2: Processing environment options: -comp=gcc
hbmk2: Dependency 'bzip2' found: /usr/include
hbmk2: Compiling...
hbmk2: Creating dynamic library... ../bin/sunos/gcc/libhbbz2.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libhbbz2.so to libhbbz2.so.3.2.0
hbmk2: Created symbolic link ../bin/sunos/gcc/libhbbz2.so.3.2 to libhbbz2.so.3.2.0


NOTE
Again, you could gather the previous commands on a script just for convenience or maybe multiple builds targets. For instance:
#!/bin/bash

if [[ -z $HB_INSTALL_PREFIX ]] 
then
  echo HB_INSTALL_PREFIX not set!
  exit 1
fi

if [[ -z $HB ]] 
then
  echo HB not set!
  exit 1
fi

echo
echo Fixing libraries from $HB/contrib
echo

export PATH=$HB_INSTALL_PREFIX/bin:$PATH

cd $HB/contrib
INCLUDE_FIX="$(pwd)/rddsql"

echo sddsqlt3
../bin/sunos/gcc/hbmk2 -cflag=-I"$INCLUDE_FIX" \
-width=0 -autohbm- @hbpre -inc -hbdyn \
sddsqlt3/sddsqlt3.hbp @hbpost sddsqlt3/sddsqlt3.hbc

echo

echo sddodbc
../bin/sunos/gcc/hbmk2 -cflag=-I"$INCLUDE_FIX" \
-width=0 -autohbm- @hbpre -inc -hbdyn \
sddodbc/sddodbc.hbp @hbpost sddodbc/sddodbc.hbc

echo

echo hbziparc
../bin/sunos/gcc/hbmk2 \
-width=0 -autohbm- @hbpre -inc -hbdyn \
hbziparc/hbziparc.hbp @hbpost hbziparc/hbziparc.hbc

echo

echo hbgd
../bin/sunos/gcc/hbmk2 \
-width=0 -autohbm- @hbpre -inc -hbdyn \
hbgd/hbgd.hbp @hbpost hbgd/hbgd.hbc

echo

echo hbbz2
../bin/sunos/gcc/hbmk2 \
-width=0 -autohbm- @hbpre -inc hbbz2/hbbz2.hbp @hbpost
../bin/sunos/gcc/hbmk2 \
-width=0 -autohbm- @hbpre -inc -hbdyn hbbz2/hbbz2.hbp @hbpost
Take the @build snapshot:

$ zfs snapshot $DS/hb-3.2.0-gnu32@build

Repeat the manual library copying step to ensure that the manually build libraries also get copied to $HB_INSTALL_PREFIX/lib.

$ cd $HB
$ su
# cd $HB_INSTALL_PREFIX/lib


# (cd $HB/lib/sunos/gcc; gtar cf /tmp/libs1.tar *.so*)
# gtar xf /tmp/libs1.tar

# (cd $HB/bin/sunos/gcc; gtar cf /tmp/libs2.tar *.so*)
# gtar xf /tmp/libs2.tar


And in addition, fix a few more things:

# cd ..

# rm bin/*.so*

# cat contrib/hbexpat/hbexpat.hbc
...

# libs=3rd/expat/expat.hbc          comment this line!

# mv bin/hbrun{,-bin}
# touch bin/hbrun
# chmod a+x bin/hbrun
# vim bin/hbrun
# cat bin/hbrun
#!/bin/bash
HB=/opt/hb-3.2.0/gnu32
LD_LIBRARY_PATH=$HB/lib $HB/bin/hbrun-bin $*


NOTE
Once more you could gather commands on a script for added convenience, in this case, for the hbrun "invoke fix" via LD_LIBRARY_PATH (or you could take more time in trying to find out how to pass an -R option to the hbrun make step, how knows if at ./contrib/hbrun/hbrun.hbp). For instance:
#!/bin/bash

if [[ -z $HB_INSTALL_PREFIX ]] 
then
  echo HB_INSTALL_PREFIX not set!
  exit 1
fi

cd $HB_INSTALL_PREFIX

#
# Harbour Shell / Script Runner (hbssr)
#
cat >bin/hbssr <<EOF
#!/bin/bash
HB=$HB_INSTALL_PREFIX
LD_LIBRARY_PATH=\$HB/lib \$HB/bin/hbrun \$*
EOF

chmod a+x bin/hbssr
Take the final snapshot:

# zfs snapshot .../hb-3.2.0/gnu32@release

At last, HB_INSTALL_PREFIX will look as follows:

# tree -d -L 2 $HB_INSTALL_PREFX
/opt/hb-3.2.0/gnu32
├── bin
├── contrib
│ ├── gtqtc
│ ├── hbamf
│ ├── hbblink
│ ├── hbbz2
│ ├── hbbz2io
│ ├── hbcairo
│ ├── hbcomio
│ ├── hbcomm
│ ├── hbct
│ ├── hbcups
│ ├── hbcurl
│ ├── hbexpat
│ ├── hbformat
│ ├── hbfoxpro
│ ├── hbfship
│ ├── hbgd
│ ├── hbgs
│ ├── hbgt
│ ├── hbgzio
│ ├── hbhpdf
│ ├── hbhttpd
│ ├── hblzf
│ ├── hbmemio
│ ├── hbmisc
│ ├── hbmlzo
│ ├── hbmxml
│ ├── hbmzip
│ ├── hbnetio
│ ├── hbnf
│ ├── hbodbc
│ ├── hboslib
│ ├── hbpipeio
│ ├── hbsms
│ ├── hbsqlit3
│ ├── hbssl
│ ├── hbtcpio
│ ├── hbtest
│ ├── hbtinymt
│ ├── hbtip
│ ├── hbtpathy
│ ├── hbunix
│ ├── hbxdiff
│ ├── hbxpp
│ ├── hbzebra
│ ├── hbziparc
│ ├── rddbm
│ ├── rddsql
│ ├── sddodbc
│ ├── sddsqlt3
│ └── xhb
├── etc
├── include
├── lib
└── share
  ├── doc
  └── man
58 directories

Of particularly interest are the libraries:
(some just static, some both static and dynamic)

# ls -lho $HB_INSTALL_PREFIX/lib |grep harbour
lrwxrwxrwx   ... lib/libharbour.so -> libharbour.so.3.2.0
lrwxrwxrwx   ... lib/libharbour.so.3.2 -> libharbour.so.3.2.0
-rwxr-xr-x   ... lib/libharbour.so.3.2.0


and in general:

# ls -lho $HB_INSTALL_PREFIX/lib |egrep "lib.*\.(a|so)*"

-rw-r--r--   ... lib/lib___.a
lrwxrwxrwx   ... lib/lib___.so -> lib___.so.3.2.0
lrwxrwxrwx   ... lib/lib___.so.3.2 -> lib___.so.3.2.0
-rwxr-xr-x   ... lib/lib___.so.3.2.0

...

And to the best of my understanding that's the essential start-up!
Welcome to xBASE under Solaris 11.3!

# $HB_INSTALL_PREFIX/bin/hbtest
Harbour Regression Test Suite
Copyright (c) 1999-2016, Viktor Szakats
http://harbour-project.org/
------------------------------------------------------------
      Version: Harbour 3.2.0dev (r1705200225)
     Compiler: GNU C 4.8.2 (32-bit)
           OS: SunOS 5.11 i86pc
   Date, Time: 2017-07-31 22:32:02
Shortcut opt.: On
     Switches:  
============================================================
R No.  Line         TestCall()          -> Result | Expected
------------------------------------------------------------
============================================================
Test calls passed:       4861 ( 100.00 % )
Test calls failed:          0 ( 0.00 % )
                   ----------
            Total:       4861 ( Time elapsed: 0.19 seconds )


# $HB_INSTALL_PREFIX/bin/hbmk2 -build
Harbour 3.2.0dev (r1705200225)
Copyright (c) 1999-2016, http://harbour-project.org/

Harbour Build Info
---------------------------
Version: Harbour 3.2.0dev (r1705200225)
Compiler: GNU C 4.8.2 (32-bit)
Platform: SunOS 5.11 i86pc
PCode version: 0.3
ChangeLog last entry: 2017-05-20 02:25 UTC Viktor Szakats ...
ChangeLog ID: 731297e3d5b89d9f4304719560cd95f87ba1e239
Built on: Jul 30 2017 18:05:56
Extra C compiler options: 

     -m32 -march=core2 -std=gnu89 -R/opt/hb-3.2.0/gnu32/lib
Extra linker options:
     -m32 -march=core2 -std=gnu89 -R/opt/hb-3.2.0/gnu32/lib
Build options: (Clipper 5.3b) (Clipper 5.x undoc)
---------------------------


At first I thought I had possible issues. But after further investigations the apparent inconsistency of having a lib under lib in dynprefix was of no concern. See the following output:

# $HB_INSTALL_PREFIX/bin/hbmk2 --hbinfo
{

  "platform":"sunos",
  "compiler":"gcc",
  "cpu":"x86",
  "buildname":"",
  "targetname":".adhoc.",
  "targettype":"hbexe",
  "dynprefix":"/opt/hb-3.2.0/gnu32/lib/lib",
  "dynsuffix":"",
  "inc":"no",
  "hbctree":""
}

For dynprefix that's not an issue because although dynprefix clearly contains a path, it's not a path, but just a string prefix (including the initial "lib" of the file-name) of some full library located in $HB_INSTALL_PREFIX/lib/.

As a very first personal examples, check these out:

$ cd /tmp

$ cat sample.prg 
PROCEDURE main
  SET CURSOR OFF
  CLEAR SCREEN
  msg_justify( MAXROW()/2, "Hello, world!" )
  msg_justify( ROW()+1, "Press any key to exit!" )
  INKEY(0)
  CLEAR SCREEN
  SET CURSOR ON
  RETURN

FUNCTION msg_justify
  PARAMETERS row, msg
  @ row, ( MAXCOL() - LEN(msg) )/2 SAY msg
  RETURN


$ $HB_INSTALL_PREFIX/bin/hbmk2 /tmp/sample.prg
Harbour 3.2.0dev (r1705200225)
Copyright (c) 1999-2016, http://harbour-project.org/
Compiling '/tmp/sample.prg'...
Lines 20, Functions/Procedures 2
Generating C source output to '/var/tmp/...'... Done.


$ ./sample
(did you notice the graphics mouse cursor under a $TERM=xterm ?)




















You shall note however, if $TERM=sun-color (or some other value), then the some screen commands such as CLEAR SCREEN and SET CURSOR OFF won't work as expected if they'll work at all. Therefore, it's advisable to check for $TERM for determining in which runtime environment the program is and adjust screen behavior accordingly.
    
$ cat bitness.prg
PROCEDURE main

  #ifdef __ARCH32BIT__
  ? "32"
  #else
  ? "64"
  #endif

  RETURN


If using the 64-bit build you'll get:

$ $HB_INSTALL_PREFIX/bin/hbssr bitness.prg
64

  

Wednesday, July 12, 2017

Building Tcl / Tk

Let's build an updated version of Tcl / Tk.
Solaris 11.3 (GA / Release) packages version 8.5.12.
The packaged seems good enough, but I'm running after the latest.

I won't repeat myself with respect to philosophies and preparations, but refer to another very similar post: Building SQLite. By the way, it's better to build an updated Tcl / Tk before building an updated SQLite.

The ZFS infra-structure is somewhat lengthy as I'm building 2 targets (gnu32 and gnu64) for each version series (8.5.19 and 8.6.6). Note that, in this particular scenario, the -X-gnuNN datasets are clones of their respective X@source.

NOTE
There's a little annoyance as the tarballs' names don't have the usually dash before the version numbers. It takes extra steps to adjust it.
$ DS=.../software
$ zfs list -t all -o name -r $DS/tcl $DS/tk |sed "s,$DS,...,"
NAME
.../tcl
.../tcl/tcl-8.5.19
.../tcl/tcl-8.5.19@source
.../tcl/tcl-8.5.19-gnu32
 
.../tcl/tcl-8.5.19-gnu32@start
.../tcl/tcl-8.5.19-gnu64

.../tcl/tcl-8.5.19-gnu64@start
.../tcl/tcl-8.6.6
.../tcl/tcl-8.6.6@source
.../tcl/tcl-8.6.6-gnu32

.../tcl/tcl-8.6.6-gnu32@start
.../tcl/tcl-8.6.6-gnu64
.../tcl/tcl-8.6.6-gnu64@start
.../tk
.../tk/tk-8.5.19
.../tk/tk-8.5.19@source
.../tk/tk-8.5.19-gnu32

.../tk/tk-8.5.19-gnu32@start
.../tk/tk-8.5.19-gnu64
.../tk/tk-8.5.19-gnu64@start
.../tk/tk-8.6.6
.../tk/tk-8.6.6@source
.../tk/tk-8.6.6-gnu32

.../tk/tk-8.6.6-gnu32@start 
.../tk/tk-8.6.6-gnu64
.../tk/tk-8.6.6-gnu64@start

NOTE
For proper operation of packages requiring Tk in tclsh, the configuration step must specify the same --prefix given during the Tcl configuration. Hence, there's no Tk separate dataset / directory for the build results.

$ DS=rpool/VARSHARE
$ zfs list -t all -o name,mountpoint -r $DS |egrep tcl
rpool/VARSHARE/tcl-8.5.19           /opt/tcl-8.5.19
rpool/VARSHARE/tcl-8.5.19/gnu32     /opt/tcl-8.5.19/gnu32
rpool/VARSHARE/tcl-8.5.19/gnu64     /opt/tcl-8.5.19/gnu64

rpool/VARSHARE/tcl-8.6.6            /opt/tcl-8.6.6
rpool/VARSHARE/tcl-8.6.6/gnu32      /opt/tcl-8.6.6/gnu32
rpool/VARSHARE/tcl-8.6.6/gnu64      /opt/tcl-8.6.6/gnu64


The whole process is simple and follows the GNU style, but this time, the "pitfall" is that first I should build Tcl and then refer to this build results (--with-tcl=) when configuring Tk itself. The building processes take place under each unix subdirectory.

$ DS=.../software

For GNU32:

$ cd ~/software/tcl/tcl-8.5.19-gnu32/unix
 
$ source ../../setenv-tcl-8.5.19 32
CONFIG_SHELL=/bin/bash

CC=/usr/bin/gcc CFLAGS=-m32 -march=core2 -std=gnu89
CXX=/usr/bin/g++ CXXFLAGS=-m32 -march=core2 -std=gnu++03

PATH=/opt/libtool-2.4.6/gnu32/bin:/opt/m4-1.4.18/gnu32/bin:/opt/autoconf-2.69/gnu32/bin:/opt/automake-1.15/gnu32/bin:/usr/gnu/bin:/usr/bin:/usr/sbin
PKG_CONFIG_PATH=

 

$ ./configure \
  --prefix=/opt/tcl-8.5.19/gnu32 \

  --enable-threads \
  --enable-rpath \
  --enable-dtrace 
checking whether to use symlinks for manpages... no
checking whether to compress the manpages... no
checking whether to add a package name suffix for the manpages... no
checking for gcc... /usr/bin/gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ANSI C... none needed
checking for inline... inline
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dirent.h... yes
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking values.h usability... yes
checking values.h presence... yes
checking for values.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking if the compiler understands -pipe... yes
checking for pthread_mutex_init in -lpthread... yes
checking for pthread_attr_setstacksize... yes
checking for pthread_atfork... yes
checking for pthread_attr_get_np... no
checking for pthread_getattr_np... no
checking for pthread_get_stacksize_np... no
checking for building with threads... yes
checking for sin... no
checking for main in -lieee... no
checking for main in -linet... no
checking net/errno.h usability... no
checking net/errno.h presence... no
checking for net/errno.h... no
checking for connect... no
checking for setsockopt... no
checking for setsockopt in -lsocket... yes
checking for gethostbyname... no
checking for gethostbyname in -lnsl... yes
checking how to build libraries... shared
checking for ranlib... ranlib
checking if 64bit support is requested... no
checking if 64bit Sparc VIS support is requested... no
checking if compiler supports visibility "hidden"... yes
checking if rpath support is requested... yes
checking system version... SunOS-5.11
checking for dlopen in -ldl... yes
checking for ar... ar
checking for cast to union support... yes
checking for build with symbols... no
checking for required early compiler flags... none
checking for 64-bit integer type... long long
checking for struct dirent64... yes
checking for struct stat64... yes
checking for open64... yes
checking for lseek64... yes
checking for off64_t... yes
checking whether byte ordering is bigendian... no
checking for getcwd... yes
checking for opendir... yes
checking for strtol... yes
checking for waitpid... yes
checking for strerror... yes
checking for getwd... yes
checking for wait3... yes
checking for uname... yes
checking for realpath... yes
checking for getaddrinfo... yes
checking for working getaddrinfo... yes
checking for getpwuid_r... yes
checking for getpwuid_r with 5 args... yes
checking for getpwnam_r... yes
checking for getpwnam_r with 5 args... yes
checking for getgrgid_r... yes
checking for getgrgid_r with 5 args... yes
checking for getgrnam_r... yes
checking for getgrnam_r with 5 args... yes
checking for gethostbyname_r... yes
checking for gethostbyname_r with 6 args... no
checking for gethostbyname_r with 5 args... yes
checking for gethostbyaddr_r... yes
checking for gethostbyaddr_r with 7 args... yes
checking sys/modem.h usability... no
checking sys/modem.h presence... no
checking for sys/modem.h... no
checking termios vs. termio vs. sgtty... termios
checking for fd_set in sys/types... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking whether time.h and sys/time.h may both be included... yes
checking for gmtime_r... yes
checking for localtime_r... yes
checking for mktime... yes
checking tm_tzadj in struct tm... no
checking tm_gmtoff in struct tm... no
checking long timezone variable... yes
checking for struct stat.st_blocks... yes
checking for struct stat.st_blksize... yes
checking for blkcnt_t... yes
checking for fstatfs... yes
checking for working memcmp... yes
checking for memmove... yes
checking for strstr... yes
checking proper strstr implementation... ok
checking for strtoul... yes
checking proper strtoul implementation... ok
checking for strtod... yes
checking proper strtod implementation... ok
checking for strtod... (cached) yes
checking for Solaris2.4/Tru64 strtod bugs... ok
checking for mode_t... yes
checking for pid_t... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for socklen_t... yes
checking for intptr_t... yes
checking for uintptr_t... yes
checking for opendir... (cached) yes
checking union wait... no
checking for strncasecmp... yes
checking for gettimeofday... yes
checking for gettimeofday declaration... present
checking whether char is unsigned... no
checking signed char declarations... yes
checking for a putenv() that copies the buffer... no
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking whether to use nl_langinfo... yes
checking for chflags... no
checking isnan... yes
checking for fts... no
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/filio.h usability... yes
checking sys/filio.h presence... yes
checking for sys/filio.h... yes
checking system version... (cached) SunOS-5.11
checking FIONBIO vs. O_NONBLOCK for nonblocking I/O... O_NONBLOCK
checking whether to use dll unloading... yes
checking for timezone data... /usr/share/lib/zoneinfo
checking sys/sdt.h usability... yes
checking sys/sdt.h presence... yes
checking for sys/sdt.h... yes
checking for dtrace... /usr/sbin/dtrace
checking whether to enable DTrace support... yes
checking if the C stack grows upwards in memory... no
checking whether the cpuid instruction is usable... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dltest/Makefile
config.status: creating tclConfig.sh
config.status: creating tcl.pc


Safeguard this milestone:

$ zfs snapshot $DS/tcl/tcl-8.5.19-gnu32@config

Now, for the make:

$ gmake
...

The build is comparably fast, even on a slow machine.
Safeguard this milestone:

$ zfs snapshot $DS/tcl/tcl-8.5.19-gnu32@build

The verification was interesting: the skips seemed reasonable as the build machine was a Solaris 11.3 guest on a VirturalBox Solaris 11.3 host. By looking at the errors they all seemed related to VirtualBox as well. By the way, my localtime is GMT-3. Here were the results:

$ gmake test
...
Tests began at Wed Jul 12 16:27:22 BRT 2017
...
clock.test
==== clock-38.1 regression - 

     convertUTCToLocalViaC - east of Greenwich FAILED
==== Contents of test case:

    clock format 0 -format %H:%M:%S \

    -timezone :localtime
   
---- Result was:
21:00:00
---- Result should have been (exact matching):
01:00:00
==== clock-38.1 FAILED
==== clock-40.1 regression - 

     bad month with -timezone :localtime FAILED
==== Contents of test case:

    clock scan 2000-01-01T00:00:00 \

    -timezone :localtime  -format %Y-%m-%dT%H:%M:%S
   
---- Result was:
946692000
---- Result should have been (exact matching):
946684800
==== clock-40.1 FAILED
==== clock-42.1 regression test - 

     %z in :localtime when west of Greenwich FAILED
==== Contents of test case:

    clock format 0 -format %z \

    -timezone :localtime
   
---- Result was:
-0300
---- Result should have been (exact matching):
-0500
==== clock-42.1 FAILED

...

Tests ended at Wed Jul 12 16:33:08 BRT 2017
all.tcl:    Total    27201    Passed    26204    Skipped    994    Failed    3
Sourced 138 Test Files.
Files with failing tests: clock.test
Number of tests skipped for each constraint:
    9    !ieeeFloatingPoint
    3    asyncPipeChan
    76    bigEndian
    6    bug-05489ce335
    5    bug-3057639
    4    dontCopyLinks
    61    emptyTest
    2    hasIsoLocale
    1    knownBadTest
    40    knownBug
    100    localeRegexp
    12    longIs64bit
    14    macosxFileAttr
    18    memory
    43    nonPortable
    5    notNetworkFilesystem
    9    nt
    1    pcOnly
    4    readonlyAttr
    7    testaccessproc
    1    testexprparser && !ieeeFloatingPoint
    8    testopenfilechannelproc
    7    teststatproc
    1    testwinclock
    21    testwordend
    1    thread
    2    unthreaded
    520    win
    2    win2000orXP


I did repeat the tests outside the VM by sending / receiving the containing ZFS file-system to the VM host where the resulting builds were also already installed (I also had to fix a few path references in the Makefiles) and all the clock tests were successful, although more tests were skipped (and I'm still not certain why, except that the system configurations are "only slightly" different). Apart from that, I got new (but somewhat understandable and harmless) errors:

...
socket.test

==== socket-5.1 byte order problems, 

     socket numbers, htons FAILED
==== Contents of test case:

    set x {couldn't open socket: not owner}
    if {![catch {socket -server dodo 0x1} msg]} {
        set x {htons problem, should be disallowed, 

               are you running as SU?}
    close $msg
    }
    set x

---- Result was:
htons problem, should be disallowed, are you running as SU?
---- Result should have been (exact matching):
couldn't open socket: not owner
==== socket-5.1 FAILED

==== socket-5.3 byte order problems, 

     socket numbers, htons FAILED
==== Contents of test case:

    set x {couldn't open socket: not owner}
    if {![catch {socket -server dodo 21} msg]} {
    set x {htons problem, should be disallowed, 

           are you running as SU?}
    close $msg
    }
    set x

---- Result was:
htons problem, should be disallowed, are you running as SU?
---- Result should have been (exact matching):
couldn't open socket: not owner
==== socket-5.3 FAILED

...

Actually, if the above tests were run as root, then they would have succeeded, as I subsequently confirmed. But I became curious again why they have succeeded in the first place while in the VM under the presumable same circumstances.

$ sudo gmake install
Making directory /opt/tcl-8.5.19/gnu32/lib
Making directory /opt/tcl-8.5.19/gnu32/bin
Installing libtcl8.5.so to /opt/tcl-8.5.19/gnu32/lib/
Installing tclsh as /opt/tcl-8.5.19/gnu32/bin/tclsh8.5
Installing tclConfig.sh to /opt/tcl-8.5.19/gnu32/lib/
Installing libtclstub8.5.a to /opt/tcl-8.5.19/gnu32/lib/
Installing pkg-config file to /opt/tcl-8.5.19/gnu32/lib/pkgconfig/
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/msgs
Installing message catalog files to /opt/tcl-8.5.19/gnu32/lib/tcl8.5/msgs/
Making directory /opt/tcl-8.5.19/gnu32/include
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/opt0.4
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/http1.0
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/encoding
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/../tcl8
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/../tcl8/8.4
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/../tcl8/8.4/platform
Making directory /opt/tcl-8.5.19/gnu32/lib/tcl8.5/../tcl8/8.5
Installing header files to /opt/tcl-8.5.19/gnu32/include/
Installing library files to /opt/tcl-8.5.19/gnu32/lib/tcl8.5/
Installing package http1.0 files to /opt/tcl-8.5.19/gnu32/lib/tcl8.5/http1.0/
Installing package http 2.7.13 as a Tcl Module
Installing package opt0.4 files to /opt/tcl-8.5.19/gnu32/lib/tcl8.5/opt0.4/
Installing package msgcat 1.5.2 as a Tcl Module
Installing package tcltest 2.3.8 as a Tcl Module
Installing package platform 1.0.14 as a Tcl Module
Installing package platform::shell 1.1.4 as a Tcl Module
Installing encoding files to /opt/tcl-8.5.19/gnu32/lib/tcl8.5/encoding/
Making directory /opt/tcl-8.5.19/gnu32/man
Making directory /opt/tcl-8.5.19/gnu32/man/man1
Making directory /opt/tcl-8.5.19/gnu32/man/man3
Making directory /opt/tcl-8.5.19/gnu32/man/mann
Installing and cross-linking top-level (.1) docs to /opt/tcl-8.5.19/gnu32/man/man1/
Installing and cross-linking C API (.3) docs to /opt/tcl-8.5.19/gnu32/man/man3/
Installing and cross-linking command (.n) docs to /opt/tcl-8.5.19/gnu32/man/mann/


$ ls -1 /opt/tcl-8.5.19/gnu32/*
/opt/tcl-8.5.19/gnu32/bin:
tclsh8.5

...

/opt/tcl-8.5.19/gnu32/include:
tcl.h
tclDecls.h
tclPlatDecls.h
tclTomMath.h
tclTomMathDecls.h

/opt/tcl-8.5.19/gnu32/lib:
libtcl8.5.so
libtclstub8.5.a
pkgconfig
tcl8
tcl8.5
tclConfig.sh

/opt/tcl-8.5.19/gnu32/man:
man1
man3
mann



NOTE
One may notice that under /opt/.../bin the tclsh was installed as tclsh8.5.  This is most probably happens because a previous version has been detected on /usr/bin. In fact, what I want hereafter is that new version gets detected before the legacy version, so I can create a symbolic link in /opt/.../bin as follows:
 
# ln -s tclsh8.5/ tclsh

Now it's time to build the Tk modules.
 

NOTE
With respect to the following configuration using --with-x, as usual on UNIX one doesn't need to install a full-blown desktop in order to take advantage of a remote host for X displaying. For instance, on a Solaris 11 Express text-install, one only needs to install the package X-redistributable (under Solaris 11.3 the package has been renamed to X-all or X-incorporation).

$ cd ~/software/tk/tk-8.5.19-gnu32/unix
 
$ source ../../setenv-tk-8.5.19 32
CONFIG_SHELL=/bin/bash

CC=/usr/bin/gcc CFLAGS=-m32 -march=core2 -std=gnu89
CXX=/usr/bin/g++ CXXFLAGS=-m32 -march=core2 -std=gnu++03

PATH=/opt/tcl-8.5.19/gnu32/bin:/opt/libtool-2.4.6/gnu32/bin:/opt/m4-1.4.18/gnu32/bin:/opt/autoconf-2.69/gnu32/bin:/opt/automake-1.15/gnu32/bin:/usr/gnu/bin:/usr/bin:/usr/sbin
PKG_CONFIG_PATH=/opt/tcl-8.5.19/gnu32/lib/pkgconfig
 

$ ./configure \
  --prefix=/opt/tcl-8.5.19/gnu32 \

  --enable-threads \
  --enable-rpath \
  --enable-dtrace \
  --with-tcl=/opt/tcl-8.5.19/gnu32/lib \
  --with-x 
schecking for Tcl configuration... found /opt/tcl-8.5.19/gnu32/lib/tclConfig.sh
checking for existence of /opt/tcl-8.5.19/gnu32/lib/tclConfig.sh... loading
checking for tclsh... /opt/tcl-8.5.19/gnu32/bin/tclsh8.5
checking for tclsh in Tcl build directory... /opt/tcl-8.5.19/gnu32/lib/tclsh
checking whether to use symlinks for manpages... no
checking whether to compress the manpages... no
checking whether to add a package name suffix for the manpages... no
checking for gcc... /usr/bin/gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking if the compiler understands -pipe... yes
checking for pthread_mutex_init in -lpthread... yes
checking for pthread_attr_setstacksize... yes
checking for pthread_atfork... yes
checking for pthread_attr_get_np... no
checking for pthread_getattr_np... no
checking for pthread_get_stacksize_np... no
checking for building with threads... yes (threaded core)
checking how to build libraries... shared
checking for ranlib... ranlib
checking if 64bit support is requested... no
checking if 64bit Sparc VIS support is requested... no
checking if compiler supports visibility "hidden"... yes
checking if rpath support is requested... yes
checking system version... SunOS-5.11
checking for dlopen in -ldl... yes
checking for ar... ar
checking for cast to union support... yes
checking for build with symbols... no
checking for required early compiler flags... none
checking for 64-bit integer type... long long
checking for struct dirent64... yes
checking for struct stat64... yes
checking for open64... yes
checking for lseek64... yes
checking for off64_t... yes
checking whether byte ordering is bigendian... no
checking for fd_set in sys/types... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking whether time.h and sys/time.h may both be included... yes
checking for strtod... yes
checking for Solaris2.4/Tru64 strtod bugs... ok
checking for mode_t... yes
checking for pid_t... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for intptr_t... yes
checking for uintptr_t... yes
checking pw_gecos in struct pwd... yes
checking for X... libraries , headers
checking for main in -lXbsd... no
checking whether to use xft... yes
checking for X11/Xft/Xft.h... yes
checking for XftFontOpen in -lXft... yes
checking for FcFontSort in -lfontconfig... yes
checking for X11/XKBlib.h... yes
checking for XkbKeycodeToKeysym in -lX11... yes
checking whether to try to use XScreenSaver... yes
checking for X11/extensions/scrnsaver.h... yes
checking for XScreenSaverQueryInfo... no
checking for XScreenSaverQueryInfo in -lXext... yes
checking whether char is unsigned... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating tkConfig.sh
config.status: creating tk.pc

 
$ zfs snapshot $DS/tk/tk-8.5.19-gnu32@config

$ gmake
...

$ zfs snapshot $DS/tk/tk-8.5.19-gnu32@build

NOTE
The gmake test or
the gmake test TESTFLAGS="-constraints userInteraction" must be run under an X session. The tests are somewhat fun to follow, but under a VM guest there were some erros yet to investigate.
$ gmake test
...
Tests ended at Thu Jul 13 14:11:30 BRT 2017
all.tcl:    Total    8957    Passed    7980    Skipped    944    Failed    33
Sourced 87 Test Files.
Files with failing tests: focus.test font.test id.test scrollbar.test textWind.test unixFont.test unixWm.test wm.test
Number of tests skipped for each constraint:
    14    altDisplay
    1    aqua
    16    colorsFree
    3    colorsLeftover
    21    defaultPseudocolor8
    6    emptyTest
    140    fonts
    1    hasArial
    1    hasCourierNew
    1    hasTimesNew
    1    havePseudocolorVisual
    8    knownBug
    1    memory
    166    nonPortable
    33    nt
    5    pseudocolor8
    11    testmetrics
    7    testwinevent
    143    textfonts
    1    unthreaded
    1    userInteraction
    312    win
    51    winSend

...
==== focus-6.1 miscellaneous - embedded application in same process FAILED


==== font-4.9 font command: actual FAILED
==== font-24.5 Tk_ComputeTextLayout: break line FAILED
==== font-44.1 TkFontGetPixels: size < 0 FAILED

==== id-1.1 WindowIdCleanup, delaying window release FAILED

==== scrollbar-3.36 ScrollbarWidgetCmd procedure, "fraction" option FAILED
==== scrollbar-3.38 ScrollbarWidgetCmd procedure, "fraction" option FAILED
==== scrollbar-6.12 ScrollbarPosition procedure FAILED
==== scrollbar-6.29 ScrollbarPosition procedure FAILED
==== scrollbar-6.35 ScrollbarPosition procedure FAILED
==== scrollbar-6.44 ScrollbarPosition procedure FAILED

==== textWind-10.6.1 EmbWinLayoutProc procedure, error in creating window FAILED

==== unixfont-1.2 TkpGetNativeFont procedure: native FAILED
==== unixfont-2.6 TkpGetFontFromAttributes: fallback to fixed family FAILED
==== unixfont-2.8 TkpGetFontFromAttributes: loop over returned font names FAILED
==== unixfont-2.9 TkpGetFontFromAttributes: reject adobe courier if possible FAI
==== unixfont-5.9 Tk_MeasureChars procedure: TK_PARTIAL_OK FAILED
==== unixfont-8.4 AllocFont procedure: classify characters FAILED
==== unixfont-8.5 AllocFont procedure: setup widths of normal chars FAILED
==== unixfont-8.6 AllocFont procedure: setup widths of special chars FAILED
==== unixfont-9.1 GetControlCharSubst procedure: 2 chars subst FAILED
==== unixfont-9.2 GetControlCharSubst procedure: 4 chars subst FAILED

==== unixWm-4.3 moving window while withdrawn FAILED
==== unixWm-45.2 UpdateSizeHints procedure FAILED
==== unixWm-45.4 UpdateSizeHints procedure, not resizable with menu FAILED
==== unixWm-51.7 TkWmRestackToplevel procedure, other window isn't mapped FAILED

==== 2.2 testing bevel.tcl FAILED
==== 2.8 testing canvPsBmap.tcl FAILED
==== 2.11 testing canvPsBmap.tcl FAILED

==== wm-stackorder-2.2 stacking order FAILED
==== wm-stackorder-2.3 stacking order FAILED
==== wm-stackorder-2.4 stacking order FAILED
==== wm-stackorder-2.5 stacking order FAILED
==== wm-stackorder-4.3 wm stackorder isabove|isbelow FAILED
==== wm-stackorder-4.4 wm stackorder isabove|isbelow FAILED
 ==== wm-stackorder-5.1 a menu is not a toplevel FAILED
...
Tests ended at Thu Jul 13 14:11:42 BRT 2017
all.tcl:    Total    460    Passed    442    Skipped    17    Failed    1
Sourced 17 Test Files.
Files with failing tests: ttk.test
Number of tests skipped for each constraint:
    2    NA
    4    coreEntry
    3    coreScrollbar
    5    nyi
    3    xpnative

... 
==== ttk-2.8 bug 3223850: button state disabled during click FAILED

NOTE
In fact there are some errors and I don't know yet if they are due to running the tests from inside a VM. By their titles, they may or may not be significant. And I started wondering about how many the Solaris 11.3 (GA / Release) packaged older version would have...
$ sudo gmake install
Making directory /opt/tcl-8.5.19/gnu32/lib/tk8.5
Creating package index /opt/tcl-8.5.19/gnu32/lib/tk8.5/pkgIndex.tcl
Installing libtk8.5.so to /opt/tcl-8.5.19/gnu32/lib/
Installing wish as /opt/tcl-8.5.19/gnu32/bin/wish8.5
Installing tkConfig.sh to /opt/tcl-8.5.19/gnu32/lib/
Installing libtkstub8.5.a to /opt/tcl-8.5.19/gnu32/lib/
Installing pkg-config file to /opt/tcl-8.5.19/gnu32/lib/pkgconfig/
Making directory /opt/tcl-8.5.19/gnu32/lib/tk8.5/images
Making directory /opt/tcl-8.5.19/gnu32/lib/tk8.5/msgs
Making directory /opt/tcl-8.5.19/gnu32/lib/tk8.5/ttk
Installing Tk library files to /opt/tcl-8.5.19/gnu32/lib/tk8.5/
Installing Ttk library files to /opt/tcl-8.5.19/gnu32/lib/tk8.5/ttk/
Installing library image files to /opt/tcl-8.5.19/gnu32/lib/tk8.5/images/
Installing message catalog files to /opt/tcl-8.5.19/gnu32/lib/tk8.5/msgs/
Installing and cross-linking top-level (.1) docs to /opt/tcl-8.5.19/gnu32/man/man1/
Installing and cross-linking C API (.3) docs to /opt/tcl-8.5.19/gnu32/man/man3/
Installing and cross-linking command (.n) docs to /opt/tcl-8.5.19/gnu32/man/mann/
Installing header files to /opt/tcl-8.5.19/gnu32/include/
Making directory /opt/tcl-8.5.19/gnu32/lib/tk8.5/demos
Making directory /opt/tcl-8.5.19/gnu32/lib/tk8.5/demos/images
Installing demo files to /opt/tcl-8.5.19/gnu32/lib/tk8.5/demos/
Installing demo image files to /opt/tcl-8.5.19/gnu32/lib/tk8.5/demos/images/


$ sudo ln -s /opt/.../bin/wish8.5 /opt/.../bin/wish
 $ sudo zfs snapshot rpool/VARSHARE/tcl-8.5.19/gnu32@release
 
If necessary, package the results in a tarball or some other method of choice.
Now, it rests setting up PATH and PKG_CONFIG_PATH as necessary.

For GNU64:

$ cd ~/software/tcl/tcl-8.5.19-gnu64/unix

$ source ../../setenv-tcl-8.5.19 64 
CONFIG_SHELL=/bin/bash

CC=/usr/bin/gcc CFLAGS=-m64 -march=core2 -std=gnu89
CXX=/usr/bin/g++ CXXFLAGS=-m64 -march=core2 -std=gnu++03

PATH=/opt/libtool-2.4.6/gnu64/bin:/opt/m4-1.4.18/gnu64/bin:/opt/autoconf-2.69/gnu64/bin:/opt/automake-1.15/gnu64/bin:/usr/gnu/bin:/usr/bin:/usr/sbin
PKG_CONFIG_PATH=


$ ./configure \
  --prefix=/opt/tcl-8.5.19/gnu64 \
  --enable-threads \
  --enable-64bit \
  --enable-rpath \
  --enable-dtrace
checking whether to use symlinks for manpages... no
checking whether to compress the manpages... no
checking whether to add a package name suffix for the manpages... no
checking for gcc... /usr/bin/gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ANSI C... none needed
checking for inline... inline
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dirent.h... yes
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking values.h usability... yes
checking values.h presence... yes
checking for values.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking if the compiler understands -pipe... yes
checking for pthread_mutex_init in -lpthread... yes
checking for pthread_attr_setstacksize... yes
checking for pthread_atfork... yes
checking for pthread_attr_get_np... no
checking for pthread_getattr_np... no
checking for pthread_get_stacksize_np... no
checking for building with threads... yes
checking for sin... no
checking for main in -lieee... no
checking for main in -linet... no
checking net/errno.h usability... no
checking net/errno.h presence... no
checking for net/errno.h... no
checking for connect... no
checking for setsockopt... no
checking for setsockopt in -lsocket... yes
checking for gethostbyname... no
checking for gethostbyname in -lnsl... yes
checking how to build libraries... shared
checking for ranlib... ranlib
checking if 64bit support is requested... yes
checking if 64bit Sparc VIS support is requested... no
checking if compiler supports visibility "hidden"... yes
checking if rpath support is requested... yes
checking system version... SunOS-5.11
checking for dlopen in -ldl... yes
checking for ar... ar
checking for cast to union support... yes
checking for build with symbols... no
checking for required early compiler flags... none
checking for 64-bit integer type... using long
checking whether byte ordering is bigendian... no
checking for getcwd... yes
checking for opendir... yes
checking for strtol... yes
checking for waitpid... yes
checking for strerror... yes
checking for getwd... yes
checking for wait3... yes
checking for uname... yes
checking for realpath... yes
checking for getaddrinfo... yes
checking for working getaddrinfo... yes
checking for getpwuid_r... yes
checking for getpwuid_r with 5 args... yes
checking for getpwnam_r... yes
checking for getpwnam_r with 5 args... yes
checking for getgrgid_r... yes
checking for getgrgid_r with 5 args... yes
checking for getgrnam_r... yes
checking for getgrnam_r with 5 args... yes
checking for gethostbyname_r... yes
checking for gethostbyname_r with 6 args... no
checking for gethostbyname_r with 5 args... yes
checking for gethostbyaddr_r... yes
checking for gethostbyaddr_r with 7 args... yes
checking sys/modem.h usability... no
checking sys/modem.h presence... no
checking for sys/modem.h... no
checking termios vs. termio vs. sgtty... termios
checking for fd_set in sys/types... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking whether time.h and sys/time.h may both be included... yes
checking for gmtime_r... yes
checking for localtime_r... yes
checking for mktime... yes
checking tm_tzadj in struct tm... no
checking tm_gmtoff in struct tm... no
checking long timezone variable... yes
checking for struct stat.st_blocks... yes
checking for struct stat.st_blksize... yes
checking for blkcnt_t... yes
checking for fstatfs... yes
checking for working memcmp... yes
checking for memmove... yes
checking for strstr... yes
checking proper strstr implementation... ok
checking for strtoul... yes
checking proper strtoul implementation... ok
checking for strtod... yes
checking proper strtod implementation... ok
checking for strtod... (cached) yes
checking for Solaris2.4/Tru64 strtod bugs... ok
checking for mode_t... yes
checking for pid_t... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for socklen_t... yes
checking for intptr_t... yes
checking for uintptr_t... yes
checking for opendir... (cached) yes
checking union wait... no
checking for strncasecmp... yes
checking for gettimeofday... yes
checking for gettimeofday declaration... present
checking whether char is unsigned... no
checking signed char declarations... yes
checking for a putenv() that copies the buffer... no
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking whether to use nl_langinfo... yes
checking for chflags... no
checking isnan... yes
checking for fts... no
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/filio.h usability... yes
checking sys/filio.h presence... yes
checking for sys/filio.h... yes
checking system version... (cached) SunOS-5.11
checking FIONBIO vs. O_NONBLOCK for nonblocking I/O... O_NONBLOCK
checking whether to use dll unloading... yes
checking for timezone data... /usr/share/lib/zoneinfo
checking sys/sdt.h usability... yes
checking sys/sdt.h presence... yes
checking for sys/sdt.h... yes
checking for dtrace... /usr/sbin/dtrace
checking whether to enable DTrace support... yes
checking if the C stack grows upwards in memory... no
checking whether the cpuid instruction is usable... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dltest/Makefile
config.status: creating tclConfig.sh
config.status: creating tcl.pc


$ zfs snapshot $DS/tcl/tcl-8.5.19-gnu64@config

$ gmake
...

$ zfs snapshot $DS/tcl/tcl-8.5.19-gnu64@build

The test results for the 64-bits build were similar.

$ gmake test
...
Tests ended at Wed Jul 12 18:22:01 BRT 2017
all.tcl:        Total   27201   Passed  26164   Skipped 1034    Failed  3
Sourced 138 Test Files.
Files with failing tests: clock.test
Number of tests skipped for each constraint:
        9       !ieeeFloatingPoint
        3       asyncPipeChan
        76      bigEndian
        6       bug-05489ce335
        5       bug-3057639
        4       dontCopyLinks
        61      emptyTest
        2       hasIsoLocale
        1       knownBadTest
        40      knownBug
        100     localeRegexp
        50      longIs32bit
        14      macosxFileAttr
        18      memory
        43      nonPortable
        5       notNetworkFilesystem
        9       nt
        1       pcOnly
        4       readonlyAttr
        7       testaccessproc
        1       testexprparser && !ieeeFloatingPoint
        8       testopenfilechannelproc
        7       teststatproc
        1       testwinclock
        21      testwordend
        1       thread
        2       unthreaded
        2       wideBiggerThanInt
        520     win
        2       win2000orXP


$ sudo gmake install
Making directory /opt/tcl-8.5.19/gnu64/lib
Making directory /opt/tcl-8.5.19/gnu64/bin
Installing libtcl8.5.so to /opt/tcl-8.5.19/gnu64/lib/
Installing tclsh as /opt/tcl-8.5.19/gnu64/bin/tclsh8.5
Installing tclConfig.sh to /opt/tcl-8.5.19/gnu64/lib/
Installing libtclstub8.5.a to /opt/tcl-8.5.19/gnu64/lib/
Installing pkg-config file to /opt/tcl-8.5.19/gnu64/lib/pkgconfig/
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/msgs
Installing message catalog files to /opt/tcl-8.5.19/gnu64/lib/tcl8.5/msgs/
Making directory /opt/tcl-8.5.19/gnu64/include
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/opt0.4
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/http1.0
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/encoding
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/../tcl8
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/../tcl8/8.4
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/../tcl8/8.4/platform
Making directory /opt/tcl-8.5.19/gnu64/lib/tcl8.5/../tcl8/8.5
Installing header files to /opt/tcl-8.5.19/gnu64/include/
Installing library files to /opt/tcl-8.5.19/gnu64/lib/tcl8.5/
Installing package http1.0 files to /opt/tcl-8.5.19/gnu64/lib/tcl8.5/http1.0/
Installing package http 2.7.13 as a Tcl Module
Installing package opt0.4 files to /opt/tcl-8.5.19/gnu64/lib/tcl8.5/opt0.4/
Installing package msgcat 1.5.2 as a Tcl Module
Installing package tcltest 2.3.8 as a Tcl Module
Installing package platform 1.0.14 as a Tcl Module
Installing package platform::shell 1.1.4 as a Tcl Module
Installing encoding files to /opt/tcl-8.5.19/gnu64/lib/tcl8.5/encoding/
Making directory /opt/tcl-8.5.19/gnu64/man
Making directory /opt/tcl-8.5.19/gnu64/man/man1
Making directory /opt/tcl-8.5.19/gnu64/man/man3
Making directory /opt/tcl-8.5.19/gnu64/man/mann
Installing and cross-linking top-level (.1) docs to /opt/tcl-8.5.19/gnu64/man/man1/
Installing and cross-linking C API (.3) docs to /opt/tcl-8.5.19/gnu64/man/man3/
Installing and cross-linking command (.n) docs to /opt/tcl-8.5.19/gnu64/man/mann/


$ sudo ln -s /opt/.../bin/tclsh8.5 /opt/.../bin/tclsh
 
$ ls -1 /opt/tcl-8.5.19/gnu64/*
/opt/tcl-8.5.19/gnu64/bin:
tclsh8.5
...

/opt/tcl-8.5.19/gnu64/include:
tcl.h
tclDecls.h
tclPlatDecls.h
tclTomMath.h
tclTomMathDecls.h

/opt/tcl-8.5.19/gnu64/lib:
libtcl8.5.so
libtclstub8.5.a
pkgconfig
tcl8
tcl8.5
tclConfig.sh

/opt/tcl-8.5.19/gnu64/man:
man1
man3
mann


Now it's time to build the Tk modules.

$ cd ~/software/tk/tk-8.5.19-gnu64/unix
 
$ source ../../setenv-tk-8.5.19 64
CONFIG_SHELL=/bin/bash

CC=/usr/bin/gcc CFLAGS=-m64 -march=core2 -std=gnu89
CXX=/usr/bin/g++ CXXFLAGS=-m64 -march=core2 -std=gnu++03

PATH=/opt/libtool-2.4.6/gnu64/bin:/opt/m4-1.4.18/gnu64/bin:/opt/autoconf-2.69/gnu64/bin:/opt/automake-1.15/gnu64/bin:/opt/tcl-8.5.19/gnu64/bin:/usr/gnu/bin:/usr/bin:/usr/sbin
PKG_CONFIG_PATH=/opt/tcl-8.5.19/gnu64/lib/pkgconfig


$ ./configure \
  --prefix=/opt/tcl-8.5.19/gnu64 \

  --enable-threads \
  --enable-64bit \
  --enable-rpath \
  --enable-dtrace \
  --with-tcl=/opt/tcl-8.5.19/gnu64/lib \
  --with-x
checking for Tcl configuration... found /opt/tcl-8.5.19/gnu64/lib/tclConfig.sh
checking for existence of /opt/tcl-8.5.19/gnu64/lib/tclConfig.sh... loading
checking for tclsh... /opt/tcl-8.5.19/gnu64/bin/tclsh8.5
checking for tclsh in Tcl build directory... /opt/tcl-8.5.19/gnu64/lib/tclsh
checking whether to use symlinks for manpages... no
checking whether to compress the manpages... no
checking whether to add a package name suffix for the manpages... no
checking for gcc... /usr/bin/gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking if the compiler understands -pipe... yes
checking for pthread_mutex_init in -lpthread... yes
checking for pthread_attr_setstacksize... yes
checking for pthread_atfork... yes
checking for pthread_attr_get_np... no
checking for pthread_getattr_np... no
checking for pthread_get_stacksize_np... no
checking for building with threads... yes (threaded core)
checking how to build libraries... shared
checking for ranlib... ranlib
checking if 64bit support is requested... yes
checking if 64bit Sparc VIS support is requested... no
checking if compiler supports visibility "hidden"... yes
checking if rpath support is requested... yes
checking system version... SunOS-5.11
checking for dlopen in -ldl... yes
checking for ar... ar
checking for cast to union support... yes
checking for build with symbols... no
checking for required early compiler flags... none
checking for 64-bit integer type... using long
checking whether byte ordering is bigendian... no
checking for fd_set in sys/types... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking whether time.h and sys/time.h may both be included... yes
checking for strtod... yes
checking for Solaris2.4/Tru64 strtod bugs... ok
checking for mode_t... yes
checking for pid_t... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for intptr_t... yes
checking for uintptr_t... yes
checking pw_gecos in struct pwd... yes
checking for X... libraries , headers
checking for main in -lXbsd... no
checking whether to use xft... yes
checking for X11/Xft/Xft.h... yes
checking for XftFontOpen in -lXft... yes
checking for FcFontSort in -lfontconfig... yes
checking for X11/XKBlib.h... yes
checking for XkbKeycodeToKeysym in -lX11... yes
checking whether to try to use XScreenSaver... yes
checking for X11/extensions/scrnsaver.h... yes
checking for XScreenSaverQueryInfo... no
checking for XScreenSaverQueryInfo in -lXext... yes
checking whether char is unsigned... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating tkConfig.sh
config.status: creating tk.pc

 
$ zfs snapshot $DS/tk/tk-8.5.19-gnu64@config

$ gmake
...

$ zfs snapshot $DS/tk/tk-8.5.19-gnu64@build

$ gmake test
...

The only differences in test results were:

==== font-44.1 TkFontGetPixels: size < 0 OK 
==== send-8.16 Tk_SendCmd procedure, bogusCommWindow FAILED
==== 2.2 testing bevel.tcl OK
==== 2.8 testing canvPsBmap.tcl OK
==== 2.11 testing canvPsBmap.tcl OK


$ sudo gmake install
Making directory /opt/tcl-8.5.19/gnu64/lib/tk8.5
Creating package index /opt/tcl-8.5.19/gnu64/lib/tk8.5/pkgIndex.tcl
Installing libtk8.5.so to /opt/tcl-8.5.19/gnu64/lib/
Installing wish as /opt/tcl-8.5.19/gnu64/bin/wish8.5
Installing tkConfig.sh to /opt/tcl-8.5.19/gnu64/lib/
Installing libtkstub8.5.a to /opt/tcl-8.5.19/gnu64/lib/
Installing pkg-config file to /opt/tcl-8.5.19/gnu64/lib/pkgconfig/
Making directory /opt/tcl-8.5.19/gnu64/lib/tk8.5/images
Making directory /opt/tcl-8.5.19/gnu64/lib/tk8.5/msgs
Making directory /opt/tcl-8.5.19/gnu64/lib/tk8.5/ttk
Installing Tk library files to /opt/tcl-8.5.19/gnu64/lib/tk8.5/
Installing Ttk library files to /opt/tcl-8.5.19/gnu64/lib/tk8.5/ttk/
Installing library image files to /opt/tcl-8.5.19/gnu64/lib/tk8.5/images/
Installing message catalog files to /opt/tcl-8.5.19/gnu64/lib/tk8.5/msgs/
Installing and cross-linking top-level (.1) docs to /opt/tcl-8.5.19/gnu64/man/man1/
Installing and cross-linking C API (.3) docs to /opt/tcl-8.5.19/gnu64/man/man3/
Installing and cross-linking command (.n) docs to /opt/tcl-8.5.19/gnu64/man/mann/
Installing header files to /opt/tcl-8.5.19/gnu64/include/
Making directory /opt/tcl-8.5.19/gnu64/lib/tk8.5/demos
Making directory /opt/tcl-8.5.19/gnu64/lib/tk8.5/demos/images
Installing demo files to /opt/tcl-8.5.19/gnu64/lib/tk8.5/demos/
Installing demo image files to /opt/tcl-8.5.19/gnu64/lib/tk8.5/demos/images/


$ sudo ln -s /opt/.../bin/wish8.5 /opt/.../bin/wish
 
$ sudo zfs snapshot rpool/VARSHARE/tcl-8.5.19/gnu64@release

If necessary, package the results in a tarball or some other method of choice.
Now, it rests setting up PATH and PKG_CONFIG_PATH as necessary.

That's it for Tcl / Tk version 8.5.19!

NOTE
For building version 8.6.6, being by making sure that version 8.5.19 is in PATH and in PKG_CONFIG_PATH, because version 8.6.6 searchs for a previous tclsh which could indicate that it would be better to make sure it gets the most updated instance of version 8.5 series (which would not be the version packaged with Solaris).
In the process of building version 8.6.6 some modules don't recognize the --enable-dtrace configuration option, but the messages are flagged as mere warnings so this shouldn't be a problem except that DTrace may not be available on such modules.

The whole process is pretty much the same, so I will only describe eventual differences in the procedures and some results which I've found more interesting (using the GNU32 target as an example). For instance, the tests results were pretty much better with only 2 errors not solvable by running as root (at least under a VM):

==== socket_inet-13.1 Testing use of shared socket between two threads FAILED
==== socket_inet6-13.1 Testing use of shared socket between two threads FAILED

During installation, it's somewhat interesting that the following "packages" get "installed" (although I'm still not aware of their usefulness):

Installing package 'sqlite3.13.0'
Installing package 'tdbc1.0.4'
Installing package 'tdbcmysql1.0.4'
Installing package 'tdbcpostgres1.0.4'
Installing package 'tdbcsqlite3-1.0.4'
Installing package 'thread2.8.0'

$ ls -1 /opt/tcl-8.6.6/gnu32/*
/opt/tcl-8.6.6/gnu32/bin:
sqlite3_analyzer
tclsh8.6

...

/opt/tcl-8.6.6/gnu32/include:
fakemysql.h
fakepq.h
fakesql.h
itcl.h
itcl2TclOO.h
itclDecls.h
itclInt.h
itclIntDecls.h
itclMigrate2TclCore.h
itclTclIntStubsFcn.h
mysqlStubs.h
odbcStubs.h
pqStubs.h
tcl.h
tclDecls.h
tclOO.h
tclOODecls.h
tclPlatDecls.h
tclThread.h
tclTomMath.h
tclTomMathDecls.h
tdbc.h
tdbcDecls.h
tdbcInt.h

/opt/tcl-8.6.6/gnu32/lib:

itcl4.0.5
libtcl8.6.so
libtclstub8.6.a
pkgconfig
sqlite3.13.0
tcl8
tcl8.6
tclConfig.sh
tclooConfig.sh
tdbc1.0.4
tdbcmysql1.0.4
tdbcodbc1.0.4
tdbcpostgres1.0.4
thread2.8.0

/opt/tcl-8.6.6/gnu32/man:
man1
man3
mann

/opt/tcl-8.6.6/gnu32/share:
man


$ cd ~/software/tk/tk-8.6.6-gnu32/unix

$ source ../../setenv-tk-8.6.6 32
CONFIG_SHELL=/bin/bash

CC=/usr/bin/gcc CFLAGS=-m32 -march=core2 -std=gnu89
CXX=/usr/bin/g++ CXXFLAGS=-m32 -march=core2 -std=gnu++03

PATH=/opt/tcl-8.6.6/gnu32/bin:/opt/libtool-2.4.6/gnu32/bin:/opt/m4-1.4.18/gnu32/bin:/opt/autoconf-2.69/gnu32/bin:/opt/automake-1.15/gnu32/bin:/usr/gnu/bin:/usr/bin:/usr/sbin
PKG_CONFIG_PATH=/opt/tcl-8.6.6/gnu32/lib/pkgconfig


$ ./configure \
  --prefix=/opt/tcl-8.6.6/gnu32 \
  --enable-threads \
  --enable-rpath \
  --enable-dtrace \
  --with-tcl=/opt/tcl-8.6.6/gnu32/lib \
  --with-x
...

$ zfs snapshot $DS/tk/tk-8.6.6-gnu32@config

$ gmake
...

$ zfs snapshot $DS/tk/tk-8.6.6-gnu32@build
 
$ gmake test # Under X!
...

$ sudo gmake install
...

$ sudo ln -s /opt/.../bin/wish8.6 /opt/.../bin/wish

$ sudo zfs snapshot rpool/VARSHARE/tcl-8.6.6/gnu32@release

If necessary, package the results in a tarball or some other method of choice.
Now, it rests setting up PATH and PKG_CONFIG_PATH as necessary.

For the GNU64 everything is analogous and as this post is already exremelly lengthy I'll omit this last part as I believe I've already made my point!
     
The next step is learning this beast! :-)