Blame INSTALL

Packit Service 8bf002
This file explains how to generate executables by compiling the MCPP
Packit Service 8bf002
source.  For further details, please refer to mcpp-porting.html.
Packit Service 8bf002
Packit Service 8bf002
1. Types of MCPP executables
Packit Service 8bf002
Packit Service 8bf002
There are several types of MCPP executable corresponding to its building
Packit Service 8bf002
methods.  The building methods of MCPP have following two axis:
Packit Service 8bf002
Packit Service 8bf002
    1. stand-alone-build vs subroutine-build
Packit Service 8bf002
    2. compiler-independent-build vs compiler-specific-build
Packit Service 8bf002
Packit Service 8bf002
stand-alone-build:  The preprocessor which is invoked as a command.
Packit Service 8bf002
    Some of this type is invoked by compiler-driver.
Packit Service 8bf002
subroutine-build:  The preprocessor to be called as a subroutine
Packit Service 8bf002
    (repeatedly, if required) from other main program.
Packit Service 8bf002
Packit Service 8bf002
compiler-independent-build:  The preprocessor which behaves on its own
Packit Service 8bf002
    not depending on any compiler system.  The invocation options, for
Packit Service 8bf002
    example, are the same across the compilers with which MCPP is
Packit Service 8bf002
    compiled.  Although it can preprocess source files, it cannot behave
Packit Service 8bf002
    as an integrated part of a compiler system.
Packit Service 8bf002
compiler-specific-build:  The preprocessor to replace (if possible) the
Packit Service 8bf002
    resident preprocessor of certain compiler system.  It has some
Packit Service 8bf002
    specifications for the compiler system only and is installed into
Packit Service 8bf002
    the compiler-system-specific directory.
Packit Service 8bf002
Packit Service 8bf002
This document does not explain subroutine-build.  As for it, please
Packit Service 8bf002
refer to mcpp-porting.html 3.12.  All the explanations below are of
Packit Service 8bf002
stand-alone-build.
Packit Service 8bf002
Packit Service 8bf002
2. Configure and make
Packit Service 8bf002
Packit Service 8bf002
To compile MCPP, the configure script can be used on UNIX-like systems
Packit Service 8bf002
and CygWIN, MinGW.  You can do configure and make in any directory.  In
Packit Service 8bf002
this document ${mcpp-dir} represents the path of 'mcpp-${VERSION}'
Packit Service 8bf002
directory.  The ${VERSION} represents the version of MCPP such as 2.6.4
Packit Service 8bf002
or 2.7.1.
Packit Service 8bf002
Packit Service 8bf002
The configure script searches for compilers by name of 'cc' ('c++') and
Packit Service 8bf002
'gcc' ('g++') according to the path list set in the environment variable
Packit Service 8bf002
$PATH.  So, if you use compilers named like 'gcc-4.3.0' and 'g++-4.3.0',
Packit Service 8bf002
you have to specify them by CC and CXX environment variables, or link
Packit Service 8bf002
them to 'gcc' and 'g++', prior to do configure.  If you use a pair of
Packit Service 8bf002
compilers other than the one first found in the path list, you have to
Packit Service 8bf002
change the $PATH such as:
Packit Service 8bf002
Packit Service 8bf002
    export PATH=/my/gcc/bin:$PATH
Packit Service 8bf002
Packit Service 8bf002
The setting should be kept the same while you do 'configure' and 'make'.
Packit Service 8bf002
Do not specify a compiler by CC or CXX variable with any directory part,
Packit Service 8bf002
even in an absolute path, when it is not the first one found in the
Packit Service 8bf002
$PATH, because $PATH influences everything of configure.
Packit Service 8bf002
Packit Service 8bf002
2.1. The compiler-independent-build
Packit Service 8bf002
Packit Service 8bf002
If you type the commands as:
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure; make; make install
Packit Service 8bf002
Packit Service 8bf002
the compiler-independent executable will be generated and installed by
Packit Service 8bf002
name of 'mcpp'.  Also a few document files will be installed.
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --prefix=/usr; make; make install
Packit Service 8bf002
Packit Service 8bf002
will install the executable into 'bin' directory in the directory
Packit Service 8bf002
specified by '--prefix' option.  If this option is omitted, the
Packit Service 8bf002
directory defaults to '/usr/local'.
Packit Service 8bf002
Packit Service 8bf002
'make install' usually requires root privilege, and you can do it by:
Packit Service 8bf002
Packit Service 8bf002
    sudo make install
