Creating an Eiffel wrapper for The GNU Multiple Precision Arithmetic Library (GMP)
Installing CIL (if not yet done):git clone git://cil.git.sourceforge.net/gitroot/cil/cil; cd cil
./configure
make
export PATH=$PATH:`pwd`/bin
1. Compiling the library (business as usual)
wget ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2tar xfj gmp-5.0.5.tar.bz2; cd gmp-5.0.5
./configure
make
2. CIL preprocessing
-
Creating the C file:
You have to create a C file that includes all necessary library header files; for GMP this is only gmp.h.
[GMP specific] Since gmp.h excludes certain functions if stdio.h is not present (but we want all functions), we also add it:
echo -e "#include <stdio.h>\n#include \"gmp.h\"" > gmp.c -
Creating the CIL C file:
export CILLY_DONT_COMPILE_AFTER_MERGE=1
cilly --merge --save-temps --keepunused --noWrap gmp.c -
Removing compiler builtins (we don't want to translate them):
perl -0pi -e 's/\/\* compiler builtin:.*?\*\/\n//sg' gmp.cil.c -
Removing inlined functions (we don't want to translate them):
perl -0pi -e 's/__inline extern [^;]*?{.*?\n}\n}\n//sg' gmp.cil.c