Counter

COUNTER9225From April 2, 2013

Journal

2014/10/15

How to compile MISRA-C:2012 Example Suite

Tweet ThisSend to Facebook | by kaizen
How to compile MISRA-C:2012 Example Suite

This is a part of proposing paper  for WOCS2015 and Safety Engineering Symposium Japan 2015 by Science Counsil of Japan

This description has no official relation with MIRA, MISRA and MISRA-C.
This is only an user, a programmer effort for MISRA-C.

If you want to compile MISRA-C Example Suite on the  MISRA Forum, please read this document.
Some codes may be compile error or only warning are depend on each C compiler implementation. 
Some compile errors may be intentions of display wrong codes.

Now, I use LLVM(clang) 3.5- Xcode 6.0.

Before you compile the codes, please read some back ground information, which are very important to avoid errors.

1 C programming language
C programming language is using C compiler and operating system(OS) and its standard is ISO/IEC 9899, working draft(WG14 N1570) can read through ISO/IEC JTC1 SC22 WG14 web.

MISRA-C
MISRA-C is a cording standard on C programming language for Automotive Industry and Safety Industry. MISRA Forum  is a resource of the guide and example program.

3 Example program from MISRA Forum
There are some example program the name is MISRA C:2012 Examples Suite in the MISRA Forum.
Some program are in the guide, MISRA-C:2012 Guidelines for the Use of the C Language in Critical Systems, on MISRA web shop.

There are more than 150 programs.
3 types of C langue files in the Example Suite.
1) Header file, *.h
2) C function program of a Rule or Directives, like R_nn_mm.c or D_nn_mm.c respectively.
3) C function program of calling a functions(above) on a  Rule section or a  Directives section, such as R_nn_support.c, D_nn_support.c, R__nn_system.c or D_nn_system.c.
X_nn_system for host environment and X_nn_support for free standing  environment.

3.1 Header files
3.1.1 common header file
There are 2 common header file, mc3_header.h and mc3_types.h. "mc3" mean misra-c version 3, 2012.

3.1.1.1 mc3_types.h
typedef          char           char_t;
typedef          float          float32_t;

for C99
#include <stdint.h>
#include <stdbool.h>
typedef _Bool bool_t;

for C90
typedef signed   char           int8_t;
typedef signed   short          int16_t;
typedef signed   int            int32_t;
typedef unsigned char           uint8_t;
typedef unsigned short          uint16_t;
typedef unsigned int            uint32_t;
typedef          int            bool_t;
typedef          int            bool;
enum { false, true };

3.1.1.2 mc3_header.h
There are 2 type of declaration, common functions and individual functions.

3.1.1.2.1 common functions
common functions has 4 type.
3.1.1.2.1.1 get value 
extern bool get_bool ( void );
extern char_t get_char ( void );
...
3.1.1.2.1.2 get pointer(ptr)
extern bool *get_bool_ptr ( void );
extern char_t *get_char_ptr ( void );
...
3.1.2.1.3 use value
extern void use_bool ( bool use_bool_param );
extern void use_char ( char_t use_char_param );
...
3.1.2.1.4 use pointer(ptr)
extern void use_void_ptr ( void * void_ptr_param );
extern void use_bool_ptr ( bool *use_bool_ptr_param );
...
3.1.2.2 individual functions
extern void R_8_1 ( void );
extern void R_8_2 ( void );
...
3.1.2 Individual header file
Some C program file has own header file, for example Directives 4.1, in D_04_01.c 
#include "D_04_01.h"

4 Add some codes for compile 
4.1  #define some compile switch
4.1.1 #ifdef __error_debug__
There are some error codes. 
I add __error_debug__ .
If you will not see compile error, then compile without -D
__error_debug__.
If you want to see compile error, you can compile with -D__error_debug__

If an individual file has no code, then before a calling functions in X_nn_sytem.c and X_nn_support.c,  please add #ifdef __error_debug__.