Packit Service 8bf002
Packit Service 8bf002
or by first 'su', then 'configure; make; make install'.
Packit Service 8bf002
On FreeBSD, you'd better to use 'gmake' instead of 'make'.
Packit Service 8bf002
To strip the executable, do:
Packit Service 8bf002
Packit Service 8bf002
    make install-strip
Packit Service 8bf002
Packit Service 8bf002
instead of 'make install'.
Packit Service 8bf002
Packit Service 8bf002
To uninstall the executable, do:
Packit Service 8bf002
Packit Service 8bf002
    make uninstall
Packit Service 8bf002
Packit Service 8bf002
If you specify 'DESTDIR=DIR' option with make (un)install, all the files
Packit Service 8bf002
will be installed under (or uninstalled from) the 'DIR' directory.  For
Packit Service 8bf002
example,
Packit Service 8bf002
Packit Service 8bf002
    make DESTDIR=/tmp/mcpp install
Packit Service 8bf002
Packit Service 8bf002
will install MCPP into '/tmp/mcpp/usr/local/bin/', (Non-existent
Packit Service 8bf002
directories will be generated.  If '--prefix=DIR' option was specified
Packit Service 8bf002
in configure, '/usr/local' part will be replaced by 'DIR').  This option
Packit Service 8bf002
is used to make a binary package.
Packit Service 8bf002
Packit Service 8bf002
GCC 4.1 or later has the option '-fstack-protector' ('-fstack-protector-
Packit Service 8bf002
all').  You can enable it by adding "CFLAGS+='-fstack-protector'" option
Packit Service 8bf002
to make command.  The same can be said on GCC-specific-build.  Also, you
Packit Service 8bf002
can use "CFLAGS+='-ggdb -O0'" option to debug mcpp by gdb.
Packit Service 8bf002
Packit Service 8bf002
'make install' of compiler-independent-build installs a few documents as
Packit Service 8bf002
well as the executable.  This is for the convenience of making a binary
Packit Service 8bf002
package.
Packit Service 8bf002
Packit Service 8bf002
Note that on Linux, Mac OS X, CygWIN and MinGW, the system's standard
Packit Service 8bf002
headers have certain defects, and some workarounds are necessary for the
Packit Service 8bf002
compiler-independent-build of MCPP.  See mcpp-manual.html 3.9.9 for this
Packit Service 8bf002
problem.
Packit Service 8bf002
Packit Service 8bf002
2.2. The compiler-specific-build
Packit Service 8bf002
Packit Service 8bf002
This line of commands will generate a compiler-specific executable and
Packit Service 8bf002
will install it into the compiler-specific directory.
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --enable-replace-cpp; make; make install
Packit Service 8bf002
Packit Service 8bf002
'make install', 'make install-strip', 'make uninstall' are the same as
Packit Service 8bf002
compiler-independent-build.
Packit Service 8bf002
Packit Service 8bf002
The prefix directory is automatocally set from the path of GCC: for
Packit Service 8bf002
example, '/usr/local' of '/usr/local/bin/gcc'.  If you specify --prefix
Packit Service 8bf002
option for configure and it conflicts with the GCC path, the --prefix
Packit Service 8bf002
option will be ignored.  'DESTDIR' option of make has also no relevance
Packit Service 8bf002
to the executable's installation.
Packit Service 8bf002
Packit Service 8bf002
For the compiler systems other than GCC, however, it may not be compiled
Packit Service 8bf002
or installed properly if some porting work has not been done beforehand
Packit Service 8bf002
and if some of the options are not specified with configure.
Packit Service 8bf002
Packit Service 8bf002
2.2.1 When the compiler system is GCC
Packit Service 8bf002
Packit Service 8bf002
When the compiler system is GCC, the appropriate settings will be set by
Packit Service 8bf002
the configure without any options other than '--enable-replace-cpp'.
Packit Service 8bf002
After configuring, do 'make'.
Packit Service 8bf002
Packit Service 8bf002
2.2.1.1. make install
Packit Service 8bf002
Packit Service 8bf002
After configuring and 'make', the 'make install' command installs MCPP
Packit Service 8bf002
into the compiler's directory (e.g. /usr/libexec or /usr/lib/gcc-lib/
Packit Service 8bf002
SYSTEM/VERSION).  This is the directory where cc1 (cpp0), which is
Packit Service 8bf002
called by gcc, is located.  'make install' saves GCC / cc1, cc1plus
Packit Service 8bf002
(cpp0) and setups gcc and g++ command appropriately to call MCPP.  This
Packit Service 8bf002
setting is different depending on GCC being V.2.* or V.3.*-4.*. (Refer
Packit Service 8bf002
section 3.9.5 and 3.9.7 of mcpp-manual.html).  In addition, it generates
Packit Service 8bf002
some GCC-version-dependent header files under 'mcpp-gcc*' directory in
Packit Service 8bf002
compiler-specific include directory.
Packit Service 8bf002
Packit Service 8bf002
2.2.1.2. make check
Packit Service 8bf002
Packit Service 8bf002
In the MCPP Validation Suite, there is an edition which can be used as
Packit Service 8bf002
testsuite of GCC.  If GCC / testsuite has been installed, 'make check'
Packit Service 8bf002
can test MCPP using the testsuite edition of Validation Suite.  Because
Packit Service 8bf002
this edition is to be used as a part of GCC / testsuite, the testsuite
Packit Service 8bf002
should be installed and ready to execute in advance.  GCC / testsuite is
Packit Service 8bf002
usually a part of the source code of GCC. (It can be a separate package
Packit Service 8bf002
in some cases.)  You can use any version of testsuite from GCC V.2.95.*
Packit Service 8bf002
to V.4.2.*.
Packit Service 8bf002
Packit Service 8bf002
Also, 'configure' needs an option to specify the directory where GCC /
Packit Service 8bf002
testsuite is located, as:
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --with-gcc-testsuite-dir=DIR  \
Packit Service 8bf002
            --enable-replace-cpp
