1109998SmarkmThere are two ways to build this code;
2109998Smarkm
3109998Smarkm(1) Manually
4109998Smarkm
5109998Smarkm(2) Using all-singing all-dancing (all-confusing) autotools, ie. autoconf,
6109998Smarkmautomake, and their little friends (autoheader, etc).
7109998Smarkm
8109998Smarkm=================
9109998SmarkmBuilding Manually
10109998Smarkm=================
11109998Smarkm
12109998SmarkmThere is a basic "Makefile" in this directory that gets moved out of the way and
13109998Smarkmignored when building with autoconf et al. This Makefile is suitable for
14109998Smarkmbuilding tunala on Linux using gcc. Any other platform probably requires some
15109998Smarkmtweaking. Here are the various bits you might need to do if you want to build
16109998Smarkmthis way and the default Makefile isn't sufficient;
17109998Smarkm
18109998Smarkm* Compiler: Edit the "CC" definition in Makefile
19109998Smarkm
20109998Smarkm* Headers, features: tunala.h controls what happens in the non-autoconf world.
21109998Smarkm  It, by default, assumes the system has *everything* (except autoconf's
22109998Smarkm  "config.h") so if a target system is missing something it must define the
23109998Smarkm  appropriate "NO_***" symbols in CFLAGS. These include;
24109998Smarkm
25109998Smarkm  - NO_HAVE_UNISTD_H, NO_HAVE_FCNTL_H, NO_HAVE_LIMITS_H
26109998Smarkm    Indicates the compiling system doesn't have (or need) these header files.
27109998Smarkm  - NO_HAVE_STRSTR, NO_HAVE_STRTOUL
28109998Smarkm    Indicates the compiling system doesn't have these functions. Replacements
29109998Smarkm    are compiled and used in breakage.c
30109998Smarkm  - NO_HAVE_SELECT, NO_HAVE_SOCKET
31109998Smarkm    Pointless symbols - these indicate select() and/or socket() are missing in
32109998Smarkm    which case the program won't compile anyway.
33109998Smarkm
34109998Smarkm  If you want to specify any of these, add them with "-D" prefixed to each in
35109998Smarkm  the CFLAGS definition in Makefile.
36109998Smarkm
37109998Smarkm* Compilation flags: edit DEBUG_FLAGS and/or CFLAGS directly to control the
38109998Smarkm  flags passed to the compiler. This can also be used to change the degree of
39109998Smarkm  optimisation.
40109998Smarkm
41109998Smarkm* Linker flags: some systems (eg. Solaris) require extra linker flags such as;
42109998Smarkm  -ldl, -lsocket, -lnsl, etc. If unsure, bring up the man page for whichever
43109998Smarkm  function is "undefined" when the linker fails - that usually indicates what
44109998Smarkm  you need to add. Make changes to the LINK_FLAGS symbol.
45109998Smarkm
46109998Smarkm* Linker command: if a different linker syntax or even a different program is
47109998Smarkm  required to link, edit the linker line directly in the "tunala:" target
48109998Smarkm  definition - it currently assumes the "CC" (compiler) program is used to link.
49109998Smarkm
50109998Smarkm======================
51109998SmarkmBuilding Automagically
52109998Smarkm======================
53109998Smarkm
54109998SmarkmAutomagic building is handled courtesy of autoconf, automake, etc. There are in
55109998Smarkmfact two steps required to build, and only the first has to be done on a system
56109998Smarkmwith these tools installed (and if I was prepared to bloat out the CVS
57109998Smarkmrepository, I could store these extra files, but I'm not).
58109998Smarkm
59109998SmarkmFirst step: "autogunk.sh"
60109998Smarkm-------------------------
61109998Smarkm
62109998SmarkmThe "./autogunk.sh" script will call all the necessary autotool commands to
63109998Smarkmcreate missing files and run automake and autoconf. The result is that a
64109998Smarkm"./configure" script should be generated and a "Makefile.in" generated from the
65109998Smarkmsupplied "Makefile.am". NB: This script also moves the "manual" Makefile (see
66109998Smarkmabove) out of the way and calls it "Makefile.plain" - the "ungunk" script
67109998Smarkmreverses this to leave the directory it was previously.
68109998Smarkm
69109998SmarkmOnce "ungunk" has been run, the resulting directory should be able to build on
70109998Smarkmother systems without autoconf, automake, or libtool. Which is what the second
71109998Smarkmstep describes;
72109998Smarkm
73109998SmarkmSecond step: "./configure"
74109998Smarkm--------------------------
75109998Smarkm
76109998SmarkmThe second step is to run the generated "./configure" script to create a
77109998Smarkmconfig.h header for your system and to generate a "Makefile" (generated from
78109998Smarkm"Makefile.in") tweaked to compile on your system. This is the standard sort of
79109998Smarkmthing you see in GNU packages, for example, and the standard tricks also work.
80109998SmarkmEg. to override "configure"'s choice of compiler, set the CC environment
81109998Smarkmvariable prior to running configure, eg.
82109998Smarkm
83109998Smarkm    CC=gcc ./configure
84109998Smarkm
85109998Smarkmwould cause "gcc" to be used even if there is an otherwise preferable (to
86109998Smarkmautoconf) native compiler on your system.
87109998Smarkm
88109998SmarkmAfter this run "make" and it should build the "tunala" executable.
89109998Smarkm
90109998SmarkmNotes
91109998Smarkm-----
92109998Smarkm
93109998Smarkm- Some versions of autoconf (or automake?) generate a Makefile syntax that gives
94109998Smarkm  trouble to some "make" programs on some systems (eg. OpenBSD). If this
95109998Smarkm  happens, either build 'Manually' (see above) or use "gmake" instead of "make".
96109998Smarkm  I don't like this either but like even less the idea of sifting into all the
97109998Smarkm  script magic crud that's involved.
98109998Smarkm
99109998Smarkm- On a solaris system I tried, the "configure" script specified some broken
100109998Smarkm  compiler flags in the resulting Makefile that don't even get echoed to
101109998Smarkm  stdout/err when the error happens (evil!). If this happens, go into the
102109998Smarkm  generated Makefile, find the two affected targets ("%.o:" and "%.lo"), and
103109998Smarkm  remove the offending hidden option in the $(COMPILE) line all the sludge after
104109998Smarkm  the two first lines of script (ie. after the "echo" and the "COMPILE" lines).
105109998Smarkm  NB: This will probably only function if "--disable-shared" was used, otherwise
106109998Smarkm  who knows what would result ...
107109998Smarkm
108