4.1.2 #ifdef debug
If a program have no output, then add  
 #ifdef debug and printf() output the console.

4.2 Add some definitions of functions and variables.
4.2.1 common functions 
I made a file use_data.c like this.(please remove .txt from file name. it is constraints of this site.)

void use_bool ( bool use_bool_param ){
(void)printf("%d",use_bool_param);
}
void use_char ( char_t use_char_param ){
(void)printf("%d",use_char_param);
} 

4.2.2 individual functions and variables
I made a file use_func.c like this.(please remove .txt from file name. it is constraints of this site.)

// R_05_03.c
#ifdef __R_05_03__ 
void   g (  struct astruct* xyz){
printf("%d\n",(int)xyz);
}
#endif
In this file, my intention is output the state.

4.2.3 Makefile(please remove .txt from file name. it is constraints of this site.)
Now I am making Makefile for compile activities.

These 3 files are beta version to maintain daily compile.
Official release will be at one of  symposium 2015 above. 

The compile command may be
make dir4
make rule02
...
make rule22

dir1, dir2, dir3 and rule01 have no effective code.

The results will be reported next month at MISRA Forum.

Best Regards
Dr Kiyoshi Ogawa

ps
If your compiler is different behavior, please inform me through the MISRA Forum.

Reference

C Traps and Pitfalls
Andrew Koenig
Addison-Wesley Professional(1989/01/01)
値段:¥ 4,729


C Puzzle Book, The
Alan R. Feuer
Addison-Wesley Professional(1998/10/15)
値段:¥ 2,955


08:49 | Impressed! | Voted(0) | Comment(0)
2013/05/21

MISRA-C:2004 and MISRA-C:2012

Tweet ThisSend to Facebook | by kaizen
Compare MISRA-C:2004 and MISRA-C:2012 as a word list in rule statements.

MISRA-C:2004 has 2193 word counts 504 different word without numbers and symbols.
MISRA-C:2012 has 2058 word counts 465 different word without numbers and symbols.

It looks like more easy to understand the rule statements.

Top 10 technical terms in MISRA-C:2004 are
shall122
type38
function23
should21
statement21
expression20
pointer16
for15
if14
object14
Top 10 technical terms in MISRA-C:2012 are
shall121
should38
type37
object33
pointer31
function30
expression19
functions18
statement14
declared14
macro14

"for" and "if" may not be technical terms.


15:08 | Impressed! | Voted(0) | Comment(0)
2013/05/21

MISRA-C information list

Tweet ThisSend to Facebook | by kaizen
This list come from wiki.
to check the existence of the information now. 2013/5/20

TOOL
Coverity Static Analysis
ECLAIR by BUGSENG
GrammaTech CodeSonar
Klocwork Insight & Inspect
LDRA Testbed by Liverpool Data Research Associates
Parasoft C/C++test
PC-Lint by Gimpel Software
Polyspace by MathWorks
PRQA/Programming Research's QA·C
Understand by SciTools
Sonar (software quality) by SonarSource (Open Source with some commercial plug-in components).
C compilers that support MISRA conformance are
Green Hills Software
IAR Systems

References 
 http://www.programmingresearch.com/solutions/coding-standards/misra/
 http://www.cosmicsoftware.com/misra.php
 http://www.ldra.com/misra
 A brief history of MISRA C
 "MISRA C: 2012 News Release."
 "Buying MISRA C"
 "MISRA C FAQ list." MISRA Consortium

 links 
Official website
"Introduction to MISRA C". embedded.com.
"MISRA C: Safer Is Better". electronicdesign.com.
"MISRA C — Some key rules to make embedded systems safer". iar.com.
"Commentary on the first edition of the MISRA C guidelines". knosof.co.uk.
"Automating Compliance to MISRA C/C++ Standards". johndayautomotivelectronics.com.
"New Version of MISRA C: Why Should You Care?". http://electronicdesign.com.
"MISRA C:2012 release date announced". http://www.misra.org.uk.
"MISRA C:2012: Plenty Of Good Reasons To Change". http://electronicdesign.com.
"MISRA C:2012 fact sheet". http://www.programmingresearch.com.
"MISRA C:2012 ensures automotive software safety". http://www.automotive-eetimes.com/.