Packit Service 8bf002
Packit Service 8bf002
If the directory where GCC source is located is ${gcc-source}, this
Packit Service 8bf002
'DIR' should become:
Packit Service 8bf002
Packit Service 8bf002
    ${gcc-source}/gcc/testsuite
Packit Service 8bf002
Packit Service 8bf002
Configured as above, 'make check' after 'make; make install' copies the
Packit Service 8bf002
testsuite edition of Validation Suite into GCC / testsuite, and applies
Packit Service 8bf002
required settings according to whether GCC is V.2.* or V.3.*-4.*.  When
Packit Service 8bf002
the name of the gcc command is not 'gcc', for example 'gcc-4.1.2' or
Packit Service 8bf002
'powerpc-apple-darwin9-gcc-4.0.1', 'make check' links 'gcc' to that name
Packit Service 8bf002
temporarily, because GCC testsuite expects literal 'gcc' for the name.
Packit Service 8bf002
Then, the testsuite will be executed.  Usually, 'make check' would be
Packit Service 8bf002
run before 'make install' in the normal software, but this order is
Packit Service 8bf002
reversed in MCPP.  This is because testsuite cannot be applied to MCPP
Packit Service 8bf002
unless MCPP is called from gcc.  Due to this, the option '--enable-
Packit Service 8bf002
replace-cpp' is also required.
Packit Service 8bf002
Packit Service 8bf002
Depending on the location of ${gcc-source} directory, you should do
Packit Service 8bf002
'sudo make check' instead of 'make check'.  In this case, make sure that
Packit Service 8bf002
gcc is the same between root and the current user.
Packit Service 8bf002
Packit Service 8bf002
The testsuite edition of Validation Suite can also be applied to cc1,
Packit Service 8bf002
cc1plus (cpp0) of GCC V.2.95 and later, not only for MCPP.  (Refer cpp-
Packit Service 8bf002
test.html 3.2.3).
Packit Service 8bf002
Packit Service 8bf002
2.2.1.3. make uninstall
Packit Service 8bf002
Packit Service 8bf002
When you type 'make uninstall', the executables of MCPP will get deleted.
Packit Service 8bf002
The header files in mcpp-gcc* directory will be deleted, too.  The
Packit Service 8bf002
settings of gcc and cc1, cc1plus (cpp0) will be reset to the initial
Packit Service 8bf002
state.  When the re-execution of configure is required after completing
Packit Service 8bf002
'make install' for some reason, 'make uninstall' needs to be done
Packit Service 8bf002
beforehand.  This is because the configure should check GCC, not MCPP.
Packit Service 8bf002
Packit Service 8bf002
If you have done 'make check', the 'make uninstall' will also remove the
Packit Service 8bf002
testsuite edition of Validation Suite.  If you want to use Validation
Packit Service 8bf002
Suite for GCC, copy it manually.
Packit Service 8bf002
Packit Service 8bf002
The Makefiles generated by configure are necessary to do 'make
Packit Service 8bf002
uninstall', so you should not remove them.  When you do 'make distclean',
Packit Service 8bf002
first do 'make uninstall', because it is a little troublesome to
Packit Service 8bf002
uninstall GCC-specific-MCPP manually.  Also you should do 'make
Packit Service 8bf002
uninstall; make distclean' even before updating configure or Makefile.in,
Packit Service 8bf002
when you update MCPP.
Packit Service 8bf002
Packit Service 8bf002
2.2.2. When the compiler system is Apple-GCC on Mac OS X
Packit Service 8bf002
Packit Service 8bf002
Although Mac OS X is one of the UNIX-like systems, it has some
Packit Service 8bf002
peculiarities such as "framework" directories.  Its system compiler is a
Packit Service 8bf002
GCC with many extensions added by Apple.  Moreover, since the appearance
Packit Service 8bf002
of Intel-Mac, both of the compiler system for x86 and the compiler
Packit Service 8bf002
system for powerpc, one is a native compiler and the other is a cross
Packit Service 8bf002
compiler, begun to co-exist in a same machine.  And even a so-called
Packit Service 8bf002
"universal binary", which is a bundle of binaries for x86 and powerpc,
Packit Service 8bf002
hence is able to work on either machine, has become popular.  The
Packit Service 8bf002
structure of compiler systems is rather complex.
Packit Service 8bf002
Packit Service 8bf002
To install MCPP for this complex system, the command sequence of 2.2.1
Packit Service 8bf002
is not sufficient.  Here, I explain the case of Mac OS X / Apple-GCCs
Packit Service 8bf002
apart from other UNIX.  I am using Mac OS X Leopard on Intel-Mac, so I
Packit Service 8bf002
take the examples of the system.  If you use Powerpc-Mac, read the
Packit Service 8bf002
section below swapping 'i686' and 'powerpc'.  On Tiger, read 'darwin9'
Packit Service 8bf002
as 'darwin8'.
Packit Service 8bf002
Packit Service 8bf002
Apple provides GCC 4.0.1, and also provides GCC 3.3 as an addition.  I
Packit Service 8bf002
explain only GCC 4.0.1, and omit GCC 3.3, because it has not been
Packit Service 8bf002
properly compiled at least on Leopard.
Packit Service 8bf002
Packit Service 8bf002
2.2.2.1. Native compiler versus cross compiler
Packit Service 8bf002
Packit Service 8bf002
It is simple to compile and install MCPP for a native compiler, i.e. for
Packit Service 8bf002
x86 on Intel-Mac.  The command sequence in 2.2.1 is sufficient for it.
Packit Service 8bf002
Packit Service 8bf002
Making of MCPP with a cross compiler, however, is not so easy.
Packit Service 8bf002
Generally, the configure script of MCPP does not support cross compiling,
Packit Service 8bf002
because it contains a few tests to be compiled and executed.  A binary
Packit Service 8bf002
for a target environment cannot be run on a build environment usually.
Packit Service 8bf002
If we test the build environment instead, the results are not
Packit Service 8bf002
necessarily the same with the target.
Packit Service 8bf002
Packit Service 8bf002
Nevertheless, on Mac OS X, we can exceptionally configure cross-
Packit Service 8bf002
compiling for different CPUs in most cases.  First, Intel-Mac
Packit Service 8bf002
automatically executes a ppc binary with an emulator.  Second, if the
Packit Service 8bf002
build environment and the target differ only in CPU and its related
Packit Service 8bf002
settings, and OS, its version and GCC's version are all the same between
Packit Service 8bf002
them, we can substitute most of the tests of the target with that of the
Packit Service 8bf002
build.
Packit Service 8bf002
Packit Service 8bf002
On Intel-Mac, for a compiler-independent-build, you should specify the C
Packit Service 8bf002
compiler (the name of compiler driver) and C++ compiler by the
Packit Service 8bf002
environment-variables CC and CXX.  There are many gccs and g++s in /usr/
Packit Service 8bf002
bin of Mac OS X.  In Mac OS X Leopard on Intel-Mac, powerpc-apple-
Packit Service 8bf002
darwin9-gcc-4.0.1 and powerpc-apple-darwin9-g++-4.0.1 are the C compiler
Packit Service 8bf002
and the C++ compiler for powerpc.  (Actually, all the gccs and g++s in
Packit Service 8bf002
/usr/bin are universal binaries of i386 and ppc.) In addition, you
Packit Service 8bf002
should specify the target system by --target option.  In this case, you
Packit Service 8bf002
should use the compiler's name removing '-gcc-4.0.1', i.e. powerpc-apple-
Packit Service 8bf002
darwin9.  This is the configure command to make compiler-independent-
Packit Service 8bf002
build:
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --target=powerpc-apple-darwin9    \
Packit Service 8bf002
            CC=powerpc-apple-darwin9-gcc-4.0.1      \
