1#!/bin/sh
2
3set -e
4set -u
5
6myself=`echo "$0" | sed 's,.*/,,'`
7
8say()
9{
10	echo "$myself: $@."
11}
12
13die()
14{
15	echo >&2 "$myself: $@."
16	exit 1
17}
18
19if [ $# -eq 1 ]
20then
21	version=$1
22else
23	version=3.2.2
24fi
25
26if [ ! -f lib/system.h ]
27then
28	if [ -f ../lib/system.h ]
29	then
30		cd ..
31	else
32		die 'Please call me from the NSCA-ng source directory'
33	fi
34fi
35
36install_dir=`pwd`/lib/confuse
37tarball="confuse-$version.tar.gz"
38
39if [ ! -f "$tarball" ]
40then
41	if type curl >/dev/null 2>&1
42	then
43		get="curl -L -o $tarball"
44	elif type wget >/dev/null 2>&1
45	then
46		get=wget
47	else
48		say 'Cannot find an HTTP client'
49		die "Please download '$tarball' into `pwd`"
50	fi
51
52	$get "https://github.com/martinh/libconfuse/releases/download/v$version/$tarball"
53	test -f "$tarball" || die "Downloading '$tarball' failed"
54fi
55
56gzip -c -d "$tarball" | tar xf -
57cd `expr "$tarball" : '\(.*\)\.tar\.gz$'`
58
59./configure --prefix="$install_dir" --enable-static --disable-shared
60make
61make install
62
63say 'Success'
64
65# vim:set joinspaces noexpandtab textwidth=80:
66