First of all, you must get source of GCC, binutils, and Newlib. Perhaps these
are easily found, in a web/ftp site, or a CD-ROM. In this document,
gcc-2.7.2.3
, binutils-2.9.1
and
newlib-1.7.1
are used.
After getting source package, unpack them. We assume that they are unpacked to
/usr/local/src/
.
To compile binutils, run configure
and make
.
./configure --target=h8300-hms --prefix=/usr/local make all make install
h8300-hms is a target identifier for H8. When you install other target CPU (such as SH-2), it must be replaced to another keyword. You may install it to any directory.
Now, assembler and linker is installed in your PC. Names of them begin with
h8300-hms- , for example, as
for H8 is
h8300-hms-as
.
To compile GCC, run configure script first. Specify same options specified in binutil installation.
./configure --target=h8300-hms --prefix=/usr/local
In the prefix option, you must specify same directory as specified for binutils.
Unfortunately, makefile generated by the configure script must be modified slightly for H8. Two option must be added, the one is -Dinhibit_libc and the other is -mh. The former option is to compile without standard library, and the latter is to enable H8/300H instructions. Search the line where LIBGCC2_INCLUDES is defined in Makefile, and add these options like:
LIBGCC2_INCLUDES = -Dinhibit_libc -mh
Then, execute make
command. At this point, only C compiler ( not
C++ ) can be made. To avoid making C++ compiler (and stopping by error),
LANGUAGES=C option must be specified.
make LANGUAGES=C all make LANGUAGES=C install
Next, you must replace float.h
to the one in the normal compiler
(the one in your linux distribution). Normally, representation scheme of
floating point in the host CPU is different from that of target CPU, then GCC
disables floating point features. But in this case, it is not a problem
because H8 does not contain FPU and rely on the software FPU emulation library.
Then copying float.h
of host CPU to that of target CPU, floating
point features are enabled. To do this, copy this file as follows. Modify
directories in the following example for your system.
cp /usr/lib/gcc-lib/i386-linux/2.95.2/include/float.h /usr/local/lib/gcc-lib/h8300-hms/2.7.2.3/include/float.h
If everything goes, GCC for H8 (h8300-hms-gcc
)is installed. You
can compile simple C source. ( Perhaps an error is occured while linking
stage. )
Newlib is also easily installed by configure
and
make
, by specifying same option used before.
./configure --target=h8300-hms --prefix=/usr/local make all make install
That's all. By newlib
, you may use math functions and string
functions, including sscanf. File I/O and time support functions cannot be
used, because they are related to hardware. Of cource, OS support functions
(such as process I/O functions) cannt be used too.
If you intend to use C++ language, now compile it. In GCC source directory,
run make
as follows.
make all make install
configure
script explicitly,
because default directory of GCC is different from that of binutils.
make
makes C, C++, Objective-C compilers simultaneously.
But, to make C++ and Objective-C compiler, standard C library is needed. If
you intend to use C++ or Objective-C, they must be compiled after Newlib is
installed.
float.h
. See GCC
Installation, Section 2.3.
kp9m-iwt@asahi-net.or.jp