Packit Service 8bf002
            CXX=powerpc-apple-darwin9-g++-4.0.1
Packit Service 8bf002
Packit Service 8bf002
On the other hand, ppc-Mac cannot execute an x86 binary, so you cannot
Packit Service 8bf002
make the compiler-independent-build with this method.  Instead, you can
Packit Service 8bf002
cross-compile it manually, using the difference file and mac_osx.mak.
Packit Service 8bf002
See mcpp-porting.html#3.1.4 and #3.11, if needed.  You can also make a
Packit Service 8bf002
universal binary on ppc-Mac with its native compiler using the configure,
Packit Service 8bf002
as explained in the next section.
Packit Service 8bf002
Packit Service 8bf002
To make a GCC-specific-build, you should specify the C compiler by
Packit Service 8bf002
--with-target-cc= option instead of CC and CXX as: (the configure deduce
Packit Service 8bf002
the name of C++ compiler from the name of C compiler, replacing 'gcc'
Packit Service 8bf002
with 'g++'.)
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --target=powerpc-apple-darwin9    \
Packit Service 8bf002
            --with-target-cc=powerpc-apple-darwin9-gcc-4.0.1    \
Packit Service 8bf002
            --enable-replace-cpp
Packit Service 8bf002
Packit Service 8bf002
This configuration does not contain any running test of the target, so
Packit Service 8bf002
it can be used on ppc-Mac too, changing 'powerpc' with 'i686'.
Packit Service 8bf002
Packit Service 8bf002
When the version of the default native compiler (gcc and g++) greatly
Packit Service 8bf002
differs from that of the cross compiler specified by --with-target-cc=
Packit Service 8bf002
option, you should specify a native compiler of a version as close as
Packit Service 8bf002
possible to the target by the environment-variables CC and CXX.  The
Packit Service 8bf002
compiler specified by CC (CXX) is to be used to build MCPP, while the
Packit Service 8bf002
compiler specified by --with-target-cc= is the target compiler into
Packit Service 8bf002
which MCPP is installed.
Packit Service 8bf002
Packit Service 8bf002
The cross compiler differs from the native compiler in libexec directory,
Packit Service 8bf002
compiler-specific include directory and predefined macros.  The
Packit Service 8bf002
configure with these options appropriately sets them.  These options
Packit Service 8bf002
should be used for configure, not for make command.
Packit Service 8bf002
Packit Service 8bf002
Note that a cross compiler itself runs on a host system, so does a
Packit Service 8bf002
compiler-specific-build MCPP installed "to a cross compiler".  On the
Packit Service 8bf002
other hand, a compiler-independent-build MCPP compiled "with a cross
Packit Service 8bf002
compiler" runs on a target system.  Also note that both of the GCC-
Packit Service 8bf002
specific-build for the native compiler and for the cross compiler are
Packit Service 8bf002
compiled by the native compiler, therefore, if you install both, you
Packit Service 8bf002
should first install the one for the cross compiler.
Packit Service 8bf002
Packit Service 8bf002
2.2.2.2. Making a universal binary
Packit Service 8bf002
Packit Service 8bf002
To make a universal binary, specify the CPUs by -arch options and add
Packit Service 8bf002
them to the 'make' command as "CFLAGS+='-arch i386 -arch ppc'".  The
Packit Service 8bf002
valid CPU types are 'i386', 'x86_64', 'ppc' and 'ppc64'.  For example,
Packit Service 8bf002
this command generates a bundled binary for 4 CPU types.
Packit Service 8bf002
Packit Service 8bf002
    make CFLAGS+='-arch i386 -arch x86_64 -arch ppc -arch ppc64'
