build-sys: rename bootstrap.sh to autogen.sh
[platform/upstream/libatasmart.git] / autogen.sh
1 #!/bin/bash
2
3 # This file is part of libatasmart.
4 #
5 # Copyright 2008-2011 Lennart Poettering
6 #
7 # libatasmart is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser General Public License as
9 # published by the Free Software Foundation, either version 2.1 of the
10 # License, or (at your option) any later version.
11 #
12 # libatasmart is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with libatasmart; If not, see
19 # <http://www.gnu.org/licenses/>.
20
21 AM_VERSION=1.11
22 AC_VERSION=2.63
23
24 run_versioned() {
25     local P
26     local V
27
28     V=$(echo "$2" | sed -e 's,\.,,g')
29
30     if [ -e "`which $1$V 2> /dev/null`" ] ; then
31         P="$1$V"
32     else
33         if [ -e "`which $1-$2 2> /dev/null`" ] ; then
34             P="$1-$2"
35         else
36             P="$1"
37         fi
38     fi
39
40     shift 2
41     "$P" "$@"
42 }
43
44 set -ex
45
46 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
47     cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
48     chmod +x .git/hooks/pre-commit && \
49     echo "Activated pre-commit hook."
50 fi
51
52 if type -p colorgcc > /dev/null ; then
53    export CC=colorgcc
54 fi
55
56 libdir() {
57     echo $(cd $1/$(gcc -print-multi-os-directory); pwd)
58 }
59
60 if [ "x$1" = "xam" ] ; then
61     run_versioned automake "$AM_VERSION" -a -c --foreign
62     ./config.status
63 else
64     rm -rf autom4te.cache
65     rm -f config.cache
66
67     libtoolize -c --force
68     run_versioned aclocal "$AM_VERSION" -I m4
69     run_versioned autoconf "$AC_VERSION" -Wall
70     run_versioned autoheader "$AC_VERSION"
71     run_versioned automake "$AM_VERSION" --copy --foreign --add-missing
72
73     if [ "x$1" != "xac" ]; then
74         CFLAGS="$CFLAGS -g -O0" ./configure \
75           --sysconfdir=/etc \
76           --localstatedir=/var \
77           --libexecdir=/usr/lib \
78           --libdir=$(libdir /usr/local/lib) \
79           "$@"
80         make clean
81     fi
82 fi