Fix bug #203: install to temporary location with DESTDIR.

Attempting to install Mercury into a temporary location, with DESTDIR
set, would:

- wrongly install libatomic_ops into DESTDIR

- be unable to install library grades because the installed mmc script
  expects files in their final locations, without the DESTDIR prefix.

Thanks to Jeremy Huddleston and Nikolay Orlyuk for reporting the bug,
and an earlier version of this patch.

Mmakefile:
	Override MERCURY_COMPILER and MERCURY_CONFIG_DIR when installing
	library grades.

boehm_gc/build_atomic_ops.sh:
	Clear DESTDIR so that libatomic_ops is installed into the
	boehm_gc directory, as intended.
Add a `pregen' grade component.

Add a `pregen' grade component and associated option `--pregenerated-dist',
intended for use in the pre-generated C files in the source distribution
ONLY.

Traditionally, by forcing the use of 2 tag bits and boxed floats, we
could provide one set of pre-generated C files, nominally targeting
32-bit platforms but also working on 64-bit platforms.
This became insufficient after I made two data representation changes.
The same constructor may have different layouts of its arguments
for --bits-per-word=32 and --bits-per-word=64:

  - double-precision `float' arguments can be stored across two
    words on 32-bit, whereas only one word is required on 64-bit;

  - consecutive enum arguments can be packed into a single word
    but the number of arguments that can be packed differs.

As a result, data structures created in a user module could be
misinterpreted when passed to a pre-generated standard library module,
and vice versa.  (The enum case probably does not occur in practice.)

The solution adopted here is to allow configure to detect normal 64-bit
settings (3 tag bits, unboxed floats) irrespective of whether a usable
Mercury installation already exists.  When present, the `pregen' grade
component causes the compiler and scripts to override the configuration
and enforce settings for portable C source files.  The source
distribution should supply C source files from a `pregen' grade.

During installation, if required, the pre-generated C source files are
used to build and install a Mercury compiler _in a .pregen grade_.
Then it is used to install the libraries _in non-.pregen grades_,
so that configured settings have their usual effect.

Another benefit is that a user on a 64-bit system will get the "optimal"
installation using 3 tag bits and unboxed floats without additional
effort.

A small disadvantage is that a minimal installation of Mercury takes
slightly longer, as the default library grade no longer comes from the
pre-generated C source files.

compiler/options.m:
	Add `--pregenerated-dist' option (same as `pregen' grade component).

	Add `--arg-pack-bits <n>' internal option.
	`--allow-argument-packing' is obsolete.

	Add `--allow-double-word-fields' internal option.

compiler/handle_options.m:
	Add `pregen' grade component.  `pregen' implies boxed floats and
	`spf' (single-prec float) implies unboxed floats, so we consider
	them incompatible.  There should be no need to use both at once.

	In `pregen' grades, override settings to create portable C
	source files.

	Handle the internal `--arg-pack-bits <n>' option.

compiler/make_hlds_passes.m:
	Pack only as many consecutive arguments as will fit into the
	number of bits specified by `--arg-pack-bits', rather than into
	the number of word bits.  `pregen' implies --arg-pack-bits=32

	Use `--allow-double-word-fields' to decide whether to store
	floats across two words.  `pregen' disables it.

compiler/compile_target_code.m:
	Define MR_PREGENERATED_DIST when compiling C files in a `pregen'
	grade.

compiler/c_util.m:
	Write PREGENERATED_DIST={yes,no} into the grade info header at
	the top of C files.  This is checked by configure.

runtime/mercury_conf_param.h:
	Make MR_PREGENERATED_DIST force the same settings as the
	`--pregenerated-dist' option.

runtime/mercury_grade.h:
	Add "_pregen" to the MR_GRADE macro so that `pregen' and
	non-`pregen' object files are not accidentally mixed.

configure.ac:
	As above, do NOT force 2 tag bits and unboxed floats when there
	is no usable Mercury compiler installed.

	BOOTSTRAP_GRADE is now a grade containing `.pregen'.

	Make a minimal installation install $BEST_GRADE_FOR_COMPILER as
	the default grade, not the grade that the compiler happens to be
	built in, which might be a `pregen' grade.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
	Support `pregen' grade component and `--pregenerated-dist'
	in shell scripts.

tools/test_mercury:
	Add a note.
Avoid a configure script problem with MinGW64.

configure.ac:
	Make a configure check more specific: we should not
	attempt to link against libpthread just because $host
	matches  "*mingw*".  That doesn't (currently) work
	for x86_64-w64-mingw32.
Fix a problem with the valid/impure_detism test case.

GCC was emitting warnings about excess elements in structure initializers for
the above test.  The problem was that some #ifdefs were missing from the
initializers generated for MR_ProcStatic structures.  This meant that they did
not necessarily match the definition given for that structure in the runtime.

compiler/layout_out.m:
    Include the appropriate #ifdef guards for fields that only exist
    when MR_DEEP_PROFILING_COVERAGE is defined.
Avoid warnings from mmake in the tests directory.

tests/Mmmake.common:
    Delete a left-over reference the the TARGET_ASM variable.
Shift common code out of a switch.

compiler/layout_out.m:
    Respond to review comments from Paul.
Avoid GCC warnings in runtime on 64-bit Windows.

runtime/mercury_debug.c:
runtime/mercury_memory_zones.c:
runtime/mercury_wrapper.c:
   Fix some spots that assumed the machine word size is
   <= sizeof(long).  This is not true on 64-bit Windows.
Avoid more GCC warnings in the runtime on 64-bit Windows.

runtime/mercury_ml_expand_body.h:
	Fix another spot where we are incorrectly assuming that
	the machine word size is <= sizeof(long).

runtime/mercury_debug.c:
runtime/mercury_memory_zones.c:
runtime/mercury_wrapper.c:
	s/MR_WORD_TYPE/MR_Integer/ in my last change.
Fix int.{min,max}_int/0 on Windows 64.

library/int.m:
    On 64-bit Windows MR_Integer has the same size as C's long long type; the
    implementations of int.{min,max}_int/0 did not handle this case.
Avoid warnings in high-level C runtime with MinGW64.

runtime/mercury_conf_param.h:
    On MinGW64, define the macro __USE_MINGW_ANSI_STDIO.
    This avoids problems with incomplete (i.e. broken) support
    for long long format specifiers in formatted I/O functions
    in Microsoft's C library.
Fix float.float64_bits_string/1 on MinGW64.

library/float.m:
     Use the appropriate conversion specifier for
     MR_int_least64_t on MinGW64 in a spot.

runtime/mercury_conf_param.h:
     Define MR_MINGW64 on MinGW64 systems.
Avoid using sleep() in trace library on MinGW64.

The standard autoconf tests report that the sleep function is available on
MinGW64.  It isn't and we currently get a warning about an implicitly declared
function in the trace directory.   What is happening here is that the function
is not officially supported, and hence not in the library headers, but a symbol
corresponding to is exported from somewhere in the standard library.  (This is
what had happened last time something similar occurred on MinGW.)

The fix is to tell configure that sleep is not available on *mingw* and use
Sleep instead.

configure.ac:
     Don't attempt to use the function sleep on MinGW.
Workaround a C stack overflow on MinGW64.

The hlc.gc version of the Mercury compiler exhausts the C stack while compiling
the standard library.  This is because the default size of the C stack on
Windows is ridiculously low.

compiler/Mmakefile:
    On the x86_64-w64-mingw32 architecture, bump the default size
    of the C stack up to something more reasonable.

    XXX in the long term, i.e. when we support 64-bit MSVC, we
    should add a --stack option to the ml script and use that.
    (The above is specific to GCC.)
Fix a build problem on Mac OS X.

library/int.m:
    LLONG_{MIN,MAX} are the standard (C99) names for the limits
    of the long long int type; use them in preference to LONG_LONG_{MIN,MAX},
    which are a GNU C thing.

    Make the use of the above macros conditional on them actually being
    defined since we cannot guarantee that they will be defined if the
    C compiler is not in C99 mode (or something similar to it).
Clean up a file created by the bootcheck script.

scripts/Mmakefile:
     During a realclean delete the file test_mdbrc if
     it is present.
Output a newline after --output-{libgrades,cflags}.

compiler/mercury_compile.m:
    As above.
Fix errors in the bootcheck script.

tools/bootcheck:
	Fix a typo: s/MDCOMP/MDBCOMP/

	Don't copy or link files that no longer exist
	into the stage 2 dir.
Avoid a problem with the bootcheck script on MinGW/MSYS.

tools/bootcheck:
	Avoid building the dependencies in the slice directory
	in parallel since it doesn't work correctly at -j2
	on MSYS.
Fix the namespace cleanliness check on MinGW64.

configure.ac:
	Check for the host specific version of the nm tool.
	For MinGW64 we need to use the MinGW64 version, not
	the MinGW32 version (i.e. x86_64-w64-mingw32-nm, not
	nm).

Mmake.common.in:
	Use the host specific version of the nm tool to list
	external symbols in object files.
Update the list of reserved macro names.

browser/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
mdbcomp/RESERVED_MACRO_NAMES:
runtime/RESERVED_MACRO_NAMES:
ssdb/RESERVED_MACRO_NAMES:
trace/RESERVED_MACRO_NAMES:
	Ignore the __USE_MINGW_ANSI_STDIO macro which we
	need to define on MinGW64.

	Ignore the __GCC_HAVE_DWARF2_CFI_ASM macro which
	some versions of GCC define if -g is enabled.

compiler/.gitignore:
deep_profiler/.gitignore:
profiler/.gitignore:
slice/.gitignore:
util/.gitignore:
	Have git ignore .exe files in these directories.