Packit Service 8bf002
Packit Service 8bf002
The configure needs no special option for universal binary, it needs
Packit Service 8bf002
only options for non-universal binary, if any.
Packit Service 8bf002
Packit Service 8bf002
GCC has '-isysroot DIR' or '--sysroot=DIR' options, which change root of
Packit Service 8bf002
system include directories to DIR.  These options are not limited to Mac
Packit Service 8bf002
OS, but are commonly used on Mac OS to compile a universal binary in
Packit Service 8bf002
order to widen compatibility with older version of Mac OS.  For example,
Packit Service 8bf002
if '-isysroot /Developer/SDKs/MacOSX10.4u.sdk' is specified, /usr/
Packit Service 8bf002
include becomes /Developer/SDKs/MacOSX10.4u.sdk/usr/include.  This is an
Packit Service 8bf002
example to compile a universal binary compatible with Mac OS X 10.4
Packit Service 8bf002
(Tiger) on 10.5 (Leopard).  When you use this option in making MCPP, you
Packit Service 8bf002
should also specify the version of SDK by -mmacosx-version-min= option.
Packit Service 8bf002
Packit Service 8bf002
Any universal binary of MCPP can be generated with a combination of the
Packit Service 8bf002
above configure options and these make options, on either of compiler-
Packit Service 8bf002
independent-build or GCC-specific-build, and on either of native
Packit Service 8bf002
compiler or cross compiler.  This example shows the sequence to generate
Packit Service 8bf002
a universal binary of compiler-independent-build compatible with Tiger
Packit Service 8bf002
for i386 and ppc.  (Actually, you should write the '*' in one line.)
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure
Packit Service 8bf002
    make CFLAGS+='-isysroot /Developer/SDKs/MacOSX10.4u.sdk     \
Packit Service 8bf002
            -mmacosx-version-min=10.4 -arch i386 -arch ppc'
