• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -e
4
5builddir=
6install=no
7
8while [ $# -gt 0 ]; do
9	case "$1" in
10	--build-dir)
11		if [ $# -lt 2 ]; then
12			echo "ERROR: missing argument for --build-dir option" >&2
13			exit 1
14		fi
15		builddir=$2
16		shift 2
17		;;
18	--install)
19		install=yes
20		shift
21		;;
22	--)
23		shift
24		break;
25		;;
26	*)
27		echo "ERROR: Unexpected argument: $1" >&2
28		exit 1
29	esac
30done
31
32if [ -z "${builddir}" ]; then
33	echo "ERROR: --build-dir option not specified" >&2
34	exit 1
35fi
36
37if [ -e "${builddir}" ]; then
38	echo "ERROR: directory entry named '${builddir}' already exists" >&2
39	exit 1
40fi
41
42mkdir "${builddir}"
43cd "${builddir}"
44
45cflags="-O2"
46
47# enable extra warnings
48cflags+=" -Winline"
49cflags+=" -Wmissing-include-dirs"
50cflags+=" -Wnested-externs"
51cflags+=" -Wpointer-arith"
52cflags+=" -Wredundant-decls"
53cflags+=" -Wswitch-enum"
54
55echo ""
56echo "Configuring ..."
57CFLAGS="${cflags}" ../configure --enable-examples-build --enable-tests-build "$@"
58
59echo ""
60echo "Building ..."
61make -j4 -k
62
63if [ "${install}" = "yes" ]; then
64	echo ""
65	echo "Installing ..."
66	make install
67fi
68