Compiling a TOM Program

This document will guide you through building your first TOM program. The source to this program is short and easy to type. If, however, you don't feel like typing, copy the files hello.t and GNUmakefile from one of the following places into an empty directory, possibly called hello:

This is the source to the `Hello, world!' program when written in TOM. If you didn't copy the source files, enter it into a file called hello.t into a preferrably empty directory (and make that directory your current directory).

hello.t:
implementation class
HelloWorld

/* The main method (starts a program).  */
int
  main Array arguments
{
  [[[stdio out] print "Hello, world!"] nl];

  = 0;
}

end;

/* We don't need instances of HelloWorld, so this definition (which must
   be present) can be empty.  */
implementation instance HelloWorld end;
For a step-by-step explanation of what exactly this program does (if it is not obvious), see the section `Getting Started' in (WWW link) the TOM Programming Language. For now, we're only interested in creating a working executable program from this source.

When writing your own TOM program, you'll probably always want to use the TOM makefiles, since they can take care of the details of compilation. Make sure your hello directory contains a file called GNUmakefile (which is a makefile for GNU make), with the following contents (the prefix and exec_prefix might need to be adjusted if you started with the GNUmakefile.in from the TOM WWW site):

GNUmakefile:
# makefile for TOM hello.
# Administrativia on where to find the TOM makefiles.
prefix=			/usr
exec_prefix=		/usr
tomdir=			$(exec_prefix)/tom
TOM_MAKEFILES_DIR=	$(tomdir)/makefiles

# Name of the program that will be built.
UNIT=			hello

# The program consists of one file: hello.t.
TOM_SRC=		hello

include $(TOM_MAKEFILES_DIR)/GNUmakefile.bin
For an explanation of the macro's in a TOM makefile, see the TOM makefiles.

To compile this example program, type make (or gnumake or gmake or whatever GNU make is called at your site). If all goes well, this will create an executable named hello. Run it:

$ ./hello
Hello, world!
You are now ready to hack in TOM.
Up: TOM local documentation.
Related: TOM makefiles.
Further reading: (WWW link) pointers all TOM documentation.
Visit TOM on the WWW at http://www.gerbil.org/tom/
Pieter Schoenmakers <tiggr@gerbil.org>
$Id: introduction.html.in,v 1.4 1998/02/14 22:42:53 tiggr Exp $