Packit Service 8bf002
    sudo make install
Packit Service 8bf002
Packit Service 8bf002
2.2.3. When the compiler system is not GCC
Packit Service 8bf002
Packit Service 8bf002
When the compiler system is not GCC, some options need to be specified
Packit Service 8bf002
in the configure.  Also, to use MCPP replacing the preprocessor of the
Packit Service 8bf002
compiler system, the "porting" or adding source code is required.  MCPP
Packit Service 8bf002
have already been ported to GCC, because the author is using GCC on
Packit Service 8bf002
Linux, FreeBSD, Mac OS X, CygWIN and MinGW systems, and so the
Packit Service 8bf002
informations can be collected by the configure.  However, as he does not
Packit Service 8bf002
know any compiler systems on UNIX-like systems other than GCC, he does
Packit Service 8bf002
not even know what or how it needs to be checked by the configure, let
Packit Service 8bf002
alone the porting.
Packit Service 8bf002
Packit Service 8bf002
For compiler systems other than GCC on UNIX systems, please compile with
Packit Service 8bf002
the following procedures.
Packit Service 8bf002
Packit Service 8bf002
2.2.3.1. Configure by specifying options
Packit Service 8bf002
Packit Service 8bf002
First, do configure by specifying some options, for example:
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --enable-replace-cpp --bindir=DIR \
Packit Service 8bf002
            --with-cxx-include-dir=CXXDIR   \
Packit Service 8bf002
            --enable-SYSTEM-STD-macro=_MACRO=val
Packit Service 8bf002
Packit Service 8bf002
Specify the directory where the preprocessor, which is called from the
Packit Service 8bf002
compiler-driver, is located with --bindir, specify the C++ specific
Packit Service 8bf002
include directory with --with-cxx-include-dir and specify the predefined
Packit Service 8bf002
macro of the resident preprocessor with --enable-SYSTEM-STD-macro or
Packit Service 8bf002
other options.
Packit Service 8bf002
Packit Service 8bf002
If you type
Packit Service 8bf002
Packit Service 8bf002
    ${mcpp-dir}/configure --help
