use libtoolize --force to overwrite existing (older) files
[platform/upstream/curl.git] / buildconf
1 #!/bin/sh
2
3 die(){
4         echo "$@"
5         exit
6 }
7
8 #--------------------------------------------------------------------------
9 # autoconf 2.57 or newer
10 #
11 need_autoconf="2.57"
12 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
13 if test -z "$ac_version"; then
14   echo "buildconf: autoconf not found."
15   echo "            You need autoconf version $need_autoconf or newer installed."
16   exit 1
17 fi
18 IFS=.; set $ac_version; IFS=' '
19 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
20   echo "buildconf: autoconf version $ac_version found."
21   echo "            You need autoconf version $need_autoconf or newer installed."
22   echo "            If you have a sufficient autoconf installed, but it"
23   echo "            is not named 'autoconf', then try setting the"
24   echo "            AUTOCONF environment variable."
25   exit 1
26 fi
27
28 echo "buildconf: autoconf version $ac_version (ok)"
29
30 #--------------------------------------------------------------------------
31 # autoheader 2.50 or newer
32 #
33 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
34 if test -z "$ah_version"; then
35   echo "buildconf: autoheader not found."
36   echo "            You need autoheader version 2.50 or newer installed."
37   exit 1
38 fi
39 IFS=.; set $ah_version; IFS=' '
40 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
41   echo "buildconf: autoheader version $ah_version found."
42   echo "            You need autoheader version 2.50 or newer installed."
43   echo "            If you have a sufficient autoheader installed, but it"
44   echo "            is not named 'autoheader', then try setting the"
45   echo "            AUTOHEADER environment variable."
46   exit 1
47 fi
48
49 echo "buildconf: autoheader version $ah_version (ok)"
50
51 #--------------------------------------------------------------------------
52 # automake 1.7 or newer
53 #
54 need_automake="1.7"
55 am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
56 if test -z "$am_version"; then
57   echo "buildconf: automake not found."
58   echo "            You need automake version $need_automake or newer installed."
59   exit 1
60 fi
61 IFS=.; set $am_version; IFS=' '
62 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
63   echo "buildconf: automake version $am_version found."
64   echo "            You need automake version $need_automake or newer installed."
65   echo "            If you have a sufficient automake installed, but it"
66   echo "            is not named 'automake', then try setting the"
67   echo "            AUTOMAKE environment variable."
68   exit 1
69 fi
70
71 echo "buildconf: automake version $am_version (ok)"
72
73
74 #--------------------------------------------------------------------------
75 # libtool check
76 #
77 LIBTOOL_WANTED_MAJOR=1
78 LIBTOOL_WANTED_MINOR=4
79 LIBTOOL_WANTED_PATCH=2
80 LIBTOOL_WANTED_VERSION=1.4.2
81
82 libtool=`which glibtool 2>/dev/null`
83 if test ! -x "$libtool"; then
84   libtool=`which libtool`
85 fi
86 #lt_pversion=`${LIBTOOL:-$libtool} --version 2>/dev/null|head -1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
87 lt_pversion=`$libtool --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//g' -e 's/[- ].*//'`
88 if test -z "$lt_pversion"; then
89   echo "buildconf: libtool not found."
90   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
91   exit 1
92 fi
93 lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$//'`
94 IFS=.; set $lt_version; IFS=' '
95 lt_status="good"
96
97 major=$1
98 minor=$2
99 patch=$3
100
101 if test "$major" = "$LIBTOOL_WANTED_MAJOR"; then
102    if test "$minor" -lt "$LIBTOOL_WANTED_MINOR"; then
103       lt_status="bad"
104    elif test -n "$LIBTOOL_WANTED_PATCH"; then
105        if test "$minor" -gt "$LIBTOOL_WANTED_MINOR"; then
106          lt_status="good"
107        elif test -n "$patch"; then
108           if test "$patch" -lt "$LIBTOOL_WANTED_PATCH"; then
109              lt_status="bad"
110           fi
111        else
112           lt_status="bad"
113        fi
114    fi
115 fi
116 if test $lt_status != "good"; then
117   echo "buildconf: libtool version $lt_pversion found."
118   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
119   exit 1
120 fi
121
122 echo "buildconf: libtool version $lt_version (ok)"
123
124 # ------------------------------------------------------------
125
126 # run the correct scripts now
127
128 echo "buildconf: running libtoolize"
129 ${LIBTOOLIZE:-libtoolize} --copy --automake --force || die "The command '${LIBTOOLIZE:-libtoolize}  --copy --automake --force' failed"
130 echo "buildconf: running aclocal"
131 ${ACLOCAL:-aclocal}       || die "The command '${AUTOHEADER:-aclocal}' failed"
132 echo "buildconf: running aclocal hack to convert all mv to mv -f"
133 perl -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
134 echo "buildconf: running autoheader"
135 ${AUTOHEADER:-autoheader} || die "The command '${AUTOHEADER:-autoheader}' failed"
136 echo "buildconf: running autoconf"
137 ${AUTOCONF:-autoconf}     || die "The command '${AUTOCONF:-autoconf}' failed"
138
139 if test -d ares; then
140   echo "buildconf: running autoconf in the ares directory"
141   cd ares
142   ${AUTOCONF:-autoconf}     || die "The command '${AUTOCONF:-autoconf}' failed"
143   cd ..
144 fi
145
146 echo "buildconf: running automake"
147 ${AUTOMAKE:-automake} -a  || die "The command '${AUTOMAKE:-automake} -a' failed"
148
149 echo "buildconf: OK"
150 exit 0