1#!/bin/sh
2
3# This file is part of libdaemon.
4#
5# Copyright 2003-2008 Lennart Poettering
6#
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23# SOFTWARE.
24
25VERSION=1.9
26
27run_versioned() {
28    local P
29    local V
30
31    V=$(echo "$2" | sed -e 's,\.,,g')
32
33    if [ -e "`which $1$V 2> /dev/null`" ] ; then
34        P="$1$V"
35    else
36	if [ -e "`which $1-$2 2> /dev/null`" ] ; then
37            P="$1-$2"
38	else
39	    P="$1"
40	fi
41    fi
42
43    shift 2
44    "$P" "$@"
45}
46
47set -ex
48
49if [ "x$1" = "xam" ] ; then
50    run_versioned automake "$VERSION" -a -c --foreign
51    ./config.status
52else
53    rm -rf autom4te.cache
54    rm -f config.cache
55
56    touch config.rpath
57    test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize
58
59    mkdir -p common
60
61    "$LIBTOOLIZE" -c --force
62    run_versioned aclocal "$VERSION" -I m4
63    run_versioned autoconf 2.59 -Wall
64    run_versioned autoheader 2.59
65    run_versioned automake "$VERSION" -a -c --foreign
66
67    if test "x$NOCONFIGURE" = "x"; then
68        CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var "$@"
69        make clean
70    fi
71fi
72