This document helps you to install the MonetDB source and compile it.
Once succeeded, refer to doc/MonetDB.html for the user documentation
generated as part of the process.

In case you prefer to install a pre-compiled binary distribution, please
check-out http://sourceforge.net/project/showfiles.php?group_id=56967 .

This document assumes that you are planning to compile and install
MonetDB on a native Windows system (NT, 2000, XP). 
For compilation and installation on a Unix system (e.g., Linux, IRIX,
Solaris, AIX, MacOS X/Darwin, or CYGWIN) see the instructions in the
file 'HowToStart'.


Prerequisites:
==============

CVS
	You need to have a working CVS. Several solutions are
	available. We use internally WinCVS (http://www.wincvs.org)
	and CVS under Cygwin (http://www.cygwin.com)
	For general information about the sourceforge repository, see
	http://sourceforge.net/docman/?group_id=1 and look under the
	heading CVS Instructions.  Pointers to CVS implementations 
	for Windows can be found at e.g.:
	http://www.cvshome.org/cyclic/cvs/windows.html
	http://www.wincvs.org/
	http://www.componentsoftware.com/products/CVS/

Python
	MonetDB uses Python (version 2.0.0 or better) during
	configuration of the software.  See http://www.python.org/ for
	more information.

Pthreads for Win32
	(ftp://sources.redhat.com/pub/pthreads-win32/)
	Pthreads should be installed to C:\Pthreads, otherwise you need
	to patch the "PTHREAD = C:\Pthreads" line in "NT\rules.msc"
	according to your setup. Newer versions of Pthreads seem to
	have the "include" & "lib" directory not in C:\Pthreads, but in
	C:\Pthreads\prebuilt. In that case, you either have to move the
	"include" & "lib" directory from C:\Pthreads\prebuilt to 
	C:\Pthreads, or set "PTHREAD = C:\Pthreads\prebuilt" in
	"NT\rules.msc".
	note: MonetDB is known not to compile against the latest 
	Pthreads libraries. Use for instance Pthreads_2003-09-18.

UnxUtils for Win32
	(http://UnxUtils.sourceforge.net/)
	UnxUtils must be installed in the root directory ("\", i.e.,
	without the default "\UnxUtils\" prefix) of the drive where you
	want to compile MonetDB.
	The same drive is required, as the UnxUtils do not know about
	drive letters, and hence absolute paths start with "\" (i.e.,
	without a leading "C:", "D:", ...).  The default "\UnxUtils\"
	prefix has to be omitted, as otherwise the UnxUtils' "bison"
	does not find its own "bison.simple" file, which it expects to
	be in "/usr/share/bison/bison.simple"
	(aka. "\usr\share\bison\bison.simple").
	Next to some tools used by Mtest.py for testing MonetDB (see
	below), UnxUtils provide the lexical analyzer generator "flex"
	and the parser generator "bison", which are required to compile
	MonetDB.
	Note: You have to install the UnxUtils using the original .zip
	file (http://UnxUtils.sourceforge.net/UnxUtils.zip). With the
	third-party executable installer
	(http://www.braindonors.net/products/unxutils.asp), choosing
	another than the default installation directory doesn't seem to
	work...
	
Microsoft Visual C++
	You need Microsoft Visual C++ 5 or higher.

	Notice that if you do not own Microsoft Visual C++, you can
	still compile on Windows using the Cygnus Posix-emulation
	environment "CYGWIN" (http://www.cygwin.com). In that case, you
	should follow the standard instructions in the file
	'HowToStart'. Alternatively, it might be possible to use the
	free WIN32-GNU compilers (http://www.mingw.org/index.shtml) as a
	drop-in replacement for the Microsoft tools, but we have not
	tried this yet.

disk space
	After downloading, MonetDB takes up about 40 MB of disk space;
	compilation adds another 70 MB.  Testing takes about 45 MB, and
	the installation about 20 MB (not including any databases).


Optional Software:
==================

PHP
	Download both the Windows binaries in a zip package (i.e. not
	the Windows installer) and the source package from
	http://www.php.net/.  Unzip the binaries into e.g. C:\ (for
	PHP-4, the zip file contains a top-level directory
	php-4...-Win32 and so can be unzipped into C:).  If you want
	to follow the PHP standard, rename the resulting dirctory to
	C:\php4.  We will follow this convention.  In any case, make
	sure there are no spaces in the path chosen.
	Also extract the sources somewhere, e.g. in a directory
	parallel to MonetDB.
	If you don't use C:\php4 for the binaries or you don't extract
	the sources into php-4.3.11 in the same directory where
	MonetDB is extracted, you will have to edit MonetDB's
	NT\rules.msc to change the variables PHP_SRCDIR and
	PHP_INSTDIR to reflect this.  Make sure there are no spaces in
	these two path names.  Also note that the paths are only used
	from inside the NT\src\mapi\clients\php directory, so if they
	are relative, they have to be relative from there.
	When compiling MonetDB, add the flag HAVE_PHP=1 to the nmake
	command line.
	Note that only PHP version 4.3.11 has been tested.

Pear:
	Pear is the PHP Extension and Application Repository.  At the
	MonetDB side of things, nothing more than what is described
	for PHP needs to be done.  PEAR support is automatically
	enabled.

Java:
	The Java SDK (JDK) can be found at http://java.sun.com/.
	After installing, make sure that the directory with java.exe
	and javac.exe are in your PATH environment variable, and then
	compile MonetDB with the additional flag HAVE_JAVA=1 on the
	nmake command line.

Getting the Software:
=====================

This command should be done once.  It records a password on the local
machine to be used for all subsequent CVS accesses with this server.

 cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/monetdb login

Just type RETURN when asked for the password. The actual steps depend on
your CVS tool, e.g. in WinCVS you have to set the Admin preferences.
Then get the software by using the command:

 cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/monetdb checkout MonetDB

This will create a directory MonetDB in your current working directory.

Also see http://sourceforge.net/cvs/?group_id=56967 for more
information.


Compiling:
==========
Open a Windows command shell or a UnxUtils shell and go to the 
top-level directory of MonetDB.

Make sure that the proper environment for MSVC++ is set,
otherwise call the corresponding BAT file.
(see C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT).

Make sure that Python, C:\Pthreads\lib (or wherever you installed
Pthreads), and \usr\local\wbin are in the PATH of your command shell.

When all prerequisites have been satisfied, you type

 cd NT
 nmake

to compile the source code.


Testing the Build:
==================

If nmake went successfully, you can try

 nmake check

This will do a lot of tests, some are unfortunately still expected to
fail, but most should go successfully.  At the end of the output there
is a reference to an HTML file which is created by the test process and
shows the test results.  An explanation of the test results can be found
in XXX--to be filled in.

Testing takes about 46 MB of disk space in the build directory.


Installing:
===========

Give the command

 nmake install

By default this will install MonetDB to <sourcedir>\NT\ where
<sourcedir> is the top-level directory of MonetDB source tree.
The current version does not provide any means to change this default.


Testing the Installation:
=========================

Make sure that <sourcedir>\NT\bin, <sourcedir>\NT\lib, and
<sourcedir>\NT\lib\MonetDB are in your PATH.

In the MonetDB top-level directory issue the command

 Mtest.py -r

(Make sure Mtest.py can be found, it should be in the bin directory that
was filled by the nmake install command.)

This should produce much the same output as nmake check above, but uses
the installed version of MonetDB.


Usage:
======

There are two alternatives to use MonetDB interactively.
In both cases, you first need to make sure, that your environment is set as
described in "Configure and Make" and "Testing the Installation" above.

If you're "in a hurry", you can then simply start

 Mserver

an you get the "server console", where you can type you MIL commands.
Please, that the server console is mainly meant for administrative use, hence
there are no conveniences such as commandline editing or command history.

For a more convenient MIL interface, you should use the "MapiClient" with
the Mserver. To do so, first start an Mserver with MAPI (MonetDB Application
Programmer's Interfaces) support as follows:

 Mserver --dbinit="module(mapi); mapi_start();"

Then, in a second shell, set up the same environment and start the
MapiClient:

 MapiClient

With MapiClient, you get a text-based MIL interface that supports
commandline editing and a commandline history. The latter can even be stored
persistently to be re-used after stopping and restarting MapiClient; see

 MapiClient --help

for details.


Documentation:
==============

The documentation starts in <sourcedir>\NT\doc\MonetDB.html

NOTE: the current 'nmake install' does not yet generate this
      documentation to do this manually, execute *after* successful
      'nmake install'. In the top-level directory of the MonetDB build
      tree, call

 nmake docs

