#!/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 $OLDPWD > /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/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/include/uapi/scsi/cxlflash_ioctl.h'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/include/uapi/scsi/cxlflash_ioctl.h?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/include/uapi/scsi/cxlflash_ioctl.h?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/include/uapi/scsi/cxlflash_ioctl.h?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/uapi/scsi/cxlflash_ioctl.h'>
<input type='hidden' name='id' value='a810007afe239d59c1115fcaa06eb5b480f876e9'/><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/?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/uapi?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>uapi</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/uapi/scsi?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>scsi</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/uapi/scsi/cxlflash_ioctl.h?id=a810007afe239d59c1115fcaa06eb5b480f876e9'>cxlflash_ioctl.h</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/include/uapi/scsi/cxlflash_ioctl.h?id=a810007afe239d59c1115fcaa06eb5b480f876e9&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>