#!/bin/bash
# -*- coding: utf-8 -*-
#
# nacl_build.sh -- NaCl library build script
#
# Copyright (C) 2011 Daniel Borkmann <borkmann@redhat.com>
# Copyright (C) 2009-2011 Emmanuel Roullit <emmanuel@netsniff-ng.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

cc="gcc"
nacl_dir="/tmp"
nacl_version="nacl-20110221"
nacl_suffix="tar.bz2"
nacl_base_url="http://hyperelliptic.org/nacl"
nacl_path="$nacl_dir/$nacl_version.$nacl_suffix"
nacl_build_dir="$1"

if test -z "$nacl_build_dir"; then
	echo "Please input the path where NaCl should be build"
	exit 1
fi

if ! test -d "$nacl_build_dir"; then
	mkdir "$nacl_build_dir"
fi

wget -O "$nacl_path" "$nacl_base_url/$nacl_version.$nacl_suffix"
tar xjf "$nacl_path" -C "$nacl_build_dir"

$cc -Wall -O2 ./abiname.c -o ./abiname
arch="`./abiname`"
shorthostname=$(hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]')

echo "Building NaCl for arch $arch on host $shorthostname (grab a coffee, this takes a while) ..."

cd "$nacl_build_dir"/"$nacl_version"
./do
cd - > /dev/null

nacl_lib_path="$nacl_build_dir/$nacl_version/build/$shorthostname/lib/$arch"
nacl_include_path="$nacl_build_dir/$nacl_version/build/$shorthostname/include/$arch"

echo "NaCl lib path $nacl_lib_path"
echo "NaCl include path $nacl_include_path"

./nacl_path.sh "$nacl_include_path" "$nacl_lib_path"

echo "Done!"
><tr><td>
<a href='/cgit.cgi/linux/net-next.git/?h=nds-private-remove'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/kernel/configs?h=nds-private-remove'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/kernel/configs?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/kernel/configs?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/kernel/configs?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/kernel/configs'>
<input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/kernel?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>kernel</a>/<a href='/cgit.cgi/linux/net-next.git/log/kernel/configs?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2'>configs</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/kernel/configs?h=nds-private-remove&amp;id=283725af0bd2a4a8600bbe5edeb9d7c72780d3a2&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>