Experimenting with mod development and due to a conversation with 500ISE, I've successfully gotten Fortran code to compile and run as a MCPE/BlockLauncher mod.
About building toolchains with languages not shipped with stock Android NDK:
Although this thread has Fortran in the title, these methods could theoretically be adapted to program mods in most of GCC's supported languages. This is for native BlockLauncher mods.
Note: building toolchains isn't an exact science and many times you may run into troubles at every step. Please don't report what does and doesn't work in the process. Many of your build problems can be solved by searching the web. This guide is strictly a rough idea of building a toolchain for Android with more than just C and C++ enabled.
Requisites:
A copy of Android/Google's version of GCC 4.8's source.
A copy of Android/Google's version of Binutils 2.24's source.
Recent Android NDK.
Recent Android SDK.
Native library template.
Some low-level understanding of programming in target language.
A terminal (linux/mac/unix) or terminal emulator (cygwin/mingw on windows)
Open your terminal and type/copy-paste the following commands:
mkdir mytoolkit
cd mytoolkit
git clone https://android.googlesource.com/toolchain/gcc
git clone https://android.googlesource.com/toolchain/binutils
cd gcc/gcc-4.8
./contrib/download_prerequisites
cd ../..
mkdir binutils-build
cd binutils-build
../binutils/binutils-2.24/configure --prefix=/tmp/ndk-User/build/toolchain/prefix --target=arm-linux-androideabi
make
make install
cd ..
mkdir gcc-build
cd gcc-build
../gcc/gcc-4.8/configure --prefix=/tmp/ndk-User/build/toolchain/prefix --target=arm-linux-androideabi --enable-languages=c,c++,fortran --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -lstdc++ -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-initfini-array --disable-nls --prefix=/tmp/ndk-User/build/toolchain/prefix --with-sysroot=SYSROOT --with-binutils-version=2.24 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.8 --with-gdb-version=7.6 --with-python=/Users/User/mydroid/ndk/prebuilt/darwin-x86_64/bin/python-config.sh --with-gxx-include-dir=/tmp/ndk-User/build/toolchain/prefix/include/c++/4.8 --with-bugurl=http://source.android.com/source/report-bugs.html --disable-bootstrap --disable-libquadmath --enable-plugins --enable-libgomp --disable-libsanitizer --enable-gold --enable-graphite=yes --with-cloog-version=0.18.0 --with-isl-version=0.11.1 --enable-eh-frame-hdr-for-static --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default CC=gcc CXX=g++
make
make install
Note: Replace SYSROOT with the the full path to your NDK and add "/platforms/android-14/arch-arm". You should've received an error while libgfortran was being built and during installation. Ignore those and continue anyways as libgfortran isn't needed a this time.
Now you should have a toolchain located in /tmp/ndk-User/build/toolchain/prefix. Open this folder and merge it with the /toolchains/arm-linux-androideabi-4.8/prebuilt/ folder in your NDK. This should overwrite most of the GCC files in that toolchain. Now copy the following from /toolchains/arm-linux-androideabi-4.6/prebuilt/SYSTEM_OS/bin/ to /toolchains/arm-linux-androideabi-4.8/prebuilt/SYSTEM_OS/bin/
arm-linux-androideabi-ld
arm-linux-androideabi-ld.bfd
arm-linux-androideabi-ld.gold
arm-linux-androideabi-ld.mcld
Now copy the following from linux-androideabi-4.6/prebuilt/SYSTEM_OS/arm-linux-androideabi/bin/ to /toolchains/arm-linux-androideabi-4.8/prebuilt/SYSTEM_OS/arm-linux-androideabi/bin/
ld
ld.bfd
ld.gold
ld.mcld
Your toolchain should now be ready.
Included with the Fortran mod source download are Fortran bindings for 500ISE's mcpelauncher functions, the Unix dynamic linker functions (dlopen, dlsym, dlclose, dlerror), and a sample mod that prints to Logcat when an arrow entity ticks (after it is fired). Build: ndk-build in the source directory then ant debug/ant debug install.
My mods:
Coming soon..?
Not useful for players:
Prebuilt Fortran mod download:here
Fortran mod source/template download:here
About building toolchains with languages not shipped with stock Android NDK:
Note: building toolchains isn't an exact science and many times you may run into troubles at every step. Please don't report what does and doesn't work in the process. Many of your build problems can be solved by searching the web. This guide is strictly a rough idea of building a toolchain for Android with more than just C and C++ enabled.
Requisites:
- A copy of Android/Google's version of GCC 4.8's source.
- A copy of Android/Google's version of Binutils 2.24's source.
- Recent Android NDK.
- Recent Android SDK.
- Native library template.
- Some low-level understanding of programming in target language.
- A terminal (linux/mac/unix) or terminal emulator (cygwin/mingw on windows)
- git and gcc installed on your machine.
- Fortran Mod source template (download:here)
Downloading:Note: Replace SYSROOT with the the full path to your NDK and add "/platforms/android-14/arch-arm". You should've received an error while libgfortran was being built and during installation. Ignore those and continue anyways as libgfortran isn't needed a this time.
Now you should have a toolchain located in /tmp/ndk-User/build/toolchain/prefix. Open this folder and merge it with the /toolchains/arm-linux-androideabi-4.8/prebuilt/ folder in your NDK. This should overwrite most of the GCC files in that toolchain. Now copy the following from /toolchains/arm-linux-androideabi-4.6/prebuilt/SYSTEM_OS/bin/ to /toolchains/arm-linux-androideabi-4.8/prebuilt/SYSTEM_OS/bin/
- arm-linux-androideabi-ld
- arm-linux-androideabi-ld.bfd
- arm-linux-androideabi-ld.gold
- arm-linux-androideabi-ld.mcld
Now copy the following from linux-androideabi-4.6/prebuilt/SYSTEM_OS/arm-linux-androideabi/bin/ to /toolchains/arm-linux-androideabi-4.8/prebuilt/SYSTEM_OS/arm-linux-androideabi/bin/- ld
- ld.bfd
- ld.gold
- ld.mcld
Your toolchain should now be ready.My mods:
Coming soon..?
Not useful for players:
Prebuilt Fortran mod download:here
Fortran mod source/template download:here