09:36 | Impressed! | Voted(0) | Comment(0)
2013/04/02

Ocaml install on a Macintosh OS X

Tweet ThisSend to Facebook | by kaizen
This article is a record of how can I install OCaml(from Github) on a Macintosh OS X.

0. After download, extract the files.
-rwxr-xr-x@   1 kaizen  staff   61133  3 28 15:23 .depend
-rwxr-xr-x@   1 kaizen  staff     214  3 28 15:23 .ignore
-rwxr-xr-x@   1 kaizen  staff  144455  3 28 15:23 Changes
-rwxr-xr-x@   1 kaizen  staff   13991  3 28 15:23 INSTALL
-rwxr-xr-x@   1 kaizen  staff   32038  3 28 15:23 LICENSE
-rwxr-xr-x@   1 kaizen  staff   24374  3 28 15:23 Makefile
-rwxr-xr-x@   1 kaizen  staff   21886  3 28 15:23 Makefile.nt
-rwxr-xr-x@   1 kaizen  staff    5065  3 28 15:23 README
-rwxr-xr-x@   1 kaizen  staff   17344  3 28 15:23 README.win32
-rwxr-xr-x@   1 kaizen  staff     133  3 28 15:23 VERSION
-rwxr-xr-x@   1 kaizen  staff    4037  3 28 15:23 _tags
drwxr-xr-x@  70 kaizen  staff    2380  3 28 15:23 asmcomp
drwxr-xr-x@  22 kaizen  staff     748  3 28 15:23 asmrun
drwxr-xr-x@   7 kaizen  staff     238  3 28 15:23 boot
drwxr-xr-x@  32 kaizen  staff    1088  3 28 15:23 build
drwxr-xr-x@  47 kaizen  staff    1598  3 28 15:23 bytecomp
drwxr-xr-x@  97 kaizen  staff    3298  3 28 15:23 byterun
drwxr-xr-x@  27 kaizen  staff     918  3 28 15:23 camlp4
drwxr-xr-x@   3 kaizen  staff     102  3 28 15:23 compilerlibs
drwxr-xr-x@  14 kaizen  staff     476  3 28 15:23 config
-rwxr-xr-x@   1 kaizen  staff   53846  3 28 15:23 configure
drwxr-xr-x@  68 kaizen  staff    2312  3 28 15:23 debugger
drwxr-xr-x@  19 kaizen  staff     646  3 28 15:23 driver
drwxr-xr-x@  19 kaizen  staff     646  3 28 15:23 emacs
drwxr-xr-x@   5 kaizen  staff     170  3 28 15:23 experimental
drwxr-xr-x@  26 kaizen  staff     884  3 28 15:23 lex
drwxr-xr-x@  15 kaizen  staff     510  3 28 15:23 man
-rwxr-xr-x@   1 kaizen  staff   43145  3 28 15:23 myocamlbuild.ml
-rwxr-xr-x@   1 kaizen  staff    2261  3 28 15:23 myocamlbuild_config.mli
drwxr-xr-x@ 112 kaizen  staff    3808  3 28 15:23 ocamlbuild
drwxr-xr-x@  80 kaizen  staff    2720  3 28 15:23 ocamldoc
drwxr-xr-x@  16 kaizen  staff     544  3 28 15:23 otherlibs
drwxr-xr-x@  22 kaizen  staff     748  3 28 15:23 parsing
drwxr-xr-x@ 102 kaizen  staff    3468  3 28 15:23 stdlib
drwxr-xr-x@   9 kaizen  staff     306  3 28 15:23 testsuite
drwxr-xr-x@  45 kaizen  staff    1530  3 28 15:23 tools
drwxr-xr-x@  22 kaizen  staff     748  3 28 15:23 toplevel
drwxr-xr-x@  64 kaizen  staff    2176  3 28 15:23 typing
drwxr-xr-x@  20 kaizen  staff     680  3 28 15:23 utils
drwxr-xr-x@  18 kaizen  staff     612  3 28 15:23 yacc

