Commit 3866752e authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

- New INSTALL document describing different ways to build "tunala" and

  possible problems.
- New file breakage.c handles (so far) missing functions.
- Get rid of some signed/unsigned/const warnings thanks to solaris-cc
- Add autoconf/automake input files, and helper scripts to populate missing
  (but auto-generated) files.

This change adds a configure.in and Makefile.am to build everything using
autoconf, automake, and libtool - and adds "gunk" scripts to generate the
various files those things need (and clean then up again after). This means
that "autogunk.sh" needs to be run first on a system with the autotools,
but the resulting directory should be "configure"able and compilable on
systems without those tools.
parent 3e3dac9f
Loading
Loading
Loading
Loading

demos/tunala/INSTALL

0 → 100644
+119 −0
Original line number Original line Diff line number Diff line
There are two ways to build this code;

(1) Manually

(2) Using all-singing all-dancing (all-confusing) autotools, ie. autoconf,
automake, libtool, and their little friends (autoheader, etc).

=================
Building Manually
=================

There is a basic "Makefile" in this directory that gets moved out of the way and
ignored when building with autoconf et al. This Makefile is suitable for
building tunala on Linux using gcc. Any other platform probably requires some
tweaking. Here are the various bits you might need to do if you want to build
this way and the default Makefile isn't sufficient;

* Compiler: Edit the "CC" definition in Makefile

* Headers, features: tunala.h controls what happens in the non-autoconf world.
  It, by default, assumes the system has *everything* (except autoconf's
  "config.h") so if a target system is missing something it must define the
  appropriate "NO_***" symbols in CFLAGS. These include;

  - NO_HAVE_UNISTD_H, NO_HAVE_FCNTL_H, NO_HAVE_LIMITS_H
    Indicates the compiling system doesn't have (or need) these header files.
  - NO_HAVE_STRSTR, NO_HAVE_STRTOUL
    Indicates the compiling system doesn't have these functions. Replacements
    are compiled and used in breakage.c
  - NO_HAVE_SELECT, NO_HAVE_SOCKET
    Pointless symbols - these indicate select() and/or socket() are missing in
    which case the program won't compile anyway.

  If you want to specify any of these, add them with "-D" prefixed to each in
  the CFLAGS definition in Makefile.

* Compilation flags: edit DEBUG_FLAGS and/or CFLAGS directly to control the
  flags passed to the compiler. This can also be used to change the degree of
  optimisation.

* Linker flags: some systems (eg. Solaris) require extra linker flags such as;
  -ldl, -lsocket, -lnsl, etc. If unsure, bring up the man page for whichever
  function is "undefined" when the linker fails - that usually indicates what
  you need to add. Make changes to the LINK_FLAGS symbol.

* Linker command: if a different linker syntax or even a different program is
  required to link, edit the linker line directly in the "tunala:" target
  definition - it currently assumes the "CC" (compiler) program is used to link.

======================
Building Automagically
======================

Automagic building is handled courtesy of autoconf, automake, and libtool. There
is in fact two steps required to build, and only the first has to be done on a
system with these tools installed (and if I was prepared to bloat out the CVS
repository, I could store these extra files, but I'm not).

First step: "autogunk.sh"
-------------------------

The "./autogunk.sh" script will call all the necessary autotool commands to
create missing files and run automake and autoconf. The result is that a
"./configure" script should be generated and a "Makefile.in" generated from the
supplied "Makefile.am". NB: This script also moves the "manual" Makefile (see
above) out of the way and calls it "Makefile.plain" - the "ungunk" script
reverses this to leave the directory it was previously.

Once "ungunk" has been run, the resulting directory should be able to build on
other systems without autoconf, automake, or libtool. Which is what the second
step describes;

Second step: "./configure"
--------------------------

The second step is to run the generated "./configure" script to create a
config.h header for your system and to generate a "Makefile" (generated from
"Makefile.in") tweaked to compile on your system. This is the standard sort of
thing you see in GNU packages, for example, and the standard tricks also work.
Eg. to override "configure"'s choice of compiler, set the CC environment
variable prior to running configure, eg.

    CC=gcc ./configure

would cause "gcc" to be used even if there is an otherwise preferable (to
autoconf) native compiler on your system.

*IMPORTANT* It's highly recommended to pass "--disable-shared" to the configure
script. Otherwise, libtool may elect to build most of the code as a
shared-library, hide various bits of it in dotted directories and generating
wrapper scripts in place of the linked binary. The autotool stuff, when "make
install" is run (which you probably won't want to do for this dinky little
thing) will unravel all that mess and either install a small executable +
shared-lib or will install a linked executable. Passing the above flag ensures
this is all done statically even if the platform supports building and using
shared-libraries. Ie;

    ./configure --disable-shared

After this run "make" and it should build the "tunala" executable.

Notes
-----

- Some versions of autoconf (or automake?) generate a Makefile syntax that gives
  trouble to some "make" programs on some systems (eg. OpenBSD). If this
  happens, either build 'Manually' (see above) or use "gmake" instead of "make".
  I don't like this either but like even less the idea of sifting into all the
  script magic crud that's involved.

- On a solaris system I tried, the "configure" script specified some broken
  compiler flags in the resulting Makefile that don't even get echoed to
  stdout/err when the error happens (evil!). If this happens, go into the
  generated Makefile, find the two affected targets ("%.o:" and "%.lo"), and
  remove the offending hidden option in the $(COMPILE) line all the sludge after
  the two first lines of script (ie. after the "echo" and the "COMPILE" lines).
  NB: This will probably only function if "--disable-shared" was used, otherwise
  who knows what would result ...
