Update tag value for tizen 2.0 build
[external/curl.git] / buildconf
1 #!/bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
10 #
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
14 #
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
18 #
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
21 #
22 ###########################################################################
23
24 die(){
25         echo "$@"
26         exit
27 }
28
29 #--------------------------------------------------------------------------
30 # findtool works as 'which' but we use a different name to make it more
31 # obvious we aren't using 'which'! ;-)
32 #
33 findtool(){
34   file="$1"
35
36   if { echo $file | grep "/" >/dev/null 2>&1; } then
37     # we only check for the explicit file name if the file is given
38     # including a slash. Use ./ for current dir. Previously this would
39     # otherwise always cause findtool to search the local dir first, which
40     # is wrong.
41     if test -f "$file"; then
42       echo "$file"
43       return
44     fi
45   fi
46
47   old_IFS=$IFS; IFS=':'
48   for path in $PATH
49   do
50     IFS=$old_IFS
51     # echo "checks for $file in $path" >&2
52     if test -f "$path/$file"; then
53       echo "$path/$file"
54       return
55     fi
56   done
57   IFS=$old_IFS
58 }
59
60 #--------------------------------------------------------------------------
61 # removethis() removes all files and subdirectories with the given name,
62 # inside and below the current subdirectory at invocation time.
63 #
64 removethis(){
65   if test "$#" = "1"; then
66     find . -depth -name $1 -print > buildconf.tmp.$$
67     while read fdname
68     do
69       if test -f "$fdname"; then
70         rm -f "$fdname"
71       elif test -d "$fdname"; then
72         rm -f -r "$fdname"
73       fi
74     done < buildconf.tmp.$$
75     rm -f buildconf.tmp.$$
76   fi
77 }
78
79 #--------------------------------------------------------------------------
80 # Ensure that buildconf runs from the subdirectory where configure.ac lives
81 #
82 if test ! -f configure.ac ||
83   test ! -f src/main.c ||
84   test ! -f lib/urldata.h ||
85   test ! -f include/curl/curl.h; then
86   echo "Can not run buildconf from outside of curl's source subdirectory!"
87   echo "Change to the subdirectory where buildconf is found, and try again."
88   exit 1
89 fi
90
91 #--------------------------------------------------------------------------
92 # autoconf 2.57 or newer
93 #
94 need_autoconf="2.57"
95 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
96 if test -z "$ac_version"; then
97   echo "buildconf: autoconf not found."
98   echo "            You need autoconf version $need_autoconf or newer installed."
99   exit 1
100 fi
101 old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
102 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
103   echo "buildconf: autoconf version $ac_version found."
104   echo "            You need autoconf version $need_autoconf or newer installed."
105   echo "            If you have a sufficient autoconf installed, but it"
106   echo "            is not named 'autoconf', then try setting the"
107   echo "            AUTOCONF environment variable."
108   exit 1
109 fi
110
111 echo "buildconf: autoconf version $ac_version (ok)"
112
113 am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
114 if test -z "$am4te_version"; then
115   echo "buildconf: autom4te not found. Weird autoconf installation!"
116   exit 1
117 fi
118 if test "$am4te_version" = "$ac_version"; then
119   echo "buildconf: autom4te version $am4te_version (ok)"
120 else
121   echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
122   exit 1
123 fi
124
125 #--------------------------------------------------------------------------
126 # autoheader 2.50 or newer
127 #
128 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
129 if test -z "$ah_version"; then
130   echo "buildconf: autoheader not found."
131   echo "            You need autoheader version 2.50 or newer installed."
132   exit 1
133 fi
134 old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
135 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
136   echo "buildconf: autoheader version $ah_version found."
137   echo "            You need autoheader version 2.50 or newer installed."
138   echo "            If you have a sufficient autoheader installed, but it"
139   echo "            is not named 'autoheader', then try setting the"
140   echo "            AUTOHEADER environment variable."
141   exit 1
142 fi
143
144 echo "buildconf: autoheader version $ah_version (ok)"
145
146 #--------------------------------------------------------------------------
147 # automake 1.7 or newer
148 #
149 need_automake="1.7"
150 am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
151 if test -z "$am_version"; then
152   echo "buildconf: automake not found."
153   echo "            You need automake version $need_automake or newer installed."
154   exit 1
155 fi
156 old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
157 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
158   echo "buildconf: automake version $am_version found."
159   echo "            You need automake version $need_automake or newer installed."
160   echo "            If you have a sufficient automake installed, but it"
161   echo "            is not named 'automake', then try setting the"
162   echo "            AUTOMAKE environment variable."
163   exit 1
164 fi
165
166 echo "buildconf: automake version $am_version (ok)"
167
168 acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
169 if test -z "$acloc_version"; then
170   echo "buildconf: aclocal not found. Weird automake installation!"
171   exit 1
172 fi
173 if test "$acloc_version" = "$am_version"; then
174   echo "buildconf: aclocal version $acloc_version (ok)"
175 else
176   echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
177   exit 1
178 fi
179
180 #--------------------------------------------------------------------------
181 # libtool check
182 #
183 LIBTOOL_WANTED_MAJOR=1
184 LIBTOOL_WANTED_MINOR=4
185 LIBTOOL_WANTED_PATCH=2
186 LIBTOOL_WANTED_VERSION=1.4.2
187
188 # this approach that tries 'glibtool' first is some kind of work-around for
189 # some BSD-systems I believe that use to provide the GNU libtool named
190 # glibtool, with 'libtool' being something completely different.
191 libtool=`findtool glibtool 2>/dev/null`
192 if test ! -x "$libtool"; then
193   libtool=`findtool ${LIBTOOL:-libtool}`
194 fi
195
196 if test -z "$LIBTOOLIZE"; then
197   # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
198   # $libtool is already the full path
199   libtoolize="${libtool}ize"
200 else
201   libtoolize=`findtool $LIBTOOLIZE`
202 fi
203
204 lt_pver=`$libtool --version 2>/dev/null|head -n 1`
205 lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
206 lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
207 if test -z "$lt_version"; then
208   echo "buildconf: libtool not found."
209   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
210   exit 1
211 fi
212 old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
213 lt_major=$1
214 lt_minor=$2
215 lt_patch=$3
216 lt_status="good"
217
218 if test "$lt_major" = "$LIBTOOL_WANTED_MAJOR"; then
219    if test "$lt_minor" -lt "$LIBTOOL_WANTED_MINOR"; then
220       lt_status="bad"
221    elif test -n "$LIBTOOL_WANTED_PATCH"; then
222        if test "$lt_minor" -gt "$LIBTOOL_WANTED_MINOR"; then
223          lt_status="good"
224        elif test -n "$lt_patch"; then
225           if test "$lt_patch" -lt "$LIBTOOL_WANTED_PATCH"; then
226              lt_status="bad"
227           fi
228        else
229           lt_status="bad"
230        fi
231    fi
232 fi
233 if test $lt_status != "good"; then
234   echo "buildconf: libtool version $lt_version found."
235   echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
236   exit 1
237 fi
238
239 echo "buildconf: libtool version $lt_version (ok)"
240
241 if test -f "$libtoolize"; then
242   echo "buildconf: libtoolize found"
243 else
244   echo "buildconf: libtoolize not found. Weird libtool installation!"
245   exit 1
246 fi
247
248 #--------------------------------------------------------------------------
249 # m4 check
250 #
251 m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`;
252 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
253
254 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
255   echo "buildconf: GNU m4 version $m4_version (ok)"
256 else
257   if test -z "$m4"; then
258     echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
259   else
260     echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
261   fi
262   exit 1
263 fi
264
265 #--------------------------------------------------------------------------
266 # perl check
267 #
268 PERL=`findtool ${PERL:-perl}`
269
270 #--------------------------------------------------------------------------
271 # Remove files generated on previous buildconf/configure run.
272 #
273 for fname in .deps \
274     .libs \
275     *.la \
276     *.lo \
277     *.a \
278     *.o \
279     Makefile \
280     Makefile.in \
281     aclocal.m4 \
282     aclocal.m4.bak \
283     ares_build.h \
284     ares_config.h \
285     ares_config.h.in \
286     autom4te.cache \
287     compile \
288     config.guess \
289     curl_config.h \
290     curl_config.h.in \
291     config.log \
292     config.lt \
293     config.status \
294     config.sub \
295     configure \
296     configurehelp.pm \
297     curl-config \
298     curlbuild.h \
299     depcomp \
300     libcares.pc \
301     libcurl.pc \
302     libtool \
303     libtool.m4 \
304     ltmain.sh \
305     ltoptions.m4 \
306     ltsugar.m4 \
307     ltversion.m4 \
308     lt~obsolete.m4 \
309     stamp-h1 \
310     stamp-h2 \
311     stamp-h3 ; do
312   removethis "$fname"
313 done
314
315 #--------------------------------------------------------------------------
316 # run the correct scripts now
317 #
318
319 echo "buildconf: running libtoolize"
320 $libtoolize --copy --automake --force || die "The libtoolize command failed"
321
322 if test ! -f m4/curl-functions.m4; then
323   echo "buildconf: cURL m4 macros not found"
324   exit 1
325 fi
326
327 echo "buildconf: running aclocal"
328 ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "The aclocal command line failed"
329
330 if test -n "$PERL"; then
331   echo "buildconf: running aclocal hack to convert all mv to mv -f"
332   $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
333 else
334   echo "buildconf: perl not found"
335   exit 1
336 fi
337
338 echo "buildconf: running autoheader"
339 ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
340
341 echo "buildconf: cp lib/curl_config.h.in src/curl_config.h.in"
342 cp lib/curl_config.h.in src/curl_config.h.in
343
344 echo "buildconf: running autoconf"
345 ${AUTOCONF:-autoconf}     || die "The autoconf command failed"
346
347 if test -d ares; then
348   cd ares
349   echo "buildconf: running in ares"
350   ./buildconf
351   cd ..
352 fi
353
354 echo "buildconf: running automake"
355 ${AUTOMAKE:-automake} -a -c  || die "The automake command failed"
356
357 #--------------------------------------------------------------------------
358 # Depending on the libtool and automake versions being used, config.guess
359 # might not be installed in the subdirectory until automake has finished.
360 # So we can not attempt to use it until this very last buildconf stage.
361 #
362
363 if test ! -f ./config.guess; then
364   echo "buildconf: config.guess not found"
365 else
366   buildhost=`./config.guess 2>/dev/null|head -n 1`
367   case $buildhost in
368     *-*-darwin*)
369       need_lt_major=1
370       need_lt_minor=5
371       need_lt_patch=26
372       need_lt_check="yes"
373       ;;
374     *-*-hpux*)
375       need_lt_major=1
376       need_lt_minor=5
377       need_lt_patch=24
378       need_lt_check="yes"
379       ;;
380   esac
381   if test ! -z "$need_lt_check"; then
382     if test -z "$lt_major"; then
383       lt_status="bad"
384     elif test "$lt_major" -gt "$need_lt_major"; then
385       lt_status="good"
386     elif test "$lt_major" -lt "$need_lt_major"; then
387       lt_status="bad"
388     elif test -z "$lt_minor"; then
389       lt_status="bad"
390     elif test "$lt_minor" -gt "$need_lt_minor"; then
391       lt_status="good"
392     elif test "$lt_minor" -lt "$need_lt_minor"; then
393       lt_status="bad"
394     elif test -z "$lt_patch"; then
395       lt_status="bad"
396     elif test "$lt_patch" -gt "$need_lt_patch"; then
397       lt_status="good"
398     elif test "$lt_patch" -lt "$need_lt_patch"; then
399       lt_status="bad"
400     else
401       lt_status="good"
402     fi
403     if test "$lt_status" != "good"; then
404       need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
405       echo "buildconf: libtool version $lt_version found."
406       echo "            $buildhost requires libtool $need_lt_version or newer installed."
407       rm -f configure
408       exit 1
409     fi
410   fi
411 fi
412
413 #--------------------------------------------------------------------------
414 # Finished succesfully.
415 #
416
417 echo "buildconf: OK"
418 exit 0