Building Hadoop native libs for Raspberry Pi 2 B

If you try to download and install the binary packages of Apache Hadoop 2.7.1 on a Raspberry PI 2 B, you will get some ugly warnings about the native libs being all wrong, something along:

Unable to load native-hadoop library for your platform... using builtin-java classes
where applicable...
warning: You have loaded library
/usr/local/hadoop/lib/native/libhadoop.so.1.0.0 which might have
disabled stack guard. The VM will try to fix the stack guard now. It's
highly recommended that you fix the library with 'execstack -c
<libfile>', or link it with '-z noexecstack'.

Those warnings also mess up the start-all.sh script for starting a cluster of several machines.

From searching on the web it looks like the cleanes option to remove the warnings is to compile hadoop natively on your Raspberry. A good source of information is

http://www.instructables.com/id/Native-Hadoop-260-Build-on-Pi/?ALLSTEPS

Which is a tutorial for compiling Hadoop 2.6.0, but it is still valid for 2.7.1 it seems.

When compiling the current version, I got out-of-memory errors, so I disabled javadoc generation. Afterwards, it worked:

mvn package -Pdist,native -DskipTests -Dtar -Dmaven.javadoc.skip=true