+3 −3
Original line number Original line Diff line number Diff line
@@ -11,14 +11,14 @@ RM=rm -f
CC=gcc
CC=gcc
DEBUG_FLAGS=-g -ggdb3 -Wall -Wshadow
DEBUG_FLAGS=-g -ggdb3 -Wall -Wshadow
INCLUDE_FLAGS=-I$(SSL_INCLUDEDIR)
INCLUDE_FLAGS=-I$(SSL_INCLUDEDIR)
CFLAGS=$(DEBUG_FLAGS) $(INCLUDE_FLAGS)
CFLAGS=$(DEBUG_FLAGS) $(INCLUDE_FLAGS) -DNO_CONFIG_H
COMPILE=$(CC) $(CFLAGS) -c
COMPILE=$(CC) $(CFLAGS) -c


# Edit, particularly the "-ldl" if not building with "dlfcn" support
# Edit, particularly the "-ldl" if not building with "dlfcn" support
LINK_FLAGS=-L$(SSL_LIBDIR) -lssl -lcrypto -ldl
LINK_FLAGS=-L$(SSL_LIBDIR) -lssl -lcrypto -ldl


SRCS=buffer.c cb.c ip.c sm.c tunala.c
SRCS=buffer.c cb.c ip.c sm.c tunala.c breakage.c
OBJS=buffer.o cb.o ip.o sm.o tunala.o
OBJS=buffer.o cb.o ip.o sm.o tunala.o breakage.o


TARGETS=tunala
TARGETS=tunala


+11 −0
Original line number Original line Diff line number Diff line
# Our includes come from the OpenSSL build-tree we're in
INCLUDES		= -I$(top_builddir)/../../include

lib_LTLIBRARIES		= libtunala.la

libtunala_la_SOURCES	= buffer.c cb.c ip.c sm.c breakage.c

bin_PROGRAMS		= tunala

tunala_SOURCES		= tunala.c
tunala_LDADD		= libtunala.la -L$(top_builddir)/../.. -lssl -lcrypto
+8 −10
Original line number Original line Diff line number Diff line
@@ -188,20 +188,16 @@ flags inside the Makefile. Likewise, if you want to tweak the building, it's
best to try and do so in the makefile (eg. removing the debug flags and adding
best to try and do so in the makefile (eg. removing the debug flags and adding
optimisation flags).
optimisation flags).


Secondly, this code so far has only ever been built and run on Linux - network
Secondly, this code has mostly only been tested on Linux. However, some
specifics are more than likely to create little glitches on other unixen,
autoconf/etc support has been added and the code has been compiled on openbsd
particularly Solaris in my experience. If you're not on Linux, please read the
and solaris using that.
code wherever compilation flares up and try to make the necessary changes -
usually the man-page associated with the relevant function is enough (eg. all
that AF_INET/PF_INET stuff, subtlely different parameters to various
IPv4-related functions like socket(), bind(), fcntl(), etc).


Thirdly, if you are Win32, you probably need to do some *major* rewriting of
Thirdly, if you are Win32, you probably need to do some *major* rewriting of
ip.c to stand a hope in hell. Good luck, and please mail me the diff if you do
ip.c to stand a hope in hell. Good luck, and please mail me the diff if you do
this, otherwise I will take a look at another time. It can certainly be done,
this, otherwise I will take a look at another time. It can certainly be done,
but it's very non-POSIXy.
but it's very non-POSIXy.


Type make.
See the INSTALL document for details on building.


Now, if you don't have an executable "tunala" compiled, go back to "First,...".
Now, if you don't have an executable "tunala" compiled, go back to "First,...".
Rinse and repeat.
Rinse and repeat.
@@ -217,8 +213,10 @@ In another console, type;
              -cert A-server.pem -server 1 -out_totals -v_peer -v_strict
              -cert A-server.pem -server 1 -out_totals -v_peer -v_strict


Now if you open another console and "telnet localhost 8080", you should be
Now if you open another console and "telnet localhost 8080", you should be
tunneled through to the telnet service on your local machine. Feel free to
tunneled through to the telnet service on your local machine (if it's running -
experiment :-)
you could change it to port "22" and tunnel ssh instead if you so desired). When
you logout of the telnet session, the tunnel should cleanly shutdown and show
you some traffic stats in both consoles. Feel free to experiment. :-)


Notes:
Notes:


+25 −0
Original line number Original line Diff line number Diff line
#!/bin/sh

# This script tries to follow the "GNU way" w.r.t. the autobits.
# This does of course generate a number of irritating files.
# Try to get over it (I am getting there myself).

# This should generate any missing crud, and then run autoconf which should turn
# configure.in into a "./configure" script and "Makefile.am" into a
# "Makefile.in". Then running "./configure" should turn "Makefile.in" into
# "Makefile" and should generate the config.h containing your systems various
# settings. I know ... what a hassle ...

# Also, sometimes these autobits things generate bizarre output (looking like
# errors). So I direct everything "elsewhere" ...

(aclocal
autoheader
libtoolize --copy --force
automake --foreign --add-missing --copy
autoconf) 1> /dev/null 2>&1

# Move the "no-autotools" Makefile out of the way
if test ! -f Makefile.plain; then
	mv Makefile Makefile.plain
fi
Loading