1. Read "README" file
OVERVIEW:

OCaml is an implementation of the ML language, based on the Caml Light
dialect extended with a complete class-based object system and a
powerful module system in the style of Standard ML.

OCaml comprises two compilers. One generates bytecode which is then
interpreted by a C program. This compiler runs quickly, generates
compact code with moderate memory requirements, and is portable to
essentially any 32 or 64 bit Unix platform. Performance of generated
programs is quite good for a bytecoded implementation.  This compiler
can be used either as a standalone, batch-oriented compiler that
produces standalone programs, or as an interactive, toplevel-based
system.

The other compiler generates high-performance native code for a number
of processors. Compilation takes longer and generates bigger code, but
the generated programs deliver excellent performance, while retaining
the moderate memory requirements of the bytecode compiler. The
native-code compiler currently runs on the following platforms:

Tier 1 (actively used and maintained by the core OCaml team):

    AMD64 (Opteron)    Linux, MacOS X, MS Windows
    IA32 (Pentium)     Linux, FreeBSD, MacOS X, MS Windows
    PowerPC            Linux, MacOS X
    ARM                Linux

Tier 2 (maintained when possible, with help from users):

    AMD64              FreeBSD, OpenBSD
    IA32 (Pentium)     NetBSD, OpenBSD, Solaris 9
    PowerPC            NetBSD
    SPARC              Solaris, Linux, NetBSD

Other operating systems for the processors above have not been tested,
but the compiler may work under other operating systems with little work.

Before the introduction of objects, OCaml was known as Caml Special
Light. OCaml is almost upwards compatible with Caml Special Light,
except for a few additional reserved keywords that have forced some
renaming of standard library functions.

CONTENTS:

  Changes               what's new with each release
  INSTALL               instructions for installation
  LICENSE               license and copyright notice
  Makefile              main Makefile
  README                this file
  README.win32          infos on the MS Windows ports of OCaml
  asmcomp/              native-code compiler and linker
  asmrun/               native-code runtime library
  boot/                 bootstrap compiler
  bytecomp/             bytecode compiler and linker
  byterun/              bytecode interpreter and runtime system
  camlp4/               the Camlp4 preprocessor
  config/               autoconfiguration stuff
  debugger/             source-level replay debugger
  driver/               driver code for the compilers
  emacs/                OCaml editing mode and debugger interface for GNU Emacs
  lex/                  lexer generator
  maccaml/              the Macintosh GUI
  ocamldoc/             documentation generator
  otherlibs/            several external libraries
  parsing/              syntax analysis
  stdlib/               standard library
  tools/                various utilities
  toplevel/             interactive system
  typing/               typechecking
  utils/                utility libraries
  yacc/                 parser generator

COPYRIGHT:

All files marked "Copyright INRIA" in this distribution are copyright
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012 Institut National de Recherche en
Informatique et en Automatique (INRIA) and distributed under the
conditions stated in file LICENSE.

INSTALLATION:

See the file INSTALL for installation instructions on Unix, Linux and
MacOS X machines.  For MS Windows, see README.win32.

DOCUMENTATION:

The OCaml manual is distributed in HTML, PDF, Postscript, DVI, and
Emacs Info files.  It is available on the World Wide Web, at


AVAILABILITY:

The complete OCaml distribution can be accessed at


KEEPING IN TOUCH WITH THE CAML COMMUNITY:

There exists a mailing list of users of the OCaml implementations
developed at INRIA. The purpose of this list is to share
experience, exchange ideas (and even code), and report on applications
of the OCaml language. Messages can be written in English or in
French. The list has more than 1000 subscribers.