Packit Service 8bf002
Packit Service 8bf002
some options will be displayed.
Packit Service 8bf002
Packit Service 8bf002
Then, after doing 'make; make install', some work for making MCPP
Packit Service 8bf002
callable from the compiler driver is required.  Please see the setup on
Packit Service 8bf002
GCC for how to do this.
Packit Service 8bf002
Packit Service 8bf002
2.2.3.2. "Porting" work
Packit Service 8bf002
Packit Service 8bf002
To be able to use the MCPP replacing the preprocessor of the compiler
Packit Service 8bf002
system, it is required to do "porting" work by adding source code.
Packit Service 8bf002
These are the execution options for the compiler system or the
Packit Service 8bf002
implementation of #pragma directives.  Especially, when there are some
Packit Service 8bf002
execution time options which are used frequently but different from MCPP,
Packit Service 8bf002
they at least need to be implemented.  In order to do that, define the
Packit Service 8bf002
macro to designate the compiler in configed.H, and write some codes in
Packit Service 8bf002
system.c. (Refer mcpp-porting.html 4.2).
Packit Service 8bf002
Packit Service 8bf002
2.2.3.3. Re-configure by adding an option
Packit Service 8bf002
Packit Service 8bf002
Once porting of source is completed, re-configure by adding the option
Packit Service 8bf002
--with-compiler-name=COMPILER.  'COMPILER' is the macro for the compiler
Packit Service 8bf002
defined in configed.H.
Packit Service 8bf002
Packit Service 8bf002
After 'make; make install' is done successfully, do 'make clean; make'
Packit Service 8bf002
which recompiles MCPP using the installed MCPP.  If it passes, it can be
Packit Service 8bf002
said that basic porting has been done successfully.
Packit Service 8bf002
Packit Service 8bf002
2.2.4. The limitations of the configure
Packit Service 8bf002
Packit Service 8bf002
In the compilation of compiler-specific-build of MCPP, the
Packit Service 8bf002
specifications of the target system (the compiler system which will use
Packit Service 8bf002
MCPP as a preprocessor) must be understood in detail.  At the same time
Packit Service 8bf002
the host system (the compiler system with which MCPP is compiled) need
Packit Service 8bf002
to be understood.  In case these two are not the same, the source code
Packit Service 8bf002
of MCPP is written with the settings of both systems separately in the
Packit Service 8bf002
header file (configed.H).  However, the configure cannot detect both of
Packit Service 8bf002
them at the same time.  Therefore, it assumes the target system is the
Packit Service 8bf002
same as the host system.
Packit Service 8bf002
Packit Service 8bf002
If these two systems are not the same, Part 2 of the configed.H needs to
Packit Service 8bf002
be modified.
Packit Service 8bf002
Packit Service 8bf002
Cross-compiling is not supported by the configure of MCPP, either.  Some
Packit Service 8bf002
tests which cannot be executed by the cross-compiler are included as
Packit Service 8bf002
well.  In case of cross-compiling, the default values will be set, but
Packit Service 8bf002
this may not work.
Packit Service 8bf002
Packit Service 8bf002
3. 'make' on the Windows compiler systems
Packit Service 8bf002
Packit Service 8bf002
Since all compiler systems on Windows other than CygWIN and MinGW are
Packit Service 8bf002
not subject to the 'configure', they need a bit of modification of the
Packit Service 8bf002
source in order to do 'make'.  As there are difference files for already
Packit Service 8bf002
ported systems, a patch can be applied by using them.  The procedure for
Packit Service 8bf002
the use of the difference files is explained below.
Packit Service 8bf002
Packit Service 8bf002
Even the systems subject to the 'configure' can also be controlled in
Packit Service 8bf002
detail by editing the makefile and header files directly.
Packit Service 8bf002
Packit Service 8bf002
3.1. Applying a patch
Packit Service 8bf002
Packit Service 8bf002
The difference files and makefiles for various compiler systems are
Packit Service 8bf002
available in 'noconfig' directory.  The source of MCPP is defaulted to
Packit Service 8bf002
FreeBSD / GCC 3.4 setting.  The difference files are used in order to
Packit Service 8bf002
modify this source for the particular compiler systems.  The makefile is
Packit Service 8bf002
written for using the make command attached to each compiler system.
Packit Service 8bf002
Packit Service 8bf002
In the 'src' directory, run as below.  All of the following process
Packit Service 8bf002
should be done within the 'src' directory.
Packit Service 8bf002
Packit Service 8bf002
    patch -c < ..\noconfig\which-compiler.dif
Packit Service 8bf002
    copy ..\noconfig\which-compiler.mak Makefile
Packit Service 8bf002
Packit Service 8bf002
'patch' is a UNIX command, but it can be used in Windows as it has been
Packit Service 8bf002
ported.  Of course, you can directly edit the noconfig.H file referring
Packit Service 8bf002
the difference file.
Packit Service 8bf002
Packit Service 8bf002
3.2. Modifying noconfig.H and Makefile if required
Packit Service 8bf002
Packit Service 8bf002
The settings of various directories in the difference files are based on
Packit Service 8bf002
the environment of the author, hence you have to modify them.
Packit Service 8bf002
Packit Service 8bf002
If the version of the compiler system is different from that of the
Packit Service 8bf002
difference file, modify the header file noconfig.H.  (See noconfig.H
Packit Service 8bf002
itself and mcpp-porting.html 3.1).  Similarly, if the multi-byte
Packit Service 8bf002
character for normal use is not Japanese, change the macro definition
Packit Service 8bf002
MBCHAR in noconfig.H.
Packit Service 8bf002
Packit Service 8bf002
Also, define BINDIR in the Makefile to the directory in which MCPP
Packit Service 8bf002
executable should be installed.  As for the Makefile for Visual C,
Packit Service 8bf002
remove '#' of this line and make 'install' target effective.
Packit Service 8bf002
Packit Service 8bf002
    #install :
Packit Service 8bf002
Packit Service 8bf002
3.3. Compiler-independent-build
Packit Service 8bf002
Packit Service 8bf002
Now, you can do 'make' and 'make install' successfully for the compiler-
Packit Service 8bf002
independent executable. (For Visual C, use 'nmake' instead of 'make').
Packit Service 8bf002
Packit Service 8bf002
3.4. Compiler-specific-build
Packit Service 8bf002
Packit Service 8bf002
To make the compiler-specific-build, rewrite BINDIR in the Makefile to
Packit Service 8bf002
the directory in which the executables of the compiler system are
Packit Service 8bf002
located.  Then, rewrite this line in noconfig.H:
Packit Service 8bf002
Packit Service 8bf002
    #define COMPILER    INDEPENDENT
