Porting Zzipp.3.1.01 to OpenBSD by George Peter Staplin

This document provides instruction about how Zzipp.3.1.01 was ported to OpenBSD 2.6. This document assumes that the reader is familiar with compiling programs and knows some basic information about makefiles. Eben H. Oldmixon, Ph.D. has helped me throughout my quest to compile zzi in OpenBSD.

This document may be copied and distributed provided that George Peter Staplin is given credit.

The Steps Taken

Note: You can skip to the end of this document to get the modified files needed.

The Flex lexical analyzer/generator had problems with Zzipp. Eben Oldmixon provided me with the zzLexer.c and zzParser.c files, as well as the needed header files zzParser.tab.h and y.tab.h from his SGI machine, and they work in OpenBSD 2.6 x86 without a problem. SGI_zzi_lexparse.tar.gz Copy the files into the zzi directory.

Modifications to the Makefile are needed to use the SGI lexer and parser C files. The new Makefile does not require running make parser. The new Makefile will not delete the zzLexer.c and zzParser.c files if you run make clean.

The following are some changes I made to the new Makefile. You may need to modify these on your system.

I changed part of the X11 include path from -I/usr/include/X11 to -I/usr/X11R6/include. I changed this because unlike some systems, /usr/include/X11 on my system is not a symbolic link to /usr/X11R6/include.

I changed LD_DIRS = -L/usr/lib32 -L/usr/lib -L/usr/local/lib to LD_DIRS = -L/usr/local/lib -L/usr/lib -L/usr/X11R6/lib.

I changed LIBS = -ltk8.3 -ltcl8.3 -lX11 -lm -lc to LIBS = -lX11 -lm -lc /usr/local/lib/libtcl83.so.1.0 /usr/local/lib/libtk83.so.1.0

You may need to change the LD_DIRS path to the shared Tcl and Tk libraries. On your system -ltk8.3 and -ltcl8.3 may work properly. On my system it didn't work properly. I believe this was a problem because I had the shared .so and non-shared .a libraries for Tcl/Tk 8.3. It may also be caused by my shared object libraries not ending in .so.

This is what part of my /usr/local/lib looks like:
-r-xr-xr-x 1 root wheel 580944 Oct 4 22:52 libtcl80.a
-r-xr-xr-x 1 root wheel 422753 Oct 4 22:52 libtcl80.so.1.5
-r-xr-xr-x 1 root wheel 743564 Mar 12 00:22 libtcl83.a
-r-xr-xr-x 1 root wheel 535399 Feb 29 12:24 libtcl83.so.1.0
-rw-r--r-- 1 root wheel 1036 Mar 12 00:22 libtclstub83.a
-r-xr-xr-x 1 root wheel 807850 Oct 4 23:21 libtk80.a
-r-xr-xr-x 1 root wheel 597251 Oct 4 23:21 libtk80.so.1.5
-r-xr-xr-x 1 root wheel 980228 Mar 12 00:26 libtk83.a
-r-xr-xr-x 1 root wheel 724290 Feb 29 12:25 libtk83.so.1.0

By now if you run make zzi you will probably get an error like this:
./zzParser.y:292: values.h: No such file or directory
*** Error code 1

Stop in /home/imagine/test/Zzipp.3.1.01/zzi.
$

Eben Oldmixon said that values.h was not needed so he suggested that I comment it out in zzParser.c, which I did. To comment out values.h go to the line that reads as #include <values.h> and change it to /*#include <values.h>*/. You may note that the error message reports a problem in zzParser.y, but the actual problem is in zzParser.c.

Now when you run make zzi it will probably report this:
gcc -I../ -I/usr/X11R6/include -I/usr/local/include -O2 -c ./zzParser.c
In file included from ./zzParser.y:289:
/usr/include/malloc.h:4: warning: #warning "<malloc.h> is obsolete, use <stdlib.h>"
gcc -I../ -I/usr/X11R6/include -I/usr/local/include -O2 -o zzi ./zzAS.o ./zzBI.o ./zzBP.o ./zzBR.o ./zzFF.o ./zzFH.o ./zzFM.o
./zzFR.o ./zzHH.o ./zzHR.o ./zzHU.o ./zzIP.o ./zzIR.o ./zzIS.o ./zzJH.o ./zzJN.o ./zzKF.o ./zzNU.o ./zzPX.o ./zzRA.o ./zzRF.o ./zzRH.o ./zzRI.o ./zzRN.o ./zzRP.o ./zzRR.o ./zzRS.o ./zzRT.o ./zzRU.o ./zzRX.o ./zzUC.o ./zzUH.o ./zzUR.o ./zzWT.o ./zzFFF.o ./zzFFR.o ./zzFKF.o ./zzFKR.o ./zzHRS.o ./zzJJH.o ./zzPPP.o ./zzRBR.o ./zzRRR.o ./zzRRRP.o ./zzRRRR.o ./tkImgFmtZZ.o ./zzAppInit.o ./zzCmd.o ./Zz_Init.o ./zzMoreLexParse.o ./zzLexer.o ./zzParser.o -L/usr/local/lib -L/usr/lib -L/usr/X11R6/lib -lX11 -lm -lc /usr/local/lib/libtcl83.so.1.0 /usr/local/lib/libtk83.so.1.0
./zzFF.o: Undefined symbol `_truncf' referenced from text segment
./zzParser.o: Undefined symbol `_gettxt' referenced from text segment
./zzParser.o: Undefined symbol `_gettxt' referenced from text segment
collect2: ld returned 1 exit status
*** Error code 1

Stop in /home/imagine/test/Zzipp.3.1.01/zzi.
$

The problem with this is that gettxt is not a valid function in OpenBSD with GNU gettext. I had to install GNU gettext to get this next part to work. It can be found in the ports tree in the devel directory. The first step is to add #include "/usr/local/share/gettext/intl/libgettext.h" to zzParser.c. Next you will need to replace all calls named gettxt in zzParser.c to dgettext.

Now you will probably have an error about truncf in zzFF.c if you run make zzi, which we will fix next.

You will need to change the function name truncf to ftruncate in zzFF.c on line 233.

It should look like this:
if (*roip++) {
*dfp = truncf( *sfp);
}

Change it to look like this:
if (*roip++) {
*dfp = ftruncate( *sfp);
}

What we Have Done

Now you should understand how Zzipp was ported to OpenBSD 2.6. The basic steps are to place the zzLexer.c, zzParser.c, zzParser.tab.h, and y.tab.h in the zzi directory. The next step is to replace the Makefile, so that it uses the already made lexer and parser files. Then comment out values.h in zzParser.c. Next include the GNU gettext header file in zzParser.c and replace all occurances of gettxt with dgettext. Then replace truncf with ftruncate in zzFF.c.

All of the modified files can be found in this archive.

Basic Usage

You probably want to test out the zzi executable now. You can copy zzi to one of your bin directories, or you can add the zzi directory to your path. Next you will need to set the environment variables for zzi to run. On my system with sh I added these lines to my ~/.profile:
export ZZIPP_HOME=/home/imagine/Zzipp.3.1.01
export ZZI_TCL_HOME=/home/imagine/Zzipp.3.1.01/TCL

If you have a different shell than sh or bash, you will need to consult the documentation provided with Zzipp.

Change to the TUTORIAL directory and start Zzipp by executing zzi. Then when the window opens type zz ur to ./imgs/cellPics/1 r1 in to the entry box in the upper left. Now press enter and Zzipp should accept the command. Now press the start button and you should see two images appear at the bottom. For further information read Manual.pdf which can be found in the DOCS directory.

Please send George P. Staplin any comments or questions about this document.