Hacking Survex

(That's hacking in the "tinkering with code" sense, not in the "breaking into other people's computer systems" sense).

This is currently a random collection of notes that need to be written down while I remember. With time it should evolve into a more coherent document. If you have any questions which this should answer but doesn't then ask me and I'll add them.

Network code debugging

You can pick which network simplifications are attempted using "-z" with an argument listing code letters. So:

And you can combine these in any combination:

"-z=lpd" is the default (in 0.99 at least - more transformations may conceivably be added in future, although the simple common cases are already covered).

Developing on Unix Platforms

You'll need automake 1.5 or later (earlier versions don't support per-executable CFLAGS; 1.6 has been tested and works, but wasn't a very stable release - automake 1.6.1 is a better bet) and autoconf 2.50 or later (autoconf 2.52, 2.53 and 2.64 have all been used successfully).

For building the documentation you'll need sgmltools 2 or later, jadetex, docbook-to-man, and w3m.

Building on Non-Unix Platforms

DJGPP (MSDOS for 386 or better)

Currently I build this with a Linux hosted cross-compiler. I built this myself mostly following instructions from:

http://www.objsw.com/CrossGCC/

I suggest using binutils-2.14 rather than binutils-2.9.1, and also newer version of the DJGPP crosscompiler kit (djcrx - use 204 which is in beta at the time of writing) and GCC. Newer binutils versions include the patch they supply, so the instructions boil down to this sequence of commands:

bash
mkdir ~/djcross
cd ~/djcross
wget ftp://ftp.objsw.com/pub/crossgcc/build-djgpp.sh
mkdir tars
cd tars
wget http://www.mirror.ac.uk/sites/ftp.delorie.com/pub/djgpp/current/v2/beta/djcrx204.zip
wget http://www.mirror.ac.uk/sites/ftp.gnu.org/gnu/gcc/gcc-3.3.2.tar.gz
wget http://www.mirror.ac.uk/sites/ftp.gnu.org/gnu/binutils/binutils-2.14.tar.gz
cd ..
patch -l build-djgpp.sh <<END
24,26c24,26
< binfile=djcrx202.zip
< gcc=gcc-2.95.2
< binutils=binutils-2.9.1
---
> binfile=djcrx204.zip
> gcc=gcc-3.3.2
> binutils=binutils-2.14
97c97
<       patch -p1 <\$patches/\$binutilsdiff
---
>       #patch -p1 <\$patches/\$binutilsdiff
END
sh build-djgpp.sh
If the build of GCC fails, you may need to apply this patch:
--- gcc-3.3.2-orig/libiberty/getpwd.c	2001-10-07 22:53:31.000000000 +0100
+++ gcc-3.3.2/libiberty/getpwd.c	2004-01-12 02:00:41.000000000 +0000
@@ -50,2 +50,3 @@
 
+#undef MAXPATHLEN
 #ifdef MAXPATHLEN
You may also need to configure and build GCC without support for C++ (the script downloaded configures all languages and builds C and C++). Sorry if that's a bit vague - email Olly if you can't work out what to do.

Then you need to build and install the Allegro graphics library:

http://prdownloads.sourceforge.net/alleg/allegro-4.0.3.tar.gz

And follow the instructions for building using a cross-compiler which you can in docs/build/djgpp.txt. In 4.0.3 these boil down to:

cd allegro-4.0.3
./fix.sh djgpp --quick
NATIVEPATH=$PATH
export NATIVEPATH
DJDIR=/usr/i386-pc-msdosdjgpp
export DJDIR
PATH=$DJDIR/bin:$PATH
CROSSCOMPILE=1
export CROSSCOMPILE
make msg lib
make install
PATH=$NATIVEPATH

Building Survex under DOS in a native djgpp environment will require some tinkering. Best bet is either to install bash and use the current configure script, or perhaps simpler to modify miniam.pl to generate a suitable makefile. I'm happy to help if you want to try this, and I'll incorporate patches provided they're fairly clean.

Mingw (Microsoft Windows)

Currently I build this with a Linux hosted cross-compiler. I use the packaged cross-compiler in the debian testing/unstable distribution. You can probably install these on other distributions using alien to convert them to RPMs or similar.

Building on Windows in a native mingw environment will probably require tinkering. Best bet is probably to install bash and use the current configure script. I'm happy to help if you want to try this, and I'll incorporate patches provided they're fairly clean.

MSDOS for 286 and earlier (BorlandC)

Wookey currently builds this with a rather elderly BorlandC++ 3.1. BorlandC++ 5.5 can be downloaded for free, but it appears to only compile to 32 bit code. You can also download TurboC version 2, which might do the job (I've not tried).

You can build a suitable source archive for this version using `make alien_src_zip' on the source distribution on a Unix box (you need to have run `./configure' first). Then unzip the src<version>.zip file produced on the MSDOS machine and run make.bat.

RISC OS

We now build this with Acorn C V5. It will probably still build with Acorn C V4. You also need to get and install OSLib from:

http://www.arcade.demon.co.uk/oslib/homepage.html

You can build a suitable source archive for compiling the RISC OS version by running `make alien_src_zip' on the source distribution on a Unix box (you need to have run `./configure' first). However for this you'll need a specially tweaked version of zip to create the zip file with the correct RISC OS file types. I can supply this on request. You need to put it in the top level of the source tree and call it `zip-magic'.

You'll probably need to use Acorn's Make Utility (`amu') to build - the GNU make 1.02 port doesn't seem up to the job.

To build, create a fresh directory (or empty one) and unpack the contents of srcN_NN.zip into it (using !SparkFS or similar). Then double-click on `!ObeyMe' in the unpacked directory to rename the source files into c and h subdirectories. Then double-click on `!MakeMe' to build survex.