Messages to the list should be sent to:

              caml-list@inria.fr

You can subscribe to this list via the Web interface at

        https://sympa-roc.inria.fr/wws/info/caml-list  <- not connected
https://sympa.inria.fr/sympa/info/caml-list
https://sympa.inria.fr/sympa/subscribe/caml-list


Archives of the list are available on the Web site above.

The Usenet news groups comp.lang.ml and comp.lang.functional
also contains discussions about the ML family of programming languages,
including OCaml.

BUG REPORTS AND USER FEEDBACK:

Please report bugs using the Web interface to the bug-tracking system

To be effective, bug reports should include a complete program
(preferably small) that exhibits the unexpected behavior, and the
configuration you are using (machine type, etc).

You can also contact the implementors directly at caml@inria.fr.
-----------
2. INSTALL
            Installing OCaml on a Unix machine
            ----------------------------------

PREREQUISITES

* The GNU C compiler gcc is recommended, as the bytecode
  interpreter takes advantage of gcc-specific features to enhance
  performance.  gcc is the standard compiler under Linux, MacOS X,
  and many other systems.

* Under MacOS X 10.5, you need version 3.1 or later of the XCode
  development tools.  The version of XCode found on MacOS X 10.5
  installation media causes linking problems.  XCode updates
  are available free of charge at http://developer.apple.com/tools/xcode/

* Under MacOS X up to version 10.2.8, you must raise the limit on the
  stack size with one of the following commands:

    limit stacksize 64M  # if your shell is zsh or tcsh
    ulimit -s 65536      # if your shell is bash <-- Error: ulimit: stack size: cannot modify limit: Invalid argument
   ulimit -s 65532  #this is max on Macbook Pro & OS X10.7.5

* If you do not have write access to /tmp, you should set the environment
  variable TMPDIR to the name of some other temporary directory.

* Under HP/UX, the GNU C compiler gcc, the GNU assembler gas, and GNU make
  are all *required*.  The vendor-provided compiler, assembler and make
  have major problems.

* GNU make is needed to build ocamlbuild and camlp4.  If your system's
  default make is not GNU make, you need to define the GNUMAKE environment
  variable to the name of GNU make, typically with this command:

    export GNUMAKE=gnumake

INSTALLATION INSTRUCTIONS

1- Configure the system. From the top directory, do:

        ./configure

This generates the three configuration files "Makefile", "m.h" and "s.h"
in the config/ subdirectory.

The "configure" script accepts the following options:

-prefix <dir>                   (default: /usr/local)
        Set the PREFIX variable used to define the defaults of the
        following three options.  Must be an absolute path name.

-bindir <dir>                   (default: $(PREFIX)/bin)
        Directory where the binaries will be installed.
        Must be an absolute path name, or start with "$(PREFIX)"

-libdir <dir>                   (default: $(PREFIX)/lib/ocaml)
        Directory where the OCaml library will be installed
        Must be an absolute path name, or start with "$(PREFIX)"

-mandir <dir>                   (default: $(PREFIX)/man/man1)
        Directory where the manual pages will be installed
        Must be an absolute path name, or start with "$(PREFIX)"

-cc <C compiler and options>    (default: gcc if available, cc otherwise)
        C compiler to use for building the system

-libs <extra libraries>         (default: none)
        Extra libraries to link with the system

-no-curses
        Do not use the curses library.

-host <hosttype>                (default: determined automatically)
        The type of the host machine, in GNU's "configuration name"
        format (CPU-COMPANY-SYSTEM or CPU-COMPANY-KERNEL-SYSTEM).
        This info is generally determined automatically by the
        "configure" script, and rarely ever needs to be provided by
        hand. The installation instructions for gcc or emacs contain a
        complete list of configuration names.

