Files
i2p.i2p/core/c

======
JCPUID
======

Linux -> Windows cross-compilation
----------------------------------
Install ming-w64 (on debian or whichever package that provides i686-w64-mingw32 and x86_64_w64_mingw32).

To build the 32-bit binaries run something like this:
    CC=i686-w64-mingw32-gcc TARGET=windows BITS=32 ./build.sh

To build the 64-bit binaries run something like this:
    CC=x86_64-w64-mingw32-gcc TARGET=windows BITS=64 ./build.sh

FreeBSD
-------
Compiled natively, x86 on a 32-bit install and x86_64 on a 64-bit install

To build the 32-bit binaries run something like this:
    BITS=32 ./build.sh

To build the 64-bit binaries run something like this:
    BITS=64 ./build.sh


Linux
-----
Compiled natively x86 and x86_64 on a 64-bit install

To build the 32-bit binaries run something like this:
    BITS=32 ./build.sh

To build the 64-bit binaries run something like this:
    BITS=64 ./build.sh


OSX
---
Compiled natively on OSX machine

To build the 32-bit binaries run something like this:
    BITS=32 ./build.sh

To build the 64-bit binaries run something like this:
    BITS=64 ./build.sh


=====
JBIGI
=====


Dynamic library build
=====================

If you have a libgmp.so installed on your system already
(check in /usr/lib), you can build a dynamically linked libjbigi.so as follows:
	cd jbigi
	build.sh dynamic
You do, of course, need the gmp headers installed.
On ubuntu, check for libgmp3 and libgmp3-dev packages.
This is much easier and faster than building GMP from source.
	

Static library build
=====================

Otherwise, the build script build.sh will download the the GMP source,
unpack and build it. The GMP version and download location are configured
in jbigi/build.sh, please review it to ensure you download
and build the desired version.

To build the native jbigi and jcpuid libraries for the current host CPU,
simply run sh build.sh and the results will be packaged up into jbigi.jar
and the libjbigi.so library.

To build the native jbigi libraries for all supported CPUs (on the current OS),
go into jbigi/ and run build-all.sh (the results will be under jbigi/lib/)


Build for more than one target at a time
========================================

jbigi/mbuild-all.sh is used to build a whole set of binaries at a time.
Each run will build a set of binaries for a specific platform.

Linux -> Windows cross-compilation
----------------------------------
Install ming-w64 (on debian or whichever package that provides i686-w64-mingw32 and x86_64_w64_mingw32).

To build the 32-bit binaries run something like this:
    CC=i686-w64-mingw32-gcc TARGET=windows BITS=32 ./mbuild-all.sh

To build the 64-bit binaries run something like this:
    CC=x86_64-w64-mingw32-gcc TARGET=windows BITS=64 ./mbuild-all.sh

Linux -> FreeBSD cross-compilation
----------------------------------
Install gcc-multilib (on debian or whichever package that provides the C runtime)
I used clang3.6 as CC, but gcc or most other things should work too.

To build the 32-bit binaries run something like this:
    TARGET=freebsd BITS=32 ./mbuild-all.sh

To build the 64-bit binaries run something like this:
    TARGET=freebsd BITS=64 ./mbuild-all.sh

OSX Compilation
---------------
No working cross-compilation setup has been found. The gmp6 binaries were produced on an OSX host.


Installation and testing
========================

To test, copy jbigi/lib/libjbigi.so
and jcpuid/lib/freenet/support/CPUInformation/libjcpuid-*.so
to your i2p installation directory ($I2P). You may also copy jbigi.jar to the $I2P/lib/ directory;
it will be used only if the router fails to load the native library
from the I2P installation directory.

The build.sh script runs two speed tests, one with your existing
I2P installation and one with the new libjbigi.

Alternatively, after copying the files to the i2p/ directory,
to run a speed test comparing the native library to the java library,
run the shell script below. Adjust the I2P= line as necessary.

-----------------

#!/bin/sh
export I2P=~/i2p
java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger