Merge pull request #58 from electronjoe/a1cf780cccc4819eb360cda1e0e94e17935cb8c7
[netsniff-ng-old.git] / curvetun / build_nacl.sh
blob7a973029b9f4f302254edcb0ea8270407e9ea93a
1 #!/bin/bash
3 # netsniff-ng - the packet sniffing beast
4 # By Emmanuel Roullit <emmanuel@netsniff-ng.org>
5 # Copyright 2009, 2011 Emmanuel Roullit.
6 # Subject to the GPL, version 2.
8 cc="gcc"
9 nacl_dir="/tmp"
10 nacl_version="nacl-20110221"
11 nacl_suffix="tar.bz2"
12 nacl_base_url="http://hyperelliptic.org/nacl"
13 nacl_path="$nacl_dir/$nacl_version.$nacl_suffix"
14 nacl_build_dir="$1"
16 if test -z "$nacl_build_dir"; then
17 echo "Please input the path where NaCl should be build"
18 exit 1
21 if ! test -d "$nacl_build_dir"; then
22 mkdir "$nacl_build_dir"
25 wget -O "$nacl_path" "$nacl_base_url/$nacl_version.$nacl_suffix"
26 tar xjf "$nacl_path" -C "$nacl_build_dir"
28 $cc -Wall -O2 ./abiname.c -o ./abiname
29 arch="`./abiname`"
30 shorthostname=$(hostname | sed 's/\..*//' | tr -cd '[a-z][A-Z][0-9]')
32 echo "Building NaCl for arch $arch on host $shorthostname (grab a coffee, this takes a while) ..."
34 cd "$nacl_build_dir"/"$nacl_version"
35 ./do
36 cd - > /dev/null
38 nacl_lib_path="$nacl_build_dir/$nacl_version/build/$shorthostname/lib/$arch"
39 nacl_include_path="$nacl_build_dir/$nacl_version/build/$shorthostname/include/$arch"
41 echo "NaCl lib path $nacl_lib_path"
42 echo "NaCl include path $nacl_include_path"
44 ./nacl_path.sh "$nacl_include_path" "$nacl_lib_path"
46 echo "Done!"