Packit Service 8bf002
Packit Service 8bf002
Replace 'INDEPENDENT' with the macro to designate the compiler.  Then do
Packit Service 8bf002
'make' and 'make install'.  'COMPILER' can be overwritten also by make
Packit Service 8bf002
option, hence the file can be left as it is.  For example, in Visual C,
Packit Service 8bf002
'nmake COMPLIER=MSC' and 'nmake COMPILER=MSC install' or in Borland C,
Packit Service 8bf002
'make -DCOMPILER=BORLANDC' and 'make -DCOMPILER=BORLANDC install'.
Packit Service 8bf002
Packit Service 8bf002
If the target system and the compiling system are different, noconfig.H
Packit Service 8bf002
/ Part 1 should be set to the specifications of the target system and
Packit Service 8bf002
Part 2 should be set for the compiling system.  The Makefile that should
Packit Service 8bf002
be used is the compiling system's one, and modify the installation
Packit Service 8bf002
directory to the target system's one.
Packit Service 8bf002
Packit Service 8bf002
Since most compiler systems on Windows integrate preprocessor into its
Packit Service 8bf002
compiler, it is impossible to replace the preprocessor of such a one-
Packit Service 8bf002
path compiler with MCPP.  To use MCPP, a source program should be first
Packit Service 8bf002
preprocessed with MCPP and then the output should be passed to the
Packit Service 8bf002
compiler.  To use MCPP with a one-path compiler, the procedure should be
Packit Service 8bf002
written in makefile.  For sample procedures, refer to the makefile's
Packit Service 8bf002
settings used to recompile MCPP using MCPP itself.
Packit Service 8bf002
Packit Service 8bf002
In Visual C++, if you create "makefile project" by IDE using the
Packit Service 8bf002
attached makefile, all the functions of IDE, such as source level debug,
Packit Service 8bf002
become available. (Refer mcpp-manual.html 2.10)
Packit Service 8bf002
Packit Service 8bf002
3.5. Test
Packit Service 8bf002
Packit Service 8bf002
On Windows, any include directory is not preset except MinGW/GCC-
Packit Service 8bf002
specific-build and GygWIN, hence you should specify them by the
Packit Service 8bf002
environment variable INCLUDE (and CPLUS_INCLUDE, if necessary).
Packit Service 8bf002
Packit Service 8bf002
GCC / testsuite cannot be used in Windows, MCPP needs to be checked
Packit Service 8bf002
directly by preprocessing the test samples in test-t, test-c and test-l
Packit Service 8bf002
directories.  If you use tool/cpp_test.c, it can test some parts
Packit Service 8bf002
automatically. (Refer cpp-test.html 3.2.2).
Packit Service 8bf002
Packit Service 8bf002
For the compiler-specific-build of MCPP, if you re-compile MCPP with the
Packit Service 8bf002
"pre-preprocess" functionality of MCPP, by using MCPP itself as the
Packit Service 8bf002
preprocessor of the compiler system, you can check whether it has been
Packit Service 8bf002
ported successfully for the compiler system. (Refer mcpp-porting.html 3.
Packit Service 8bf002
7)
Packit Service 8bf002
Packit Service 8bf002
4. Please send me the information for porting.
Packit Service 8bf002
Packit Service 8bf002
To port to the compiler systems which have not been ported yet, lots of
Packit Service 8bf002
information is required.  It will be great to hear from many people.
Packit Service 8bf002
Packit Service 8bf002
Please let me know if you know the values for options of the 'configure',
Packit Service 8bf002
for compiler systems other than GCC.  I would like to work on configure.
Packit Service 8bf002
ac.
Packit Service 8bf002
Packit Service 8bf002
5. Validation Suite
Packit Service 8bf002
Packit Service 8bf002
MCPP provides "Validation Suite" which tests and evaluates C/C++
Packit Service 8bf002
preprocessor comprehensively.  Validation Suite has 265 items and can be
Packit Service 8bf002
applied to any preprocessor as well as MCPP.  Refer to 3.1 and 3.2 of
Packit Service 8bf002
cpp-test.html.
Packit Service 8bf002
Packit Service 8bf002
November, 2008
Packit Service 8bf002
Kiyoshi Matsui <kmatsui@t3.rim.or.jp>
Packit Service 8bf002