From Wiki
Jump to: navigation, search

To build a shared, dynamically linkable library from the nacl sourcecode:

# Download and extract the NaCl sourcecode:
wget -O- | bunzip2 | tar -xf -
cd nacl-20110221
# Remove some implementations that do not want to be relocatable (it will fall back to another implementation)
rm -r crypto_onetimeauth/poly1305/amd64
# Patch the compiler commands to create relocatable code
sed -i "s/$/ -fPIC/" okcompilers/c
# Patch the code to accept application input for the key generation functions
wget -O- | patch -p1
# Build the NaCl library, this takes some time...
# Build and locate some utilities used by the nacl build process to find the CPU architecture (and output directory) and an useable compiler
gcc okcompilers/abiname.c -o abiname
ABINAME="$(./abiname "" | cut -b 2-)"
BUILDDIR="build/$(hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]')"
OKCOMPILER="$($BUILDDIR/bin/okc-${ABINAME} | head -n 1)"
# Compile some frontend code into a shared library (download, preprocess with NaCl header files, rewrite some lines, compile and link with the static nacl library)
wget -O- |
${OKCOMPILER} -x c -E - -I "${BUILDDIR}/include/${ABINAME}" |
       sed "s/export_//" |
       ${OKCOMPILER} -fPIC -nostdlib -shared -Wl,--no-undefined -o "" -x c - -x none "${NACLLIB}"
# Install library to /usr/lib
install -m 644 /usr/lib/
# Install header files to /usr/include/nacl
mkdir /usr/include/nacl
  cd /usr/include/nacl

File list