-x11include <include_dir>       (default: determined automatically)
-x11lib     <lib_dir>           (default: determined automatically)
        Location of the X11 include directory (e.g. /usr/X11R6/include)
        and the X11 library directory (e.g. /usr/X11R6/lib).

-tkdefs <cpp flags>             (default: none)
-tklibs <flags and libraries>   (default: determined automatically)
        These options specify where to find the Tcl/Tk libraries for
        LablTk. "-tkdefs" helps to find the headers, and "-tklibs"
        the C libraries. "-tklibs" may contain either only -L/path and
        -Wl,... flags, in which case the library names are determined
        automatically, or the actual libraries, which are used as given.
        Example: for a Japanese tcl/tk whose headers are in specific
        directories and libraries in /usr/local/lib, you can use
        ./configure -tklibs "-L/usr/local/lib -ltk8.0jp -ltcl8.0jp"
          -tkdefs "-I/usr/local/include/tcl8.0jp -I/usr/local/include/tk8.0jp"

-tk-no-x11
        Build LablTk without using X11. This option is needed on Cygwin.

-no-tk
        Do not attempt to build LablTk.

-no-pthread
        Do not attempt to use POSIX threads.

-with-pthread
        Attempt to use POSIX threads (this is the default).

-no-shared-libs
        Do not configure support for shared libraries

-dldefs <cpp flags>
-dllibs <flags and libraries>
        These options specify where to find the libraries for dynamic
        linking (i.e. use of shared libraries).  "-dldefs" specifies
        options for finding the header files, and "-dllibs" for finding
        the C libraries.

-as <assembler and options>     (default: determined automatically)
        The assembler to use for assembling ocamlopt-generated code.

-aspp <assembler and options>   (default: determined automatically)
        The assembler to use for assembling the parts of the
        run-time system manually written in assembly language.
        This assembler must preprocess its input with the C preprocessor.

-with-debug-runtime
        Compile and install the debug version of the runtimes, useful
        for debugging C stubs and other low-level code.

-verbose
        Verbose output of the configuration tests. Use it if the outcome
        of configure is not what you were expecting.

-no-camlp4
        Do not compile Camlp4.

-no-graph
        Do not compile the Graphics library.

-partialld <linker and options>  (default: determined automatically)
        The linker and options to use for producing an object file
        (rather than an executable) from several other object files.

Examples:

  Standard installation in /usr/{bin,lib,man} instead of /usr/local:
    ./configure -prefix /usr

  Installation in /usr, man pages in section "l":
    ./configure -bindir /usr/bin -libdir /usr/lib/ocaml -mandir /usr/man/manl
  or:
    ./configure -prefix /usr -mandir '$(PREFIX)/man/manl'

  On a MacOSX 10.5/Intel Core 2 or MacOSX 10.5/PowerPC host,
  to build a 64-bit version of OCaml:
    ./configure -cc "gcc -m64"

  On a MacOSX 10.6/Intel Core 2, to build a 32-bit version of OCaml:
    ./configure -cc "gcc -m32" -as "as -arch i386" -aspp "gcc -m32 -c"

  On a Linux x86/64 bits host, to build a 32-bit version of OCaml:
    ./configure -cc "gcc -m32" -as "as --32" -aspp "gcc -m32 -c"

  On a Linux x86/64 bits host, to build the run-time system in PIC mode
  (enables putting the runtime in a shared library,
   at a small performance cost):
    ./configure -cc "gcc -fPIC" -aspp "gcc -c -fPIC"

  For Sun Solaris with the "acc" compiler:
    ./configure -cc "acc -fast" -libs "-lucb"

  For Sun Solaris on Sparc 64bit, to compile natively (32bit only)
    ./configure -cc "gcc -m32" -as "as -32" -aspp "gcc -m32 -c"

  For AIX 4.3 with the IBM compiler xlc:
    ./configure -cc "xlc_r -D_AIX43 -Wl,-bexpall,-brtl -qmaxmem=8192"

