HOW TO COMPILE AND INSTALL GCC4TI FROM SOURCE
============================================

Please note: read README.linux first. The instructions below apply only to
compiling and installing the whole package from source. I recommend installing
from binaries if possible.


REQUIREMENTS
------------

You must have the following programs AND sources before you attempt
to install gcc4ti-unix.

REQUIRED:
	1. GNU GCC 2.95 or later (other compilers might work, but are NOT supported)
	   GNU GCC cross-compilers are supported.

	2. GNU binutils (ld, ar, as, etc.) 2.8 or later.
	   Other binutils might work, but are NOT supported.

	3. GNU or BSD patch (Solaris patch will NOT work)

	4. bzip2 (to decompress this archive)

	5. tar (all of GNU, BSD and Solaris tar seem to be OK)

	6. GNU make (Solaris make will NOT work)

	7. GNU or BSD install (Solaris install will NOT work)

	8. At least 130 MB of free space (archive expands to over 80,
	   build can take another 30-40 depending upon architecture)

	9. bison or yacc

	10. flex

	11. GNU GCC 4.1.2 and GNU binutils 2.16.1 _sources_, which are used
	    for compiling gcc and as for m68k-coff target.
	    You'll need to download them from one of the numerous GCC / binutils
	    mirrors listed at http://gcc.gnu.org/mirrors.html, e.g.
	    ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.1.2/gcc-core-4.1.2.tar.bz2
	    ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/binutils/releases/binutils-2.16.1.tar.bz2
	    (DON'T use gcc-4.1.2.tar.bz2, i.e. the full version: it may fail to compile !)

OPTIONAL:
	12. Windows or Wine to compile the documentation from source
	    (optional: the source distribution includes pre-generated HTML
	    documentation)

	13. Wine or equivalent + binfmt-support with Wine registered, when
	    cross-compiling, under a *nix host, executables running on Windows
	    platforms. Without this (or something equivalent), `configure`
	    aborts early, because the *nix host cannot run Windows executables.

If you run into any problems, please contact us (tigccpp AT box.godzil.net) 
and let us know what platform you're running on, and where the install failed.

Depending on your machine, compilation can take some time !


INSTALLING GCC4TI FOR UNIX
-------------------------

The installation should be very simple. The package has worked on Ubuntu 9.04,
Fedora 8, Fedora 11, SimplyMEPIS 8 (very close to Debian Lenny), OpenSolaris
2009.06, FreeBSD 7.2. UN*X provides some things better, some things worse.
Let us know if you have a problem with the worse...

NOTE: the GCC4TI scripts can handle paths containing spaces, but the `configure`
in binutils 2.16.1 and gcc 4.1.2 cannot. Don't use spaces either in the path
where you decompress the GCC4TI source distribution or in the target PATH ($TIGCC).

First, extract the source to a directory of your choosing such as /tmp.

	mkdir /tmp/gcc4ti-src
	cd /tmp/gcc4ti-src
	# substitute the directory you are using for /tmp
	bunzip2 gcc4ti-src.tar.bz2
	tar xfv gcc4ti-src.tar

Then, copy or link binutils-2.16.1 and gcc-core-4.1.2.tar.bz2 in that folder.

At this point, you have 2 options:


1. Use the installation wizard
------------------------------

All you need to do now is:
	scripts/Install
and follow the instructions. If you want a text-mode install on a system with
KDE installed, you can use:
	cd scripts; DIALOG=dialog ./Install
to tell the script to use the text-mode (curses) dialog instead of kdialog.

You will be prompted for:
* the destination directory you want to install GCC4TI to ($PREFIX_GCC4TI,
  used only internally during the compilation stage: will become $TIGCC when the
  build is finished)
* the bootstrap compiler ($CC) you want to compile GCC4TI with (usually "gcc",
  unless you're cross-compiling, e.g. with "i586-mingw32msvc-gcc").
* the optimization flags ($CFLAGS) you want to compile GCC4TI with (read the GCC
  documentation or just use the defaults)
* the host platform of the generated executables ($GCC4TIHOST), leave blank if
  not cross-compiling. "i586-mingw32msvc" is a value that suits well when
  CC=i586-mingw32msvc-gcc.

The wizard will ask you whether you want to apply the GCC4TI patch. The answer is
usually "Yes". It will be "No" only if you are rebuilding the same source for a
second (or more) time.

When done, the wizard will ask you whether you want to add your $TIGCC setting
to bashrc. If you answer "Yes", you are done here, you only need to restart
bash. If you prefer to do things by hand, answer "No" and follow the
instructions in section 2.1 below. (If you selected "No", but changed your mind,
you can also run envreg by hand afterwards.)

2. Use the install scripts directly
-----------------------------------


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WARNING: below, a number of places mention appending $TIGCC/bin to the path.
We _really_ mean appending. This is because $TIGCC/bin contains "gcc" and "as" for
m68k-coff target, and if $TIGCC/bin appears before /usr/bin in the PATH, the "gcc"
and "as" in $TIGCC/bin would be used instead of the host system's executables...
This is definitely not what you want.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


2.1. Environment variable settings
----------------------------------

Now, set the environment variable PREFIX_GCC4TI to the directory you want to
install GCC4TI into (for example /usr/local/share/gcc4ti). This variable is
used only during the compilation stage, so as not to interfere with any
prior user-defined setting for the TIGCC environment variable (which is used
_after_ the compilation stage).

If you use bash, add it to your .bashrc file in your home directory. You could
also use your .profile or .login if you have those. If you use tcsh or csh, put
it in your .cshrc file (or if you use .tcshrc, put it there).

I've never used korn shell. You're on your own if you do.

For bash/sh users

	export PREFIX_GCC4TI=/usr/local/share/gcc4ti
	export PATH=$PATH:$PREFIX_GCC4TI/bin

For csh/tcsh users

	setenv PREFIX_GCC4TI /usr/local/share/gcc4ti
	set path=($path $PREFIX_GCC4TI/bin)

I've had problems using setenv to reset the path in tcsh.
setenv path "$path ${PREFIX_GCC4TI}/bin"
doesn't seem to work.

You may need to logout and log back in for that to take
effect. Or you can resource your profile.

	source ~/.profile
	source ~/.bashrc
	source ~/.cshrc
	source ~/.tcshrc

You only need to resource the file you changed.

2.2. Installation
-----------------

The hard part should be over. Now, just change into the directory
you extracted GCC4TI into

	cd /tmp/gcc4ti-src

Optionally, you can now rebuild the HTML documentation from source: the required
source code is in tigcclib/doc/source.tar.bz2 in your source tree. See the last
section below for instructions to compile the documentation. Note that the tools
to compile the documentation from source are for Windows only, so you will need
Windows or WINE if you want to build the documentation from source. Unless of
course you manage to port the Delphi sources of those tools yourself.
Note that it comes precompiled, so you need not do this. (As for platform-
independence: the documentation is "compiled" into platform-independent HTML
files, so compiling it from source should usually not be necessary.)

And run the installation script...

	export CFLAGS='-Os -s'

If cross-compiling or using another custom compiler for some reason, set the
CC and GCC4TIHOST environment variables, e.g.
	export CC=i586-mingw32msvc-gcc
	export GCC4TIHOST=i586-mingw32msvc

Then launch the installation procedure.
	cd scripts; ./Install_All

Assuming you have all the required tools, you should have yourself
a GCC4TI build (except the Delphi executables) in 5 - 60 minutes.

I hope this installation goes smoothly for you.

2.3. ALTERNATE WAY for installation
-----------------------------------

The following is the "hard" way to do step 2.2. It is used primarily for
development purposes. You can use this if you experience some problems with
the automated script.

At first, you will have to register a variable depending on the location you
want to install GCC4TI

	export PREFIX_GCC4TI=/usr/local/share/gcc4ti
	export PATH=$PATH:$PREFIX_GCC4TI/bin
	export CFLAGS='-Os -s'

Next, simply go into the scripts directory.
Then you must apply the patch supplied with this package:

	./Install_step_1

If cross-compiling or using another custom compiler for some reason, set the
CC and GCC4TIHOST environment variables, e.g.
	export CC=i586-mingw32msvc-gcc
	export GCC4TIHOST=i586-mingw32msvc

Next, compile binutils and gcc. This may take a while...

	./Install_step_2

If everything went correctly, you now should have a working GCC4TI for Linux
compiler. For installing the TIGCC library, simply launch:

	./Install_step_3

If you want to be able to use the tigcc front-end and tprbuilder, you should
append (not prepend !) $PREFIX_GCC4TI/bin to your PATH.

You need the TI-68k Developer Utilities (several are required for using the
tigcc front-end, most others are useful, well, utilities). Simply do:

	./Install_step_4

At last, you have to install the full documentation by

	./Install_step_5


REBUILDING THE DOCUMENTATION FROM ITS TRUE SOURCE (REQUIRES WINDOWS)
--------------------------------------------------------------------

This section is lifted from Sebastian's Readme.txt accompanying the Windows
source release. Note that the Linux/Unix source release includes pre-generated
HTML documentation, so you only need to rebuild it if you modify the hs? files.

First, modify the file HelpSystem.ini in the 'Programs' subfolder of the
'Doc' folder to reflect your actual folder names. It exists so that the
'Programs' folder can reside at any given place on the hard disk.
Then, you need to call all 'Update...' programs once.

UpdateInclude.exe and UpdateInfo.exe take one or more complete file name(s)
as parameters. The actual names of the files are discarded, and the remaining
folder name is the folder to be updated. If the first parameter is '/ALL' or
no parameters are specified, all folders are updated, and in case of
UpdateInclude.exe, a header file index is generated.

UpdateKeywords.exe and UpdateIndex.exe do not take any parameters.

To compile the documentation, download the HTML Help Workshop from
http://msdn.microsoft.com. Then compile the project in the 'System\CHMFiles'
folder.

Tools to make editing help system files more convenient are also included in
this distribution.

A tools to create help system files from the original GNU Texinfo documents
is included as well, but it might need a recompilation to work with future
versions of the documentation. Anyway, the .texi files should be in the
current directory, and you should specify one of them in the command line.
The appropriate subfolders need to exist (e.g. gnuexts).

If you need detailed information about the file formats, look at the
Readme.txt file in the documentation folder.

When done with building the CHM documentation, you can convert it to the QT
assistant format using my converters:
cd srcdir/doc/converter # substitute the directory you are using for srcdir
gcc -Os -s -Wall -W -Wwrite-strings chm2dcf.c -o chm2dcf # compile chm2dcf
cd ../html
../converter/chm2dcf # convert the CHM to a Documentation Content File (DCF)
../converter/dcf2adp # convert the DCF to an Assistant Document Profile (ADP)
(There is also a script called updatedoc to automate the copying and
converting of the documentation.)
WARNING: chm2dcf is slow (several minutes on a Core 2 @ 2 GHz).