If something goes wrong during the automatic configuration, or if the
generated files cause errors later on, then look at the template files

        config/Makefile-templ
        config/m-templ.h
        config/s-templ.h

for guidance on how to edit the generated files by hand.

2- From the top directory, do:

        make world

This builds the OCaml bytecode compiler for the first time.  This
phase is fairly verbose; consider redirecting the output to a file:

        make world > log.world 2>&1     # in sh
        make world >& log.world         # in csh

3- (Optional) To be sure everything works well, you can try to
bootstrap the system --- that is, to recompile all OCaml sources with
the newly created compiler. From the top directory, do:

        make bootstrap

or, better:

        make bootstrap > log.bootstrap 2>&1     # in sh
        make bootstrap >& log.bootstrap         # in csh

The "make bootstrap" checks that the bytecode programs compiled with
the new compiler are identical to the bytecode programs compiled with
the old compiler. If this is the case, you can be pretty sure the
system has been correctly compiled. Otherwise, this does not
necessarily mean something went wrong. The best thing to do is to try
a second bootstrapping phase: just do "make bootstrap" again.  It will
either crash almost immediately, or re-re-compile everything correctly
and reach the fixpoint.

4- If your platform is supported by the native-code compiler (as
reported during the autoconfiguration), you can now build the
native-code compiler. From the top directory, do:

        make opt
or:
        make opt > log.opt 2>&1     # in sh
        make opt >& log.opt         # in csh

5- Compile fast versions of the OCaml compilers, by compiling them
with the native-code compiler (you have only compiled them to bytecode
so far).  Just do:

        make opt.opt

Later, you can compile your programs to bytecode using ocamlc.opt
instead of ocamlc, and to native-code using ocamlopt.opt instead of
ocamlopt.  The ".opt" compilers should run faster than the normal
compilers, especially on large input files, but they may take longer
to start due to increased code size.  If compilation times are an issue on
your programs, try the ".opt" compilers to see if they make a
significant difference.

An alternative, and faster approach to steps 2 to 5 is

        make world.opt          # to build using native-code compilers

The result is equivalent to "make world opt opt.opt", but this may
fail if anything goes wrong in native-code generation.

6- You can now install the OCaml system. This will create the
following commands (in the binary directory selected during
autoconfiguration):

        ocamlc           the batch bytecode compiler
        ocamlopt         the batch native-code compiler (if supported)
        ocamlrun         the runtime system for the bytecode compiler
        ocamlyacc        the parser generator
        ocamllex         the lexer generator
        ocaml            the interactive, toplevel-based system
        ocamlmktop       a tool to make toplevel systems that integrate
                         user-defined C primitives and OCaml code
        ocamldebug       the source-level replay debugger
        ocamldep         generator of "make" dependencies for OCaml sources
        ocamldoc         documentation generator
        ocamlprof        execution count profiler
        ocamlcp          the bytecode compiler in profiling mode

and also, if you built them during step 5,

        ocamlc.opt       the batch bytecode compiler compiled with ocamlopt
        ocamlopt.opt     the batch native-code compiler compiled with ocamlopt
        ocamllex.opt     the lexer generator compiled with ocamlopt

From the top directory, become superuser and do:

        umask 022       # make sure to give read & execute permission to all
        make install 

7- Installation is complete. Time to clean up. From the toplevel
directory, do "make clean".

8- (Optional) The emacs/ subdirectory contains Emacs-Lisp files for an
OCaml editing mode and an interface for the debugger.  To install
these files, change to the emacs/ subdirectory and do

        make EMACSDIR=<directory where to install the files> install
or
       make install

In the latter case, the destination directory defaults to the
"site-lisp" directory of your Emacs installation.

9- After installation, do *not* strip the ocamldebug and ocamlbrowser
executables.  (These are mixed-mode executables, containing both
compiled C code and OCaml bytecode; stripping erases the bytecode!)
Other executables such as ocamlrun can safely be stripped.

IF SOMETHING GOES WRONG:

Read the "common problems" and "machine-specific hints" section at the
end of this file.

Check the files m.h and s.h in config/. Wrong endianness or alignment
constraints in m.h will immediately crash the bytecode interpreter.

If you get a "segmentation violation" signal, check the limits on the
stack size and data segment size (type "limit" under csh or
"ulimit -a" under bash). Make sure the limit on the stack size is
at least 4M.

Try recompiling the runtime system with optimizations turned off
(change CFLAGS in byterun/Makefile and asmrun/Makefile).
The runtime system contains some complex, atypical pieces of C code
that can uncover bugs in optimizing compilers. Alternatively, try
another C compiler (e.g. gcc instead of the vendor-supplied cc).

You can also build a debug version of the runtime system. Go to the
byterun/ directory and do "make ocamlrund". Then, copy ocamlrund to
../boot/ocamlrun, and try again. This version of the runtime system
contains lots of assertions and sanity checks that could help you
pinpoint the problem.

COMMON PROBLEMS:

* The Makefiles do not support parallel make (e.g. make -j2).
Fix: do not pass the -j option to make, and be patient.

* The Makefiles use the "include" directive, which is not supported by
all versions of make. Use GNU make if this is a problem.

* The Makefiles assume that make executes commands by calling /bin/sh. They
won't work if /bin/csh is called instead. You may have to unset the SHELL
environment variable, or set it to /bin/sh.

* On some systems, localization causes build problems.  You should
try to set the C locale (export LC_ALL=C) before compiling if you have
strange errors while compiling OCaml.

* gcc 2.7.2.1 generates incorrect code for the runtime system in -O mode
on some Intel x86 platforms (e.g. Linux RedHat 4.1 and 4.2).
If this causes a problem, the solution is to upgrade to 2.7.2.3 or above.

* Some versions of gcc 2.96 for the Intel x86 (as found in RedHat 7.2,
Mandrake 8.0 and Mandrake 8.1) generates incorrect code for the runtime
system.  The "configure" script tries to work around this problem.

* On HP 9000/700 machines under HP/UX 9.  Some versions of cc are
unable to compile correctly the runtime system (wrong code is
generated for (x - y) where x is a pointer and y an integer).
Fix: use gcc.

3. start ocaml
./ocaml
        OCaml version 4.01.0+dev12-2013-03-28

09:27 | Impressed! | Voted(1) | Comment(0)
2013/04/02

How can I install MinCaml on Macintosh OS X

Tweet ThisSend to Facebook | by kaizen
How can I install MinCaml  on Macintosh OS X?

1. Change from 'global' to 'globl' and from 'string' to  'asciz/ascii".
1.1  "to_x86_mac", instead of "to_x86" 
sed -e "s/global/globl/g" x86/libmincaml.S | sed -e "s/string/asciz/g" > x86/libmincaml.S2
cp x86/libmincaml.S2 x86/libmincaml.S

1.2 Makefile

sed -e "s/global/globl/g" test/$*.s > test/$*.s2 
cp test/$*.s2 test/$*.s 

2. in libmincaml.S, add  "#define __CYGWIN__" on first line.

3.  Change ".align 16" to ".align 10"
 ".align 16" cause a warning "libmincaml.S:229:Alignment too large: 15. assumed."

Resolved.
.global to globl
.string to.asciz/.ascii
add #define __CYGWIN__
.align 16 to .align 10

Open 
1. Segmentation fault: 11
 At test/cls-bug2 > test/cls-bug2.res
sp = 0xbff0b988, hp = 0x200000
Segmentation fault: 11

2. in "to_x86" file,  cd ../bytemark; ln -sf x86/Makefile is not work.
no x86 folder in bytemark. No Makefile

3.  gcc -m64 
32-bit absolute addressing is not supported for x86-64

09:09 | Impressed! | Voted(0) | Comment(0)